Changeset 6318
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dialogs.py
r6310 r6318 1115 1115 elif event_type == _('Groupchat Invitation'): 1116 1116 bg_color = 'tan1' 1117 elif event_type == _('Contact Changed status'): 1118 bg_color = 'thistle2' 1117 1119 else: # Unknown event ! Shouldn't happen but deal with it 1118 1120 bg_color = 'white' -
trunk/src/gajim.py
r6265 r6318 417 417 # play sound 418 418 if old_show < 2 and new_show > 1: 419 if gajim.config.get_per('soundevents', 'contact_connected', 420 'enabled') and not gajim.block_signed_in_notifications[account]: 421 helpers.play_sound('contact_connected') 422 if not gajim.awaiting_events[account].has_key(jid) and \ 423 gajim.config.get('notify_on_signin') and \ 424 not gajim.block_signed_in_notifications[account]: 425 if helpers.allow_showing_notification(account): 426 transport_name = gajim.get_transport_name_from_jid(jid) 427 img = None 428 if transport_name: 429 img = os.path.join(gajim.DATA_DIR, 'iconsets', 430 'transports', transport_name, '48x48', 431 'online.png') 432 if not img or not os.path.isfile(img): 433 iconset = gajim.config.get('iconset') 434 img = os.path.join(gajim.DATA_DIR, 'iconsets', 435 iconset, '48x48', 'online.png') 436 path = gtkgui_helpers.get_path_to_generic_or_avatar(img, 437 jid = jid, suffix = '_notif_size_colored.png') 438 title = _('%(nickname)s Signed In') % \ 439 {'nickname': gajim.get_name_from_jid(account, jid)} 440 text = '' 441 if status_message: 442 text = status_message 443 notify.notify(_('Contact Signed In'), jid, account, 444 path_to_image = path, title = title, text = text) 445 419 notify.notify('contact_connected', jid, account, status_message) 446 420 if self.remote_ctrl: 447 421 self.remote_ctrl.raise_signal('ContactPresence', … … 449 423 450 424 elif old_show > 1 and new_show < 2: 451 if gajim.config.get_per('soundevents', 'contact_disconnected', 452 'enabled'): 453 helpers.play_sound('contact_disconnected') 454 if not gajim.awaiting_events[account].has_key(jid) and \ 455 gajim.config.get('notify_on_signout'): 456 if helpers.allow_showing_notification(account): 457 transport_name = gajim.get_transport_name_from_jid(jid) 458 img = None 459 if transport_name: 460 img = os.path.join(gajim.DATA_DIR, 'iconsets', 461 'transports', transport_name, '48x48', 462 'offline.png') 463 if not img or not os.path.isfile(img): 464 iconset = gajim.config.get('iconset') 465 img = os.path.join(gajim.DATA_DIR, 'iconsets', 466 iconset, '48x48', 'offline.png') 467 path = gtkgui_helpers.get_path_to_generic_or_avatar(img, 468 jid = jid, suffix = '_notif_size_bw.png') 469 title = _('%(nickname)s Signed Out') % \ 470 {'nickname': gajim.get_name_from_jid(account, jid)} 471 text = '' 472 if status_message: 473 text = status_message 474 notify.notify(_('Contact Signed Out'), jid, account, 475 path_to_image = path, title = title, text = text) 476 425 notify.notify('contact_disconnected', jid, account, status_message) 477 426 if self.remote_ctrl: 478 427 self.remote_ctrl.raise_signal('ContactAbsence', (account, array)) 479 428 # FIXME: stop non active file transfers 429 elif new_show > 1: # Status change (not connected/disconnected or error (<1)) 430 notify.notify('status_change', jid, account, [new_show, status_message]) 480 431 else: 481 432 # FIXME: Msn transport (CMSN1.2.1 and PyMSN0.10) doesn't follow the JEP … … 584 535 text = _('%(nickname)s: %(message)s') % {'nickname': nick, 585 536 'message': message} 586 notify. notify(_('New Private Message'), full_jid_with_resource,537 notify.popup(_('New Private Message'), full_jid_with_resource, 587 538 account, 'pm', path_to_image = path, title = title, 588 539 text = text) … … 613 564 {'nickname': gajim.get_name_from_jid(account, jid)} 614 565 path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 615 notify. notify(event_type, jid_of_control, account, msg_type,566 notify.popup(event_type, jid_of_control, account, msg_type, 616 567 path_to_image = path, title = title, text = text) 617 568 … … 969 920 path = gtkgui_helpers.get_path_to_generic_or_avatar(path) 970 921 event_type = _('Groupchat Invitation') 971 notify. notify(event_type, jid, account, 'gc-invitation', path,922 notify.popup(event_type, jid, account, 'gc-invitation', path, 972 923 event_type, room_jid) 973 924 … … 1071 1022 path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 1072 1023 event_type = _('File Transfer Error') 1073 notify. notify(event_type, jid, account, 'file-send-error', path,1024 notify.popup(event_type, jid, account, 'file-send-error', path, 1074 1025 event_type, file_props['name']) 1075 1026 … … 1084 1035 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) 1085 1036 path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 1086 notify. notify(_('New E-mail'), jid, account, 'gmail',1037 notify.popup(_('New E-mail'), jid, account, 'gmail', 1087 1038 path_to_image = path, title = title, text = text) 1088 1039 … … 1200 1151 path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 1201 1152 event_type = _('File Transfer Error') 1202 notify. notify(event_type, jid, account, msg_type, path,1153 notify.popup(event_type, jid, account, msg_type, path, 1203 1154 title = event_type, text = file_props['name']) 1204 1155 … … 1223 1174 path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 1224 1175 event_type = _('File Transfer Request') 1225 notify. notify(event_type, jid, account, 'file-request',1176 notify.popup(event_type, jid, account, 'file-request', 1226 1177 path_to_image = path, title = event_type, text = txt) 1227 1178 … … 1314 1265 # we want to be notified and we are online/chat or we don't mind 1315 1266 # bugged when away/na/busy 1316 notify. notify(event_type, jid, account, msg_type, path_to_image = path,1267 notify.popup(event_type, jid, account, msg_type, path_to_image = path, 1317 1268 title = event_type, text = txt) 1318 1269 -
trunk/src/notify.py
r6275 r6318 25 25 from common import gajim 26 26 from common import i18n 27 from common import helpers 27 28 i18n.init() 28 29 _ = i18n._ … … 35 36 import dbus.service 36 37 37 def notify(event_type, jid, account, msg_type = '', path_to_image = None, 38 def notify(event, jid, account, parameters): 39 '''Check what type of notifications we want, depending on basic configuration 40 of notifications and advanced one and do these notifications''' 41 # First, find what notifications we want 42 do_popup = False 43 do_sound = False 44 if (event == 'status_change'): 45 new_show = parameters[0] 46 status_message = parameters[1] 47 # Default : No popup for status change 48 elif (event == 'contact_connected'): 49 status_message = parameters 50 if gajim.config.get('notify_on_signin') and \ 51 not gajim.block_signed_in_notifications[account]\ 52 and helpers.allow_showing_notification(account): 53 do_popup = True 54 if gajim.config.get_per('soundevents', 'contact_connected', 55 'enabled') and not gajim.block_signed_in_notifications[account]: 56 do_sound = True 57 elif (event == 'contact_disconnected'): 58 status_message = parameters 59 if gajim.config.get('notify_on_signout') \ 60 and helpers.allow_showing_notification(account): 61 do_popup = True 62 if gajim.config.get_per('soundevents', 'contact_disconnected', 63 'enabled'): 64 do_sound = True 65 66 # Do the wanted notifications 67 if (do_popup): 68 if (event == 'contact_connected' or event == 'contact_disconnected' or \ 69 event == 'status_change'): # Common code for popup for these 3 events 70 if (event == 'contact_disconnected'): 71 show_image = 'offline.png' 72 suffix = '_notif_size_bw.png' 73 else: #Status Change or Connected 74 # TODO : for status change, we don't always 'online.png', but we 75 # first need 48x48 for all status 76 show_image = 'online.png' 77 suffix = '_notif_size_colored.png' 78 transport_name = gajim.get_transport_name_from_jid(jid) 79 img = None 80 if transport_name: 81 img = os.path.join(gajim.DATA_DIR, 'iconsets', 82 'transports', transport_name, '48x48', show_image) 83 if not img or not os.path.isfile(img): 84 iconset = gajim.config.get('iconset') 85 img = os.path.join(gajim.DATA_DIR, 'iconsets', 86 iconset, '48x48', show_image) 87 path = gtkgui_helpers.get_path_to_generic_or_avatar(img, 88 jid = jid, suffix = suffix) 89 if (event == 'status_change'): 90 title = _('%(nick)s Changed Status') % \ 91 {'nick': gajim.get_name_from_jid(account, jid)} 92 text = _('%(nick)s is now %(status)s') % \ 93 {'nick': gajim.get_name_from_jid(account, jid),\ 94 'status': helpers.get_uf_show(gajim.SHOW_LIST[new_show])} 95 if status_message: 96 text = text + " : " + status_message 97 popup(_('Contact Changed status'), jid, account, 98 path_to_image = path, title = title, text = text) 99 elif (event == 'contact_connected'): 100 title = _('%(nickname)s Signed In') % \ 101 {'nickname': gajim.get_name_from_jid(account, jid)} 102 text = '' 103 if status_message: 104 text = status_message 105 popup(_('Contact Signed In'), jid, account, 106 path_to_image = path, title = title, text = text) 107 elif (event == 'contact_disconnected'): 108 title = _('%(nickname)s Signed Out') % \ 109 {'nickname': gajim.get_name_from_jid(account, jid)} 110 text = '' 111 if status_message: 112 text = status_message 113 popup(_('Contact Signed Out'), jid, account, 114 path_to_image = path, title = title, text = text) 115 else: 116 print 'Event not implemeted yet' 117 if (do_sound): 118 helpers.play_sound(event) 119 120 121 def popup(event_type, jid, account, msg_type = '', path_to_image = None, 38 122 title = None, text = None): 39 123 '''Notifies a user of an event. It first tries to a valid implementation of … … 53 137 # This means that we sent the message incorrectly 54 138 gajim.log.debug(str(e)) 55 instance = dialogs.PopupNotificationWindow(event_type, jid, account, msg_type, path_to_image, title, text) 139 instance = dialogs.PopupNotificationWindow(event_type, jid, account, msg_type, \ 140 path_to_image, title, text) 56 141 gajim.interface.roster.popup_notification_windows.append(instance) 57 142 … … 145 230 elif event_type == _('Groupchat Invitation'): 146 231 ntype = 'im.invitation' 232 elif event_type == _('Contact Changed status'): 233 ntype = 'presence.status' 147 234 else: 148 235 # default failsafe values
