[ken.vandine] add indicator support. Fixes #4942

This commit is contained in:
Yann Leboulanger 2009-04-04 05:06:46 +00:00
parent 952dab118b
commit e0f0871ea6
3 changed files with 38 additions and 0 deletions

View File

@ -182,6 +182,12 @@ else:
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,

View File

@ -3448,6 +3448,10 @@ class Interface:
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:

View File

@ -32,6 +32,7 @@ import time
import dialogs
import gobject
import gtkgui_helpers
import gtk
from common import gajim
from common import helpers
@ -56,6 +57,21 @@ try:
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 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None,
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: