add new option to allow popup notifications when a chat control is opened. See #7891, #8158

This commit is contained in:
Yann Leboulanger 2015-10-25 15:06:37 +01:00
parent 5b513f763e
commit 6337606c49
5 changed files with 51 additions and 23 deletions

View file

@ -682,6 +682,23 @@
<property name="position">3</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="auto_popup_chat_opened_checkbutton">
<property name="label" translatable="yes">Allow popup/notifications when a chat window is opened</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_auto_popup_chat_opened_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child> <child>
<object class="GtkFrame" id="frame_gmail"> <object class="GtkFrame" id="frame_gmail">
<property name="visible">True</property> <property name="visible">True</property>
@ -748,7 +765,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">4</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -791,7 +808,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">5</property> <property name="position">6</property>
</packing> </packing>
</child> </child>
</object> </object>

View file

@ -73,6 +73,7 @@ class Config:
'notify_on_signout': [ opt_bool, False ], 'notify_on_signout': [ opt_bool, False ],
'notify_on_new_message': [ opt_bool, True ], 'notify_on_new_message': [ opt_bool, True ],
'autopopupaway': [ opt_bool, False ], 'autopopupaway': [ opt_bool, False ],
'autopopup_chat_opened': [ opt_bool, False, _('Show desktop notification even when a chat window is opened for this contact and does not have focus') ],
'sounddnd': [ opt_bool, False, _('Play sound when user is busy')], 'sounddnd': [ opt_bool, False, _('Play sound when user is busy')],
'use_notif_daemon': [ opt_bool, True, _('Use D-Bus and Notification-Daemon to show notifications') ], 'use_notif_daemon': [ opt_bool, True, _('Use D-Bus and Notification-Daemon to show notifications') ],
'showoffline': [ opt_bool, False ], 'showoffline': [ opt_bool, False ],

View file

@ -2302,7 +2302,7 @@ class NotificationEvent(nec.NetworkIncomingEvent):
if self.control: if self.control:
parent_win = self.control.parent_win parent_win = self.control.parent_win
if parent_win and self.control == parent_win.get_active_control() \ if parent_win and self.control == parent_win.get_active_control() \
and parent_win.window.has_focus: and parent_win.window.get_property('has-toplevel-focus'):
self.control_focused = True self.control_focused = True
def handle_incoming_msg_event(self, msg_obj): def handle_incoming_msg_event(self, msg_obj):
@ -2364,13 +2364,14 @@ class NotificationEvent(nec.NetworkIncomingEvent):
self.popup_title = _('New Message from %(nickname)s') % \ self.popup_title = _('New Message from %(nickname)s') % \
{'nickname': nick} {'nickname': nick}
if not gajim.config.get('notify_on_new_message') or \
not self.first_unread: if gajim.config.get('notify_on_new_message'):
self.do_popup = False if self.first_unread or (gajim.config.get('autopopup_chat_opened') \
elif gajim.config.get('autopopupaway'): and not self.control_focused):
if gajim.config.get('autopopupaway'):
# always show notification # always show notification
self.do_popup = True self.do_popup = True
elif gajim.connections[self.conn.name].connected in (2, 3): if gajim.connections[self.conn.name].connected in (2, 3):
# we're online or chat # we're online or chat
self.do_popup = True self.do_popup = True

View file

@ -97,8 +97,8 @@ class PreferencesWindow:
self.window = self.xml.get_object('preferences_window') self.window = self.xml.get_object('preferences_window')
self.window.set_transient_for(gajim.interface.roster.window) self.window.set_transient_for(gajim.interface.roster.window)
self.notebook = self.xml.get_object('preferences_notebook') self.notebook = self.xml.get_object('preferences_notebook')
self.one_window_type_combobox =\ self.one_window_type_combobox = self.xml.get_object(
self.xml.get_object('one_window_type_combobox') 'one_window_type_combobox')
self.iconset_combobox = self.xml.get_object('iconset_combobox') self.iconset_combobox = self.xml.get_object('iconset_combobox')
self.notify_on_signin_checkbutton = self.xml.get_object( self.notify_on_signin_checkbutton = self.xml.get_object(
'notify_on_signin_checkbutton') 'notify_on_signin_checkbutton')
@ -106,6 +106,8 @@ class PreferencesWindow:
'notify_on_signout_checkbutton') 'notify_on_signout_checkbutton')
self.auto_popup_away_checkbutton = self.xml.get_object( self.auto_popup_away_checkbutton = self.xml.get_object(
'auto_popup_away_checkbutton') 'auto_popup_away_checkbutton')
self.auto_popup_chat_opened_checkbutton = self.xml.get_object(
'auto_popup_chat_opened_checkbutton')
self.sound_dnd_checkbutton = self.xml.get_object('sound_dnd_checkbutton') self.sound_dnd_checkbutton = self.xml.get_object('sound_dnd_checkbutton')
self.auto_away_checkbutton = self.xml.get_object('auto_away_checkbutton') self.auto_away_checkbutton = self.xml.get_object('auto_away_checkbutton')
self.auto_away_time_spinbutton = self.xml.get_object( self.auto_away_time_spinbutton = self.xml.get_object(
@ -313,6 +315,10 @@ class PreferencesWindow:
st = gajim.config.get('autopopupaway') st = gajim.config.get('autopopupaway')
self.auto_popup_away_checkbutton.set_active(st) self.auto_popup_away_checkbutton.set_active(st)
# autopopup_chat_opened
st = gajim.config.get('autopopup_chat_opened')
self.auto_popup_chat_opened_checkbutton.set_active(st)
# sounddnd # sounddnd
st = gajim.config.get('sounddnd') st = gajim.config.get('sounddnd')
self.sound_dnd_checkbutton.set_active(st) self.sound_dnd_checkbutton.set_active(st)
@ -847,6 +853,9 @@ class PreferencesWindow:
def on_auto_popup_away_checkbutton_toggled(self, widget): def on_auto_popup_away_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'autopopupaway') self.on_checkbutton_toggled(widget, 'autopopupaway')
def on_auto_popup_chat_opened_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'autopopup_chat_opened')
def on_sound_dnd_checkbutton_toggled(self, widget): def on_sound_dnd_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'sounddnd') self.on_checkbutton_toggled(widget, 'sounddnd')

View file

@ -125,7 +125,7 @@ class TextViewImage(Gtk.Image):
if not parent: if not parent:
self._disconnect_signals() self._disconnect_signals()
return return
if isinstance(parent, gtk.EventBox): if isinstance(parent, Gtk.EventBox):
parent = parent.get_parent() parent = parent.get_parent()
if not parent: if not parent:
self._disconnect_signals() self._disconnect_signals()