Ability to disable message previews in notify popups. Fixes #3088
This commit is contained in:
parent
967a7e8144
commit
5f1eaeb312
2 changed files with 17 additions and 6 deletions
|
@ -182,6 +182,7 @@ class Config:
|
||||||
'tooltip_avatar_height': [opt_int, 125],
|
'tooltip_avatar_height': [opt_int, 125],
|
||||||
'vcard_avatar_width': [opt_int, 200],
|
'vcard_avatar_width': [opt_int, 200],
|
||||||
'vcard_avatar_height': [opt_int, 200],
|
'vcard_avatar_height': [opt_int, 200],
|
||||||
|
'notification_preview_message': [opt_bool, True, _('Preview new messages in notification popup?')],
|
||||||
'notification_position_x': [opt_int, -1],
|
'notification_position_x': [opt_int, -1],
|
||||||
'notification_position_y': [opt_int, -1],
|
'notification_position_y': [opt_int, -1],
|
||||||
'notification_avatar_width': [opt_int, 48],
|
'notification_avatar_width': [opt_int, 48],
|
||||||
|
|
|
@ -123,6 +123,7 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
|
||||||
do_popup = False
|
do_popup = False
|
||||||
do_sound = False
|
do_sound = False
|
||||||
do_cmd = False
|
do_cmd = False
|
||||||
|
do_preview = True # defaults to true: do not reset emtpy text in new_message
|
||||||
if event == 'status_change':
|
if event == 'status_change':
|
||||||
new_show = parameters[0]
|
new_show = parameters[0]
|
||||||
status_message = parameters[1]
|
status_message = parameters[1]
|
||||||
|
@ -154,7 +155,11 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
|
||||||
message_type = parameters[0]
|
message_type = parameters[0]
|
||||||
is_first_message = parameters[1]
|
is_first_message = parameters[1]
|
||||||
nickname = parameters[2]
|
nickname = parameters[2]
|
||||||
message = parameters[3]
|
if gajim.config.get('notification_preview_message'):
|
||||||
|
message = parameters[3]
|
||||||
|
else:
|
||||||
|
do_preview = False
|
||||||
|
message = ''
|
||||||
if helpers.allow_showing_notification(account, 'notify_on_new_message',
|
if helpers.allow_showing_notification(account, 'notify_on_new_message',
|
||||||
advanced_notif_num, is_first_message):
|
advanced_notif_num, is_first_message):
|
||||||
do_popup = True
|
do_popup = True
|
||||||
|
@ -235,8 +240,12 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
'priv_msg_recv.png')
|
'priv_msg_recv.png')
|
||||||
title = _('New Private Message from group chat %s') % room_name
|
title = _('New Private Message from group chat %s') % room_name
|
||||||
text = _('%(nickname)s: %(message)s') % {'nickname': nickname,
|
if do_preview:
|
||||||
'message': message}
|
text = _('%(nickname)s: %(message)s') % {'nickname': nickname,
|
||||||
|
'message': message}
|
||||||
|
else:
|
||||||
|
text = _('Messaged by %(nickname)s') % {'nickname': nickname}
|
||||||
|
|
||||||
else: # chat message
|
else: # chat message
|
||||||
event_type = _('New Message')
|
event_type = _('New Message')
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
|
@ -299,7 +308,7 @@ def popup(event_type, jid, account, msg_type = '', path_to_image = None,
|
||||||
gajim.log.debug(str(e))
|
gajim.log.debug(str(e))
|
||||||
# we failed to speak to notification daemon via D-Bus
|
# we failed to speak to notification daemon via D-Bus
|
||||||
if USER_HAS_PYNOTIFY: # try via libnotify
|
if USER_HAS_PYNOTIFY: # try via libnotify
|
||||||
if not text:
|
if not text and do_preview:
|
||||||
text = gajim.get_name_from_jid(account, jid) # default value of text
|
text = gajim.get_name_from_jid(account, jid) # default value of text
|
||||||
if not title:
|
if not title:
|
||||||
title = event_type
|
title = event_type
|
||||||
|
@ -408,8 +417,9 @@ class DesktopNotification:
|
||||||
self.jid = jid
|
self.jid = jid
|
||||||
self.msg_type = msg_type
|
self.msg_type = msg_type
|
||||||
|
|
||||||
if not text:
|
# default value of text
|
||||||
# default value of text
|
if not text and event_type == 'new_message':
|
||||||
|
# empty text for new_message means do_preview = False
|
||||||
self.text = gajim.get_name_from_jid(account, jid)
|
self.text = gajim.get_name_from_jid(account, jid)
|
||||||
|
|
||||||
if not title:
|
if not title:
|
||||||
|
|
Loading…
Add table
Reference in a new issue