better title / text in popup windows. Fixes #1790
This commit is contained in:
parent
c31f3cf03a
commit
ddfd3d7be6
|
@ -991,7 +991,8 @@ class ChangePasswordDialog:
|
||||||
|
|
||||||
|
|
||||||
class PopupNotificationWindow:
|
class PopupNotificationWindow:
|
||||||
def __init__(self, event_type, jid, account, msg_type = '', path_to_image = None, text = None):
|
def __init__(self, event_type, jid, account, msg_type = '',
|
||||||
|
path_to_image = None, title = None, text = None):
|
||||||
self.account = account
|
self.account = account
|
||||||
self.jid = jid
|
self.jid = jid
|
||||||
self.msg_type = msg_type
|
self.msg_type = msg_type
|
||||||
|
@ -1005,10 +1006,12 @@ class PopupNotificationWindow:
|
||||||
image = xml.get_widget('notification_image')
|
image = xml.get_widget('notification_image')
|
||||||
|
|
||||||
event_type_label.set_markup(
|
event_type_label.set_markup(
|
||||||
'<span foreground="black" weight="bold">%s</span>' % event_type)
|
'<span foreground="black" weight="bold">%s</span>' % title)
|
||||||
|
|
||||||
if not text:
|
if not text:
|
||||||
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:
|
||||||
|
title = event_type
|
||||||
|
|
||||||
# set colors [ http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html ]
|
# set colors [ http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html ]
|
||||||
self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black'))
|
self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black'))
|
||||||
|
|
101
src/gajim.py
101
src/gajim.py
|
@ -419,15 +419,13 @@ class Interface:
|
||||||
iconset, '48x48', 'online.png')
|
iconset, '48x48', 'online.png')
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img,
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img,
|
||||||
jid = jid, suffix = '_notif_size_colored.png')
|
jid = jid, suffix = '_notif_size_colored.png')
|
||||||
|
title = _('%(nickname)s Signed In') % \
|
||||||
|
{'nickname': gajim.get_name_from_jid(account, jid)}
|
||||||
|
text = ''
|
||||||
if status_message:
|
if status_message:
|
||||||
text = _('%(nickname)s with status message: %(msg)s') %\
|
text = status_message
|
||||||
{'nickname': gajim.get_name_from_jid(account, jid),
|
|
||||||
'msg': status_message}
|
|
||||||
else:
|
|
||||||
# just the nickname
|
|
||||||
text = gajim.get_name_from_jid(account, jid)
|
|
||||||
notify.notify(_('Contact Signed In'), jid, account,
|
notify.notify(_('Contact Signed In'), jid, account,
|
||||||
path_to_image = path, text = text)
|
path_to_image = path, title = title, text = text)
|
||||||
|
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('ContactPresence',
|
self.remote_ctrl.raise_signal('ContactPresence',
|
||||||
|
@ -452,15 +450,13 @@ class Interface:
|
||||||
iconset, '48x48', 'offline.png')
|
iconset, '48x48', 'offline.png')
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img,
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img,
|
||||||
jid = jid, suffix = '_notif_size_bw.png')
|
jid = jid, suffix = '_notif_size_bw.png')
|
||||||
|
title = _('%(nickname)s Signed Out') % \
|
||||||
|
{'nickname': gajim.get_name_from_jid(account, jid)}
|
||||||
|
text = ''
|
||||||
if status_message:
|
if status_message:
|
||||||
text = _('%(nickname)s with status message: %(msg)s') %\
|
text = status_message
|
||||||
{'nickname': gajim.get_name_from_jid(account, jid),
|
|
||||||
'msg': status_message}
|
|
||||||
else:
|
|
||||||
# just the nickname
|
|
||||||
text = gajim.get_name_from_jid(account, jid)
|
|
||||||
notify.notify(_('Contact Signed Out'), jid, account,
|
notify.notify(_('Contact Signed Out'), jid, account,
|
||||||
path_to_image = path, text = text)
|
path_to_image = path, title = title, text = text)
|
||||||
|
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('ContactAbsence', (account, array))
|
self.remote_ctrl.raise_signal('ContactAbsence', (account, array))
|
||||||
|
@ -566,14 +562,15 @@ class Interface:
|
||||||
helpers.allow_showing_notification(account):
|
helpers.allow_showing_notification(account):
|
||||||
room_name, t = gajim.get_room_name_and_server_from_room_jid(
|
room_name, t = gajim.get_room_name_and_server_from_room_jid(
|
||||||
room_jid)
|
room_jid)
|
||||||
txt = _('%(nickname)s in room %(room_name)s says: %(message)s') \
|
|
||||||
% {'nickname': nick, 'room_name': room_name,
|
|
||||||
'message': message}
|
|
||||||
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')
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
||||||
|
title = _('New Private Message from room %s') % room_name
|
||||||
|
text = _('%(nickname)s: %(message)s') % {'nickname': nick,
|
||||||
|
'message': message}
|
||||||
notify.notify(_('New Private Message'), full_jid_with_resource,
|
notify.notify(_('New Private Message'), full_jid_with_resource,
|
||||||
account, 'pm', path_to_image = path, text = txt)
|
account, 'pm', path_to_image = path, title = title,
|
||||||
|
text = text)
|
||||||
|
|
||||||
groupchat_control.on_private_message(nick, message, array[2])
|
groupchat_control.on_private_message(nick, message, array[2])
|
||||||
return
|
return
|
||||||
|
@ -584,23 +581,24 @@ class Interface:
|
||||||
return
|
return
|
||||||
|
|
||||||
if first:
|
if first:
|
||||||
if gajim.config.get('notify_on_new_message'):
|
if gajim.config.get('notify_on_new_message') and \
|
||||||
if helpers.allow_showing_notification(account):
|
helpers.allow_showing_notification(account):
|
||||||
txt = _('%(nickname)s says: %(message)s') % \
|
text = message
|
||||||
{'nickname': gajim.get_name_from_jid(account, jid),
|
if msg_type == 'normal': # single message
|
||||||
'message': message}
|
event_type = _('New Single Message')
|
||||||
if msg_type == 'normal': # single message
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
'single_msg_recv.png')
|
||||||
'single_msg_recv.png')
|
title = _('New Single Message from %(nickname)s') % \
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
{'nickname': gajim.get_name_from_jid(account, jid)}
|
||||||
notify.notify(_('New Single Message'), jid_of_control,
|
else: # chat message
|
||||||
account, msg_type, path_to_image = path, text = txt)
|
event_type = _('New Message')
|
||||||
else: # chat message
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
'chat_msg_recv.png')
|
||||||
'chat_msg_recv.png')
|
title = _('New Message from %(nickname)s') % \
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
{'nickname': gajim.get_name_from_jid(account, jid)}
|
||||||
notify.notify(_('New Message'), jid_of_control, account,
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
||||||
msg_type, path_to_image = path, text = txt)
|
notify.notify(event_type, jid_of_control, account, msg_type,
|
||||||
|
path_to_image = path, title = title, text = text)
|
||||||
|
|
||||||
# array: (jid, msg, time, encrypted, msg_type, subject)
|
# array: (jid, msg, time, encrypted, msg_type, subject)
|
||||||
self.roster.on_message(jid, message, array[2], account, array[3],
|
self.roster.on_message(jid, message, array[2], account, array[3],
|
||||||
|
@ -932,12 +930,14 @@ class Interface:
|
||||||
self.add_event(account, jid, 'gc-invitation', (room_jid, array[2],
|
self.add_event(account, jid, 'gc-invitation', (room_jid, array[2],
|
||||||
array[3]))
|
array[3]))
|
||||||
|
|
||||||
if helpers.allow_showing_notification(account):
|
if gajim.config.get('notify_on_new_message') and \
|
||||||
|
helpers.allow_showing_notification(account):
|
||||||
path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
'gc_invitation.png')
|
'gc_invitation.png')
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(path)
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(path)
|
||||||
notify.notify(_('Groupchat Invitation'),
|
event_type = _('Groupchat Invitation')
|
||||||
jid, account, 'gc-invitation', path, room_jid)
|
notify.notify(event_type, jid, account, 'gc-invitation', path,
|
||||||
|
event_type, room_jid)
|
||||||
|
|
||||||
def handle_event_bad_passphrase(self, account, array):
|
def handle_event_bad_passphrase(self, account, array):
|
||||||
use_gpg_agent = gajim.config.get('use_gpg_agent')
|
use_gpg_agent = gajim.config.get('use_gpg_agent')
|
||||||
|
@ -1015,8 +1015,9 @@ class Interface:
|
||||||
if helpers.allow_showing_notification(account):
|
if helpers.allow_showing_notification(account):
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 'ft_error.png')
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 'ft_error.png')
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
||||||
notify.notify(_('File Transfer Error'),
|
event_type = _('File Transfer Error')
|
||||||
jid, account, 'file-send-error', path, file_props['name'])
|
notify.notify(event_type, jid, account, 'file-send-error', path,
|
||||||
|
event_type, file_props['name'])
|
||||||
|
|
||||||
def handle_event_gmail_notify(self, account, array):
|
def handle_event_gmail_notify(self, account, array):
|
||||||
jid = array[0]
|
jid = array[0]
|
||||||
|
@ -1024,10 +1025,12 @@ class Interface:
|
||||||
if gajim.config.get('notify_on_new_gmail_email'):
|
if gajim.config.get('notify_on_new_gmail_email'):
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
'single_msg_recv.png') #FIXME: find a better image
|
'single_msg_recv.png') #FIXME: find a better image
|
||||||
txt = i18n.ngettext('You have %d new E-mail message', 'You have %d new E-mail messages', gmail_new_messages, gmail_new_messages, gmail_new_messages)
|
title = _('New E-mail on %(gmail_mail_address)s') % \
|
||||||
txt = _('%(new_mail_gajim_ui_msg)s on %(gmail_mail_address)s') % {'new_mail_gajim_ui_msg': txt, 'gmail_mail_address': jid}
|
{'gmail_mail_address': jid}
|
||||||
|
text = i18n.ngettext('You have %d new E-mail message', 'You have %d new E-mail messages', gmail_new_messages, gmail_new_messages, gmail_new_messages)
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
||||||
notify.notify(_('New E-mail'), jid, account, 'gmail', path_to_image = path, text = txt)
|
notify.notify(_('New E-mail'), jid, account, 'gmail',
|
||||||
|
path_to_image = path, title = title, text = text)
|
||||||
|
|
||||||
def save_avatar_files(self, jid, photo_decoded, puny_nick = None):
|
def save_avatar_files(self, jid, photo_decoded, puny_nick = None):
|
||||||
'''Save the decoded avatar to a separate file, and generate files for dbus notifications'''
|
'''Save the decoded avatar to a separate file, and generate files for dbus notifications'''
|
||||||
|
@ -1131,8 +1134,9 @@ class Interface:
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 'ft_error.png')
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 'ft_error.png')
|
||||||
|
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
||||||
notify.notify(_('File Transfer Error'),
|
event_type = _('File Transfer Error')
|
||||||
jid, account, msg_type, path, file_props['name'])
|
notify.notify(event_type, jid, account, msg_type, path,
|
||||||
|
title = event_type, text = file_props['name'])
|
||||||
|
|
||||||
def handle_event_file_request(self, account, array):
|
def handle_event_file_request(self, account, array):
|
||||||
jid = array[0]
|
jid = array[0]
|
||||||
|
@ -1153,7 +1157,9 @@ class Interface:
|
||||||
'ft_request.png')
|
'ft_request.png')
|
||||||
txt = _('%s wants to send you a file.') % gajim.get_name_from_jid(account, jid)
|
txt = _('%s wants to send you a file.') % gajim.get_name_from_jid(account, jid)
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
||||||
notify.notify(_('File Transfer Request'), jid, account, 'file-request', path_to_image = path, text = txt)
|
event_type = _('File Transfer Request')
|
||||||
|
notify.notify(event_type, jid, account, 'file-request',
|
||||||
|
path_to_image = path, title = event_type, text = txt)
|
||||||
|
|
||||||
def handle_event_file_progress(self, account, file_props):
|
def handle_event_file_progress(self, account, file_props):
|
||||||
self.instances['file_transfers'].set_progress(file_props['type'],
|
self.instances['file_transfers'].set_progress(file_props['type'],
|
||||||
|
@ -1243,7 +1249,8 @@ class Interface:
|
||||||
gajim.connections[account].connected in (2, 3)):
|
gajim.connections[account].connected in (2, 3)):
|
||||||
# we want to be notified and we are online/chat or we don't mind
|
# we want to be notified and we are online/chat or we don't mind
|
||||||
# bugged when away/na/busy
|
# bugged when away/na/busy
|
||||||
notify.notify(event_type, jid, account, msg_type, path_to_image = path, text = txt)
|
notify.notify(event_type, jid, account, msg_type, path_to_image = path,
|
||||||
|
title = event_type, text = txt)
|
||||||
|
|
||||||
def handle_event_stanza_arrived(self, account, stanza):
|
def handle_event_stanza_arrived(self, account, stanza):
|
||||||
if not self.instances.has_key(account):
|
if not self.instances.has_key(account):
|
||||||
|
|
|
@ -34,14 +34,14 @@ if dbus_support.supported:
|
||||||
import dbus.service
|
import dbus.service
|
||||||
|
|
||||||
def notify(event_type, jid, account, msg_type = '', path_to_image = None,
|
def notify(event_type, jid, account, msg_type = '', path_to_image = None,
|
||||||
text = None):
|
title = None, text = None):
|
||||||
'''Notifies a user of an event. It first tries to a valid implementation of
|
'''Notifies a user of an event. It first tries to a valid implementation of
|
||||||
the Desktop Notification Specification. If that fails, then we fall back to
|
the Desktop Notification Specification. If that fails, then we fall back to
|
||||||
the older style PopupNotificationWindow method.'''
|
the older style PopupNotificationWindow method.'''
|
||||||
if gajim.config.get('use_notif_daemon') and dbus_support.supported:
|
if gajim.config.get('use_notif_daemon') and dbus_support.supported:
|
||||||
try:
|
try:
|
||||||
DesktopNotification(event_type, jid, account, msg_type, path_to_image,
|
DesktopNotification(event_type, jid, account, msg_type, path_to_image,
|
||||||
text)
|
title, text)
|
||||||
return
|
return
|
||||||
except dbus.dbus_bindings.DBusException, e:
|
except dbus.dbus_bindings.DBusException, e:
|
||||||
# Connection to D-Bus failed, try popup
|
# Connection to D-Bus failed, try popup
|
||||||
|
@ -49,7 +49,7 @@ def notify(event_type, jid, account, msg_type = '', path_to_image = None,
|
||||||
except TypeError, e:
|
except TypeError, e:
|
||||||
# This means that we sent the message incorrectly
|
# This means that we sent the message incorrectly
|
||||||
gajim.log.debug(str(e))
|
gajim.log.debug(str(e))
|
||||||
instance = dialogs.PopupNotificationWindow(event_type, jid, account, msg_type, path_to_image, text)
|
instance = dialogs.PopupNotificationWindow(event_type, jid, account, msg_type, path_to_image, title, text)
|
||||||
gajim.interface.roster.popup_notification_windows.append(instance)
|
gajim.interface.roster.popup_notification_windows.append(instance)
|
||||||
|
|
||||||
class NotificationResponseManager:
|
class NotificationResponseManager:
|
||||||
|
@ -106,9 +106,10 @@ class DesktopNotification:
|
||||||
'''A DesktopNotification that interfaces with DBus via the Desktop
|
'''A DesktopNotification that interfaces with DBus via the Desktop
|
||||||
Notification specification'''
|
Notification specification'''
|
||||||
def __init__(self, event_type, jid, account, msg_type = '',
|
def __init__(self, event_type, jid, account, msg_type = '',
|
||||||
path_to_image = None, text = None):
|
path_to_image = None, title = None, text = None):
|
||||||
self.path_to_image = path_to_image
|
self.path_to_image = path_to_image
|
||||||
self.event_type = event_type
|
self.event_type = event_type
|
||||||
|
self.title = title
|
||||||
self.text = text
|
self.text = text
|
||||||
self.default_version = '0.3.1'
|
self.default_version = '0.3.1'
|
||||||
self.account = account
|
self.account = account
|
||||||
|
@ -116,8 +117,12 @@ class DesktopNotification:
|
||||||
self.msg_type = msg_type
|
self.msg_type = msg_type
|
||||||
|
|
||||||
if not text:
|
if not text:
|
||||||
self.text = gajim.get_name_from_jid(account, jid) # default value of text
|
# default value of text
|
||||||
|
self.text = gajim.get_name_from_jid(account, jid)
|
||||||
|
|
||||||
|
if not title:
|
||||||
|
self.title = event_type # default value
|
||||||
|
|
||||||
if event_type == _('Contact Signed In'):
|
if event_type == _('Contact Signed In'):
|
||||||
ntype = 'presence.online'
|
ntype = 'presence.online'
|
||||||
elif event_type == _('Contact Signed Out'):
|
elif event_type == _('Contact Signed Out'):
|
||||||
|
@ -161,7 +166,7 @@ class DesktopNotification:
|
||||||
dbus.UInt32(0),
|
dbus.UInt32(0),
|
||||||
ntype,
|
ntype,
|
||||||
dbus.Byte(0),
|
dbus.Byte(0),
|
||||||
dbus.String(self.event_type),
|
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},
|
{'default': 0},
|
||||||
|
@ -181,7 +186,7 @@ class DesktopNotification:
|
||||||
dbus.String(_('Gajim')),
|
dbus.String(_('Gajim')),
|
||||||
dbus.UInt32(0),
|
dbus.UInt32(0),
|
||||||
dbus.String(self.path_to_image),
|
dbus.String(self.path_to_image),
|
||||||
dbus.String(self.event_type),
|
dbus.String(self.title),
|
||||||
dbus.String(self.text),
|
dbus.String(self.text),
|
||||||
( dbus.String('default'), dbus.String(self.event_type) ),
|
( dbus.String('default'), dbus.String(self.event_type) ),
|
||||||
hints,
|
hints,
|
||||||
|
@ -193,7 +198,7 @@ class DesktopNotification:
|
||||||
dbus.String(_('Gajim')),
|
dbus.String(_('Gajim')),
|
||||||
dbus.String(self.path_to_image),
|
dbus.String(self.path_to_image),
|
||||||
dbus.UInt32(0),
|
dbus.UInt32(0),
|
||||||
dbus.String(self.event_type),
|
dbus.String(self.title),
|
||||||
dbus.String(self.text),
|
dbus.String(self.text),
|
||||||
dbus.String(''),
|
dbus.String(''),
|
||||||
{},
|
{},
|
||||||
|
|
Loading…
Reference in New Issue