Rework ACE
This commit is contained in:
		
							parent
							
								
									08fe232695
								
							
						
					
					
						commit
						b5416f0e97
					
				
					 2 changed files with 116 additions and 89 deletions
				
			
		| 
						 | 
				
			
			@ -1,16 +1,10 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!-- Generated with glade 3.18.3 -->
 | 
			
		||||
<!-- Generated with glade 3.22.1 -->
 | 
			
		||||
<interface>
 | 
			
		||||
  <requires lib="gtk+" version="3.12"/>
 | 
			
		||||
  <object class="GtkImage" id="image1">
 | 
			
		||||
    <property name="visible">True</property>
 | 
			
		||||
    <property name="can_focus">False</property>
 | 
			
		||||
    <property name="stock">gtk-dialog-warning</property>
 | 
			
		||||
  </object>
 | 
			
		||||
  <requires lib="gtk+" version="3.20"/>
 | 
			
		||||
  <object class="GtkWindow" id="advanced_configuration_window">
 | 
			
		||||
    <property name="can_focus">False</property>
 | 
			
		||||
    <property name="border_width">6</property>
 | 
			
		||||
    <property name="title" translatable="yes">Advanced Configuration Editor</property>
 | 
			
		||||
    <property name="title" translatable="yes">Advanced Configuration Editor (ACE)</property>
 | 
			
		||||
    <property name="role">ace</property>
 | 
			
		||||
    <property name="window_position">center-on-parent</property>
 | 
			
		||||
    <property name="default_width">650</property>
 | 
			
		||||
| 
						 | 
				
			
			@ -18,21 +12,81 @@
 | 
			
		|||
    <property name="type_hint">dialog</property>
 | 
			
		||||
    <signal name="destroy" handler="on_advanced_configuration_window_destroy" swapped="no"/>
 | 
			
		||||
    <child>
 | 
			
		||||
      <object class="GtkBox" id="box2">
 | 
			
		||||
      <placeholder/>
 | 
			
		||||
    </child>
 | 
			
		||||
    <child>
 | 
			
		||||
      <object class="GtkBox">
 | 
			
		||||
        <property name="visible">True</property>
 | 
			
		||||
        <property name="can_focus">False</property>
 | 
			
		||||
        <property name="border_width">18</property>
 | 
			
		||||
        <property name="orientation">vertical</property>
 | 
			
		||||
        <property name="spacing">6</property>
 | 
			
		||||
        <child>
 | 
			
		||||
          <object class="GtkBox" id="box3">
 | 
			
		||||
          <object class="GtkInfoBar" id="restart_warning">
 | 
			
		||||
            <property name="can_focus">False</property>
 | 
			
		||||
            <property name="no_show_all">True</property>
 | 
			
		||||
            <property name="message_type">warning</property>
 | 
			
		||||
            <child internal-child="action_area">
 | 
			
		||||
              <object class="GtkButtonBox">
 | 
			
		||||
                <property name="can_focus">False</property>
 | 
			
		||||
                <property name="spacing">6</property>
 | 
			
		||||
                <property name="layout_style">end</property>
 | 
			
		||||
                <child>
 | 
			
		||||
                  <placeholder/>
 | 
			
		||||
                </child>
 | 
			
		||||
              </object>
 | 
			
		||||
              <packing>
 | 
			
		||||
                <property name="expand">False</property>
 | 
			
		||||
                <property name="fill">False</property>
 | 
			
		||||
                <property name="position">0</property>
 | 
			
		||||
              </packing>
 | 
			
		||||
            </child>
 | 
			
		||||
            <child internal-child="content_area">
 | 
			
		||||
              <object class="GtkBox">
 | 
			
		||||
                <property name="can_focus">False</property>
 | 
			
		||||
                <property name="spacing">16</property>
 | 
			
		||||
                <child>
 | 
			
		||||
                  <object class="GtkLabel">
 | 
			
		||||
                    <property name="visible">True</property>
 | 
			
		||||
                    <property name="can_focus">False</property>
 | 
			
		||||
                    <property name="label" translatable="yes">You should restart Gajim for some changes to take effect</property>
 | 
			
		||||
                    <property name="use_markup">True</property>
 | 
			
		||||
                  </object>
 | 
			
		||||
                  <packing>
 | 
			
		||||
                    <property name="expand">False</property>
 | 
			
		||||
                    <property name="fill">True</property>
 | 
			
		||||
                    <property name="position">0</property>
 | 
			
		||||
                  </packing>
 | 
			
		||||
                </child>
 | 
			
		||||
              </object>
 | 
			
		||||
              <packing>
 | 
			
		||||
                <property name="expand">False</property>
 | 
			
		||||
                <property name="fill">False</property>
 | 
			
		||||
                <property name="position">0</property>
 | 
			
		||||
              </packing>
 | 
			
		||||
            </child>
 | 
			
		||||
          </object>
 | 
			
		||||
          <packing>
 | 
			
		||||
            <property name="expand">False</property>
 | 
			
		||||
            <property name="fill">True</property>
 | 
			
		||||
            <property name="position">0</property>
 | 
			
		||||
          </packing>
 | 
			
		||||
        </child>
 | 
			
		||||
        <child>
 | 
			
		||||
          <object class="GtkBox">
 | 
			
		||||
            <property name="visible">True</property>
 | 
			
		||||
            <property name="can_focus">False</property>
 | 
			
		||||
            <property name="spacing">12</property>
 | 
			
		||||
            <child>
 | 
			
		||||
              <object class="GtkLabel" id="label1">
 | 
			
		||||
              <object class="GtkLabel">
 | 
			
		||||
                <property name="visible">True</property>
 | 
			
		||||
                <property name="can_focus">False</property>
 | 
			
		||||
                <property name="label" translatable="yes">Filter:</property>
 | 
			
		||||
                <property name="label" translatable="yes">_Filter</property>
 | 
			
		||||
                <property name="use_underline">True</property>
 | 
			
		||||
                <property name="mnemonic_widget">advanced_entry</property>
 | 
			
		||||
                <style>
 | 
			
		||||
                  <class name="dim-label"/>
 | 
			
		||||
                </style>
 | 
			
		||||
              </object>
 | 
			
		||||
              <packing>
 | 
			
		||||
                <property name="expand">False</property>
 | 
			
		||||
| 
						 | 
				
			
			@ -56,11 +110,12 @@
 | 
			
		|||
          <packing>
 | 
			
		||||
            <property name="expand">False</property>
 | 
			
		||||
            <property name="fill">True</property>
 | 
			
		||||
            <property name="position">0</property>
 | 
			
		||||
            <property name="position">1</property>
 | 
			
		||||
          </packing>
 | 
			
		||||
        </child>
 | 
			
		||||
        <child>
 | 
			
		||||
          <object class="GtkScrolledWindow" id="scrolledwindow36">
 | 
			
		||||
          <object class="GtkScrolledWindow">
 | 
			
		||||
            <property name="height_request">200</property>
 | 
			
		||||
            <property name="visible">True</property>
 | 
			
		||||
            <property name="can_focus">True</property>
 | 
			
		||||
            <property name="hscrollbar_policy">never</property>
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +127,7 @@
 | 
			
		|||
                <property name="rules_hint">True</property>
 | 
			
		||||
                <signal name="row-activated" handler="on_advanced_treeview_row_activated" swapped="no"/>
 | 
			
		||||
                <child internal-child="selection">
 | 
			
		||||
                  <object class="GtkTreeSelection" id="treeview-selection"/>
 | 
			
		||||
                  <object class="GtkTreeSelection"/>
 | 
			
		||||
                </child>
 | 
			
		||||
              </object>
 | 
			
		||||
            </child>
 | 
			
		||||
| 
						 | 
				
			
			@ -81,47 +136,26 @@
 | 
			
		|||
            <property name="expand">True</property>
 | 
			
		||||
            <property name="fill">True</property>
 | 
			
		||||
            <property name="padding">1</property>
 | 
			
		||||
            <property name="position">1</property>
 | 
			
		||||
          </packing>
 | 
			
		||||
        </child>
 | 
			
		||||
        <child>
 | 
			
		||||
          <object class="GtkFrame" id="frame36">
 | 
			
		||||
            <property name="visible">True</property>
 | 
			
		||||
            <property name="can_focus">False</property>
 | 
			
		||||
            <property name="border_width">3</property>
 | 
			
		||||
            <property name="label_xalign">0</property>
 | 
			
		||||
            <property name="shadow_type">none</property>
 | 
			
		||||
            <child>
 | 
			
		||||
              <object class="GtkLabel" id="advanced_desc_label">
 | 
			
		||||
                <property name="visible">True</property>
 | 
			
		||||
                <property name="can_focus">False</property>
 | 
			
		||||
                <property name="margin_left">12</property>
 | 
			
		||||
                <property name="xalign">0</property>
 | 
			
		||||
                <property name="wrap">True</property>
 | 
			
		||||
              </object>
 | 
			
		||||
            </child>
 | 
			
		||||
            <child type="label">
 | 
			
		||||
              <object class="GtkLabel" id="label357">
 | 
			
		||||
                <property name="visible">True</property>
 | 
			
		||||
                <property name="can_focus">False</property>
 | 
			
		||||
                <property name="label" translatable="yes"><b>Description</b></property>
 | 
			
		||||
                <property name="use_markup">True</property>
 | 
			
		||||
              </object>
 | 
			
		||||
            </child>
 | 
			
		||||
          </object>
 | 
			
		||||
          <packing>
 | 
			
		||||
            <property name="expand">False</property>
 | 
			
		||||
            <property name="fill">True</property>
 | 
			
		||||
            <property name="position">2</property>
 | 
			
		||||
          </packing>
 | 
			
		||||
        </child>
 | 
			
		||||
        <child>
 | 
			
		||||
          <object class="GtkBox" id="restart_box">
 | 
			
		||||
          <object class="GtkBox">
 | 
			
		||||
            <property name="visible">True</property>
 | 
			
		||||
            <property name="can_focus">False</property>
 | 
			
		||||
            <property name="orientation">vertical</property>
 | 
			
		||||
            <property name="spacing">6</property>
 | 
			
		||||
            <child>
 | 
			
		||||
              <object class="GtkImage" id="image3">
 | 
			
		||||
              <object class="GtkLabel">
 | 
			
		||||
                <property name="visible">True</property>
 | 
			
		||||
                <property name="can_focus">False</property>
 | 
			
		||||
                <property name="stock">gtk-dialog-warning</property>
 | 
			
		||||
                <property name="halign">start</property>
 | 
			
		||||
                <property name="label" translatable="yes">Description</property>
 | 
			
		||||
                <property name="use_markup">True</property>
 | 
			
		||||
                <style>
 | 
			
		||||
                  <class name="bold"/>
 | 
			
		||||
                  <class name="dim-label"/>
 | 
			
		||||
                </style>
 | 
			
		||||
              </object>
 | 
			
		||||
              <packing>
 | 
			
		||||
                <property name="expand">False</property>
 | 
			
		||||
| 
						 | 
				
			
			@ -130,15 +164,16 @@
 | 
			
		|||
              </packing>
 | 
			
		||||
            </child>
 | 
			
		||||
            <child>
 | 
			
		||||
              <object class="GtkLabel" id="restart_label">
 | 
			
		||||
              <object class="GtkLabel" id="description">
 | 
			
		||||
                <property name="height_request">30</property>
 | 
			
		||||
                <property name="visible">True</property>
 | 
			
		||||
                <property name="can_focus">False</property>
 | 
			
		||||
                <property name="halign">start</property>
 | 
			
		||||
                <property name="wrap">True</property>
 | 
			
		||||
                <property name="xalign">0</property>
 | 
			
		||||
                <property name="label" translatable="yes"><b>NOTE:</b> You should restart Gajim for some settings to take effect</property>
 | 
			
		||||
                <property name="use_markup">True</property>
 | 
			
		||||
                <property name="use_underline">True</property>
 | 
			
		||||
              </object>
 | 
			
		||||
              <packing>
 | 
			
		||||
                <property name="expand">True</property>
 | 
			
		||||
                <property name="expand">False</property>
 | 
			
		||||
                <property name="fill">True</property>
 | 
			
		||||
                <property name="position">1</property>
 | 
			
		||||
              </packing>
 | 
			
		||||
| 
						 | 
				
			
			@ -147,13 +182,14 @@
 | 
			
		|||
          <packing>
 | 
			
		||||
            <property name="expand">False</property>
 | 
			
		||||
            <property name="fill">True</property>
 | 
			
		||||
            <property name="position">3</property>
 | 
			
		||||
            <property name="position">4</property>
 | 
			
		||||
          </packing>
 | 
			
		||||
        </child>
 | 
			
		||||
        <child>
 | 
			
		||||
          <object class="GtkButtonBox" id="buttonbox1">
 | 
			
		||||
          <object class="GtkButtonBox">
 | 
			
		||||
            <property name="visible">True</property>
 | 
			
		||||
            <property name="can_focus">False</property>
 | 
			
		||||
            <property name="margin_top">12</property>
 | 
			
		||||
            <property name="spacing">6</property>
 | 
			
		||||
            <property name="layout_style">end</property>
 | 
			
		||||
            <child>
 | 
			
		||||
| 
						 | 
				
			
			@ -162,10 +198,12 @@
 | 
			
		|||
                <property name="visible">True</property>
 | 
			
		||||
                <property name="sensitive">False</property>
 | 
			
		||||
                <property name="can_focus">True</property>
 | 
			
		||||
                <property name="receives_default">True</property>
 | 
			
		||||
                <property name="image">image1</property>
 | 
			
		||||
                <property name="receives_default">False</property>
 | 
			
		||||
                <property name="use_underline">True</property>
 | 
			
		||||
                <signal name="clicked" handler="on_reset_button_clicked" swapped="no"/>
 | 
			
		||||
                <style>
 | 
			
		||||
                  <class name="destructive-action"/>
 | 
			
		||||
                </style>
 | 
			
		||||
              </object>
 | 
			
		||||
              <packing>
 | 
			
		||||
                <property name="expand">False</property>
 | 
			
		||||
| 
						 | 
				
			
			@ -193,15 +231,10 @@
 | 
			
		|||
          <packing>
 | 
			
		||||
            <property name="expand">False</property>
 | 
			
		||||
            <property name="fill">True</property>
 | 
			
		||||
            <property name="position">4</property>
 | 
			
		||||
            <property name="position">5</property>
 | 
			
		||||
          </packing>
 | 
			
		||||
        </child>
 | 
			
		||||
      </object>
 | 
			
		||||
    </child>
 | 
			
		||||
  </object>
 | 
			
		||||
  <object class="GtkImage" id="image2">
 | 
			
		||||
    <property name="visible">True</property>
 | 
			
		||||
    <property name="can_focus">False</property>
 | 
			
		||||
    <property name="stock">gtk-undo</property>
 | 
			
		||||
  </object>
 | 
			
		||||
</interface>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue