root/branches/gajim_0.11/src/statusicon.py

Revision 7940, 2.5 kB (checked in by asterix, 19 months ago)

merge diff from trunk

Line 
1## statusicon.py
2##
3## Copyright (C) 2006 Nikos Kouremenos <kourem@gmail.com>
4##
5## This program is free software; you can redistribute it and/or
6## modify it under the terms of the GNU General Public License
7## as published by the Free Software Foundation; either version 2
8## of the License, or (at your option) any later version.
9##
10## This program is distributed in the hope that it will be useful,
11## but WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13## GNU General Public License for more details.
14##
15
16import gtk
17import systray
18
19from common import gajim
20from common import helpers
21
22class StatusIcon(systray.Systray):
23        '''Class for the notification area icon'''
24        #FIXME: when we migrate to GTK 2.10 stick only to this class
25        # (move base stuff from systray.py and rm it)
26        #NOTE: gtk api does NOT allow:
27        # leave, enter motion notify
28        # and can't do cool tooltips we use
29        def __init__(self):
30                systray.Systray.__init__(self)
31                self.status_icon = None
32               
33        def show_icon(self):
34                if not self.status_icon:
35                        self.status_icon = gtk.StatusIcon()
36                        self.status_icon.connect('activate', self.on_status_icon_left_clicked)
37                        self.status_icon.connect('popup-menu',
38                                self.on_status_icon_right_clicked)
39
40                self.set_img()
41                self.status_icon.props.visible = True   
42
43        def on_status_icon_right_clicked(self, widget, event_button, event_time):
44                self.make_menu(event_button, event_time)
45
46        def hide_icon(self):
47                self.status_icon.props.visible = False
48
49        def on_status_icon_left_clicked(self, widget):
50                self.on_left_click()
51
52        def set_img(self):
53                '''apart from image, we also update tooltip text here'''
54                if not gajim.interface.systray_enabled:
55                        return
56                text = helpers.get_notification_icon_tooltip_text()
57                self.status_icon.set_tooltip(text)
58                if gajim.events.get_nb_systray_events():
59                        state = 'message' # FIXME: this state should be called event, not message
60                        self.status_icon.props.blinking = True
61                else:
62                        state = self.status
63                        self.status_icon.props.blinking = False
64               
65                #FIXME: do not always use 16x16 (ask actually used size and use that)
66                image = gajim.interface.roster.jabber_state_images['16'][state]
67                if image.get_storage_type() == gtk.IMAGE_PIXBUF:
68                        self.status_icon.props.pixbuf = image.get_pixbuf()
69                #FIXME: oops they forgot to support GIF animation?
70                #or they were lazy to get it to work under Windows! WTF!
71                #elif image.get_storage_type() == gtk.IMAGE_ANIMATION:
72                #       self.img_tray.set_from_animation(image.get_animation())
Note: See TracBrowser for help on using the browser.