[James Westby] Don't use actions in notifications if the server doesn't support them. Fixes #4862
This commit is contained in:
parent
dccf065418
commit
4b3206f043
|
@ -372,6 +372,7 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None,
|
||||||
notification.set_data('account', account)
|
notification.set_data('account', account)
|
||||||
notification.set_data('msg_type', msg_type)
|
notification.set_data('msg_type', msg_type)
|
||||||
notification.set_property('icon-name', path_to_image)
|
notification.set_property('icon-name', path_to_image)
|
||||||
|
if 'actions' in pynotify.get_server_caps():
|
||||||
notification.add_action('default', 'Default Action',
|
notification.add_action('default', 'Default Action',
|
||||||
on_pynotify_notification_clicked)
|
on_pynotify_notification_clicked)
|
||||||
|
|
||||||
|
@ -507,6 +508,7 @@ class DesktopNotification:
|
||||||
if self.notif is None:
|
if self.notif is None:
|
||||||
raise dbus.DBusException('unable to get notifications interface')
|
raise dbus.DBusException('unable to get notifications interface')
|
||||||
self.ntype = ntype
|
self.ntype = ntype
|
||||||
|
self.capabilities = self.notif.GetCapabilities()
|
||||||
|
|
||||||
if self.kde_notifications:
|
if self.kde_notifications:
|
||||||
self.attempt_notify()
|
self.attempt_notify()
|
||||||
|
@ -522,6 +524,10 @@ class DesktopNotification:
|
||||||
'text': self.text, 'image': self.path_to_image}
|
'text': self.text, 'image': self.path_to_image}
|
||||||
gajim_icon = os.path.abspath(os.path.join(gajim.DATA_DIR, 'pixmaps',
|
gajim_icon = os.path.abspath(os.path.join(gajim.DATA_DIR, 'pixmaps',
|
||||||
'gajim.png'))
|
'gajim.png'))
|
||||||
|
actions = ()
|
||||||
|
if 'actions' in self.capabilities:
|
||||||
|
actions = (dbus.String('default'), dbus.String(self.event_type),
|
||||||
|
dbus.String('ignore'), dbus.String(_('Ignore')))
|
||||||
self.notif.Notify(
|
self.notif.Notify(
|
||||||
dbus.String(_('Gajim')), # app_name (string)
|
dbus.String(_('Gajim')), # app_name (string)
|
||||||
dbus.UInt32(0), # replaces_id (uint)
|
dbus.UInt32(0), # replaces_id (uint)
|
||||||
|
@ -529,9 +535,7 @@ class DesktopNotification:
|
||||||
dbus.String(gajim_icon), # app_icon (string)
|
dbus.String(gajim_icon), # app_icon (string)
|
||||||
dbus.String(_('')), # summary (string)
|
dbus.String(_('')), # summary (string)
|
||||||
dbus.String(notification_text), # body (string)
|
dbus.String(notification_text), # body (string)
|
||||||
# actions (stringlist)
|
actions, # actions (stringlist)
|
||||||
(dbus.String('default'), dbus.String(self.event_type),
|
|
||||||
dbus.String('ignore'), dbus.String(_('Ignore'))),
|
|
||||||
[], # hints (not used in KDE yet)
|
[], # hints (not used in KDE yet)
|
||||||
dbus.UInt32(timeout*1000), # timeout (int), in ms
|
dbus.UInt32(timeout*1000), # timeout (int), in ms
|
||||||
reply_handler=self.attach_by_id,
|
reply_handler=self.attach_by_id,
|
||||||
|
@ -539,6 +543,9 @@ class DesktopNotification:
|
||||||
return
|
return
|
||||||
version = self.version
|
version = self.version
|
||||||
if version[:2] == [0, 2]:
|
if version[:2] == [0, 2]:
|
||||||
|
actions = {}
|
||||||
|
if 'actions' in self.capabilities:
|
||||||
|
actions = {'default': 0}
|
||||||
try:
|
try:
|
||||||
self.notif.Notify(
|
self.notif.Notify(
|
||||||
dbus.String(_('Gajim')),
|
dbus.String(_('Gajim')),
|
||||||
|
@ -549,7 +556,7 @@ class DesktopNotification:
|
||||||
dbus.String(self.title),
|
dbus.String(self.title),
|
||||||
dbus.String(self.text),
|
dbus.String(self.text),
|
||||||
[dbus.String(self.path_to_image)],
|
[dbus.String(self.path_to_image)],
|
||||||
{'default': 0},
|
actions,
|
||||||
[''],
|
[''],
|
||||||
True,
|
True,
|
||||||
dbus.UInt32(timeout),
|
dbus.UInt32(timeout),
|
||||||
|
@ -576,13 +583,16 @@ class DesktopNotification:
|
||||||
text = self.text
|
text = self.text
|
||||||
else:
|
else:
|
||||||
text = ' '
|
text = ' '
|
||||||
|
actions = ()
|
||||||
|
if 'actions' in self.capabilities:
|
||||||
|
actions = (dbus.String('default'), dbus.String(self.event_type)),
|
||||||
self.notif.Notify(
|
self.notif.Notify(
|
||||||
dbus.String(_('Gajim')),
|
dbus.String(_('Gajim')),
|
||||||
dbus.UInt32(0), # this notification does not replace other
|
dbus.UInt32(0), # this notification does not replace other
|
||||||
dbus.String(self.path_to_image),
|
dbus.String(self.path_to_image),
|
||||||
dbus.String(self.title),
|
dbus.String(self.title),
|
||||||
dbus.String(text),
|
dbus.String(text),
|
||||||
( dbus.String('default'), dbus.String(self.event_type) ),
|
actions,
|
||||||
hints,
|
hints,
|
||||||
dbus.UInt32(timeout*1000),
|
dbus.UInt32(timeout*1000),
|
||||||
reply_handler=self.attach_by_id,
|
reply_handler=self.attach_by_id,
|
||||||
|
|
Loading…
Reference in New Issue