changeset c3966b469985 in /home/hg/repos/gajim

details:http://hg.gajim.org/gajim?cmd=changeset;node=c3966b469985
description: ability to reset options to default value. Fixes #4465

diffstat:

 data/gui/advanced_configuration_window.ui |  58 +++++++++++++++--
 plugins/dbus_plugin/plugin.py             |   2 +-
 src/advanced_configuration_window.py      |  55 ++++++++++++++++-
 src/common/config.py                      |  98 ++++++++++++++++++++----------
 src/common/optparser.py                   |   1 -
 src/remote_control.py                     |   2 +-
 6 files changed, 166 insertions(+), 50 deletions(-)

diffs (truncated from 518 to 300 lines):

diff -r 6d50c40b83de -r c3966b469985 data/gui/advanced_configuration_window.ui
--- a/data/gui/advanced_configuration_window.ui Mon Apr 09 13:38:28 2012 +0200
+++ b/data/gui/advanced_configuration_window.ui Mon Apr 09 19:45:56 2012 +0200
@@ -1,24 +1,25 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy toplevel-contextual -->
   <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="role">ace</property>
     <property name="default_width">650</property>
     <property name="default_height">540</property>
     <property name="type_hint">dialog</property>
-    <signal name="destroy" handler="on_advanced_configuration_window_destroy"/>
+    <signal name="destroy" handler="on_advanced_configuration_window_destroy" 
swapped="no"/>
     <child>
       <object class="GtkVBox" id="vbox70">
         <property name="visible">True</property>
+        <property name="can_focus">False</property>
         <property name="border_width">6</property>
-        <property name="orientation">vertical</property>
         <property name="spacing">6</property>
         <child>
           <object class="GtkTable" id="table26">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="n_rows">2</property>
             <property name="n_columns">2</property>
             <property name="column_spacing">12</property>
@@ -26,6 +27,7 @@
             <child>
               <object class="GtkLabel" id="label248">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="xalign">0</property>
                 <property name="label" translatable="yes">Filter:</property>
               </object>
@@ -38,7 +40,7 @@
               <object class="GtkEntry" id="advanced_entry">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <signal name="changed" handler="on_advanced_entry_changed"/>
+                <signal name="changed" handler="on_advanced_entry_changed" 
swapped="no"/>
               </object>
               <packing>
                 <property name="left_attach">1</property>
@@ -51,14 +53,16 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="hscrollbar_policy">never</property>
-                <property name="vscrollbar_policy">automatic</property>
                 <property name="shadow_type">in</property>
                 <child>
                   <object class="GtkTreeView" id="advanced_treeview">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="rules_hint">True</property>
-                    <signal name="row_activated" 
handler="on_advanced_treeview_row_activated"/>
+                    <signal name="row-activated" 
handler="on_advanced_treeview_row_activated" swapped="no"/>
+                    <child internal-child="selection">
+                      <object class="GtkTreeSelection" 
id="treeview-selection1"/>
+                    </child>
                   </object>
                 </child>
               </object>
@@ -71,23 +75,28 @@
             </child>
           </object>
           <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
             <property name="position">0</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="GtkAlignment" id="alignment90">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="border_width">6</property>
                 <property name="left_padding">12</property>
                 <child>
                   <object class="GtkLabel" id="advanced_desc_label">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <property name="xalign">0</property>
                     <property name="wrap">True</property>
                   </object>
@@ -97,6 +106,7 @@
             <child type="label">
               <object class="GtkLabel" id="label357">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="label" 
translatable="yes">&lt;b&gt;Description&lt;/b&gt;</property>
                 <property name="use_markup">True</property>
               </object>
@@ -104,11 +114,13 @@
           </object>
           <packing>
             <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
         </child>
         <child>
           <object class="GtkLabel" id="restart_label">
+            <property name="can_focus">False</property>
             <property name="xalign">0</property>
             <property name="label" translatable="yes">&lt;b&gt;NOTE:&lt;/b&gt; 
You should restart Gajim for some settings to take effect</property>
             <property name="use_markup">True</property>
@@ -123,27 +135,50 @@
         <child>
           <object class="GtkHButtonBox" id="hbuttonbox18">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="spacing">6</property>
             <property name="layout_style">end</property>
             <child>
+              <object class="GtkButton" id="reset_button">
+                <property name="label" translatable="yes">_Reset to 
default</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="image">image1</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="on_reset_button_clicked" 
swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkButton" id="advanced_close_button">
                 <property name="label">gtk-close</property>
+                <property name="use_action_appearance">False</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_action_appearance">False</property>
                 <property name="use_stock">True</property>
-                <signal name="clicked" 
handler="on_advanced_close_button_clicked"/>
+                <signal name="clicked" 
handler="on_advanced_close_button_clicked" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">0</property>
+                <property name="position">1</property>
               </packing>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="padding">6</property>
             <property name="position">3</property>
           </packing>
@@ -151,4 +186,9 @@
       </object>
     </child>
   </object>
+  <object class="GtkImage" id="image1">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="stock">gtk-undo</property>
+  </object>
 </interface>
diff -r 6d50c40b83de -r c3966b469985 plugins/dbus_plugin/plugin.py
--- a/plugins/dbus_plugin/plugin.py     Mon Apr 09 13:38:28 2012 +0200
+++ b/plugins/dbus_plugin/plugin.py     Mon Apr 09 19:45:56 2012 +0200
@@ -501,7 +501,7 @@
                         for node in path:
                             key += node + '#'
                     key += name
-                    prefs_dict[DBUS_STRING(key)] = DBUS_STRING(value[1])
+                    prefs_dict[DBUS_STRING(key)] = DBUS_STRING(value)
                 gajim.config.foreach(get_prefs)
                 return prefs_dict
 
diff -r 6d50c40b83de -r c3966b469985 src/advanced_configuration_window.py
--- a/src/advanced_configuration_window.py      Mon Apr 09 13:38:28 2012 +0200
+++ b/src/advanced_configuration_window.py      Mon Apr 09 19:45:56 2012 +0200
@@ -81,6 +81,7 @@
         self.entry = self.xml.get_object('advanced_entry')
         self.desc_label = self.xml.get_object('advanced_desc_label')
         self.restart_label = self.xml.get_object('restart_label')
+        self.reset_button = self.xml.get_object('reset_button')
 
         # Format:
         # key = option name (root/subopt/opt separated by \n then)
@@ -174,6 +175,13 @@
             else:
                 #we talk about option description in advanced configuration 
editor
                 self.desc_label.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)
+            else:
+                self.reset_button.set_sensitive(False)
+        else:
+            self.reset_button.set_sensitive(False)
 
     def remember_option(self, option, oldval, newval):
         if option in self.changed_opts:
@@ -195,7 +203,6 @@
                 optname = optnamerow[0].decode('utf-8')
                 keyrow = self.model[modelpath[:2]]
                 key = keyrow[0].decode('utf-8')
-                gajim.config.get_desc_per(optname, key, option)
                 self.remember_option(option + '\n' + key + '\n' + optname,
                         modelrow[1], newval)
                 gajim.config.set_per(optname, key, option, newval)
@@ -244,6 +251,42 @@
     def on_advanced_configuration_window_destroy(self, widget):
         del gajim.interface.instances['advanced_config']
 
+    def on_reset_button_clicked(self, widget):
+        model, iter_ = self.treeview.get_selection().get_selected()
+        # Check for GtkTreeIter
+        if iter_:
+            path = model.get_path(iter_)
+            opt_path =  self.get_option_path(model, iter_)
+            if len(opt_path) == 1:
+                default = gajim.config.get_default(opt_path[0])
+            elif len(opt_path) == 3:
+                default = gajim.config.get_default_per(opt_path[2], 
opt_path[0])
+
+            if model[iter_][C_TYPE] == self.types['boolean']:
+                if self.right_true_dict[default] == model[iter_][C_VALUE]:
+                    return
+                modelpath = self.modelfilter.convert_path_to_child_path(path)
+                modelrow = self.model[modelpath]
+                option = modelrow[0].decode('utf-8')
+                if len(modelpath) > 1:
+                    optnamerow = self.model[modelpath[0]]
+                    optname = optnamerow[0].decode('utf-8')
+                    keyrow = self.model[modelpath[:2]]
+                    key = keyrow[0].decode('utf-8')
+                    self.remember_option(option + '\n' + key + '\n' + optname,
+                        modelrow[C_VALUE], default)
+                    gajim.config.set_per(optname, key, option, default)
+                else:
+                    self.remember_option(option, modelrow[C_VALUE], default)
+                    gajim.config.set(option, default)
+                gajim.interface.save_config()
+                modelrow[C_VALUE] = self.right_true_dict[default]
+                self.check_for_restart()
+            else:
+                if str(default) == model[iter_][C_VALUE]:
+                    return
+                self.on_config_edited(None, path, str(default))
+
     def on_advanced_close_button_clicked(self, widget):
         self.window.destroy()
 
@@ -254,14 +297,18 @@
                 newparent = self.model.append(parent, [name, '', ''])
                 self.fill_model(item, newparent)
             else: # Leaf
-                type_ = self.types[option[OPT_TYPE][0]]
+                if len(item) == 1:
+                    type_ = self.types[gajim.config.get_type(name)]
+                elif len(item) == 3:
+                    type_ = self.types[gajim.config.get_type_per(item[0],
+                        item[2])]
                 if name == 'password':
                     value = _('Hidden')
                 else:
                     if type_ == self.types['boolean']:
-                        value = self.right_true_dict[option[OPT_VAL]]
+                        value = self.right_true_dict[option]
                     else:
-                        value = option[OPT_VAL]
+                        value = option
                 self.model.append(parent, [name, value, type_])
 
     def visible_func(self, model, treeiter):
diff -r 6d50c40b83de -r c3966b469985 src/common/config.py
--- a/src/common/config.py      Mon Apr 09 13:38:28 2012 +0200
+++ b/src/common/config.py      Mon Apr 09 19:45:56 2012 +0200
@@ -65,7 +65,7 @@
     DEFAULT_MAILAPP = 'mozilla-thunderbird -compose'
     DEFAULT_FILE_MANAGER = 'xffm'
 
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to