don't prevent removing a sevret key when none in available. Fixes #1210
[gajim.git] / src / statusicon.py
blob90bdb8c91940668409bc147e222edcb3b6df6d00
1 # -*- coding:utf-8 -*-
2 ## src/statusicon.py
3 ##
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/>.
26 import sys
27 import gtk
28 import systray
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
38 def __init__(self):
39 systray.Systray.__init__(self)
40 self.status_icon = None
42 def show_icon(self):
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)
49 self.set_img()
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)
56 def hide_icon(self):
57 self.status_icon.set_visible(False)
58 self.unsubscribe_events()
60 def on_status_icon_left_clicked(self, widget):
61 self.on_left_click()
63 def set_img(self):
64 '''apart from image, we also update tooltip text here'''
65 if not gajim.interface.systray_enabled:
66 return
67 text = helpers.get_notification_icon_tooltip_text()
68 self.status_icon.set_tooltip(text)
69 if gajim.events.get_nb_systray_events():
70 state = 'event'
71 self.status_icon.set_blinking(True)
72 else:
73 state = self.status
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())
85 # vim: se ts=3: