~ubuntu-branches/ubuntu/precise/aptoncd/precise

« back to all changes in this revision

Viewing changes to APTonCD/widgets/contextMenu.py

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-08-17 22:04:26 UTC
  • mfrom: (1.1.1 upstream) (0.1.11 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090817220426-bhxr3a21ff6y8edm
Tags: 0.1.98+bzr109-0.1
* Non-maintainer upload
* New upstream release (Closes: #452205, #423480, #433915, #541047, #427003,
  #493647, #484636)
* debian/control: 
  - Changed python build dependencies to Build-Depends-Indep
  - Moved url from Description to Homepage
  - Changed Standards-Version to 3.8.2
  - Changed Maintainer to myself
  - Deleted dependency on deprecated mkisofs 
  - Deleted recommend of nautilus-cd-burner
* debian/copyright: Changed (C) to © to make lintian happy
* debian/rules: 
  - deleted deprecated dh_desktop
  - added get-orig-source target to get the latest source from lp
* data/aptoncd.desktop.in: Fixed error and deprecated values in Desktop file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#####################################################################
 
3
#  Rafael Proença <cypherbios@ubuntu.com>
 
4
#
 
5
#  Copyright 2006 APTonCD DevTeam.
 
6
#
 
7
#  This program is free software; you can redistribute it and/or modify
 
8
#  it under the terms of the GNU General Public License as published
 
9
#  by the Free Software Foundation; version 2 only.
 
10
#
 
11
#  This program is distributed in the hope that it will be useful,
 
12
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
#  GNU General Public License for more details.
 
15
#####################################################################
 
16
import gtk
 
17
 
 
18
class ContextMenu(gtk.Menu):
 
19
    """ Creates context menus accessed by mouse right click. """
 
20
    def __init__(self, *args):
 
21
        gtk.Menu.__init__(self)
 
22
        self.menuItem = None
 
23
 
 
24
    def addMenuItem(self, menuName, actionFunction=None, menuImage=None, forceName=False):
 
25
        """
 
26
            Add itens to menu.
 
27
            
 
28
            @menuName is the text showed in the menu option.
 
29
                    If you pass a - (minus) as parameter value,
 
30
                    it will create a separation menu item.
 
31
            @actionFunction is the procedure called when activate signal is triggered from the menu.
 
32
            
 
33
        """
 
34
        if menuName == "-":
 
35
            self.menuItem = gtk.SeparatorMenuItem()
 
36
        else:
 
37
            if menuImage != None:
 
38
                if isinstance(menuImage, gtk.Image):
 
39
                    self.menuItem = gtk.ImageMenuItem(menuName)
 
40
                    self.menuItem.set_image(menuImage)
 
41
                elif isinstance(menuImage, gtk.gdk.Pixbuf):
 
42
                    self.menuItem = gtk.ImageMenuItem(menuName)
 
43
                    img = gtk.Image()
 
44
                    img.set_from_pixbuf(menuImage)
 
45
                    self.menuItem.set_image(img)
 
46
                else:
 
47
                    if not forceName:
 
48
                        self.menuItem = gtk.ImageMenuItem(menuImage)
 
49
                    else:
 
50
                        self.menuItem = gtk.ImageMenuItem(menuName)
 
51
                        img = gtk.Image()
 
52
                        img.set_from_stock(menuImage,gtk.ICON_SIZE_MENU)
 
53
                        self.menuItem.set_image(img)
 
54
            else:    
 
55
                self.menuItem = gtk.ImageMenuItem(menuName)
 
56
                
 
57
            if actionFunction is not None :
 
58
                self.menuItem.connect("activate", actionFunction)
 
59
        self.menuItem.show()
 
60
        self.append(self.menuItem)
 
61
        return