diff --git a/src/config.py b/src/config.py
index 0e8eaeb7f..f7c9fd23b 100644
--- a/src/config.py
+++ b/src/config.py
@@ -913,43 +913,11 @@ class PreferencesWindow:
if not iter:
return
path_to_snd_file = model[iter][2].decode('utf-8')
- dialog = gtk.FileChooserDialog(_('Choose Sound'), None,
- gtk.FILE_CHOOSER_ACTION_OPEN,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OPEN, gtk.RESPONSE_OK))
- dialog.set_default_response(gtk.RESPONSE_OK)
- last_sounds_dir = gajim.config.get('last_sounds_dir')
- if last_sounds_dir and os.path.isdir('last_sounds_dir'):
- dialog.set_current_folder(last_sounds_dir)
- else:
- dialog.set_current_folder(gajim.HOME_DIR)
-
- filter = gtk.FileFilter()
- filter.set_name(_('All files'))
- filter.add_pattern('*')
- dialog.add_filter(filter)
-
- filter = gtk.FileFilter()
- filter.set_name(_('Wav Sounds'))
- filter.add_pattern('*.wav')
- dialog.add_filter(filter)
- dialog.set_filter(filter)
-
path_to_snd_file = os.path.join(os.getcwd(), path_to_snd_file)
- dialog.set_filename(path_to_snd_file)
- path_to_snd_file = ''
- while True:
- response = dialog.run()
- if response != gtk.RESPONSE_OK:
- break
- path_to_snd_file = dialog.get_filename()
- try:
- path_to_snd_file = path_to_snd_file.decode(sys.getfilesystemencoding())
- except:
- pass
- if os.path.exists(path_to_snd_file):
- break
- dialog.destroy()
+ dlg_instance = dialogs.SoundChooserDialog(path_to_snd_file)
+ path_to_snd_file = dlg_instance.path_to_snd_file
+ dlg_instance.dialog.destroy()
+
if path_to_snd_file:
directory = os.path.dirname(path_to_snd_file)
gajim.config.set('last_sounds_dir', directory)
diff --git a/src/dialogs.py b/src/dialogs.py
index d2b616b57..9d50d9054 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -1467,3 +1467,101 @@ class ProgressDialog:
gobject.source_remove(self.read_from_queue_id)
self.read_from_queue_and_update_textview()
self.progressbar.set_fraction(1)
+
+class SoundChooserDialog:
+ def __init__(self, path_to_snd_file = ''):
+ '''optionally accepts path_to_snd_file so it has that as selected'''
+ self.dialog = gtk.FileChooserDialog(_('Choose Sound'), None,
+ gtk.FILE_CHOOSER_ACTION_OPEN,
+ (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+ self.dialog.set_default_response(gtk.RESPONSE_OK)
+ last_sounds_dir = gajim.config.get('last_sounds_dir')
+ if last_sounds_dir and os.path.isdir('last_sounds_dir'):
+ self.dialog.set_current_folder(last_sounds_dir)
+ else:
+ self.dialog.set_current_folder(gajim.HOME_DIR)
+
+ filter = gtk.FileFilter()
+ filter.set_name(_('All files'))
+ filter.add_pattern('*')
+ self.dialog.add_filter(filter)
+
+ filter = gtk.FileFilter()
+ filter.set_name(_('Wav Sounds'))
+ filter.add_pattern('*.wav')
+ self.dialog.add_filter(filter)
+ self.dialog.set_filter(filter)
+
+ self.path_to_snd_file = path_to_snd_file
+ self.dialog.set_filename(self.path_to_snd_file)
+
+ self.path_to_snd_file = ''
+ while True:
+ response = self.dialog.run()
+ if response != gtk.RESPONSE_OK:
+ break
+ self.path_to_snd_file = self.dialog.get_filename()
+ try:
+ self.path_to_snd_file = path_to_snd_file.decode(
+ sys.getfilesystemencoding())
+ except:
+ pass
+ if os.path.exists(self.path_to_snd_file):
+ break
+
+
+class AddSpecialNotificationDialog:
+ def __init__(self, jid):
+ '''jid is the jid for which we want to add special notification
+ (sound and notification popups)'''
+ self.xml = gtk.glade.XML(GTKGUI_GLADE, 'add_special_notification_window',
+ APP)
+ self.window = self.xml.get_widget('add_special_notification_window')
+ self.condition_combobox = self.xml.get_widget('condition_combobox')
+ self.condition_combobox.set_active(0)
+ self.notification_popup_yes_no_combobox = self.xml.get_widget(
+ 'notification_popup_yes_no_combobox')
+ self.notification_popup_yes_no_combobox.set_active(0)
+ self.listen_sound_combobox = self.xml.get_widget('listen_sound_combobox')
+ self.listen_sound_combobox.set_active(0)
+
+
+ self.jid = jid
+ self.xml.get_widget('when_foo_becomes_label').set_text(
+ _('When %s becomes:') % self.jid)
+
+
+ self.window.set_title(_('Adding Special Notification for %s') % jid)
+ self.window.show_all()
+ self.xml.signal_autoconnect(self)
+
+ def on_cancel_button_clicked(self, widget):
+ self.window.destroy()
+
+ def on_add_special_notification_window_delete_event(self, widget, event):
+ self.window.destroy()
+
+ def on_listen_sound_combobox_changed(self, widget):
+ model = widget.get_model()
+ active = widget.get_active()
+ if active == 1: # user selected 'choose sound'
+ dlg_instance = SoundChooserDialog()
+ path_to_snd_file = dlg_instance.path_to_snd_file
+ dlg_instance.dialog.destroy()
+
+ if path_to_snd_file:
+ print path_to_snd_file
+ else: # user selected nothing (X button or Cancel)
+ widget.set_active(0) # go back to No Sound
+ #model[iter][0] =
+
+ def on_ok_button_clicked(self, widget):
+ conditions = ('online', 'chat', 'online_and_chat',
+ 'away', 'xa', 'away_and_xa', 'dnd', 'xa_and_dnd', 'offline')
+ active = self.condition_combobox.get_active()
+ print conditions[active]
+
+ active_iter = self.listen_sound_combobox.get_active_iter()
+ listen_sound_model = self.listen_sound_combobox.get_model()
+ print listen_sound_model[active_iter][0]
diff --git a/src/gtkgui.glade b/src/gtkgui.glade
index e1056317d..db8da05e1 100644
--- a/src/gtkgui.glade
+++ b/src/gtkgui.glade
@@ -15218,7 +15218,7 @@ Banner
True
-
+
True
gtk-jump-to
1
@@ -15238,7 +15238,7 @@ Banner
True
-
+
True
gtk-new
1
@@ -15257,7 +15257,7 @@ Banner
True
-
+
True
gtk-refresh
1
@@ -15278,7 +15278,7 @@ Banner
-
@@ -15288,10 +15288,9 @@ Banner
True
Send File
True
-
-
+
True
gtk-file
1
@@ -15311,7 +15310,7 @@ Banner
-
+
True
gtk-dialog-authentication
1
@@ -15324,6 +15323,26 @@ Banner
+
+
+
+