diff --git a/src/notify.py b/src/notify.py
index df53ca166..efc71590f 100644
--- a/src/notify.py
+++ b/src/notify.py
@@ -115,9 +115,9 @@ def get_advanced_notification(event, account, contact):
if gajim.config.get_per('notifications', str(num), 'event') == event:
# test recipient
recipient_type = gajim.config.get_per('notifications', str(num),
- 'recipient_type')
+ 'recipient_type')
recipients = gajim.config.get_per('notifications', str(num),
- 'recipients').split()
+ 'recipients').split()
if recipient_type == 'all':
recipient_ok = True
elif recipient_type == 'contact' and contact.jid in recipients:
@@ -136,13 +136,13 @@ def get_advanced_notification(event, account, contact):
if status_ok:
# test window_opened
tab_opened = gajim.config.get_per('notifications', str(num),
- 'tab_opened')
+ 'tab_opened')
if tab_opened == 'both':
tab_opened_ok = True
else:
chat_control = helpers.get_chat_control(account, contact)
- if (chat_control and tab_opened == 'yes') or (not chat_control and \
- tab_opened == 'no'):
+ if (chat_control and tab_opened == 'yes') or (not chat_control \
+ and tab_opened == 'no'):
tab_opened_ok = True
if tab_opened_ok:
return num
@@ -152,9 +152,10 @@ def get_advanced_notification(event, account, contact):
def notify(event, jid, account, parameters, advanced_notif_num=None):
"""
- Check what type of notifications we want, depending on basic and the advanced
- configuration of notifications and do these notifications; advanced_notif_num
- holds the number of the first (top most) advanced notification
+ Check what type of notifications we want, depending on basic and the
+ advanced configuration of notifications and do these notifications;
+ advanced_notif_num holds the number of the first (top most) advanced
+ notification
"""
# First, find what notifications we want
do_popup = False
@@ -174,7 +175,8 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
gajim.block_signed_in_notifications[account_server]:
block_transport = True
if helpers.allow_showing_notification(account, 'notify_on_signin') and \
- not gajim.block_signed_in_notifications[account] and not block_transport:
+ not gajim.block_signed_in_notifications[account] and \
+ not block_transport:
do_popup = True
if gajim.config.get_per('soundevents', 'contact_connected',
'enabled') and not gajim.block_signed_in_notifications[account] and \
@@ -185,7 +187,7 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
if helpers.allow_showing_notification(account, 'notify_on_signout'):
do_popup = True
if gajim.config.get_per('soundevents', 'contact_disconnected',
- 'enabled'):
+ 'enabled'):
do_sound = True
elif event == 'new_message':
message_type = parameters[0]
@@ -206,8 +208,8 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
'first_message_received', advanced_notif_num):
do_sound = True
elif not is_first_message and focused and \
- helpers.allow_sound_notification(account, 'next_message_received_focused',
- advanced_notif_num):
+ helpers.allow_sound_notification(account,
+ 'next_message_received_focused', advanced_notif_num):
do_sound = True
elif not is_first_message and not focused and \
helpers.allow_sound_notification(account,
@@ -227,7 +229,7 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
if event == 'contact_disconnected':
show_image = 'offline.png'
suffix = '_notif_size_bw'
- else: #Status Change or Connected
+ else: # Status Change or Connected
# FIXME: for status change,
# we don't always 'online.png', but we
# first need 48x48 for all status
@@ -236,46 +238,46 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
transport_name = gajim.get_transport_name_from_jid(jid)
img_path = None
if transport_name:
- img_path = os.path.join(helpers.get_transport_path(transport_name),
- '48x48', show_image)
+ img_path = os.path.join(helpers.get_transport_path(
+ transport_name), '48x48', show_image)
if not img_path or not os.path.isfile(img_path):
iconset = gajim.config.get('iconset')
- img_path = os.path.join(helpers.get_iconset_path(iconset), '48x48',
- show_image)
- path = gtkgui_helpers.get_path_to_generic_or_avatar(img_path, jid=jid,
- suffix=suffix)
+ img_path = os.path.join(helpers.get_iconset_path(iconset),
+ '48x48', show_image)
+ path = gtkgui_helpers.get_path_to_generic_or_avatar(img_path,
+ jid=jid, suffix=suffix)
if event == 'status_change':
title = _('%(nick)s Changed Status') % \
- {'nick': gajim.get_name_from_jid(account, jid)}
+ {'nick': gajim.get_name_from_jid(account, jid)}
text = _('%(nick)s is now %(status)s') % \
- {'nick': gajim.get_name_from_jid(account, jid),\
- 'status': helpers.get_uf_show(gajim.SHOW_LIST[new_show])}
+ {'nick': gajim.get_name_from_jid(account, jid),\
+ 'status': helpers.get_uf_show(gajim.SHOW_LIST[new_show])}
if status_message:
text = text + " : " + status_message
popup(_('Contact Changed Status'), jid, account,
- path_to_image=path, title=title, text=text)
+ path_to_image=path, title=title, text=text)
elif event == 'contact_connected':
title = _('%(nickname)s Signed In') % \
- {'nickname': gajim.get_name_from_jid(account, jid)}
+ {'nickname': gajim.get_name_from_jid(account, jid)}
text = ''
if status_message:
text = status_message
popup(_('Contact Signed In'), jid, account,
- path_to_image=path, title=title, text=text)
+ path_to_image=path, title=title, text=text)
elif event == 'contact_disconnected':
title = _('%(nickname)s Signed Out') % \
- {'nickname': gajim.get_name_from_jid(account, jid)}
+ {'nickname': gajim.get_name_from_jid(account, jid)}
text = ''
if status_message:
text = status_message
popup(_('Contact Signed Out'), jid, account,
- path_to_image=path, title=title, text=text)
+ path_to_image=path, title=title, text=text)
elif event == 'new_message':
if message_type == 'normal': # single message
event_type = _('New Single Message')
img_name = 'gajim-single_msg_recv'
title = _('New Single Message from %(nickname)s') % \
- {'nickname': nickname}
+ {'nickname': nickname}
text = message
elif message_type == 'pm': # private message
event_type = _('New Private Message')
@@ -283,20 +285,21 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
img_name = 'gajim-priv_msg_recv'
title = _('New Private Message from group chat %s') % room_name
if message:
- text = _('%(nickname)s: %(message)s') % {'nickname': nickname,
- 'message': message}
+ text = _('%(nickname)s: %(message)s') % \
+ {'nickname': nickname, 'message': message}
else:
- text = _('Messaged by %(nickname)s') % {'nickname': nickname}
+ text = _('Messaged by %(nickname)s') % \
+ {'nickname': nickname}
else: # chat message
event_type = _('New Message')
img_name = 'gajim-chat_msg_recv'
title = _('New Message from %(nickname)s') % \
- {'nickname': nickname}
+ {'nickname': nickname}
text = message
img_path = gtkgui_helpers.get_icon_path(img_name, 48)
popup(event_type, jid, account, message_type,
- path_to_image=img_path, title=title, text=text)
+ path_to_image=img_path, title=title, text=text)
if do_sound:
snd_file = None
@@ -305,7 +308,7 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
if advanced_notif_num is not None and gajim.config.get_per(
'notifications', str(advanced_notif_num), 'sound') == 'yes':
snd_file = gajim.config.get_per('notifications',
- str(advanced_notif_num), 'sound_file')
+ str(advanced_notif_num), 'sound_file')
elif advanced_notif_num is not None and gajim.config.get_per(
'notifications', str(advanced_notif_num), 'sound') == 'no':
pass # do not set snd_event
@@ -324,14 +327,14 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
if do_cmd:
command = gajim.config.get_per('notifications', str(advanced_notif_num),
- 'command')
+ 'command')
try:
helpers.exec_command(command)
except Exception:
pass
def popup(event_type, jid, account, msg_type='', path_to_image=None, title=None,
- text=None):
+text=None):
"""
Notify 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
@@ -357,7 +360,7 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None, title=None,
if gajim.config.get('use_notif_daemon') and dbus_support.supported:
try:
DesktopNotification(event_type, jid, account, msg_type,
- path_to_image, title, gobject.markup_escape_text(text))
+ path_to_image, title, gobject.markup_escape_text(text))
return # sucessfully did D-Bus Notification procedure!
except dbus.DBusException, e:
# Connection to D-Bus failed
@@ -372,7 +375,7 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None, title=None,
# empty text for new_message means do_preview = False
# -> default value for text
_text = gobject.markup_escape_text(
- gajim.get_name_from_jid(account, jid))
+ gajim.get_name_from_jid(account, jid))
else:
_text = gobject.markup_escape_text(text)
@@ -404,7 +407,7 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None, title=None,
# Either nothing succeeded or the user wants old-style notifications
instance = dialogs.PopupNotificationWindow(event_type, jid, account,
- msg_type, path_to_image, title, text)
+ msg_type, path_to_image, title, text)
gajim.interface.roster.popup_notification_windows.append(instance)
def on_pynotify_notification_clicked(notification, action):
@@ -431,7 +434,8 @@ class NotificationResponseManager:
if self.interface is not None:
return
self.interface = dbus_support.get_notifications_interface()
- self.interface.connect_to_signal('ActionInvoked', self.on_action_invoked)
+ self.interface.connect_to_signal('ActionInvoked',
+ self.on_action_invoked)
self.interface.connect_to_signal('NotificationClosed', self.on_closed)
def on_action_invoked(self, id_, reason):
@@ -470,12 +474,12 @@ notification_response_manager = NotificationResponseManager()
class DesktopNotification:
"""
- A DesktopNotification that interfaces with D-Bus via the Desktop Notification
- specification
+ A DesktopNotification that interfaces with D-Bus via the Desktop
+ Notification Specification
"""
def __init__(self, event_type, jid, account, msg_type='',
- path_to_image=None, title=None, text=None):
+ path_to_image=None, title=None, text=None):
self.path_to_image = path_to_image
self.event_type = event_type
self.title = title
@@ -501,7 +505,7 @@ class DesktopNotification:
elif event_type == _('Contact Signed Out'):
ntype = 'presence.offline'
elif event_type in (_('New Message'), _('New Single Message'),
- _('New Private Message')):
+ _('New Private Message')):
ntype = 'im.received'
elif event_type == _('File Transfer Request'):
ntype = 'transfer'
@@ -525,7 +529,7 @@ class DesktopNotification:
else:
# default failsafe values
self.path_to_image = gtkgui_helpers.get_icon_path(
- 'gajim-chat_msg_recv', 48)
+ 'gajim-chat_msg_recv', 48)
ntype = 'im' # Notification Type
self.notif = dbus_support.get_notifications_interface(self)
@@ -546,21 +550,21 @@ class DesktopNotification:
ntype = self.ntype
if self.kde_notifications:
notification_text = ('' \
- '%(title)s
%(text)s') % {'title': self.title,
- 'text': self.text, 'image': self.path_to_image}
+ '%(title)s
%(text)s