From 7922426464929cdb6bb8c4ccee1813466de4bf92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=C3=ABl=20Verrier?= Date: Sun, 19 Jul 2009 16:39:07 +0200 Subject: [PATCH] * first draft of message archiving preferences window * fixed a bug in ConnectionArchive.append_or_update_item prototype --- data/glade/archiving_preferences_window.glade | 359 ++++++++++++++++++ src/common/message_archiving.py | 2 +- src/dialogs.py | 88 +++++ 3 files changed, 448 insertions(+), 1 deletion(-) create mode 100644 data/glade/archiving_preferences_window.glade diff --git a/data/glade/archiving_preferences_window.glade b/data/glade/archiving_preferences_window.glade new file mode 100644 index 000000000..bed961b3f --- /dev/null +++ b/data/glade/archiving_preferences_window.glade @@ -0,0 +1,359 @@ + + + + + + 12 + + + + True + vertical + + + True + + + True + <i>Auto Save</i> + True + + + 0 + + + + + Yes + True + True + False + True + True + + + 1 + + + + + No + True + True + False + True + True + auto_save_yes_radiobutton + + + 2 + + + + + False + 0 + + + + + True + 3 + 2 + + + True + <i>Method Auto</i> + True + + + + + True + <i>Method Local</i> + True + + + 1 + 2 + + + + + True + <i>Method Manual</i> + True + + + 2 + 3 + + + + + True + Prefer +Concede +Forbid + + + 1 + 2 + 2 + 3 + + + + + True + Prefer +Concede +Forbid + + + 1 + 2 + 1 + 2 + + + + + True + Prefer +Concede +Forbid + + + 1 + 2 + + + + + False + 1 + + + + + True + + + True + vertical + + + True + True + automatic + automatic + + + True + True + False + + + + + + 0 + + + + + True + spread + + + gtk-add + True + True + True + True + + + + False + False + 0 + + + + + gtk-remove + True + True + True + True + + + + False + False + 1 + + + + + False + 1 + + + + + 0 + + + + + True + True + False + False + + + True + + + + + True + page 1 + + + False + tab + + + + + True + 3 + 2 + + + True + expire + + + + + True + otr + + + 1 + 2 + + + + + True + save + + + 2 + 3 + + + + + True + True + + + + 1 + 2 + + + + + True + approve +concede +forbid +oppose +prefer +require + + + 1 + 2 + 1 + 2 + + + + + True + body +false +message +stream + + + 1 + 2 + 2 + 3 + + + + + 1 + + + + + True + page 2 + + + 1 + False + tab + + + + + 1 + + + + + 2 + + + + + True + end + + + gtk-close + True + True + True + False + True + + + + False + False + 0 + + + + + False + 3 + + + + + + diff --git a/src/common/message_archiving.py b/src/common/message_archiving.py index 66e058a1f..913f6c497 100644 --- a/src/common/message_archiving.py +++ b/src/common/message_archiving.py @@ -36,7 +36,7 @@ class ConnectionArchive: self.default = {'expire': expire, 'otr': otr, 'save': save, 'unset': unset} - def append_or_update_item(self, jid, expire, otr, save): + def append_or_update_item(self, jid, otr, save, expire): self.items[jid] = {'expire': expire, 'otr': otr, 'save': save} def remove_item(self, jid): diff --git a/src/dialogs.py b/src/dialogs.py index 7fe7163f4..c3ab7cb85 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -2852,6 +2852,94 @@ class ArchivingPreferencesWindow: def __init__(self, account): self.account = account + # Connect to glade + self.xml = gtkgui_helpers.get_glade('archiving_preferences_window.glade') + self.window = self.xml.get_widget('archiving_preferences_window') + + # Add Widgets + for widget_to_add in ('auto_save_yes_radiobutton', + 'auto_save_no_radiobutton', 'method_auto_combobox', + 'method_local_combobox', 'method_manual_combobox', 'close_button', + 'item_treeview', 'item_notebook', 'otr_combobox', 'save_combobox', + 'expire_entry'): + self.__dict__[widget_to_add] = self.xml.get_widget(widget_to_add) + + + auto_save = gajim.connections[account].auto_save == 'true' + self.auto_save_yes_radiobutton.set_active(auto_save) + self.auto_save_no_radiobutton.set_active(not auto_save) + + method_index = {'prefer': 0, 'concede': 1, 'forbid': 2} + self.method_auto_combobox.set_active(method_index[gajim.connections[ + self.account].method_auto]) + self.method_local_combobox.set_active(method_index[gajim.connections[ + self.account].method_local]) + self.method_manual_combobox.set_active(method_index[gajim.connections[ + self.account].method_manual]) + + model = gtk.ListStore(str) + self.item_treeview.set_model(model) + col = gtk.TreeViewColumn('name') + self.item_treeview.append_column(col) + renderer = gtk.CellRendererText() + col.pack_start(renderer, True) + col.set_attributes(renderer, text=0) + #renderer.connect('edited', self.on_msg_cell_edited) + renderer.set_property('editable', False) + #self.fill_item_treeview() + iter_ = model.append() + model.set(iter_, 0, 'Default') + for item in gajim.connections[account].items: + iter_ = model.append() + model.set(iter_, 0, item) + self.current_item = None + + self.window.set_title(_('Archiving Preferences for %s') % self.account) + + self.window.show_all() + + self.xml.signal_autoconnect(self) + + def on_archiving_preferences_window_destroy(self, widget): + if 'archiving_preferences' in gajim.interface.instances[self.account]: + del gajim.interface.instances[self.account]['archiving_preferences'] + + def on_add_item_button_clicked(self, widget): + model = self.item_treeview.get_model() + iter_ = model.append() + model.set(iter_, 0, 'jid@example.net') + + def on_item_treeview_cursor_changed(self, widget): + sel = self.item_treeview.get_selection() + (model, iter_) = sel.get_selected() + item = None + if iter_: + item = model[iter_][0] + if self.current_item and self.current_item == item: + return + + if iter: + otr_index = {'approve': 0, 'concede': 1, 'forbid': 2, 'oppose': 3, + 'prefer': 4, 'require': 5} + save_index = {'body': 0, 'false': 1, 'message': 2, 'stream': 3} + item_config = None + if item == 'Default': + item_config = gajim.connections[self.account].default + else: + item_config = gajim.connections[self.account].items[item] + self.otr_combobox.set_active(otr_index[item_config['otr']]) + self.save_combobox.set_active(save_index[item_config['save']]) + expire_value = item_config['expire'] or '' + self.expire_entry.set_text(expire_value) + self.current_item = item + if self.current_item: + self.item_notebook.set_current_page(1) + else: + self.item_notebook.set_current_page(0) + + def on_close_button_clicked(self, widget): + self.window.destroy() + class PrivacyListWindow: '''Window that is used for creating NEW or EDITING already there privacy