diff --unidirectional-new-file -ur gajim-0.13.4.original/data/glade/preferences_window.glade gajim-0.13.4/data/glade/preferences_window.glade
--- gajim-0.13.4.original/data/glade/preferences_window.glade 2010-01-20 12:59:33.000000000 +0300
+++ gajim-0.13.4/data/glade/preferences_window.glade 2010-06-04 01:57:17.680929834 +0400
@@ -556,6 +556,21 @@
+
+ True
+ True
+ Enable Ubuntu indicator support
+ True
+ 0
+ True
+
+
+
+ False
+ False
+
+
+
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
True
diff --unidirectional-new-file -ur gajim-0.13.4.original/src/common/config.py gajim-0.13.4/src/common/config.py
--- gajim-0.13.4.original/src/common/config.py 2010-01-20 12:59:33.000000000 +0300
+++ gajim-0.13.4/src/common/config.py 2010-06-04 01:36:26.964960062 +0400
@@ -86,6 +86,7 @@
'ask_online_status': [ opt_bool, False ],
'ask_offline_status': [ opt_bool, False ],
'trayicon': [opt_str, 'always', _("When to show systray icon. Can be 'never', 'on_event', 'always'."), True],
+ 'use_ubuntu_indicator': [ opt_bool, True, _("Enable Ubuntu indicator support"), ],
'iconset': [ opt_str, DEFAULT_ICONSET, '', True ],
'mood_iconset': [ opt_str, DEFAULT_MOOD_ICONSET, '', True ],
'activity_iconset': [ opt_str, DEFAULT_ACTIVITY_ICONSET, '', True ],
diff --unidirectional-new-file -ur gajim-0.13.4.original/src/config.py gajim-0.13.4/src/config.py
--- gajim-0.13.4.original/src/config.py 2010-03-28 13:35:54.000000000 +0400
+++ gajim-0.13.4/src/config.py 2010-06-04 01:40:38.777054272 +0400
@@ -97,6 +97,7 @@
self.auto_xa_time_spinbutton = self.xml.get_widget(
'auto_xa_time_spinbutton')
self.auto_xa_message_entry = self.xml.get_widget('auto_xa_message_entry')
+ self.use_ubuntu_indicator_checkbutton = self.xml.get_widget('use_ubuntu_indicator_checkbutton')
### General tab ###
# Display avatars in roster
@@ -317,6 +318,15 @@
if not gajim.interface.systray_capabilities:
systray_combobox.set_sensitive(False)
+ # indicator
+ if not gajim.interface.indicator:
+ self.use_ubuntu_indicator_checkbutton.set_sensitive(False)
+ else:
+ st = gajim.config.get('use_ubuntu_indicator')
+ self.use_ubuntu_indicator_checkbutton.set_active(st)
+ if st:
+ gajim.interface.indicator.enable()
+
# sounds
if gajim.config.get('sounds_on'):
self.xml.get_widget('play_sounds_checkbutton').set_active(True)
@@ -1013,6 +1023,13 @@
def on_notify_gmail_extra_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'notify_on_new_gmail_email_extra')
+ def on_use_ubuntu_indicator_toggled(self, widget):
+ self.on_checkbutton_toggled(widget, 'use_ubuntu_indicator')
+ if widget.get_active():
+ gajim.interface.indicator.enable()
+ else:
+ gajim.interface.indicator.disable()
+
def fill_msg_treeview(self):
self.xml.get_widget('delete_msg_button').set_sensitive(False)
model = self.msg_tree.get_model()
diff --unidirectional-new-file -ur gajim-0.13.4.original/src/gajim.py gajim-0.13.4/src/gajim.py
--- gajim-0.13.4.original/src/gajim.py 2010-03-28 13:35:54.000000000 +0400
+++ gajim-0.13.4/src/gajim.py 2010-06-04 01:36:26.956961978 +0400
@@ -3415,10 +3415,6 @@
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:
@@ -3640,6 +3636,14 @@
# set the icon to all windows
gtk.window_set_default_icon(pix)
+ try:
+ import ubuntu_indicator
+ self.indicator = ubuntu_indicator.UbuntuIndicator()
+ if gajim.config.get('use_ubuntu_indicator'):
+ self.indicator.enable()
+ except:
+ self.indicator = None
+
self.init_emoticons()
self.make_regexps()
diff --unidirectional-new-file -ur gajim-0.13.4.original/src/notify.py gajim-0.13.4/src/notify.py
--- gajim-0.13.4.original/src/notify.py 2010-03-28 13:37:23.000000000 +0400
+++ gajim-0.13.4/src/notify.py 2010-06-04 01:36:26.964960062 +0400
@@ -50,24 +50,6 @@
except ImportError:
USER_HAS_PYNOTIFY = False
-if gajim.HAVE_INDICATOR:
- import indicate
-
-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':
@@ -339,18 +321,6 @@
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.Indicator()
- 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 to show our popup via D-Bus and notification daemon
if gajim.config.get('use_notif_daemon') and dbus_support.supported:
try:
diff --unidirectional-new-file -ur gajim-0.13.4.original/src/roster_window.py gajim-0.13.4/src/roster_window.py
--- gajim-0.13.4.original/src/roster_window.py 2010-03-28 13:36:19.000000000 +0400
+++ gajim-0.13.4/src/roster_window.py 2010-06-04 01:36:26.969929688 +0400
@@ -2275,8 +2275,9 @@
def on_roster_window_delete_event(self, widget, event):
'''Main window X button was clicked'''
- if gajim.interface.systray_enabled and not gajim.config.get(
- 'quit_on_roster_x_button') and gajim.config.get('trayicon') != 'on_event':
+ if (gajim.interface.systray_enabled and not gajim.config.get(
+ 'quit_on_roster_x_button') and gajim.config.get('trayicon') != 'on_event') \
+ or (gajim.config.get('use_ubuntu_indicator') and gajim.interface.indicator):
self.tooltip.hide_tooltip()
self.window.hide()
elif gajim.config.get('quit_on_roster_x_button'):
@@ -6049,8 +6050,10 @@
if gajim.config.get('show_roster_on_startup'):
self.window.show_all()
else:
- if not gajim.config.get('trayicon') or not \
- gajim.interface.systray_capabilities:
+ if (not gajim.config.get('trayicon') or not \
+ gajim.interface.systray_capabilities) and \
+ (not gajim.config.get('use_ubuntu_indicator') or \
+ not gajim.interface.indicator):
# cannot happen via GUI, but I put this incase user touches
# config. without trayicon, he or she should see the roster!
self.window.show_all()
diff --unidirectional-new-file -ur gajim-0.13.4.original/src/ubuntu_indicator.py gajim-0.13.4/src/ubuntu_indicator.py
--- gajim-0.13.4.original/src/ubuntu_indicator.py 1970-01-01 03:00:00.000000000 +0300
+++ gajim-0.13.4/src/ubuntu_indicator.py 2010-06-04 01:36:26.969929688 +0400
@@ -0,0 +1,104 @@
+# -*- coding:utf-8 -*-
+## src/ubuntu_indicator.py
+##
+## Copyright (C) 2006 Nikos Kouremenos
+## Copyright (C) 2006-2007 Jean-Marie Traissard
+## Copyright (C) 2006-2010 Yann Leboulanger
+## Copyright (C) 2007 Lukas Petrovicky
+## Julien Pivotto
+## Copyright (C) 2008 Jonathan Schleifer
+##
+## This file is part of Gajim.
+##
+## 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.
+##
+## Gajim is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Gajim. If not, see .
+##
+
+import time
+import indicate
+from common import gajim
+
+class UbuntuIndicator:
+ """
+ Class for the Ubuntu Indicator support
+ """
+
+ def __init__(self):
+ self.server = None
+ self.indicators = {}
+
+ def enable(self):
+ """
+ Called when indicator support is enabled in config
+ """
+ self.server = indicate.indicate_server_ref_default()
+ self.server.set_type('message.instant')
+ self.server.set_desktop_file('/usr/share/applications/gajim.desktop')
+ self.server.connect('server-display', self.on_server_display)
+ self.server.show()
+
+ gajim.events.event_added_subscribe(self.on_event_added)
+ gajim.events.event_removed_subscribe(self.on_event_removed)
+
+ def disable(self):
+ """
+ Called when indicator support is disabled in config
+ """
+ gajim.events.event_added_unsubscribe(self.on_event_added)
+ gajim.events.event_removed_unsubscribe(self.on_event_removed)
+
+ self.server.hide()
+ self.server = None
+ self.indicators = {}
+
+ def on_server_display(self, server, dummy):
+ """
+ Called when user clicks our name in indicator
+ """
+ win = gajim.interface.roster.window
+ if win.get_property('visible'):
+ win.hide()
+ else:
+ win.show_all()
+
+ def on_user_display(self, indicator, dummy, account, jid):
+ gajim.interface.new_chat_from_jid(account, jid)
+
+ def on_event_added(self, event):
+ """
+ Called when an event is added to the event list
+ """
+ indicator = None
+ if self.indicators.has_key(event.account):
+ if self.indicators[event.account].has_key(event.jid):
+ indicator = self.indicators[event.account][event.jid]
+ else:
+ self.indicators[event.account] = {}
+
+ if indicator == None:
+ indicator = indicate.Indicator()
+ self.indicators[event.account][event.jid] = indicator
+ indicator.set_property('subtype', 'im')
+ indicator.set_property('sender', event.jid)
+ indicator.set_property('draw-attention', 'true')
+ indicator.connect('user-display', self.on_user_display, event.account, event.jid)
+ indicator.set_property_time('time', time.time())
+ indicator.show()
+
+ def on_event_removed(self, event_list):
+ """
+ Called when one or more events are removed from the event list
+ """
+ for event in event_list:
+ if self.indicators.has_key(event.account):
+ if self.indicators[event.account].has_key(event.jid):
+ self.indicators[event.account][event.jid].hide()