[commit-gajim] r11185 - in trunk/src: . common

asterix at gajim.org asterix at gajim.org
Sat Apr 4 07:06:46 CEST 2009


Author: asterix
Date: 2009-04-04 07:06:46 +0200 (Sat, 04 Apr 2009)
New Revision: 11185

Modified:
   trunk/src/common/gajim.py
   trunk/src/gajim.py
   trunk/src/notify.py
Log:
[ken.vandine] add indicator support. Fixes #4942


Modified: trunk/src/common/gajim.py
===================================================================
--- trunk/src/common/gajim.py	2009-04-03 18:48:31 UTC (rev 11184)
+++ trunk/src/common/gajim.py	2009-04-04 05:06:46 UTC (rev 11185)
@@ -182,6 +182,12 @@
 import latex
 HAVE_LATEX = latex.check_for_latex_support()
 
+HAVE_INDICATOR = True
+try:
+	import indicate
+except ImportError:
+	HAVE_INDICATOR = False
+
 gajim_identity = {'type': 'pc', 'category': 'client', 'name': 'Gajim'}
 gajim_common_features = [xmpp.NS_BYTESTREAM, xmpp.NS_SI, xmpp.NS_FILE,
 	xmpp.NS_MUC, xmpp.NS_MUC_USER, xmpp.NS_MUC_ADMIN, xmpp.NS_MUC_OWNER,

Modified: trunk/src/gajim.py
===================================================================
--- trunk/src/gajim.py	2009-04-03 18:48:31 UTC (rev 11184)
+++ trunk/src/gajim.py	2009-04-04 05:06:46 UTC (rev 11185)
@@ -3448,6 +3448,10 @@
 		if resolver.USE_LIBASYNCNS:
 			gobject.timeout_add(200, gajim.resolver.process)
 
+		# setup the indicator
+		if gajim.HAVE_INDICATOR:
+			notify.setup_indicator_server()
+
 		def remote_init():
 			if gajim.config.get('remote_control'):
 				try:

Modified: trunk/src/notify.py
===================================================================
--- trunk/src/notify.py	2009-04-03 18:48:31 UTC (rev 11184)
+++ trunk/src/notify.py	2009-04-04 05:06:46 UTC (rev 11185)
@@ -32,6 +32,7 @@
 import dialogs
 import gobject
 import gtkgui_helpers
+import gtk
 
 from common import gajim
 from common import helpers
@@ -56,6 +57,21 @@
 except Exception:
 	USER_HAS_GROWL = False
 
+def setup_indicator_server(): 
+	server = indicate.indicate_server_ref_default() 
+	server.set_type('message.im') 
+	server.set_desktop_file('/usr/share/applications/gajim.desktop') 
+	server.connect('server-display', server_display) 
+	server.show() 
+
+def display(indicator, account, jid, msg_type): 
+	gajim.interface.handle_event(account, jid, msg_type) 
+	indicator.hide() 
+
+def server_display(server): 
+	win = gajim.interface.roster.window 
+	win.present()
+
 def get_show_in_roster(event, account, contact, session=None):
 	'''Return True if this event must be shown in roster, else False'''
 	if event == 'gc_message_received':
@@ -327,6 +343,18 @@
 			os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
 				'chat_msg_recv.png')) # img to display
 
+	if gajim.HAVE_INDICATOR and event_type in (_('New Message'),
+	_('New Single Message'), _('New Private Message')):
+		indicator = indicate.IndicatorMessage()
+		indicator.set_property('subtype', 'im')
+		indicator.set_property('sender', jid)
+		indicator.set_property('body', text)
+		indicator.set_property_time('time', time.time())
+		pixbuf = gtk.gdk.pixbuf_new_from_file(path_to_image)
+		indicator.set_property_icon('icon', pixbuf)
+		indicator.connect('user-display', display, account, jid, msg_type)
+		indicator.show()
+
 	# Try Growl first, as we might have D-Bus and notification daemon running
 	# on OS X for some reason.
 	if USER_HAS_GROWL:



More information about the Commits mailing list