fix 80 char width

This commit is contained in:
Yann Leboulanger 2010-03-14 00:05:30 +01:00
parent 86acbd398c
commit 6b36b6729d
1 changed files with 101 additions and 94 deletions

View File

@ -141,8 +141,8 @@ def get_advanced_notification(event, account, contact):
tab_opened_ok = True tab_opened_ok = True
else: else:
chat_control = helpers.get_chat_control(account, contact) chat_control = helpers.get_chat_control(account, contact)
if (chat_control and tab_opened == 'yes') or (not chat_control and \ if (chat_control and tab_opened == 'yes') or (not chat_control \
tab_opened == 'no'): and tab_opened == 'no'):
tab_opened_ok = True tab_opened_ok = True
if tab_opened_ok: if tab_opened_ok:
return num return num
@ -152,9 +152,10 @@ def get_advanced_notification(event, account, contact):
def notify(event, jid, account, parameters, advanced_notif_num=None): def notify(event, jid, account, parameters, advanced_notif_num=None):
""" """
Check what type of notifications we want, depending on basic and the advanced Check what type of notifications we want, depending on basic and the
configuration of notifications and do these notifications; advanced_notif_num advanced configuration of notifications and do these notifications;
holds the number of the first (top most) advanced notification advanced_notif_num holds the number of the first (top most) advanced
notification
""" """
# First, find what notifications we want # First, find what notifications we want
do_popup = False do_popup = False
@ -174,7 +175,8 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
gajim.block_signed_in_notifications[account_server]: gajim.block_signed_in_notifications[account_server]:
block_transport = True block_transport = True
if helpers.allow_showing_notification(account, 'notify_on_signin') and \ 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 do_popup = True
if gajim.config.get_per('soundevents', 'contact_connected', if gajim.config.get_per('soundevents', 'contact_connected',
'enabled') and not gajim.block_signed_in_notifications[account] and \ 'enabled') and not gajim.block_signed_in_notifications[account] and \
@ -206,8 +208,8 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
'first_message_received', advanced_notif_num): 'first_message_received', advanced_notif_num):
do_sound = True do_sound = True
elif not is_first_message and focused and \ elif not is_first_message and focused and \
helpers.allow_sound_notification(account, 'next_message_received_focused', helpers.allow_sound_notification(account,
advanced_notif_num): 'next_message_received_focused', advanced_notif_num):
do_sound = True do_sound = True
elif not is_first_message and not focused and \ elif not is_first_message and not focused and \
helpers.allow_sound_notification(account, helpers.allow_sound_notification(account,
@ -236,14 +238,14 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
transport_name = gajim.get_transport_name_from_jid(jid) transport_name = gajim.get_transport_name_from_jid(jid)
img_path = None img_path = None
if transport_name: if transport_name:
img_path = os.path.join(helpers.get_transport_path(transport_name), img_path = os.path.join(helpers.get_transport_path(
'48x48', show_image) transport_name), '48x48', show_image)
if not img_path or not os.path.isfile(img_path): if not img_path or not os.path.isfile(img_path):
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
img_path = os.path.join(helpers.get_iconset_path(iconset), '48x48', img_path = os.path.join(helpers.get_iconset_path(iconset),
show_image) '48x48', show_image)
path = gtkgui_helpers.get_path_to_generic_or_avatar(img_path, jid=jid, path = gtkgui_helpers.get_path_to_generic_or_avatar(img_path,
suffix=suffix) jid=jid, suffix=suffix)
if event == 'status_change': if event == 'status_change':
title = _('%(nick)s Changed Status') % \ title = _('%(nick)s Changed Status') % \
{'nick': gajim.get_name_from_jid(account, jid)} {'nick': gajim.get_name_from_jid(account, jid)}
@ -283,10 +285,11 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
img_name = 'gajim-priv_msg_recv' img_name = 'gajim-priv_msg_recv'
title = _('New Private Message from group chat %s') % room_name title = _('New Private Message from group chat %s') % room_name
if message: if message:
text = _('%(nickname)s: %(message)s') % {'nickname': nickname, text = _('%(nickname)s: %(message)s') % \
'message': message} {'nickname': nickname, 'message': message}
else: else:
text = _('Messaged by %(nickname)s') % {'nickname': nickname} text = _('Messaged by %(nickname)s') % \
{'nickname': nickname}
else: # chat message else: # chat message
event_type = _('New Message') event_type = _('New Message')
@ -431,7 +434,8 @@ class NotificationResponseManager:
if self.interface is not None: if self.interface is not None:
return return
self.interface = dbus_support.get_notifications_interface() 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) self.interface.connect_to_signal('NotificationClosed', self.on_closed)
def on_action_invoked(self, id_, reason): def on_action_invoked(self, id_, reason):
@ -470,8 +474,8 @@ notification_response_manager = NotificationResponseManager()
class DesktopNotification: class DesktopNotification:
""" """
A DesktopNotification that interfaces with D-Bus via the Desktop Notification A DesktopNotification that interfaces with D-Bus via the Desktop
specification Notification Specification
""" """
def __init__(self, event_type, jid, account, msg_type='', def __init__(self, event_type, jid, account, msg_type='',
@ -586,7 +590,8 @@ class DesktopNotification:
reply_handler=self.attach_by_id, reply_handler=self.attach_by_id,
error_handler=self.notify_another_way) error_handler=self.notify_another_way)
except AttributeError: except AttributeError:
version = [0, 3, 1] # we're actually dealing with the newer version # we're actually dealing with the newer version
version = [0, 3, 1]
if version > [0, 3]: if version > [0, 3]:
if gajim.interface.systray_enabled and \ if gajim.interface.systray_enabled and \
gajim.config.get('attach_notifications_to_systray'): gajim.config.get('attach_notifications_to_systray'):
@ -607,7 +612,8 @@ class DesktopNotification:
text = ' ' text = ' '
actions = () actions = ()
if 'actions' in self.capabilities: if 'actions' in self.capabilities:
actions = (dbus.String('default'), dbus.String(self.event_type)) 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
@ -672,7 +678,8 @@ class DesktopNotification:
error_handler=self.version_error_handler_2_x_try) error_handler=self.version_error_handler_2_x_try)
def version_error_handler_2_x_try(self, e): def version_error_handler_2_x_try(self, e):
self.notif.GetServerInformation(reply_handler=self.version_reply_handler, self.notif.GetServerInformation(
reply_handler=self.version_reply_handler,
error_handler=self.version_error_handler_3_x_try) error_handler=self.version_error_handler_3_x_try)
def version_error_handler_3_x_try(self, e): def version_error_handler_3_x_try(self, e):