OfflineBookmarksPlugin. Use combobox instead input field.
This commit is contained in:
@@ -2,12 +2,6 @@
|
|||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="2.16"/>
|
<requires lib="gtk+" version="2.16"/>
|
||||||
<!-- interface-naming-policy toplevel-contextual -->
|
<!-- interface-naming-policy toplevel-contextual -->
|
||||||
<object class="GtkListStore" id="liststore1">
|
|
||||||
<columns>
|
|
||||||
<!-- column-name item -->
|
|
||||||
<column type="gchararray"/>
|
|
||||||
</columns>
|
|
||||||
</object>
|
|
||||||
<object class="GtkWindow" id="manage_bookmarks_window">
|
<object class="GtkWindow" id="manage_bookmarks_window">
|
||||||
<property name="border_width">12</property>
|
<property name="border_width">12</property>
|
||||||
<property name="title" translatable="yes">Manage Bookmarks</property>
|
<property name="title" translatable="yes">Manage Bookmarks</property>
|
||||||
@@ -40,7 +34,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="headers_visible">False</property>
|
<property name="headers_visible">False</property>
|
||||||
<signal name="cursor_changed" handler="on_treeview_cursor_changed"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@@ -257,7 +250,6 @@
|
|||||||
<object class="GtkComboBox" id="print_status_combobox">
|
<object class="GtkComboBox" id="print_status_combobox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="sensitive">False</property>
|
<property name="sensitive">False</property>
|
||||||
<property name="model">liststore1</property>
|
|
||||||
<signal name="changed" handler="on_print_status_combobox_changed"/>
|
<signal name="changed" handler="on_print_status_combobox_changed"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext1"/>
|
<object class="GtkCellRendererText" id="cellrenderertext1"/>
|
||||||
@@ -390,7 +382,6 @@
|
|||||||
<object class="GtkComboBox" id="import_from">
|
<object class="GtkComboBox" id="import_from">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="model">liststore1</property>
|
|
||||||
<property name="focus_on_click">False</property>
|
<property name="focus_on_click">False</property>
|
||||||
<signal name="changed" handler="on_import_from_changed"/>
|
<signal name="changed" handler="on_import_from_changed"/>
|
||||||
<child>
|
<child>
|
||||||
@@ -423,22 +414,30 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkEntry" id="import_to">
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBox" id="import_to">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="editable">False</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="invisible_char">●</property>
|
<property name="focus_on_click">False</property>
|
||||||
|
<signal name="changed" handler="on_import_to_changed"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCellRendererText" id="cellrenderertext3"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">0</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">8</property>
|
<property name="top_attach">8</property>
|
||||||
<property name="bottom_attach">9</property>
|
<property name="bottom_attach">9</property>
|
||||||
<property name="y_options"/>
|
<property name="x_options">GTK_FILL</property>
|
||||||
|
<property name="y_options">GTK_FILL</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
|||||||
@@ -166,19 +166,45 @@ class OfflineBookmarksPluginConfigDialog(GajimPluginConfigDialog,
|
|||||||
ManageBookmarksWindow):
|
ManageBookmarksWindow):
|
||||||
def init(self):
|
def init(self):
|
||||||
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(
|
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(
|
||||||
'config_dialog.ui')
|
'config_dialog.ui')
|
||||||
self.xml = gtk.Builder()
|
self.xml = gtk.Builder()
|
||||||
self.xml.set_translation_domain('gajim_plugins')
|
self.xml.set_translation_domain('gajim_plugins')
|
||||||
self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH,
|
self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH,
|
||||||
['vbox86'])
|
['vbox86'])
|
||||||
vbox = self.xml.get_object('vbox86')
|
vbox = self.xml.get_object('vbox86')
|
||||||
self.child.pack_start(vbox)
|
self.child.pack_start(vbox)
|
||||||
self.import_to_button = self.xml.get_object('import_to')
|
|
||||||
self.import_from_combo = self.xml.get_object('import_from')
|
self.import_from_combo = self.xml.get_object('import_from')
|
||||||
|
self.import_to_combo = self.xml.get_object('import_to')
|
||||||
|
|
||||||
def on_run(self):
|
def on_run(self):
|
||||||
self.fill_treeview()
|
self.fill_treeview()
|
||||||
|
|
||||||
|
#Prepare comboboxes
|
||||||
|
self.print_status_combobox = self.xml.get_object('print_status_combobox')
|
||||||
|
model = gtk.ListStore(str, str)
|
||||||
|
self.option_list = {'': _('Default'), 'all': Q_('?print_status:All'),
|
||||||
|
'in_and_out': _('Enter and leave only'),
|
||||||
|
'none': Q_('?print_status:None')}
|
||||||
|
opts = sorted(self.option_list.keys())
|
||||||
|
for opt in opts:
|
||||||
|
model.append([self.option_list[opt], opt])
|
||||||
|
self.print_status_combobox.set_model(model)
|
||||||
|
self.print_status_combobox.set_active(1)
|
||||||
|
#Prepare import_from combobox
|
||||||
|
model = gtk.ListStore(str)
|
||||||
|
for account in self.accounts:
|
||||||
|
model.append([account,])
|
||||||
|
for account_jid in self.plugin.config:
|
||||||
|
if account_jid not in self.plugin.config_default_values and \
|
||||||
|
account_jid not in self.jids:
|
||||||
|
model.append([account_jid,])
|
||||||
|
self.import_from_combo.set_model(model)
|
||||||
|
#Prepare import_to combobox
|
||||||
|
model = gtk.ListStore(str)
|
||||||
|
for account in self.accounts:
|
||||||
|
model.append([account,])
|
||||||
|
self.import_to_combo.set_model(model)
|
||||||
|
|
||||||
self.selection = self.view.get_selection()
|
self.selection = self.view.get_selection()
|
||||||
self.selection.connect('changed', self.bookmark_selected)
|
self.selection.connect('changed', self.bookmark_selected)
|
||||||
|
|
||||||
@@ -201,8 +227,6 @@ class OfflineBookmarksPluginConfigDialog(GajimPluginConfigDialog,
|
|||||||
|
|
||||||
|
|
||||||
self.show_all()
|
self.show_all()
|
||||||
# select root iter
|
|
||||||
self.selection.select_iter(self.treestore.get_iter_root())
|
|
||||||
self.view.set_cursor((0,))
|
self.view.set_cursor((0,))
|
||||||
|
|
||||||
def fill_treeview(self):
|
def fill_treeview(self):
|
||||||
@@ -222,8 +246,6 @@ class OfflineBookmarksPluginConfigDialog(GajimPluginConfigDialog,
|
|||||||
|
|
||||||
self.accounts.append(account)
|
self.accounts.append(account)
|
||||||
self.jids.append(gajim.get_jid_from_account(account))
|
self.jids.append(gajim.get_jid_from_account(account))
|
||||||
#if not gajim.connections[account].private_storage_supported:
|
|
||||||
#continue
|
|
||||||
iter_ = self.treestore.append(None, [None, account, None, None,
|
iter_ = self.treestore.append(None, [None, account, None, None,
|
||||||
None, None, None, None])
|
None, None, None, None])
|
||||||
|
|
||||||
@@ -254,27 +276,6 @@ class OfflineBookmarksPluginConfigDialog(GajimPluginConfigDialog,
|
|||||||
bookmark['nick'],
|
bookmark['nick'],
|
||||||
print_status ])
|
print_status ])
|
||||||
|
|
||||||
self.print_status_combobox = self.xml.get_object('print_status_combobox')
|
|
||||||
model = gtk.ListStore(str, str)
|
|
||||||
self.option_list = {'': _('Default'), 'all': Q_('?print_status:All'),
|
|
||||||
'in_and_out': _('Enter and leave only'),
|
|
||||||
'none': Q_('?print_status:None')}
|
|
||||||
opts = sorted(self.option_list.keys())
|
|
||||||
for opt in opts:
|
|
||||||
model.append([self.option_list[opt], opt])
|
|
||||||
self.print_status_combobox.set_model(model)
|
|
||||||
self.print_status_combobox.set_active(1)
|
|
||||||
|
|
||||||
model = gtk.ListStore(str)
|
|
||||||
for account in self.accounts:
|
|
||||||
model.append([account,])
|
|
||||||
for account_jid in self.plugin.config:
|
|
||||||
if account_jid not in self.plugin.config_default_values and \
|
|
||||||
account_jid not in self.jids:
|
|
||||||
model.append([account_jid,])
|
|
||||||
self.import_from_combo.set_model(model)
|
|
||||||
|
|
||||||
|
|
||||||
self.view = self.xml.get_object('bookmarks_treeview')
|
self.view = self.xml.get_object('bookmarks_treeview')
|
||||||
self.view.set_model(self.treestore)
|
self.view.set_model(self.treestore)
|
||||||
self.view.expand_all()
|
self.view.expand_all()
|
||||||
@@ -332,30 +333,21 @@ class OfflineBookmarksPluginConfigDialog(GajimPluginConfigDialog,
|
|||||||
gajim.connections[account_unicode].bookmarks)
|
gajim.connections[account_unicode].bookmarks)
|
||||||
gajim.interface.roster.set_actions_menu_needs_rebuild()
|
gajim.interface.roster.set_actions_menu_needs_rebuild()
|
||||||
|
|
||||||
def on_treeview_cursor_changed(self, treeview):
|
def on_import_to_changed(self, treeview):
|
||||||
selection = treeview.get_selection()
|
|
||||||
(model, iter_) = selection.get_selected()
|
|
||||||
if not iter_:
|
|
||||||
return
|
|
||||||
if model.iter_parent(iter_):
|
|
||||||
self.import_to_button.set_text(model.get_value(iter_, 0))
|
|
||||||
else:
|
|
||||||
self.import_to_button.set_text(model.get_value(iter_, 1))
|
|
||||||
self.on_import_from_changed(self.import_from_combo)
|
self.on_import_from_changed(self.import_from_combo)
|
||||||
|
|
||||||
def on_import_from_changed(self, widget):
|
def on_import_from_changed(self, widget):
|
||||||
if widget.get_active() == -1:
|
if widget.get_active() == -1 or self.import_to_combo.get_active() == -1:
|
||||||
self.xml.get_object('import_button').set_sensitive(False)
|
self.xml.get_object('import_button').set_sensitive(False)
|
||||||
else:
|
else:
|
||||||
if widget.get_active_text() != self.xml.get_object('import_to'
|
if widget.get_active_text() != self.import_to_combo.get_active_text():
|
||||||
).get_text():
|
|
||||||
self.xml.get_object('import_button').set_sensitive(True)
|
self.xml.get_object('import_button').set_sensitive(True)
|
||||||
else:
|
else:
|
||||||
self.xml.get_object('import_button').set_sensitive(False)
|
self.xml.get_object('import_button').set_sensitive(False)
|
||||||
|
|
||||||
def on_import_button_clicked(self, widget):
|
def on_import_button_clicked(self, widget):
|
||||||
from_ = self.import_from_combo.get_active_text()
|
from_ = self.import_from_combo.get_active_text()
|
||||||
to_connection = gajim.connections[self.import_to_button.get_text()]
|
to_connection = gajim.connections[self.import_to_combo.get_active_text()]
|
||||||
to_bookmarks = to_connection.bookmarks
|
to_bookmarks = to_connection.bookmarks
|
||||||
|
|
||||||
if from_ in self.accounts:
|
if from_ in self.accounts:
|
||||||
@@ -371,6 +363,6 @@ class OfflineBookmarksPluginConfigDialog(GajimPluginConfigDialog,
|
|||||||
|
|
||||||
self.fill_treeview()
|
self.fill_treeview()
|
||||||
# select root iter
|
# select root iter
|
||||||
self.selection.select_iter(self.treestore.get_iter_root())
|
|
||||||
self.view.set_cursor((0,))
|
self.view.set_cursor((0,))
|
||||||
self.import_from_combo.set_active(-1)
|
self.import_from_combo.set_active(-1)
|
||||||
|
self.import_to_combo.set_active(-1)
|
||||||
|
|||||||
Reference in New Issue
Block a user