[gevice] Fixed bug #655273
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gevice] Fixed bug #655273
- Date: Fri, 28 Sep 2012 14:54:37 +0000 (UTC)
commit 945a7a748793d69d84a3910d5f14f19a77676105
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date: Fri Sep 28 11:51:59 2012 -0300
Fixed bug #655273
ChangeLog | 5 +
src/gevice.py | 2 +-
src/geviceprefer.py | 254 +++++++++++++++++++++++++++++----------------------
3 files changed, 152 insertions(+), 109 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3c24153..941d262 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-28 Alejandro Valdes J. <avaldes gnome org>
+ * src/gevice.py:
+ * src/geviceprefer.py: port from Gconf to GSettings.
+ * Fixed bug #655273
+
2012-07-25 Alejandro Valdes J. <avaldes gnome org>
* configure.ac: Add news check of libraries.
* src/gevicemaintainer.py:
diff --git a/src/gevice.py b/src/gevice.py
index a8159f2..ab91412 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -328,7 +328,7 @@ class Gevice:
def set_listusers_on_combobox (self):
self.modelusers.clear()
- self.modelusers.append([_("User")])
+ ###self.modelusers.append([_("User")])
for user in self.gpref.listusers:
self.modelusers.append([user])
diff --git a/src/geviceprefer.py b/src/geviceprefer.py
index 49ec1e3..3b1aabf 100644
--- a/src/geviceprefer.py
+++ b/src/geviceprefer.py
@@ -1,6 +1,6 @@
-from gi.repository import Gtk, Gdk
+from gi.repository import Gtk, Gdk, Gio
import os
-import gconf
+#import gconf
import config
@@ -26,6 +26,8 @@ class GevicePrefer:
self.diagmodel = False
self.diaglink = False
self.csvseparator = "|"
+
+ self.settings = Gio.Settings.new("apps.gevice")
def load_interface (self,gevice):
builder = Gtk.Builder()
@@ -53,47 +55,58 @@ class GevicePrefer:
self.button_rem_user = builder.get_object ("button_rem_user")
self.treeview_users = builder.get_object ("treeview_users")
- 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)
- self.checkbutton_model.connect ("toggled",self.show_column,config.COLUMN_NAME_MODEL_DEV,gevice)
- self.checkbutton_serial.connect ("toggled",self.show_column,config.COLUMN_SERIAL_DEV,gevice)
- self.checkbutton_comments.connect ("toggled",self.show_column,config.COLUMN_OBS_DEV,gevice)
- self.checkbutton_location.connect ("toggled",self.show_column,config.COLUMN_LOCATION,gevice)
- self.checkbutton_ports.connect ("toggled",self.show_column,config.COLUMN_PTAS_DISP,gevice)
+ # signals
+ 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)
- self.entry_forecolor.connect ("changed",self.on_entry_forecolor_changed,gevice)
- self.entry_csvseparator.connect ("changed",self.on_entry_csvseparator_changed,gevice)
+
+ 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.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.checkbutton_ip_diag.connect ("toggled",self.change_estatus_on_diagram,gevice)
- self.checkbutton_model_diag.connect ("toggled",self.change_estatus_on_diagram,gevice)
- self.checkbutton_link_diag.connect ("toggled",self.change_estatus_on_diagram,gevice)
- self.button_add_user.connect ("clicked",self.on_button_add_user_clicked,gevice)
- self.button_rem_user.connect ("clicked",self.on_button_rem_user_clicked,gevice)
+
+ 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.checkbutton_ip.set_active(self.viewip)
- self.checkbutton_model.set_active(self.viewmodel)
- self.checkbutton_serial.set_active(self.viewserial)
- self.checkbutton_comments.set_active(self.viewcomments)
- self.checkbutton_location.set_active(self.viewlocation)
- self.checkbutton_ports.set_active(self.viewports)
- self.entry_backcolor.set_text (self.backcolor)
- self.entry_forecolor.set_text (self.forecolor)
- self.entry_csvseparator.set_text (self.csvseparator)
- self.checkbutton_ip_diag.set_active(self.diagip)
- self.checkbutton_model_diag.set_active(self.diagmodel)
- self.checkbutton_link_diag.set_active(self.diaglink)
+ 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.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")
self.flag_load_preferences = False
col = Gtk.TreeViewColumn (_("Users"))
self.treeview_users.append_column (col)
cell = Gtk.CellRendererText()
- cell.connect('edited', self.on_name_user_edited,gevice)
+ 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)
@@ -106,7 +119,7 @@ class GevicePrefer:
iter = gevice.modelusers.append ()
gevice.modelusers.set_value (iter,0,usr)
- def on_name_user_edited(self,cell,path,newname,gevice):
+ 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]
@@ -120,7 +133,11 @@ class GevicePrefer:
if not self.is_in_list:
gevice.modelusers.set_value(iter,0,newname)
- self.save_preferences(gevice)
+ self.listusers = []
+ 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),
@@ -142,17 +159,24 @@ class GevicePrefer:
def close_window (self,window):
window.destroy()
- def on_button_add_user_clicked (self,button,gevice):
+ 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);
+ ###self.save_preferences(gevice)
- self.save_preferences(gevice)
-
- def on_button_rem_user_clicked (self,button,gevice):
+ def on_button_rem_user_clicked (self,button,gevice,attr):
selection = self.treeview_users.get_selection()
model,iter = selection.get_selected()
@@ -165,7 +189,14 @@ class GevicePrefer:
if result == Gtk.ResponseType.YES:
model.remove(iter)
- self.save_preferences(gevice)
+ # 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);
+ ###self.save_preferences(gevice)
def on_button_background_clicked (self,button,entry):
self.create_color_selection_dialog(_("Select background color"),entry)
@@ -198,92 +229,98 @@ 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_spinbutton_prefer_change_value (self,spinbutton,gevice):
+ # self.save_preferences(gevice)
- def on_entry_backcolor_changed (self,editable,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):
- 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):
- 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):
- 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
+ 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):
- 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)
+ 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)
+ ###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.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):
+ def show_column (self, checkbutton, column, gevice, attr):
+ self.settings.set_boolean(attr, checkbutton.get_active())
st = checkbutton.get_active()
tcl = gevice.gmodel.treeview.get_column (column)
@@ -294,5 +331,6 @@ class GevicePrefer:
self.save_preferences(gevice)
- def change_estatus_on_diagram (self,checkbutton,gevice):
- 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]