option to disable sound when we are busy. Fixes #2256

This commit is contained in:
Yann Leboulanger 2009-02-13 21:14:50 +00:00
parent 849108b11f
commit 521239377b
5 changed files with 509 additions and 478 deletions

File diff suppressed because it is too large Load Diff

View File

@ -79,6 +79,7 @@ class Config:
'notify_on_signout': [ opt_bool, False ],
'notify_on_new_message': [ opt_bool, True ],
'autopopupaway': [ opt_bool, False ],
'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 ],
'show_only_chat_and_online': [ opt_bool, False, _('Show only online and free for chat contacts in roster.')],

View File

@ -1022,7 +1022,7 @@ def allow_popup_window(account, advanced_notif_num = None):
return True
return False
def allow_sound_notification(sound_event, advanced_notif_num = None):
def allow_sound_notification(account, sound_event, advanced_notif_num=None):
if advanced_notif_num is not None:
sound = gajim.config.get_per('notifications', str(advanced_notif_num),
'sound')
@ -1030,7 +1030,9 @@ def allow_sound_notification(sound_event, advanced_notif_num = None):
return True
if sound == 'no':
return False
if gajim.config.get_per('soundevents', sound_event, 'enabled'):
if gajim.config.get('sounddnd') or gajim.connections[account].connected != \
gajim.SHOW_LIST.index('dnd') and gajim.config.get_per('soundevents',
sound_event, 'enabled'):
return True
return False

View File

@ -87,6 +87,7 @@ class PreferencesWindow:
'notify_on_signout_checkbutton')
self.auto_popup_away_checkbutton = self.xml.get_widget(
'auto_popup_away_checkbutton')
self.sound_dnd_checkbutton = self.xml.get_widget('sound_dnd_checkbutton')
self.auto_away_checkbutton = self.xml.get_widget('auto_away_checkbutton')
self.auto_away_time_spinbutton = self.xml.get_widget(
'auto_away_time_spinbutton')
@ -301,6 +302,10 @@ class PreferencesWindow:
st = gajim.config.get('autopopupaway')
self.auto_popup_away_checkbutton.set_active(st)
# sounddnd
st = gajim.config.get('sounddnd')
self.sound_dnd_checkbutton.set_active(st)
# Systray
systray_combobox = self.xml.get_widget('systray_combobox')
if gajim.config.get('trayicon') == 'never':
@ -764,6 +769,9 @@ class PreferencesWindow:
def on_auto_popup_away_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'autopopupaway')
def on_sound_dnd_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'sounddnd')
def on_systray_combobox_changed(self, widget):
active = widget.get_active()
if active == 0:

View File

@ -184,16 +184,16 @@ def notify(event, jid, account, parameters, advanced_notif_num=None):
if helpers.allow_showing_notification(account, 'notify_on_new_message',
advanced_notif_num, is_first_message):
do_popup = True
if is_first_message and helpers.allow_sound_notification(
if is_first_message and helpers.allow_sound_notification(account,
'first_message_received', advanced_notif_num):
do_sound = True
elif not is_first_message and focused and \
helpers.allow_sound_notification('next_message_received_focused',
helpers.allow_sound_notification(account, 'next_message_received_focused',
advanced_notif_num):
do_sound = True
elif not is_first_message and not focused and \
helpers.allow_sound_notification('next_message_received_unfocused',
advanced_notif_num):
helpers.allow_sound_notification(account,
'next_message_received_unfocused', advanced_notif_num):
do_sound = True
else:
print '*Event not implemeted yet*'