2008-08-15 19:31:51 +02:00
|
|
|
# -*- coding:utf-8 -*-
|
2008-08-15 05:20:23 +02:00
|
|
|
## src/statusicon.py
|
2006-10-05 02:05:47 +02:00
|
|
|
##
|
2008-08-15 05:20:23 +02:00
|
|
|
## Copyright (C) 2006 Nikos Kouremenos <kourem AT gmail.com>
|
|
|
|
## Copyright (C) 2006-2007 Jean-Marie Traissard <jim AT lapin.org>
|
|
|
|
## Copyright (C) 2006-2008 Yann Leboulanger <asterix AT lagaule.org>
|
|
|
|
## Copyright (C) 2007 Lukas Petrovicky <lukas AT petrovicky.net>
|
|
|
|
## Julien Pivotto <roidelapluie AT gmail.com>
|
|
|
|
## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
|
2006-10-05 02:05:47 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
2008-08-15 05:20:23 +02:00
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published
|
|
|
|
## by the Free Software Foundation; version 3 only.
|
2006-10-05 02:05:47 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2006-10-05 02:05:47 +02:00
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-08-15 05:20:23 +02:00
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2006-10-05 02:05:47 +02:00
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## You should have received a copy of the GNU General Public License
|
2008-08-15 05:20:23 +02:00
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
2007-10-22 13:13:13 +02:00
|
|
|
##
|
2006-10-05 02:05:47 +02:00
|
|
|
|
2007-11-14 20:47:52 +01:00
|
|
|
import sys
|
2006-10-05 02:05:47 +02:00
|
|
|
import gtk
|
|
|
|
import systray
|
|
|
|
|
|
|
|
from common import gajim
|
|
|
|
from common import helpers
|
|
|
|
|
|
|
|
class StatusIcon(systray.Systray):
|
|
|
|
'''Class for the notification area icon'''
|
|
|
|
#NOTE: gtk api does NOT allow:
|
|
|
|
# leave, enter motion notify
|
|
|
|
# and can't do cool tooltips we use
|
|
|
|
def __init__(self):
|
|
|
|
systray.Systray.__init__(self)
|
2007-01-31 17:38:04 +01:00
|
|
|
self.status_icon = None
|
2008-12-03 22:56:12 +01:00
|
|
|
|
2006-10-05 02:05:47 +02:00
|
|
|
def show_icon(self):
|
2007-01-31 17:38:04 +01:00
|
|
|
if not self.status_icon:
|
2007-02-01 17:26:52 +01:00
|
|
|
self.status_icon = gtk.StatusIcon()
|
2007-01-31 17:38:04 +01:00
|
|
|
self.status_icon.connect('activate', self.on_status_icon_left_clicked)
|
|
|
|
self.status_icon.connect('popup-menu',
|
|
|
|
self.on_status_icon_right_clicked)
|
2006-10-05 02:05:47 +02:00
|
|
|
|
|
|
|
self.set_img()
|
2007-11-14 20:47:52 +01:00
|
|
|
self.status_icon.set_visible(True)
|
|
|
|
self.subscribe_events()
|
2006-10-05 02:05:47 +02:00
|
|
|
|
|
|
|
def on_status_icon_right_clicked(self, widget, event_button, event_time):
|
|
|
|
self.make_menu(event_button, event_time)
|
|
|
|
|
|
|
|
def hide_icon(self):
|
2007-11-14 20:47:52 +01:00
|
|
|
self.status_icon.set_visible(False)
|
|
|
|
self.unsubscribe_events()
|
2006-10-05 02:05:47 +02:00
|
|
|
|
2008-08-15 05:20:23 +02:00
|
|
|
def on_status_icon_left_clicked(self, widget):
|
2009-02-14 14:01:57 +01:00
|
|
|
self.on_left_click()
|
2006-10-05 02:05:47 +02:00
|
|
|
|
|
|
|
def set_img(self):
|
2006-10-10 10:05:02 +02:00
|
|
|
'''apart from image, we also update tooltip text here'''
|
2006-10-05 02:05:47 +02:00
|
|
|
if not gajim.interface.systray_enabled:
|
|
|
|
return
|
|
|
|
text = helpers.get_notification_icon_tooltip_text()
|
|
|
|
self.status_icon.set_tooltip(text)
|
|
|
|
if gajim.events.get_nb_systray_events():
|
2007-07-13 12:11:49 +02:00
|
|
|
state = 'event'
|
2007-11-14 20:47:52 +01:00
|
|
|
self.status_icon.set_blinking(True)
|
2006-10-05 02:05:47 +02:00
|
|
|
else:
|
|
|
|
state = self.status
|
2007-11-14 20:47:52 +01:00
|
|
|
self.status_icon.set_blinking(False)
|
2008-12-03 22:56:12 +01:00
|
|
|
|
2006-10-05 02:05:47 +02:00
|
|
|
#FIXME: do not always use 16x16 (ask actually used size and use that)
|
2008-04-17 16:17:14 +02:00
|
|
|
image = gajim.interface.jabber_state_images['16'][state]
|
2006-10-05 02:05:47 +02:00
|
|
|
if image.get_storage_type() == gtk.IMAGE_PIXBUF:
|
2007-11-14 20:47:52 +01:00
|
|
|
self.status_icon.set_from_pixbuf(image.get_pixbuf())
|
2006-10-05 02:05:47 +02:00
|
|
|
#FIXME: oops they forgot to support GIF animation?
|
|
|
|
#or they were lazy to get it to work under Windows! WTF!
|
|
|
|
#elif image.get_storage_type() == gtk.IMAGE_ANIMATION:
|
|
|
|
# self.img_tray.set_from_animation(image.get_animation())
|
2008-07-29 21:49:31 +02:00
|
|
|
|
2008-08-15 05:20:23 +02:00
|
|
|
# vim: se ts=3:
|