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>
</packing>
</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>
<object class="GtkFrame" id="frame_gmail">
<property name="visible">True</property>
@ -748,7 +765,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
<child>
@ -791,7 +808,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
</object>

View File

@ -73,6 +73,7 @@ class Config:
'notify_on_signout': [ opt_bool, False ],
'notify_on_new_message': [ opt_bool, True ],
'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')],
'use_notif_daemon': [ opt_bool, True, _('Use D-Bus and Notification-Daemon to show notifications') ],
'showoffline': [ opt_bool, False ],

View File

@ -2302,7 +2302,7 @@ class NotificationEvent(nec.NetworkIncomingEvent):
if self.control:
parent_win = self.control.parent_win
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
def handle_incoming_msg_event(self, msg_obj):
@ -2364,15 +2364,16 @@ class NotificationEvent(nec.NetworkIncomingEvent):
self.popup_title = _('New Message from %(nickname)s') % \
{'nickname': nick}
if not gajim.config.get('notify_on_new_message') or \
not self.first_unread:
self.do_popup = False
elif gajim.config.get('autopopupaway'):
# always show notification
self.do_popup = True
elif gajim.connections[self.conn.name].connected in (2, 3):
# we're online or chat
self.do_popup = True
if gajim.config.get('notify_on_new_message'):
if self.first_unread or (gajim.config.get('autopopup_chat_opened') \
and not self.control_focused):
if gajim.config.get('autopopupaway'):
# always show notification
self.do_popup = True
if gajim.connections[self.conn.name].connected in (2, 3):
# we're online or chat
self.do_popup = True
if msg_obj.attention and not gajim.config.get(
'ignore_incoming_attention'):

View File

@ -97,36 +97,38 @@ class PreferencesWindow:
self.window = self.xml.get_object('preferences_window')
self.window.set_transient_for(gajim.interface.roster.window)
self.notebook = self.xml.get_object('preferences_notebook')
self.one_window_type_combobox =\
self.xml.get_object('one_window_type_combobox')
self.one_window_type_combobox = self.xml.get_object(
'one_window_type_combobox')
self.iconset_combobox = self.xml.get_object('iconset_combobox')
self.notify_on_signin_checkbutton = self.xml.get_object(
'notify_on_signin_checkbutton')
'notify_on_signin_checkbutton')
self.notify_on_signout_checkbutton = self.xml.get_object(
'notify_on_signout_checkbutton')
'notify_on_signout_checkbutton')
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.auto_away_checkbutton = self.xml.get_object('auto_away_checkbutton')
self.auto_away_time_spinbutton = self.xml.get_object(
'auto_away_time_spinbutton')
'auto_away_time_spinbutton')
self.auto_away_message_entry = self.xml.get_object(
'auto_away_message_entry')
'auto_away_message_entry')
self.auto_xa_checkbutton = self.xml.get_object('auto_xa_checkbutton')
self.auto_xa_time_spinbutton = self.xml.get_object(
'auto_xa_time_spinbutton')
'auto_xa_time_spinbutton')
self.auto_xa_message_entry = self.xml.get_object('auto_xa_message_entry')
### General tab ###
# Display avatars in roster
st = gajim.config.get('show_avatars_in_roster')
self.xml.get_object('show_avatars_in_roster_checkbutton'). \
set_active(st)
set_active(st)
# Display status msg under contact name in roster
st = gajim.config.get('show_status_msgs_in_roster')
self.xml.get_object('show_status_msgs_in_roster_checkbutton'). \
set_active( st)
set_active( st)
# Display PEP in roster
st1 = gajim.config.get('show_mood_in_roster')
@ -313,6 +315,10 @@ class PreferencesWindow:
st = gajim.config.get('autopopupaway')
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
st = gajim.config.get('sounddnd')
self.sound_dnd_checkbutton.set_active(st)
@ -847,6 +853,9 @@ class PreferencesWindow:
def on_auto_popup_away_checkbutton_toggled(self, widget):
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):
self.on_checkbutton_toggled(widget, 'sounddnd')

View File

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