[gevice/gevice_2_0] add support to gsettings.



commit e34e0e94bf11bcc942d18319af28b445d2e44ea2
Author: Alejandro ValdÃs Jimenez <avaldes gnome org>
Date:   Fri Dec 14 12:44:15 2012 -0300

    add support to gsettings.

 ChangeLog                    |    6 +
 data/apps.gevice.gschema.xml |   61 +----------
 data/ui/pref.xml             |  260 +++---------------------------------------
 src/gevice.py                |   12 ++-
 src/geviceprefer.py          |  148 ++----------------------
 5 files changed, 48 insertions(+), 439 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 749537a..82407f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
 2012-12-14  Alejandro ValdéJimenez  <avaldes gnome org>
+	* data/apps.gevice.gschema.xml: update schema.
+	* data/ui/pref.xml: remove widgets.
+	* src/gevice.py: add support to gsettings.
+	* src/geviceprefer.py: clean code.
+
+2012-12-14  Alejandro ValdéJimenez  <avaldes gnome org>
 	* data/ui/menu.xml: Add others menuitems and entry.
 	* src/gevice.py: add entry for user ssh session
 
diff --git a/data/apps.gevice.gschema.xml b/data/apps.gevice.gschema.xml
index 26f562c..28e137f 100644
--- a/data/apps.gevice.gschema.xml
+++ b/data/apps.gevice.gschema.xml
@@ -6,80 +6,25 @@
       <summary>Show IP on diagram.</summary>
       <description>Show IP on diagram.</description>
     </key>
-    <key type="b" name="diaglink">
-      <default>false</default>
-      <summary>Show link on diagram.</summary>
-      <description>Show link on diagram.</description>
-    </key>
-    <key type="b" name="diagmodel">
-      <default>false</default>
-      <summary>Show model on diagram.</summary>
-      <description>Show model on diagram.</description>
-    </key>
-    <key type="b" name="viewcomments">
-      <default>false</default>
-      <summary>Show comments on treeview.</summary>
-      <description>Show comments on diagram.</description>
-    </key>
     <key type="b" name="viewip">
       <default>false</default>
       <summary>Show IP on treeview.</summary>
-      <description>Show IP on diagram.</description>
-    </key>
-    <key type="b" name="viewlocation">
-      <default>false</default>
-      <summary>Show location on treeview.</summary>
-      <description>Show location on diagram.</description>
-    </key>
-    <key type="b" name="viewmodel">
-      <default>false</default>
-      <summary>Show model on treeview.</summary>
-      <description>Show model on diagram.</description>
-    </key>
-    <key type="b" name="viewports">
-      <default>false</default>
-      <summary>Show ports on treeview.</summary>
-      <description>Show ports on diagram.</description>
-    </key>
-    <key type="b" name="viewserial">
-      <default>false</default>
-      <summary>Show serial on treeview.</summary>
-      <description>Show serial on diagram.</description>
+      <description>Show IP on treeview.</description>
     </key>
     <key type="s" name="backcolor">
       <summary>Background color</summary>
       <description>Background color.</description>
-			<default>'#000000'</default>
+      <default>'#000000'</default>
     </key>
     <key type="s" name="forecolor">
       <summary>Forecolor.</summary>
       <description>Forecolor.</description>
-			<default>'#ffffff'</default>
+      <default>'#ffffff'</default>
     </key>
     <key type="s" name="csvseparator">
       <summary>String separator for file CSV.</summary>
       <description>String separator for file CSV.</description>
       <default>'|'</default>
     </key>
-    <key type="s" name="dbase">
-      <summary>Data base name.</summary>
-      <description>Data base name.</description>
-      <default>'dbasename'</default>
-    </key>
-    <key type="s" name="host">
-      <summary>Host data base.</summary>
-      <description>Host data base.</description>
-      <default>'hostdbase'</default>
-    </key>
-    <key type="s" name="userdbase">
-      <summary>User data base.</summary>
-      <description>User database.</description>
-      <default>'userdbase'</default>
-    </key>
-    <key type="as" name="listusers">
-      <summary>List of users</summary>
-      <description>List of users.</description>
-      <default>['user']</default>
-    </key>
   </schema>
 </schemalist>
diff --git a/data/ui/pref.xml b/data/ui/pref.xml
index 859d95c..34a9a1c 100644
--- a/data/ui/pref.xml
+++ b/data/ui/pref.xml
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 2.6 -->
+  <!-- interface-requires gtk+ 3.0 -->
   <object class="GtkWindow" id="window_prefer">
     <property name="can_focus">False</property>
     <property name="border_width">10</property>
     <property name="title" translatable="yes" context="yes">Preferences</property>
     <property name="resizable">False</property>
+    <property name="modal">True</property>
     <property name="window_position">center</property>
     <property name="destroy_with_parent">True</property>
     <property name="type_hint">dialog</property>
@@ -23,109 +24,19 @@
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="border_width">5</property>
-                <property name="n_rows">2</property>
-                <property name="n_columns">3</property>
-                <child>
-                  <object class="GtkCheckButton" id="checkbutton_comments">
-                    <property name="label" translatable="yes" context="yes">Comment</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <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>
-                  <object class="GtkCheckButton" id="checkbutton_serial">
-                    <property name="label" translatable="yes" context="yes">Serial</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
                 <child>
                   <object class="GtkCheckButton" id="checkbutton_ip">
-                    <property name="label" translatable="yes" context="yes">IP</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="checkbutton_model">
-                    <property name="label" translatable="yes" context="yes">Model</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="checkbutton_location">
-                    <property name="label" translatable="yes" context="yes">Location</property>
+                    <property name="label" translatable="yes" context="yes">Show IP on Tree</property>
                     <property name="use_action_appearance">False</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="use_action_appearance">False</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">0.5</property>
                     <property name="active">True</property>
                     <property name="draw_indicator">True</property>
                   </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="checkbutton_ports">
-                    <property name="label" translatable="yes" context="yes">Ports Availables</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
                 </child>
               </object>
             </child>
@@ -140,97 +51,6 @@
               </packing>
             </child>
             <child>
-              <object class="GtkHBox" id="hbox1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkScrolledWindow" id="scrolledwindow2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <child>
-                      <object class="GtkTreeView" id="treeview_users">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="rules_hint">True</property>
-                        <child internal-child="selection">
-                          <object class="GtkTreeSelection" id="treeview-selection1"/>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkVBox" id="vbox1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <child>
-                      <object class="GtkButton" id="button_add_user">
-                        <property name="label" context="yes">gtk-add</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_stock">True</property>
-                        <property name="xalign">0.50999999046325684</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="button_rem_user">
-                        <property name="label" context="yes">gtk-remove</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_stock">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label7">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Lists of users</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child type="tab">
-              <placeholder/>
-            </child>
-            <child>
               <object class="GtkTable" id="table3">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -253,8 +73,8 @@
                     <property name="right_attach">3</property>
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
-                    <property name="x_options"></property>
-                    <property name="y_options"></property>
+                    <property name="x_options"/>
+                    <property name="y_options"/>
                   </packing>
                 </child>
                 <child>
@@ -270,8 +90,8 @@
                   <packing>
                     <property name="left_attach">2</property>
                     <property name="right_attach">3</property>
-                    <property name="x_options"></property>
-                    <property name="y_options"></property>
+                    <property name="x_options"/>
+                    <property name="y_options"/>
                   </packing>
                 </child>
                 <child>
@@ -285,8 +105,8 @@
                     <property name="right_attach">2</property>
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
-                    <property name="x_options"></property>
-                    <property name="y_options"></property>
+                    <property name="x_options"/>
+                    <property name="y_options"/>
                   </packing>
                 </child>
                 <child>
@@ -298,8 +118,8 @@
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
-                    <property name="x_options"></property>
-                    <property name="y_options"></property>
+                    <property name="x_options"/>
+                    <property name="y_options"/>
                   </packing>
                 </child>
                 <child>
@@ -311,8 +131,8 @@
                   <packing>
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
-                    <property name="x_options"></property>
-                    <property name="y_options"></property>
+                    <property name="x_options"/>
+                    <property name="y_options"/>
                   </packing>
                 </child>
                 <child>
@@ -322,8 +142,8 @@
                     <property name="label" translatable="yes" context="yes">Background</property>
                   </object>
                   <packing>
-                    <property name="x_options"></property>
-                    <property name="y_options"></property>
+                    <property name="x_options"/>
+                    <property name="y_options"/>
                   </packing>
                 </child>
               </object>
@@ -348,57 +168,19 @@
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="border_width">5</property>
-                <property name="n_rows">2</property>
-                <property name="n_columns">2</property>
                 <child>
                   <object class="GtkCheckButton" id="checkbutton_ip_diag">
-                    <property name="label" translatable="yes" context="yes">IP</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="checkbutton_model_diag">
-                    <property name="label" translatable="yes" context="yes">Model</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="checkbutton_link_diag">
-                    <property name="label" translatable="yes" context="yes">Link</property>
+                    <property name="label" translatable="yes" context="yes">Show IP on diagram</property>
                     <property name="use_action_appearance">False</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="use_action_appearance">False</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">0.5</property>
                     <property name="active">True</property>
                     <property name="draw_indicator">True</property>
                   </object>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <placeholder/>
                 </child>
               </object>
               <packing>
@@ -417,12 +199,6 @@
               </packing>
             </child>
             <child>
-              <placeholder/>
-            </child>
-            <child type="tab">
-              <placeholder/>
-            </child>
-            <child>
               <object class="GtkTable" id="table2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
diff --git a/src/gevice.py b/src/gevice.py
index 207b9ee..4d57de8 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -25,7 +25,7 @@ from struct import unpack
 import config
 ###import gevicefind
 ###import gevicediagram
-#import geviceprefer
+import geviceprefer
 import gevicevte
 import gevicedevice
 import gevicemodel
@@ -97,6 +97,7 @@ class Gevice:
     self.entry_user = Gtk.Entry()
     self.entry_user.set_icon_from_stock(Gtk.EntryIconPosition.SECONDARY, Gtk.STOCK_CLEAR)
     self.entry_user.set_text(_("User"))
+    self.entry_user.set_max_length(30)
     self.entry_user.connect ("icon-press", self.icon_press_entry_user);
     self.toolitem_user.add(self.entry_user)
     self.maintoolbar.insert(self.toolitem_user,11)
@@ -125,9 +126,8 @@ class Gevice:
     self.hpaned.set_position (-1)
     
     # load preferences
-    ###self.gpref = geviceprefer.GevicePrefer(self)
+    self.gpref = geviceprefer.GevicePrefer(self)
     ###self.gpref.load_interface (self)
-    ###self.set_listusers_on_combobox()
     
     # show all
     self.window_main.show_all()
@@ -155,7 +155,7 @@ class Gevice:
       ('HelpMenu', None, _('_Help')),
       ('ActionsMenu', None, _('_Actions')),
       ('Quit', Gtk.STOCK_QUIT, _('_Quit'), None, _('Quit the program'), self.on_action_quit),
-      ('Prefer', Gtk.STOCK_PREFERENCES, _('Preferences'), None, _('Setting preferences'), self.passing),
+      ('Prefer', Gtk.STOCK_PREFERENCES, _('Preferences'), None, _('Setting preferences'), self.on_action_preferences),
       ('About', Gtk.STOCK_ABOUT, None, None, None, self.on_action_about),
       ('Nbase', None, _('New Database'),None, _('New Database'), self.on_action_ndbase),
       ('Open', Gtk.STOCK_DISCONNECT, _('Connect'), None, _('Connect to database'), self.on_action_open),
@@ -472,6 +472,10 @@ class Gevice:
   def icon_press_entry_user(self, widget, position, event):
     self.entry_user.set_text ("")
 
+  def on_action_preferences (self,action):
+    self.gpref.load_interface(self)
+    self.gpref.show_interface()
+
 if __name__ == "__main__":
   gevice = Gevice()
   gevice.main()
diff --git a/src/geviceprefer.py b/src/geviceprefer.py
index cd43b01..d39b5bd 100644
--- a/src/geviceprefer.py
+++ b/src/geviceprefer.py
@@ -29,7 +29,7 @@ from gettext import gettext as _
 
 class GevicePrefer:
   def __init__ (self,gevice):    
-    self.settings = Gio.Settings.new("apps.gevice")
+    self.gsettings = Gio.Settings.new("apps.gevice")
 
   def load_interface (self,gevice):
     builder = Gtk.Builder()
@@ -38,117 +38,36 @@ class GevicePrefer:
     self.window_prefer = builder.get_object ("window_prefer")
     self.button_close_prefer = builder.get_object ("button_close_prefer")
     self.checkbutton_ip = builder.get_object ("checkbutton_ip")
-    self.checkbutton_type = builder.get_object ("checkbutton_type")
-    self.checkbutton_status = builder.get_object ("checkbutton_status")
-    self.checkbutton_model = builder.get_object ("checkbutton_model")
-    self.checkbutton_serial = builder.get_object ("checkbutton_serial")
-    self.checkbutton_comments = builder.get_object ("checkbutton_comments")
-    self.checkbutton_location = builder.get_object ("checkbutton_location")
-    self.checkbutton_ports = builder.get_object ("checkbutton_ports")
     self.entry_backcolor = builder.get_object ("entry_backcolor")
     self.entry_forecolor = builder.get_object ("entry_forecolor")
     self.entry_csvseparator = builder.get_object ("entry_csvseparator")
     self.button_backcolor = builder.get_object ("button_backcolor")
     self.button_forecolor = builder.get_object ("button_forecolor")
     self.checkbutton_ip_diag = builder.get_object ("checkbutton_ip_diag")
-    self.checkbutton_model_diag = builder.get_object ("checkbutton_model_diag")
-    self.checkbutton_link_diag = builder.get_object ("checkbutton_link_diag")
-    self.button_add_user = builder.get_object ("button_add_user")
-    self.button_rem_user = builder.get_object ("button_rem_user")
-    self.treeview_users = builder.get_object ("treeview_users")
 
     # signals
     self.window_prefer.connect ("delete-event", self.on_window_prefer_delete_event)
     self.button_close_prefer.connect ("clicked", self.on_button_close_prefer_clicked)    
     
-    self.checkbutton_ip.connect ("toggled", self.show_column, config.COLUMN_IP_DEV, gevice, "viewip")    
-    self.checkbutton_model.connect ("toggled", self.show_column, config.COLUMN_NAME_MODEL_DEV, gevice, "viewmodel")    
-    self.checkbutton_serial.connect ("toggled", self.show_column, config.COLUMN_SERIAL_DEV,gevice, "viewserial")    
-    self.checkbutton_comments.connect ("toggled", self.show_column, config.COLUMN_OBS_DEV,gevice, "viewcomments")
-    self.checkbutton_location.connect ("toggled", self.show_column, config.COLUMN_LOCATION,gevice, "viewlocation")
-    self.checkbutton_ports.connect ("toggled", self.show_column, config.COLUMN_PTAS_DISP,gevice, "viewports")        
+    self.checkbutton_ip.connect ("toggled", self.show_column, 1, gevice, "viewip")    
     
     self.entry_backcolor.connect ("changed", self.on_entry_backcolor_changed, gevice, "backcolor")
     self.entry_forecolor.connect ("changed", self.on_entry_forecolor_changed, gevice, "forecolor")
     self.entry_csvseparator.connect ("changed", self.on_entry_csvseparator_changed, gevice, "csvseparator")
     
     self.checkbutton_ip_diag.connect ("toggled", self.change_estatus_on_diagram, gevice, "diagip")
-    self.checkbutton_model_diag.connect ("toggled", self.change_estatus_on_diagram, gevice, "diagmodel")
-    self.checkbutton_link_diag.connect ("toggled", self.change_estatus_on_diagram, gevice, "diaglink")    
     
-    self.button_add_user.connect ("clicked", self.on_button_add_user_clicked, gevice, "listusers")
-    self.button_rem_user.connect ("clicked", self.on_button_rem_user_clicked, gevice, "listusers")            
     self.button_backcolor.connect ("clicked", self.on_button_background_clicked, self.entry_backcolor)
     self.button_forecolor.connect ("clicked", self.on_button_foreground_clicked, self.entry_forecolor)        
 
     # setting preferences
-    self.checkbutton_ip.set_active(self.settings.get_boolean("viewip"))
-    self.checkbutton_model.set_active(self.settings.get_boolean("viewmodel"))
-    self.checkbutton_serial.set_active(self.settings.get_boolean("viewserial"))
-    self.checkbutton_comments.set_active(self.settings.get_boolean("viewcomments"))
-    self.checkbutton_location.set_active(self.settings.get_boolean("viewlocation"))
-    self.checkbutton_ports.set_active(self.settings.get_boolean("viewports"))    
+    self.checkbutton_ip.set_active(self.gsettings.get_boolean("viewip"))
+   
+    self.entry_backcolor.set_text (self.gsettings.get_string("backcolor"))
+    self.entry_forecolor.set_text (self.gsettings.get_string("forecolor"))
+    self.entry_csvseparator.set_text (self.gsettings.get_string("csvseparator"))
     
-    self.entry_backcolor.set_text (self.settings.get_string("backcolor"))
-    self.entry_forecolor.set_text (self.settings.get_string("forecolor"))
-    self.entry_csvseparator.set_text (self.settings.get_string("csvseparator"))
-    
-    self.checkbutton_ip_diag.set_active(self.settings.get_boolean("diagip"))
-    self.checkbutton_model_diag.set_active(self.settings.get_boolean("diagmodel"))
-    self.checkbutton_link_diag.set_active(self.settings.get_boolean("diaglink"))
-
-    #listusers = self.settings.get_list("listusers")
-    self.listusers = self.settings.get_strv("listusers")
-
-    # for lists of users
-    col = Gtk.TreeViewColumn (_("Users"))
-    self.treeview_users.append_column (col)
-    cell =  Gtk.CellRendererText()
-    cell.connect('edited', self.on_name_user_edited,gevice,"listusers")
-    col.pack_start (cell,True)
-    cell.set_property('editable',True)
-    col.add_attribute (cell,"text",0)        
-
-    self.treeview_users.set_model (None)               
-    self.treeview_users.set_model (gevice.modelusers)
-    gevice.modelusers.clear()
-
-    for usr in self.listusers:
-      iter = gevice.modelusers.append ()
-      gevice.modelusers.set_value (iter,0,usr)
-
-  def on_name_user_edited(self,cell,path,newname,gevice,attr):
-    newname = newname.strip()
-    iter = gevice.modelusers.get_iter_from_string(path)
-    oldname = gevice.modelusers.get(iter,0)[0]
-
-    # check, newname exists
-    if oldname == newname:
-      return 
-       
-    self.is_in_list = False
-    gevice.modelusers.foreach(self.is_newname_in_list, newname)
-
-    if not self.is_in_list:
-      gevice.modelusers.set_value(iter,0,newname)
-      self.listusers = []
-      gevice.modelusers.foreach(self.update_list_users,None)
-      gevice.set_listusers_on_combobox()
-      self.settings.set_strv (attr, self.listusers);
-    else:
-      result = gevice.show_message (_("Name exist: ") + newname,
-        None,(Gtk.STOCK_OK, Gtk.ResponseType.OK),
-        self.window_prefer)
-
-  def is_newname_in_list(self,model,path,iter,newname):
-    oldname = model.get(iter,0)[0]
-
-    self.is_in_list = False;
-    if oldname == newname:
-      self.is_in_list = True;
-      return True
-    
-    return False;
+    self.checkbutton_ip_diag.set_active(self.gsettings.get_boolean("diagip"))
 
   def show_interface (self):
     self.window_prefer.show_all()
@@ -156,43 +75,6 @@ class GevicePrefer:
   def close_window (self,window):
     window.destroy()
 
-  def on_button_add_user_clicked (self,button,gevice,attr):
-    liststore = self.treeview_users.get_model()
-    iter = liststore.append ()
-    liststore.set_value(iter,0,"New")
-
-    path = liststore.get_path(iter)
-    self.treeview_users.set_cursor(path,None,False)
-    
-    # clear list
-    self.listusers = []
-    gevice.modelusers.foreach(self.update_list_users,None)
-    gevice.set_listusers_on_combobox()
-    
-    ###client.set_list('/apps/gevice/listusers',gconf.VALUE_STRING,self.listusers)
-    self.settings.set_strv (attr, self.listusers);
-
-  def on_button_rem_user_clicked (self,button,gevice,attr):
-    selection = self.treeview_users.get_selection()
-    model,iter = selection.get_selected()
-
-    name = model.get(iter,0)[0]
-
-    result = gevice.show_message (_("Do you want to remove: ") + name,
-      None, 
-      (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_YES, Gtk.ResponseType.YES),
-      self.window_prefer)
-
-    if result == Gtk.ResponseType.YES:
-      model.remove(iter)
-      # clear list
-      self.listusers = []
-      gevice.modelusers.foreach(self.update_list_users,None)
-      gevice.set_listusers_on_combobox()
-    
-      ###client.set_list('/apps/gevice/listusers',gconf.VALUE_STRING,self.listusers)
-      self.settings.set_strv (attr, self.listusers);
-
   def on_button_background_clicked (self,button,entry):
     self.create_color_selection_dialog(_("Select background color"),entry)
 
@@ -224,21 +106,17 @@ class GevicePrefer:
     self.close_window (window)
 
   def on_entry_backcolor_changed (self,editable,gevice,attr):
-    self.settings.set_string(attr, editable.get_text ())
+    self.gsettings.set_string(attr, editable.get_text ())
 
   def on_entry_csvseparator_changed (self,editable,gevice,attr):
-    self.settings.set_string(attr, editable.get_text ())
+    self.gsettings.set_string(attr, editable.get_text ())
 
   def on_entry_forecolor_changed (self,editable,gevice,attr):
-    self.settings.set_string(attr, editable.get_text ())
-
-  def update_list_users(self,model,path,iter,data):
-    username = model.get(iter,0)[0]
-    self.listusers.append(username)
+    self.gsettings.set_string(attr, editable.get_text ())
 
   def show_column (self, checkbutton, column, gevice, attr):
     # update preference
-    self.settings.set_boolean(attr, checkbutton.get_active())
+    self.gsettings.set_boolean(attr, checkbutton.get_active())
     
     st =  checkbutton.get_active()
     tcl = gevice.gmodel.treeview.get_column (column)
@@ -249,4 +127,4 @@ class GevicePrefer:
       tcl.set_visible (False)
 
   def change_estatus_on_diagram (self,checkbutton,gevice, attr):
-    self.settings.set_boolean(attr, checkbutton.get_active())
+    self.gsettings.set_boolean(attr, checkbutton.get_active())



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]