~ubuntu-branches/ubuntu/jaunty/gdesklets/jaunty-updates

« back to all changes in this revision

Viewing changes to main/TrayIcon.py

  • Committer: Bazaar Package Importer
  • Author(s): Deng Xiyue
  • Date: 2008-09-02 22:00:17 UTC
  • mfrom: (2.1.18 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080902220017-m66bj19l0ll8x7yh
Tags: 0.36-5
* Redo 40_dont_update_mime.diff to use a more compact syntax by 
  Loïc Minier's suggestion.  Thanks lool.
* Regenerate 70_relibtoolize.diff accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from main import ICON
2
2
 
3
 
try:
4
 
    from utils.systray import Icon as SysTrayIcon
5
 
except ImportError:
6
 
    import sys
7
 
    log("Could not import systray module!")
8
 
    sys.exit(1)
9
 
 
10
 
try:
11
 
    from utils.tiling import Tiling
12
 
except ImportError:
13
 
    import sys
14
 
    log("Could not import tiling module!")
15
 
    sys.exit(1)
16
 
 
17
3
import gtk
18
4
 
19
5
 
23
9
 
24
10
    def __init__(self):
25
11
 
26
 
        icon = Tiling()
27
 
        self.__ebox = gtk.EventBox()
28
12
        self.__menu = gtk.Menu()
29
 
        self.__trayicon = SysTrayIcon("gDesklets")
30
 
 
31
 
        icon.set_from_file(ICON);
32
 
        icon.render(24, 24, 1, 1);
33
 
 
34
 
        self.__ebox.add(icon)
35
 
        self.__ebox.show_all()
36
 
        self.__trayicon.add(self.__ebox)
37
 
 
38
 
        self.__ebox.connect("button-press-event", self.__on_button)
39
 
 
40
 
 
41
 
    def __on_button(self, src, event):
42
 
 
43
 
        if (event.button == 3):
44
 
            self.__menu.popup(None, None, None, event.button, event.time)
 
13
 
 
14
        self.__trayicon = gtk.status_icon_new_from_file(ICON)
 
15
        self.__trayicon.connect("popup-menu", self.__on_button)
 
16
 
 
17
 
 
18
 
 
19
    def __on_button(self, widget, button, time):
 
20
 
 
21
        if (button == 3):
 
22
            self.__menu.popup(None, None, None, button, time)
45
23
 
46
24
 
47
25
    def set_menu(self, items):
64
42
            item.show()
65
43
            self.__menu.append(item)
66
44
 
67
 
 
68
 
    def connect(self, event, *args):
69
 
 
70
 
        self.__ebox.connect(event, *args)