* first draft of message archiving preferences window
* fixed a bug in ConnectionArchive.append_or_update_item prototype
This commit is contained in:
parent
ee59f1754b
commit
7922426464
|
@ -0,0 +1,359 @@
|
|||
<?xml version="1.0"?>
|
||||
<glade-interface>
|
||||
<!-- interface-requires gtk+ 2.16 -->
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<widget class="GtkWindow" id="archiving_preferences_window">
|
||||
<property name="border_width">12</property>
|
||||
<signal name="destroy" handler="on_archiving_preferences_window_destroy"/>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><i>Auto Save</i></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkRadioButton" id="auto_save_yes_radiobutton">
|
||||
<property name="label" translatable="yes">Yes</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkRadioButton" id="auto_save_no_radiobutton">
|
||||
<property name="label" translatable="yes">No</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">auto_save_yes_radiobutton</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkTable" id="table1">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_columns">2</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><i>Method Auto</i></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><i>Method Local</i></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><i>Method Manual</i></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="method_manual_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Prefer
|
||||
Concede
|
||||
Forbid</property>
|
||||
</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>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="method_local_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Prefer
|
||||
Concede
|
||||
Forbid</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>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="method_auto_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Prefer
|
||||
Concede
|
||||
Forbid</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">automatic</property>
|
||||
<property name="vscrollbar_policy">automatic</property>
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="item_treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<signal name="cursor_changed" handler="on_item_treeview_cursor_changed"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">spread</property>
|
||||
<child>
|
||||
<widget class="GtkButton" id="add_item_button">
|
||||
<property name="label" translatable="yes">gtk-add</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="clicked" handler="on_add_item_button_clicked"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkButton" id="remove_item_button">
|
||||
<property name="label" translatable="yes">gtk-remove</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="clicked" handler="on_remove_item_button_clicked"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkNotebook" id="item_notebook">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="show_tabs">False</property>
|
||||
<property name="show_border">False</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label11">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">page 1</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_fill">False</property>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkTable" id="table3">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_columns">2</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label8">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">expire</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label9">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">otr</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label10">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">save</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="expire_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="otr_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">approve
|
||||
concede
|
||||
forbid
|
||||
oppose
|
||||
prefer
|
||||
require</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>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="save_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">body
|
||||
false
|
||||
message
|
||||
stream</property>
|
||||
</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>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label6">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">page 2</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
<property name="tab_fill">False</property>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<widget class="GtkButton" id="close_button">
|
||||
<property name="label" translatable="yes">gtk-close</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="clicked" handler="on_close_button_clicked"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue