Ticket #1106: donotnotifywhenV2.patch
| File donotnotifywhenV2.patch, 18.6 kB (added by Jim++, 3 years ago) |
|---|
-
src/roster_window.py
40 40 import cell_renderer_image 41 41 import tooltips 42 42 import message_control 43 import notify 43 44 44 45 from common import gajim 45 46 from common import helpers … … 1856 1857 path = None 1857 1858 autopopup = gajim.config.get('autopopup') 1858 1859 autopopupaway = gajim.config.get('autopopupaway') 1860 do_not_notify_when = gajim.config.get('do_not_notify_when') 1859 1861 1860 1862 # Do we have a queue? 1861 1863 qs = gajim.awaiting_events[account] … … 1863 1865 if qs.has_key(jid): 1864 1866 no_queue = False 1865 1867 popup = False 1866 if autopopup and (autopopupaway or gajim.connections[account].connected \ 1867 in (1, 2)): 1868 if autopopup and notify.want_notify(gajim.connections[account].connected): 1868 1869 popup = True 1869 1870 1870 1871 if msg_type == 'normal' and popup: # it's single message to be autopopuped … … 2368 2369 self.make_jabber_state_images() 2369 2370 # Update the roster 2370 2371 self.draw_roster() 2372 print "reload" 2371 2373 # Update the status combobox 2372 2374 model = self.status_combobox.get_model() 2373 2375 iter = model.get_iter_root() -
src/config.py
72 72 'notify_on_signin_checkbutton') 73 73 self.notify_on_signout_checkbutton = self.xml.get_widget( 74 74 'notify_on_signout_checkbutton') 75 self.auto_popup_away_checkbutton = self.xml.get_widget(76 'auto_popup_away_checkbutton')77 75 self.auto_away_checkbutton = self.xml.get_widget('auto_away_checkbutton') 78 76 self.auto_away_time_spinbutton = self.xml.get_widget( 79 77 'auto_away_time_spinbutton') … … 169 167 model = gtk.ListStore(str) 170 168 theme_combobox.set_model(model) 171 169 170 # Do not notify when 171 do_not_notify_when_combobox = self.xml.get_widget('do_not_notify_when_combobox') 172 cell = gtk.CellRendererText() 173 do_not_notify_when_combobox.pack_start(cell, True) 174 do_not_notify_when_combobox.add_attribute(cell, 'text', 0) 175 model = gtk.ListStore(str) 176 do_not_notify_when_combobox.set_model(model) 177 172 178 #use speller 173 179 if os.name == 'nt': 174 180 self.xml.get_widget('speller_checkbutton').set_no_show_all(True) … … 257 263 st = gajim.config.get('notify_on_signout') 258 264 self.notify_on_signout_checkbutton.set_active(st) 259 265 260 #autopopupaway261 st = gajim.config.get('autopopupaway')262 self.auto_popup_away_checkbutton.set_active(st)263 264 266 #Ignore messages from unknown contacts 265 267 self.xml.get_widget('ignore_events_from_unknown_contacts_checkbutton').\ 266 268 set_active(gajim.config.get('ignore_unknown_contacts')) … … 443 445 i += 1 444 446 self.on_theme_combobox_changed(theme_combobox) 445 447 448 #Do not notify when 449 do_not_notify_when_combobox = self.xml.get_widget('do_not_notify_when_combobox') 450 model = do_not_notify_when_combobox.get_model() 451 model.clear() 452 453 do_not_notify_when_list = ['dnd','away xa dnd invisible'] 454 custom = True 455 always_text = _('Always notify') 456 457 #Always notify part, config option is empty 458 model.append([always_text]) 459 if gajim.config.get('do_not_notify_when') == '': 460 do_not_notify_when_combobox.set_active(0) 461 custom = False 462 463 i = 1 # line 0 was just before 464 for config_do_not_notify_when in do_not_notify_when_list: 465 model.append([config_do_not_notify_when]) 466 if gajim.config.get('do_not_notify_when') == config_do_not_notify_when: 467 do_not_notify_when_combobox.set_active(i) 468 custom = False 469 i += 1 470 if custom: 471 custom_text = _('Custom') 472 model.append([custom_text]) 473 do_not_notify_when_combobox.set_active(i) 474 475 self.on_do_not_notify_when_combobox_changed(do_not_notify_when_combobox) 476 446 477 # Notify user of new gmail e-mail messages, 447 478 # only show checkbox if user has a gtalk account 448 479 self.xml.get_widget('notify_gmail_checkbutton').hide() … … 548 579 gajim.interface.roster.repaint_themed_widgets() 549 580 gajim.interface.roster.change_roster_style(None) 550 581 gajim.interface.save_config() 582 583 def on_do_not_notify_when_combobox_changed(self, widget): 584 model = widget.get_model() 585 active = widget.get_active() 586 config_do_not_notify_when = model[active][0].decode('utf-8') 587 588 custom_text = _('Custom') 589 if config_do_not_notify_when <> custom_text: 590 #Do not save "Custom", don't touch anything 591 always_text = _('Always notify') 592 if config_do_not_notify_when == always_text: 593 #Always notify : empty status list 594 config_do_not_notify_when='' 595 gajim.config.set('do_not_notify_when', config_do_not_notify_when) 596 gajim.interface.save_config() 551 597 552 598 def on_one_window_type_combo_changed(self, widget): 553 599 active = widget.get_active() … … 681 727 gajim.interface.save_config() 682 728 683 729 def on_notify_on_new_message_radiobutton_toggled(self, widget): 684 self.on_checkbutton_toggled(widget, 'notify_on_new_message', 685 [self.auto_popup_away_checkbutton]) 730 self.on_checkbutton_toggled(widget, 'notify_on_new_message') 686 731 687 732 def on_popup_new_message_radiobutton_toggled(self, widget): 688 self.on_checkbutton_toggled(widget, 'autopopup', 689 [self.auto_popup_away_checkbutton]) 733 self.on_checkbutton_toggled(widget, 'autopopup') 690 734 691 def on_only_in_roster_radiobutton_toggled(self, widget):692 if widget.get_active():693 self.auto_popup_away_checkbutton.set_sensitive(False)694 695 735 def on_notify_on_signin_checkbutton_toggled(self, widget): 696 736 self.on_checkbutton_toggled(widget, 'notify_on_signin') 697 737 698 738 def on_notify_on_signout_checkbutton_toggled(self, widget): 699 739 self.on_checkbutton_toggled(widget, 'notify_on_signout') 700 740 701 def on_auto_popup_away_checkbutton_toggled(self, widget):702 self.on_checkbutton_toggled(widget, 'autopopupaway')703 704 741 def on_ignore_events_from_unknown_contacts_checkbutton_toggled(self, widget): 705 742 self.on_checkbutton_toggled(widget, 'ignore_unknown_contacts') 706 743 -
src/notify.py
47 47 import dbus.glib 48 48 import dbus.service 49 49 50 STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd', 51 'invisible'] 52 50 53 def notify(event_type, jid, account, msg_type = '', path_to_image = None, 51 54 text = None): 52 55 '''Notifies a user of an event. It first tries to a valid implementation of … … 65 68 gajim.log.debug(str(e)) 66 69 instance = dialogs.PopupNotificationWindow(event_type, jid, account, msg_type, path_to_image, text) 67 70 gajim.interface.roster.popup_notification_windows.append(instance) 71 72 73 def want_notify(status): 74 '''Tell if we want to be notified by sounds/popup and want to auto open 75 messages depending of our status (and config)''' 76 do_not_notify_when = gajim.config.get('do_not_notify_when').split(' ') 77 if STATUS_LIST[status] not in do_not_notify_when: 78 return True 79 else: 80 return False 81 68 82 69 83 class NotificationResponseManager: 70 84 '''Collects references to pending DesktopNotifications and manages there -
src/gtkgui.glade
4862 4862 <property name="fill">True</property> 4863 4863 </packing> 4864 4864 </child> 4865 4865 4866 4866 <child> 4867 <widget class="Gtk CheckButton" id="auto_popup_away_checkbutton">4867 <widget class="GtkHBox" id="hbox2957"> 4868 4868 <property name="visible">True</property> 4869 <property name="can_focus">True</property> 4870 <property name="label" translatable="yes">Allow popup/notifications when I'm _away/na/busy/invisible</property> 4871 <property name="use_underline">True</property> 4872 <property name="relief">GTK_RELIEF_NORMAL</property> 4873 <property name="focus_on_click">True</property> 4874 <property name="active">False</property> 4875 <property name="inconsistent">False</property> 4876 <property name="draw_indicator">True</property> 4877 <signal name="toggled" handler="on_auto_popup_away_checkbutton_toggled" last_modification_time="Wed, 06 Apr 2005 12:46:30 GMT"/> 4869 <property name="homogeneous">False</property> 4870 <property name="spacing">12</property> 4871 4872 <child> 4873 <widget class="GtkLabel" id="label250"> 4874 <property name="visible">True</property> 4875 <property name="label" translatable="yes">Do not disturb me with popups/sounds/auto open when I'm :</property> 4876 <property name="use_underline">False</property> 4877 <property name="use_markup">False</property> 4878 <property name="justify">GTK_JUSTIFY_LEFT</property> 4879 <property name="wrap">False</property> 4880 <property name="selectable">False</property> 4881 <property name="xalign">0.5</property> 4882 <property name="yalign">0.5</property> 4883 <property name="xpad">0</property> 4884 <property name="ypad">0</property> 4885 <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> 4886 <property name="width_chars">-1</property> 4887 <property name="single_line_mode">False</property> 4888 <property name="angle">0</property> 4889 </widget> 4890 <packing> 4891 <property name="padding">0</property> 4892 <property name="expand">False</property> 4893 <property name="fill">False</property> 4894 </packing> 4895 </child> 4896 4897 <child> 4898 <widget class="GtkComboBox" id="do_not_notify_when_combobox"> 4899 <property name="visible">True</property> 4900 <property name="add_tearoffs">False</property> 4901 <property name="focus_on_click">True</property> 4902 <signal name="changed" handler="on_do_not_notify_when_combobox_changed" last_modification_time="Fri, 29 Apr 2005 11:44:52 GMT"/> 4903 </widget> 4904 <packing> 4905 <property name="padding">0</property> 4906 <property name="expand">False</property> 4907 <property name="fill">True</property> 4908 </packing> 4909 </child> 4910 4878 4911 </widget> 4879 <packing> 4880 <property name="padding">0</property> 4881 <property name="expand">False</property> 4882 <property name="fill">False</property> 4883 </packing> 4912 4884 4913 </child> 4885 </widget>4914 </widget> 4886 4915 </child> 4887 4916 </widget> 4888 4917 </child> -
src/gajim.py
387 387 if array[1] in ('offline', 'error'): 388 388 contact1.our_chatstate = contact1.chatstate = None 389 389 self.roster.chg_contact_status(contact1, array[1], array[2], account) 390 # play sound391 390 if old_show < 2 and new_show > 1: 392 if gajim.config.get_per('soundevents', 'contact_connected', 393 'enabled') and gajim.allow_notifications[account]: 394 helpers.play_sound('contact_connected') 395 if not gajim.interface.msg_win_mgr.has_window(jid, account) and \ 396 not gajim.awaiting_events[account].has_key(jid) and \ 397 gajim.config.get('notify_on_signin') and \ 398 gajim.allow_notifications[account]: 399 show_notification = False 400 # check OUR status and if we allow notifications for that status 401 if gajim.config.get('autopopupaway'): # always notify 402 show_notification = True 403 elif gajim.connections[account].connected in (2, 3): 404 # we're online or chat 405 show_notification = True 406 if show_notification: 391 # check OUR status and if we allow notifications for that status 392 if notify.want_notify(gajim.connections[account].connected): 393 # play sound 394 if gajim.config.get_per('soundevents', 'contact_connected', 395 'enabled') and gajim.allow_notifications[account]: 396 helpers.play_sound('contact_connected') 397 if not gajim.interface.msg_win_mgr.has_window(jid, account) and \ 398 not gajim.awaiting_events[account].has_key(jid) and \ 399 gajim.config.get('notify_on_signin') and \ 400 gajim.allow_notifications[account]: 401 407 402 transport_name = gajim.get_transport_name_from_jid(jid) 408 403 img = None 409 404 if transport_name: … … 424 419 (account, array)) 425 420 426 421 elif old_show > 1 and new_show < 2: 427 if gajim.config.get_per('soundevents', 'contact_disconnected', 428 'enabled'): 429 helpers.play_sound('contact_disconnected') 430 if not gajim.interface.msg_win_mgr.has_window(jid, account) and \ 431 not gajim.awaiting_events[account].has_key(jid) and \ 432 gajim.config.get('notify_on_signout'): 433 show_notification = False 434 # check OUR status and if we allow notifications for that status 435 if gajim.config.get('autopopupaway'): # always notify 436 show_notification = True 437 elif gajim.connections[account].connected in (2, 3): 438 # we're online or chat 439 show_notification = True 440 if show_notification: 422 # check OUR status and if we allow notifications for that status 423 if notify.want_notify(gajim.connections[account].connected): 424 # play sound 425 if gajim.config.get_per('soundevents', 'contact_disconnected', 426 'enabled'): 427 helpers.play_sound('contact_disconnected') 428 if not gajim.interface.msg_win_mgr.has_window(jid, account) and \ 429 not gajim.awaiting_events[account].has_key(jid) and \ 430 gajim.config.get('notify_on_signout'): 431 441 432 transport_name = gajim.get_transport_name_from_jid(jid) 442 433 img = None 443 434 if transport_name: … … 473 464 if jid.find('@') <= 0: 474 465 jid = jid.replace('@', '') 475 466 476 show_notification = False 477 if gajim.config.get('notify_on_new_message'): 478 # check OUR status and if we allow notifications for that status 479 if gajim.config.get('autopopupaway'): # always show notification 480 show_notification = True 481 elif gajim.connections[account].connected in (2, 3): # we're online or chat 482 show_notification = True 467 # check OUR status and if we allow notifications for that status 468 show_notification = notify.want_notify(gajim.connections[account].connected) 483 469 484 470 chat_control = gajim.interface.msg_win_mgr.get_control(jid, account) 485 471 if chat_control and chat_control.type_id == message_control.TYPE_GC: … … 488 474 fjid = array[0] 489 475 if not gajim.interface.msg_win_mgr.has_window(fjid, account) and \ 490 476 not gajim.awaiting_events[account].has_key(fjid): 491 if show_notification:477 if gajim.config.get('notify_on_new_message') and show_notification: 492 478 room_jid, nick = gajim.get_room_and_nick_from_fjid(fjid) 493 479 room_name,t = gajim.get_room_name_and_server_from_room_jid(room_jid) 494 480 txt = _('%(nickname)s in room %(room_name)s has sent you a new message.')\ … … 531 517 not gajim.awaiting_events[account].has_key(jid): 532 518 first = True 533 519 if gajim.config.get('notify_on_new_message'): 534 show_notification = False535 # check OUR status and if we allow notifications for that status536 if gajim.config.get('autopopupaway'): # always show notification537 show_notification = True538 elif gajim.connections[account].connected in (2, 3): # we're online or chat539 show_notification = True540 520 if show_notification: 541 521 txt = _('%s has sent you a new message.') % gajim.get_name_from_jid(account, jid) 542 522 if msg_type == 'normal': # single message … … 556 536 self.roster.on_message(jid, array[1], array[2], account, array[3], 557 537 msg_type, array[5], resource) 558 538 if gajim.config.get_per('soundevents', 'first_message_received', 559 'enabled') and first:539 'enabled') and show_notification and first: 560 540 helpers.play_sound('first_message_received') 561 if gajim.config.get_per('soundevents', 'next_message_received',562 'enabled') and not first:541 elif gajim.config.get_per('soundevents', 'next_message_received', 542 'enabled') and show_notification and not first: 563 543 helpers.play_sound('next_message_received') 564 544 if self.remote_ctrl: 565 545 self.remote_ctrl.raise_signal('NewMessage', (account, array)) 566 546 567 547 def handle_event_msgerror(self, account, array): 568 548 #('MSGERROR', account, (jid, error_code, error_msg, msg, time)) 569 549 fjid = array[0] … … 606 586 #('MSGSENT', account, (jid, msg, keyID)) 607 587 msg = array[1] 608 588 # do not play sound when standalone chatstate message (eg no msg) 609 if msg and gajim.config.get_per('soundevents', 'message_sent', 'enabled'): 589 if msg and gajim.config.get_per('soundevents', 'message_sent', 'enabled')\ 590 and notify.want_notify(gajim.connections[account].connected): 610 591 helpers.play_sound('message_sent') 611 592 612 593 def handle_event_subscribe(self, account, array): … … 1120 1101 txt = '' 1121 1102 1122 1103 if gajim.config.get('notify_on_file_complete') and \ 1123 (gajim.config.get('autopopupaway') or \ 1124 gajim.connections[account].connected in (2, 3)): 1125 # we want to be notified and we are online/chat or we don't mind 1126 # bugged when away/na/busy 1104 notify.want_notify(gajim.connections[account].connected): 1105 # want_notify() tell us if we want to be notified depending on our status 1127 1106 notify.notify(event_type, jid, account, msg_type, path_to_image = path, text = txt) 1128 1107 1129 1108 def handle_event_stanza_arrived(self, account, stanza): -
src/groupchat_control.py
35 35 import cell_renderer_image 36 36 import history_window 37 37 import tooltips 38 import notify 38 39 39 40 from common import gajim 40 41 from common import helpers … … 415 416 416 417 # Do we play a sound on every muc message? 417 418 if gajim.config.get_per('soundevents', 'muc_message_received', 'enabled'): 418 if gajim.config.get('notify_on_all_muc_messages'): 419 if gajim.config.get('notify_on_all_muc_messages') \ 420 and notify.want_notify(gajim.connections[self.account].connected): 419 421 sound = 'received' 420 422 421 423 # Are any of the defined highlighting words in the text? 422 424 if self.needs_visual_notification(text): 423 425 highlight = True 424 if gajim.config.get_per('soundevents', 'muc_message_highlight', 425 'enabled'):426 if gajim.config.get_per('soundevents', 'muc_message_highlight', 'enabled')\ 427 and notify.want_notify(gajim.connections[self.account].connected): 426 428 sound = 'highlight' 427 429 428 430 # Is it a history message? Don't want sound-floods when we join. -
src/common/config.py
52 52 'notify_on_signout': [ opt_bool, False ], 53 53 'notify_on_new_message': [ opt_bool, True ], 54 54 'autopopupaway': [ opt_bool, False ], 55 'do_not_notify_when': [ opt_str, '' , _('List of all status for which we don\'t want popups/sounds/auto open new messages, separated with a space (online chat away xa dnd invisible)')], 55 56 'use_notif_daemon': [ opt_bool, True , _('Use DBus and Notification-Daemon to show notifications') ], 56 57 'ignore_unknown_contacts': [ opt_bool, False ], 57 58 'showoffline': [ opt_bool, False ],
