[gevice] update schema gsettings



commit 80146d00538bd1205199b2f15b0af23e62c97a7a
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date:   Fri Sep 28 15:22:59 2012 -0300

    update schema gsettings

 ChangeLog                    |    6 ++
 data/apps.gevice.gschema.xml |    6 +--
 src/gevice.py                |    6 +--
 src/geviceprefer.py          |  150 +++++++-----------------------------------
 src/gevicevte.py             |   11 ++--
 5 files changed, 37 insertions(+), 142 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 941d262..9cc684e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
 2012-09-28  Alejandro Valdes J.  <avaldes gnome org>
+	* data/apps.gevice.gschema.xml: update schema gsettings.
+	* src/gevice.py: clear code.
+	* src/geviceprefer.py: clear code.
+	* src/gevicevte.py: fixed color selections.
+
+2012-09-28  Alejandro Valdes J.  <avaldes gnome org>
 	* src/gevice.py:
 	* src/geviceprefer.py: port from Gconf to GSettings.
 	* Fixed bug #655273
diff --git a/data/apps.gevice.gschema.xml b/data/apps.gevice.gschema.xml
index a8ed7d4..26f562c 100644
--- a/data/apps.gevice.gschema.xml
+++ b/data/apps.gevice.gschema.xml
@@ -52,7 +52,6 @@
 			<default>'#000000'</default>
     </key>
     <key type="s" name="forecolor">
-      <default>''</default>
       <summary>Forecolor.</summary>
       <description>Forecolor.</description>
 			<default>'#ffffff'</default>
@@ -63,19 +62,16 @@
       <default>'|'</default>
     </key>
     <key type="s" name="dbase">
-      <default>''</default>
       <summary>Data base name.</summary>
       <description>Data base name.</description>
       <default>'dbasename'</default>
     </key>
     <key type="s" name="host">
-      <default>''</default>
       <summary>Host data base.</summary>
       <description>Host data base.</description>
       <default>'hostdbase'</default>
     </key>
     <key type="s" name="userdbase">
-      <default>''</default>
       <summary>User data base.</summary>
       <description>User database.</description>
       <default>'userdbase'</default>
@@ -83,7 +79,7 @@
     <key type="as" name="listusers">
       <summary>List of users</summary>
       <description>List of users.</description>
-      <default>['deb', 'avaldes']</default>
+      <default>['user']</default>
     </key>
   </schema>
 </schemalist>
diff --git a/src/gevice.py b/src/gevice.py
index ab91412..efd66d4 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -197,7 +197,6 @@ class Gevice:
     
     # load preferences
     self.gpref = geviceprefer.GevicePrefer(self)
-    self.gpref.load_preferences(self)
     self.gpref.load_interface (self)
     self.set_listusers_on_combobox()
     
@@ -326,9 +325,7 @@ class Gevice:
     Gtk.main()
   
   def set_listusers_on_combobox (self):
-    self.modelusers.clear()
-    
-    ###self.modelusers.append([_("User")])
+    self.modelusers.clear()    
     
     for user in self.gpref.listusers:
       self.modelusers.append([user])
@@ -667,7 +664,6 @@ class Gevice:
     self.on_delete_event ()
     
   def on_action_preferences (gevice,action):
-    gevice.gpref.load_preferences(gevice)
     gevice.gpref.load_interface(gevice)
     gevice.gpref.show_interface()
   
diff --git a/src/geviceprefer.py b/src/geviceprefer.py
index 3b1aabf..47a0877 100644
--- a/src/geviceprefer.py
+++ b/src/geviceprefer.py
@@ -1,6 +1,5 @@
 from gi.repository import Gtk, Gdk, Gio
 import os
-#import gconf
 
 import config
 
@@ -11,22 +10,7 @@ gettext.bind_textdomain_codeset (config.PACKAGE, "UTF-8");
 from gettext import gettext as _
 
 class GevicePrefer:
-  def __init__ (self,gevice):
-    self.flag_load_preferences = False
-
-    self.viewip = False
-    self.viewmodel = False
-    self.viewserial = False
-    self.viewcomments = False
-    self.viewlocation = False
-    self.viewports = False
-    self.backcolor = "#EBE9AE"
-    self.forecolor = "#000000"
-    self.diagip = False
-    self.diagmodel = False
-    self.diaglink = False
-    self.csvseparator = "|"
-    
+  def __init__ (self,gevice):    
     self.settings = Gio.Settings.new("apps.gevice")
 
   def load_interface (self,gevice):
@@ -56,33 +40,30 @@ class GevicePrefer:
     self.treeview_users = builder.get_object ("treeview_users")
 
     # signals
-    self.button_close_prefer.connect ("clicked",self.on_button_close_prefer_clicked)    
+    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.window_prefer.connect ("delete-event",self.on_window_prefer_delete_event)
-    
-    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_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.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)
+    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.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")            
-
-    # for not activate callback when loading preferences
-    self.flag_load_preferences = True
+    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"))
@@ -101,8 +82,7 @@ class GevicePrefer:
     #listusers = self.settings.get_list("listusers")
     self.listusers = self.settings.get_strv("listusers")
 
-    self.flag_load_preferences = False
-
+    # for lists of users
     col = Gtk.TreeViewColumn (_("Users"))
     self.treeview_users.append_column (col)
     cell =  Gtk.CellRendererText()
@@ -137,7 +117,6 @@ class GevicePrefer:
       gevice.modelusers.foreach(self.update_list_users,None)
       gevice.set_listusers_on_combobox()
       self.settings.set_strv (attr, self.listusers);
-      ###self.save_preferences(gevice)
     else:
       result = gevice.show_message (_("Name exist: ") + newname,
         None,(Gtk.STOCK_OK, Gtk.ResponseType.OK),
@@ -174,7 +153,6 @@ class GevicePrefer:
     
     ###client.set_list('/apps/gevice/listusers',gconf.VALUE_STRING,self.listusers)
     self.settings.set_strv (attr, self.listusers);
-    ###self.save_preferences(gevice)
 
   def on_button_rem_user_clicked (self,button,gevice,attr):
     selection = self.treeview_users.get_selection()
@@ -196,7 +174,6 @@ class GevicePrefer:
     
       ###client.set_list('/apps/gevice/listusers',gconf.VALUE_STRING,self.listusers)
       self.settings.set_strv (attr, self.listusers);
-      ###self.save_preferences(gevice)      
 
   def on_button_background_clicked (self,button,entry):
     self.create_color_selection_dialog(_("Select background color"),entry)
@@ -207,11 +184,11 @@ class GevicePrefer:
   def create_color_selection_dialog (self,title,entry):
     # current color
     colorstr = entry.get_text()
-    status, colorgdk = Gdk.color_parse(colorstr)
+    colorgdk = Gdk.color_parse(colorstr)
 
     colord = Gtk.ColorSelectionDialog(title)
     colorselection = colord.get_color_selection()
-    colorselection.set_current_color(colorgdk)	
+    colorselection.set_current_color(colorgdk)	    
 
     response = colord.run()
 
@@ -219,7 +196,6 @@ class GevicePrefer:
       gdkcolor = colorselection.get_current_color()
       color = gdkcolor.to_string()
       entry.set_text(color)
-      print "Colour selected: %s" % color
 
     colord.destroy()
 
@@ -229,98 +205,23 @@ class GevicePrefer:
   def on_window_prefer_delete_event (self,window,event):
     self.close_window (window)
 
-  #def on_spinbutton_prefer_change_value (self,spinbutton,gevice):
-  #  self.save_preferences(gevice)
-
   def on_entry_backcolor_changed (self,editable,gevice,attr):
     self.settings.set_string(attr, editable.get_text ())
-    #self.save_preferences(gevice)
 
   def on_entry_csvseparator_changed (self,editable,gevice,attr):
     self.settings.set_string(attr, editable.get_text ())
-    #self.save_preferences(gevice)
 
   def on_entry_forecolor_changed (self,editable,gevice,attr):
     self.settings.set_string(attr, editable.get_text ())
-    #self.save_preferences(gevice)
-
-  def load_preferences (self,gevice):
-    pass
-    #client = gconf.client_get_default()
-
-    #backcolor = client.get_string('/apps/gevice/backcolor')
-    #forecolor = client.get_string('/apps/gevice/forecolor')
-    #csvseparator = client.get_string('/apps/gevice/csvseparator')
-    #listusers = client.get_list('/apps/gevice/listusers',gconf.VALUE_STRING)
-
-    #self.viewip = client.get_bool('/apps/gevice/viewip')
-    #self.viewmodel = client.get_bool('/apps/gevice/viewmodel')
-    #self.viewserial = client.get_bool('/apps/gevice/viewserial')
-    #self.viewcomments = client.get_bool('/apps/gevice/viewcomments')
-    #self.viewlocation = client.get_bool('/apps/gevice/viewlocation')
-    #self.viewports = client.get_bool('/apps/gevice/viewports')
-    #self.diagip = client.get_bool('/apps/gevice/diagip')
-    #self.diagmodel = client.get_bool('/apps/gevice/diagmodel')
-    #self.diaglink = client.get_bool('/apps/gevice/diaglink')
-
-    #if (listusers):
-    #  self.listusers = listusers
-    #else:
-    #  self.listusers = ['user']
-
-    #if (backcolor):
-    #  self.backcolor = backcolor            
-
-    #if (forecolor):
-    #  self.forecolor = forecolor
-
-    #if (csvseparator):
-    #  self.csvseparator = csvseparator
-
-  def save_preferences(self,gevice):
-    if (not self.flag_load_preferences):
-      pass
-      #self.viewip = self.checkbutton_ip.get_active()
-      #self.viewmodel = self.checkbutton_model.get_active()
-      #self.viewserial = self.checkbutton_serial.get_active()
-      #self.viewcomments = self.checkbutton_comments.get_active()
-      #self.viewlocation = self.checkbutton_location.get_active()
-      #self.viewports = self.checkbutton_ports.get_active()
-      #self.backcolor = self.entry_backcolor.get_text ()
-      #self.forecolor = self.entry_forecolor.get_text ()
-      #self.csvseparator = self.entry_csvseparator.get_text ()
-      #self.diagip = self.checkbutton_ip_diag.get_active()
-      #self.diagmodel = self.checkbutton_model_diag.get_active()
-      #self.diaglink = self.checkbutton_link_diag.get_active()
-
-      #client = gconf.client_get_default()
-      #client.set_bool('/apps/gevice/viewip', self.viewip)
-      #client.set_bool('/apps/gevice/viewmodel', self.viewmodel)
-      #client.set_bool('/apps/gevice/viewserial', self.viewserial)
-      #client.set_bool('/apps/gevice/viewcomments', self.viewcomments)
-      #client.set_bool('/apps/gevice/viewlocation', self.viewlocation)
-      #client.set_bool('/apps/gevice/viewports', self.viewports)
-      #client.set_string('/apps/gevice/backcolor', self.backcolor)
-      #client.set_string('/apps/gevice/forecolor', self.forecolor)
-      #client.set_string('/apps/gevice/csvseparator', self.csvseparator)
-      #client.set_bool('/apps/gevice/diagip', self.diagip)
-      #client.set_bool('/apps/gevice/diagmodel', self.diagmodel)
-      #client.set_bool('/apps/gevice/diaglink', self.diaglink)
-
-      # clear list
-      ###self.listusers = []
-      ###gevice.modelusers.foreach(self.update_list_users,None)
-      ###client.set_list('/apps/gevice/listusers',gconf.VALUE_STRING,self.listusers)
-
-      ###gevice.set_listusers_on_combobox()
-      #gevice.update_statusbar ()
 
   def update_list_users(self,model,path,iter,data):
     username = model.get(iter,0)[0]
     self.listusers.append(username)
 
   def show_column (self, checkbutton, column, gevice, attr):
+    # update preference
     self.settings.set_boolean(attr, checkbutton.get_active())
+    
     st =  checkbutton.get_active()
     tcl = gevice.gmodel.treeview.get_column (column)
 
@@ -329,8 +230,5 @@ class GevicePrefer:
     else:
       tcl.set_visible (False)
 
-    self.save_preferences(gevice)
-
   def change_estatus_on_diagram (self,checkbutton,gevice, attr):
     self.settings.set_boolean(attr, checkbutton.get_active())
-    #self.save_preferences(gevice)
diff --git a/src/gevicevte.py b/src/gevicevte.py
index 82fe64f..d82ad05 100644
--- a/src/gevicevte.py
+++ b/src/gevicevte.py
@@ -22,13 +22,12 @@ class GeviceVte:
     terminal = Vte.Terminal()
     terminal.set_mouse_autohide(True)       
     terminal.set_default_colors()
-
-    ###status,bgcolor = Gdk.color_parse(gevice.gpref.backcolor)
-    ### ERROR: TypeError: 'Color' object is not iterable
-    ###terminal.set_color_background(bgcolor)
     
-    ###status,fgcolor = Gdk.color_parse(gevice.gpref.forecolor)
-    ###terminal.set_color_foreground(fgcolor)
+    bgcolor = Gdk.color_parse(gevice.gpref.settings.get_string("backcolor"))
+    terminal.set_color_background(bgcolor)
+    
+    fgcolor = Gdk.color_parse(gevice.gpref.settings.get_string("forecolor"))
+    terminal.set_color_foreground(fgcolor)
     
     terminal.set_size_request(10,10)
     terminal.set_size (30,1)



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