[ken.vandine] add indicator support. Fixes #4942
This commit is contained in:
parent
952dab118b
commit
e0f0871ea6
3 changed files with 38 additions and 0 deletions
|
@ -182,6 +182,12 @@ else:
|
||||||
import latex
|
import latex
|
||||||
HAVE_LATEX = latex.check_for_latex_support()
|
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_identity = {'type': 'pc', 'category': 'client', 'name': 'Gajim'}
|
||||||
gajim_common_features = [xmpp.NS_BYTESTREAM, xmpp.NS_SI, xmpp.NS_FILE,
|
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,
|
xmpp.NS_MUC, xmpp.NS_MUC_USER, xmpp.NS_MUC_ADMIN, xmpp.NS_MUC_OWNER,
|
||||||
|
|
|
@ -3448,6 +3448,10 @@ class Interface:
|
||||||
if resolver.USE_LIBASYNCNS:
|
if resolver.USE_LIBASYNCNS:
|
||||||
gobject.timeout_add(200, gajim.resolver.process)
|
gobject.timeout_add(200, gajim.resolver.process)
|
||||||
|
|
||||||
|
# setup the indicator
|
||||||
|
if gajim.HAVE_INDICATOR:
|
||||||
|
notify.setup_indicator_server()
|
||||||
|
|
||||||
def remote_init():
|
def remote_init():
|
||||||
if gajim.config.get('remote_control'):
|
if gajim.config.get('remote_control'):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -32,6 +32,7 @@ import time
|
||||||
import dialogs
|
import dialogs
|
||||||
import gobject
|
import gobject
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
|
import gtk
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from common import helpers
|
from common import helpers
|
||||||
|
@ -56,6 +57,21 @@ try:
|
||||||
except Exception:
|
except Exception:
|
||||||
USER_HAS_GROWL = False
|
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):
|
def get_show_in_roster(event, account, contact, session=None):
|
||||||
'''Return True if this event must be shown in roster, else False'''
|
'''Return True if this event must be shown in roster, else False'''
|
||||||
if event == 'gc_message_received':
|
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',
|
os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
'chat_msg_recv.png')) # img to display
|
'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
|
# Try Growl first, as we might have D-Bus and notification daemon running
|
||||||
# on OS X for some reason.
|
# on OS X for some reason.
|
||||||
if USER_HAS_GROWL:
|
if USER_HAS_GROWL:
|
||||||
|
|
Loading…
Add table
Reference in a new issue