4 ## Copyright (C) 2006 Nikos Kouremenos <kourem AT gmail.com>
5 ## Copyright (C) 2006-2007 Jean-Marie Traissard <jim AT lapin.org>
6 ## Copyright (C) 2006-2008 Yann Leboulanger <asterix AT lagaule.org>
7 ## Copyright (C) 2007 Lukas Petrovicky <lukas AT petrovicky.net>
8 ## Julien Pivotto <roidelapluie AT gmail.com>
9 ## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
11 ## This file is part of Gajim.
13 ## Gajim is free software; you can redistribute it and/or modify
14 ## it under the terms of the GNU General Public License as published
15 ## by the Free Software Foundation; version 3 only.
17 ## Gajim is distributed in the hope that it will be useful,
18 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ## GNU General Public License for more details.
22 ## You should have received a copy of the GNU General Public License
23 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
30 from common
import gajim
31 from common
import helpers
33 class StatusIcon(systray
.Systray
):
34 '''Class for the notification area icon'''
35 #NOTE: gtk api does NOT allow:
36 # leave, enter motion notify
37 # and can't do cool tooltips we use
39 systray
.Systray
.__init
__(self
)
40 self
.status_icon
= None
43 if not self
.status_icon
:
44 self
.status_icon
= gtk
.StatusIcon()
45 self
.status_icon
.connect('activate', self
.on_status_icon_left_clicked
)
46 self
.status_icon
.connect('popup-menu',
47 self
.on_status_icon_right_clicked
)
50 self
.status_icon
.set_visible(True)
51 self
.subscribe_events()
53 def on_status_icon_right_clicked(self
, widget
, event_button
, event_time
):
54 self
.make_menu(event_button
, event_time
)
57 self
.status_icon
.set_visible(False)
58 self
.unsubscribe_events()
60 def on_status_icon_left_clicked(self
, widget
):
64 '''apart from image, we also update tooltip text here'''
65 if not gajim
.interface
.systray_enabled
:
67 text
= helpers
.get_notification_icon_tooltip_text()
68 self
.status_icon
.set_tooltip(text
)
69 if gajim
.events
.get_nb_systray_events():
71 self
.status_icon
.set_blinking(True)
74 self
.status_icon
.set_blinking(False)
76 #FIXME: do not always use 16x16 (ask actually used size and use that)
77 image
= gajim
.interface
.jabber_state_images
['16'][state
]
78 if image
.get_storage_type() == gtk
.IMAGE_PIXBUF
:
79 self
.status_icon
.set_from_pixbuf(image
.get_pixbuf())
80 #FIXME: oops they forgot to support GIF animation?
81 #or they were lazy to get it to work under Windows! WTF!
82 #elif image.get_storage_type() == gtk.IMAGE_ANIMATION:
83 # self.img_tray.set_from_animation(image.get_animation())