commit first part of special notifications (aka buddy pounces). at last make Choose Sound dlg a class; TODO: actually write to config user settings as well as take those into account [jim++]

This commit is contained in:
Nikos Kouremenos 2006-03-15 17:45:55 +00:00
parent 22ab2f5300
commit f65a5be6e5
4 changed files with 410 additions and 68 deletions

View File

@ -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)

View File

@ -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]

View File

@ -15218,7 +15218,7 @@ Banner</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1308">
<widget class="GtkImage" id="image1423">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property>
@ -15238,7 +15238,7 @@ Banner</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1309">
<widget class="GtkImage" id="image1424">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -15257,7 +15257,7 @@ Banner</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1310">
<widget class="GtkImage" id="image1425">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">1</property>
@ -15278,7 +15278,7 @@ Banner</property>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator4">
<widget class="GtkSeparatorMenuItem" id="above_send_file_separator">
<property name="visible">True</property>
</widget>
</child>
@ -15288,10 +15288,9 @@ Banner</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Send File</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_send_file_menuitem_activate" last_modification_time="Thu, 01 Sep 2005 23:13:17 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1311">
<widget class="GtkImage" id="image1426">
<property name="visible">True</property>
<property name="stock">gtk-file</property>
<property name="icon_size">1</property>
@ -15311,7 +15310,7 @@ Banner</property>
<signal name="activate" handler="on_assign_openpgp_key_menuitem_activate" last_modification_time="Thu, 30 Jun 2005 22:57:59 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1312">
<widget class="GtkImage" id="image1427">
<property name="visible">True</property>
<property name="stock">gtk-dialog-authentication</property>
<property name="icon_size">1</property>
@ -15324,6 +15323,26 @@ Banner</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="add_special_notification_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">Add Special _Notification</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1428">
<property name="visible">True</property>
<property name="stock">gtk-info</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator5">
<property name="visible">True</property>
@ -15336,7 +15355,7 @@ Banner</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1313">
<widget class="GtkImage" id="image1429">
<property name="visible">True</property>
<property name="stock">gtk-dialog-question</property>
<property name="icon_size">1</property>
@ -15357,7 +15376,7 @@ Banner</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1314">
<widget class="GtkImage" id="image1430">
<property name="visible">True</property>
<property name="stock">gtk-go-up</property>
<property name="icon_size">1</property>
@ -15377,7 +15396,7 @@ Banner</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1315">
<widget class="GtkImage" id="image1431">
<property name="visible">True</property>
<property name="stock">gtk-go-down</property>
<property name="icon_size">1</property>
@ -15395,10 +15414,9 @@ Banner</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Forbid him/her to see my status</property>
<property name="use_underline">True</property>
<signal name="activate" handler="revoke_authorization_to_menuitem" last_modification_time="Fri, 25 Nov 2005 21:26:31 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1316">
<widget class="GtkImage" id="image1432">
<property name="visible">True</property>
<property name="stock">gtk-stop</property>
<property name="icon_size">1</property>
@ -15421,7 +15439,7 @@ Banner</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1317">
<widget class="GtkImage" id="image1433">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -15440,7 +15458,7 @@ Banner</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1318">
<widget class="GtkImage" id="image1434">
<property name="visible">True</property>
<property name="stock">gtk-remove</property>
<property name="icon_size">1</property>
@ -15472,7 +15490,7 @@ Banner</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1319">
<widget class="GtkImage" id="image1435">
<property name="visible">True</property>
<property name="stock">gtk-justify-fill</property>
<property name="icon_size">1</property>
@ -19290,4 +19308,254 @@ topic</property>
</child>
</widget>
<widget class="GtkWindow" id="add_special_notification_window">
<property name="border_width">6</property>
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<signal name="delete_event" handler="on_add_special_notification_window_delete_event" last_modification_time="Wed, 15 Mar 2006 16:44:15 GMT"/>
<child>
<widget class="GtkVBox" id="vbox114">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="label384">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Please modify your special notification below&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table35">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<widget class="GtkLabel" id="when_foo_becomes_label">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="condition_combobox">
<property name="visible">True</property>
<property name="items" translatable="yes">Available
Free for Chat
Available or Free for Chat
Away
Not Available
Away or Not Available
Busy
Not Available or Busy
Offline</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label386">
<property name="visible">True</property>
<property name="label" translatable="yes">I want a notification popup:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label387">
<property name="visible">True</property>
<property name="label" translatable="yes">I want to listen to:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="listen_sound_combobox">
<property name="visible">True</property>
<property name="items" translatable="yes">Nothing
Select Sound...</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
<signal name="changed" handler="on_listen_sound_combobox_changed" last_modification_time="Wed, 15 Mar 2006 16:59:03 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="notification_popup_yes_no_combobox">
<property name="visible">True</property>
<property name="items" translatable="yes">Yes
No</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox34">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="cancel_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Wed, 15 Mar 2006 16:21:17 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="ok_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_ok_button_clicked" last_modification_time="Wed, 15 Mar 2006 16:21:21 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -1095,7 +1095,7 @@ class RosterWindow:
gajim.interface.instances['logs'][contact.jid] = history_window.\
HistoryWindow(contact.jid, account)
def on_send_single_message_menuitem_activate(self, wiget, account,
def on_send_single_message_menuitem_activate(self, widget, account,
contact = None):
if contact is None:
dialogs.SingleMessageWindow(account, action = 'send')
@ -1105,6 +1105,9 @@ class RosterWindow:
def on_send_file_menuitem_activate(self, widget, account, contact):
gajim.interface.instances['file_transfers'].show_file_send_request(
account, contact)
def on_add_special_notification_menuitem_activate(self, widget, jid):
dialogs.AddSpecialNotificationDialog(jid)
def mk_menu_user(self, event, iter):
'''Make contact's popup menu'''
@ -1118,25 +1121,28 @@ class RosterWindow:
APP)
roster_contact_context_menu = xml.get_widget(
'roster_contact_context_menu')
childs = roster_contact_context_menu.get_children()
#childs = roster_contact_context_menu.get_children()
start_chat_menuitem = childs[0]
send_single_message_menuitem = childs[1]
rename_menuitem = childs[2]
edit_groups_menuitem = childs[3]
# separator4 goes with assign_openpgp_key_menuitem
assign_openpgp_separator = childs[4]
send_file_menuitem = childs[5]
assign_openpgp_key_menuitem = childs[6]
start_chat_menuitem = xml.get_widget('start_chat_menuitem')
send_single_message_menuitem = xml.get_widget('send_single_message_menuitem')
rename_menuitem = xml.get_widget('rename_menuitem')
edit_groups_menuitem = xml.get_widget('edit_groups_menuitem')
# separator has with send file, assign_openpgp_key_menuitem, etc..
above_send_file_separator = xml.get_widget('above_send_file_separator')
send_file_menuitem = xml.get_widget('send_file_menuitem')
assign_openpgp_key_menuitem = xml.get_widget('assign_openpgp_key_menuitem')
add_special_notification_menuitem = xml.get_widget(
'add_special_notification_menuitem')
#skip a seperator
subscription_menuitem = xml.get_widget('subscription_menuitem')
send_auth_menuitem, ask_auth_menuitem, revoke_auth_menuitem =\
childs[8].get_submenu().get_children()
add_to_roster_menuitem = childs[9]
remove_from_roster_menuitem = childs[10]
subscription_menuitem.get_submenu().get_children()
add_to_roster_menuitem = xml.get_widget('add_to_roster_menuitem')
remove_from_roster_menuitem = xml.get_widget('remove_from_roster_menuitem')
#skip a seperator
information_menuitem = childs[12]
history_menuitem = childs[13]
information_menuitem = xml.get_widget('information_menuitem')
history_menuitem = xml.get_widget('history_menuitem')
contacts = gajim.contacts.get_contact(account, jid)
if len(contacts) > 1: # sevral resources
@ -1198,6 +1204,8 @@ class RosterWindow:
send_auth_menuitem.connect('activate', self.authorize, jid, account)
if contact.sub in ('to', 'both'):
ask_auth_menuitem.set_sensitive(False)
add_special_notification_menuitem.connect('activate',
self.on_add_special_notification_menuitem_activate, jid)
else:
ask_auth_menuitem.connect('activate', self.req_sub, jid,
_('I would like to add you to my roster'), account)
@ -1212,8 +1220,8 @@ class RosterWindow:
edit_groups_menuitem.hide()
edit_groups_menuitem.set_no_show_all(True)
# hide first of the two consecutive separators
assign_openpgp_separator.hide()
assign_openpgp_separator.set_no_show_all(True)
above_send_file_separator.hide()
above_send_file_separator.set_no_show_all(True)
assign_openpgp_key_menuitem.hide()
assign_openpgp_key_menuitem.set_no_show_all(True)