add a new event to allow not playing sound when chat window is focused. fixes #2907
This commit is contained in:
parent
4c219e4f57
commit
7d5602c4b1
|
@ -1,5 +1,5 @@
|
|||
AC_INIT([Gajim - A Jabber Instant Messager],
|
||||
[0.11.4.1-svn],[http://trac.gajim.org/],[gajim])
|
||||
[0.11.4.2-svn],[http://trac.gajim.org/],[gajim])
|
||||
AC_PREREQ([2.59])
|
||||
AM_INIT_AUTOMAKE([1.8])
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
|
|
@ -408,7 +408,8 @@ class Config:
|
|||
|
||||
soundevents_default = {
|
||||
'first_message_received': [ True, '../data/sounds/message1.wav' ],
|
||||
'next_message_received': [ True, '../data/sounds/message2.wav' ],
|
||||
'next_message_received_focused': [ True, '../data/sounds/message2.wav' ],
|
||||
'next_message_received_unfocused': [ True, '../data/sounds/message2.wav' ],
|
||||
'contact_connected': [ True, '../data/sounds/connected.wav' ],
|
||||
'contact_disconnected': [ True, '../data/sounds/disconnected.wav' ],
|
||||
'message_sent': [ True, '../data/sounds/sent.wav' ],
|
||||
|
|
|
@ -2,7 +2,7 @@ docdir = '../'
|
|||
|
||||
datadir = '../'
|
||||
|
||||
version = '0.11.4.1-svn'
|
||||
version = '0.11.4.2-svn'
|
||||
|
||||
import sys, os.path
|
||||
for base in ('.', 'common'):
|
||||
|
|
|
@ -176,6 +176,8 @@ class OptionsParser:
|
|||
self.update_config_to_01121()
|
||||
if old < [0, 11, 4, 1] and new >= [0, 11, 4, 1]:
|
||||
self.update_config_to_01141()
|
||||
if old < [0, 11, 4, 2] and new >= [0, 11, 4, 2]:
|
||||
self.update_config_to_01142()
|
||||
|
||||
gajim.logger.init_vars()
|
||||
gajim.config.set('version', new_version)
|
||||
|
@ -526,3 +528,18 @@ class OptionsParser:
|
|||
con.close()
|
||||
gajim.config.set('version', '0.11.4.1')
|
||||
|
||||
def update_config_to_01142(self):
|
||||
'''next_message_received sound event is splittedin 2 events'''
|
||||
gajim.config.add_per('soundevents', 'next_message_received_focused')
|
||||
gajim.config.add_per('soundevents', 'next_message_received_unfocused')
|
||||
if gajim.config.get_per('soundevents', 'next_message_received'):
|
||||
enabled = gajim.config.get_per('soundevents', 'next_message_received',
|
||||
'enabled')
|
||||
path = gajim.config.get_per('soundevents', 'next_message_received',
|
||||
'path')
|
||||
gajim.config.del_per('soundevents', 'next_message_received')
|
||||
gajim.config.set_per('soundevents', 'next_message_received_focused',
|
||||
'enabled', enabled)
|
||||
gajim.config.set_per('soundevents', 'next_message_received_focused',
|
||||
'path', path)
|
||||
gajim.config.set('version', '0.11.1.2')
|
||||
|
|
|
@ -1089,12 +1089,15 @@ class PreferencesWindow:
|
|||
def fill_sound_treeview(self):
|
||||
model = self.sound_tree.get_model()
|
||||
model.clear()
|
||||
model.set_sort_column_id(1, gtk.SORT_ASCENDING)
|
||||
|
||||
# NOTE: sounds_ui_names MUST have all items of
|
||||
# sounds = gajim.config.get_per('soundevents') as keys
|
||||
sounds_dict = {
|
||||
'first_message_received': _('First Message Received'),
|
||||
'next_message_received': _('Next Message Received'),
|
||||
'next_message_received_focused': _('Next Message Received Focused'),
|
||||
'next_message_received_unfocused':
|
||||
_('Next Message Received Unfocused'),
|
||||
'contact_connected': _('Contact Connected'),
|
||||
'contact_disconnected': _('Contact Disconnected'),
|
||||
'message_sent': _('Message Sent'),
|
||||
|
|
|
@ -847,8 +847,14 @@ class Interface:
|
|||
msg = message
|
||||
if subject:
|
||||
msg = _('Subject: %s') % subject + '\n' + msg
|
||||
focused = False
|
||||
if chat_control:
|
||||
parent_win = chat_control.parent_win
|
||||
if chat_control == parent_win.get_active_control() and \
|
||||
parent_win.window.has_focus:
|
||||
focused = True
|
||||
notify.notify('new_message', jid_of_control, account, [msg_type,
|
||||
first, nickname, msg], advanced_notif_num)
|
||||
first, nickname, msg, focused], advanced_notif_num)
|
||||
|
||||
if self.remote_ctrl:
|
||||
self.remote_ctrl.raise_signal('NewMessage', (account, array))
|
||||
|
|
|
@ -175,14 +175,20 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
|
|||
else:
|
||||
# We don't want message preview, do_preview = False
|
||||
message = ''
|
||||
focused = parameters[4]
|
||||
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(
|
||||
'first_message_received', advanced_notif_num):
|
||||
do_sound = True
|
||||
elif not is_first_message and helpers.allow_sound_notification(
|
||||
'next_message_received', advanced_notif_num):
|
||||
elif not is_first_message and focused and \
|
||||
helpers.allow_sound_notification('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):
|
||||
do_sound = True
|
||||
else:
|
||||
print '*Event not implemeted yet*'
|
||||
|
@ -285,8 +291,10 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
|
|||
pass # do not set snd_event
|
||||
elif is_first_message:
|
||||
snd_event = 'first_message_received'
|
||||
elif focused:
|
||||
snd_event = 'next_message_received_focused'
|
||||
else:
|
||||
snd_event = 'next_message_received'
|
||||
snd_event = 'next_message_received_unfocused'
|
||||
elif event in ('contact_connected', 'contact_disconnected'):
|
||||
snd_event = event
|
||||
if snd_file:
|
||||
|
|
Loading…
Reference in New Issue