From b5416f0e9717ab969a87564319f89113f57818dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Br=C3=B6tzmann?= Date: Fri, 26 Oct 2018 00:06:27 +0200 Subject: [PATCH] Rework ACE --- .../data/gui/advanced_configuration_window.ui | 163 +++++++++++------- gajim/gtk/advanced_config.py | 42 ++--- 2 files changed, 116 insertions(+), 89 deletions(-) diff --git a/gajim/data/gui/advanced_configuration_window.ui b/gajim/data/gui/advanced_configuration_window.ui index 88cef610f..a75893665 100644 --- a/gajim/data/gui/advanced_configuration_window.ui +++ b/gajim/data/gui/advanced_configuration_window.ui @@ -1,16 +1,10 @@ - + - - - True - False - gtk-dialog-warning - + False - 6 - Advanced Configuration Editor + Advanced Configuration Editor (ACE) ace center-on-parent 650 @@ -18,21 +12,81 @@ dialog - + + + + True False + 18 vertical 6 - + + False + True + warning + + + False + 6 + end + + + + + + False + False + 0 + + + + + False + 16 + + + True + False + You should restart Gajim for some changes to take effect + True + + + False + True + 0 + + + + + False + False + 0 + + + + + False + True + 0 + + + + True False 12 - + True False - Filter: + _Filter + True + advanced_entry + False @@ -56,11 +110,12 @@ False True - 0 + 1 - + + 200 True True never @@ -72,7 +127,7 @@ True - + @@ -81,47 +136,26 @@ True True 1 - 1 - - - - - True - False - 3 - 0 - none - - - True - False - 12 - 0 - True - - - - - True - False - <b>Description</b> - True - - - - - False - True 2 - + + True False + vertical + 6 - + + True False - gtk-dialog-warning + start + Description + True + False @@ -130,15 +164,16 @@ - + + 30 + True False + start + True 0 - <b>NOTE:</b> You should restart Gajim for some settings to take effect - True - True - True + False True 1 @@ -147,13 +182,14 @@ False True - 3 + 4 - + True False + 12 6 end @@ -162,10 +198,12 @@ True False True - True - image1 + False True + False @@ -193,15 +231,10 @@ False True - 4 + 5 - - True - False - gtk-undo - diff --git a/gajim/gtk/advanced_config.py b/gajim/gtk/advanced_config.py index ea4ed3d76..650f5f010 100644 --- a/gajim/gtk/advanced_config.py +++ b/gajim/gtk/advanced_config.py @@ -69,13 +69,8 @@ def tree_model_pre_order(model, treeiter): class AdvancedConfig: def __init__(self, transient): - self.xml = get_builder('advanced_configuration_window.ui') - self.window = self.xml.get_object('advanced_configuration_window') - self.window.set_transient_for(transient) - self.entry = self.xml.get_object('advanced_entry') - self.desc_label = self.xml.get_object('advanced_desc_label') - self.restart_box = self.xml.get_object('restart_box') - self.reset_button = self.xml.get_object('reset_button') + self._ui = get_builder('advanced_configuration_window.ui') + self._ui.advanced_configuration_window.set_transient_for(transient) # Format: # key = option name (root/subopt/opt separated by \n then) @@ -90,7 +85,7 @@ class AdvancedConfig: 'string': _('Text'), 'color': _('Color')} - treeview = self.xml.get_object('advanced_treeview') + treeview = self._ui.advanced_treeview self.treeview = treeview self.model = Gtk.TreeStore(str, str, str) self.fill_model() @@ -121,13 +116,12 @@ class AdvancedConfig: treeview.set_model(self.modelfilter) - # connect signal for selection change + # Connect signal for selection change treeview.get_selection().connect('changed', self.on_advanced_treeview_selection_changed) - self.xml.connect_signals(self) - self.restart_box.set_no_show_all(True) - self.window.show_all() + self._ui.connect_signals(self) + self._ui.advanced_configuration_window.show_all() app.interface.instances['advanced_config'] = self def cb_value_column_data(self, col, cell, model, iter_, data): @@ -168,17 +162,17 @@ class AdvancedConfig: elif len(opt_path) == 1: desc = app.config.get_desc(opt_path[0]) if desc: - self.desc_label.set_text(desc) + self._ui.description.set_text(desc) else: - #we talk about option description in advanced configuration editor - self.desc_label.set_text(_('(None)')) + # We talk about option description in advanced configuration editor + self._ui.description.set_text(_('(None)')) if len(opt_path) == 3 or (len(opt_path) == 1 and not \ model.iter_has_child(iter_)): - self.reset_button.set_sensitive(True) + self._ui.reset_button.set_sensitive(True) else: - self.reset_button.set_sensitive(False) + self._ui.reset_button.set_sensitive(False) else: - self.reset_button.set_sensitive(False) + self._ui.reset_button.set_sensitive(False) def remember_option(self, option, oldval, newval): if option in self.changed_opts: @@ -211,7 +205,7 @@ class AdvancedConfig: self.check_for_restart() def check_for_restart(self): - self.restart_box.hide() + self._ui.restart_warning.hide() for opt in self.changed_opts: opt_path = opt.split('\n') if len(opt_path) == 3: @@ -221,12 +215,12 @@ class AdvancedConfig: restart = app.config.get_restart(opt_path[0]) if restart: if self.changed_opts[opt][0] != self.changed_opts[opt][1]: - self.restart_box.set_no_show_all(False) - self.restart_box.show_all() + self._ui.restart_warning.set_no_show_all(False) + self._ui.restart_warning.show() break def on_config_edited(self, cell, path, text): - # convert modelfilter path to model path + # Convert modelfilter path to model path path = Gtk.TreePath.new_from_string(path) modelpath = self.modelfilter.convert_path_to_child_path(path) modelrow = self.model[modelpath] @@ -287,7 +281,7 @@ class AdvancedConfig: self.on_config_edited(None, path.to_string(), str(default)) def on_advanced_close_button_clicked(self, widget): - self.window.destroy() + self._ui.advanced_configuration_window.destroy() def fill_model(self, node=None, parent=None): for item, option in app.config.get_children(node): @@ -314,7 +308,7 @@ class AdvancedConfig: self.model.append(parent, [name, value, type_]) def visible_func(self, model, treeiter, data): - search_string = self.entry.get_text().lower() + search_string = self._ui.advanced_entry.get_text().lower() for it in tree_model_pre_order(model, treeiter): if model[it][Column.TYPE] != '': opt_path = self.get_option_path(model, it)