[gevice] move mantainer actions to actiongroup_model.
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gevice] move mantainer actions to actiongroup_model.
- Date: Mon, 21 Nov 2011 21:01:52 +0000 (UTC)
commit c6f59ff4945c49afd1af31e6168f9a966d8155f5
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date: Mon Nov 21 18:01:43 2011 -0300
move mantainer actions to actiongroup_model.
ChangeLog | 4 +
src/gevice.py | 18 +-
src/geviceprefer.py | 574 +++++++++++++++++++++++++--------------------------
3 files changed, 297 insertions(+), 299 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e31abdb..0a86140 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
2011-11-21 Alejandro Valdes Jimenez <avaldes gnome org>
+ * src/gevice.py: move mantainer actions to actiongroup_model.
+ * src/geviceprefer.py: reorder code (delete tab spaces)
+
+2011-11-21 Alejandro Valdes Jimenez <avaldes gnome org>
* src/gevice.py: update functions called por GtkAction
* src/gevicevte.py: Disable set bgcolor and textcolor. (FIX)
diff --git a/src/gevice.py b/src/gevice.py
index b87baeb..7875cee 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -251,15 +251,7 @@ class Gevice:
('Find', Gtk.STOCK_FIND, _('Find'),None, _('Search a device'), self.on_action_find),
('Save', Gtk.STOCK_SAVE, _('Save'), None, _('Save model'), self.on_action_save),
('Export', Gtk.STOCK_SELECT_ALL, _('Export all to CSV'), None, _('Export all to CSV'), self.on_action_export),
- ('AddDevice', Gtk.STOCK_ADD, _('Add'),None, _('Add a device'), self.on_action_adddevice),
- ])
-
- self.actiongroup_device.add_actions([
- ('RemoveDevice', Gtk.STOCK_REMOVE, _('Remove'), None, _('Remove device selected'), self.on_action_removedevice),
- ('EditDevice', Gtk.STOCK_EDIT, _('Edit'), None, _('Edit data of device selected'), self.on_action_editdevice),
- ('Expand', Gtk.STOCK_INDENT, _('Expand'), None, _('Expand tree of device selected'), self.on_action_expand),
- ('Decrease', Gtk.STOCK_UNINDENT, _('Decrease'), None, _('Decrease tree of device selected'), self.on_action_decrease),
- ('Diagram', Gtk.STOCK_CONVERT, _('Generate Diagram'),None, _('Generate diagram of devices'), self.on_action_diagram),
+ ('AddDevice', Gtk.STOCK_ADD, _('Add'),None, _('Add a device'), self.on_action_adddevice),
('Mark', Gtk.STOCK_EDIT, _('Mark'),None, _('Mark'), self.on_action_mark),
('TypeOfLink', Gtk.STOCK_EDIT, _('Type of link'),None, _('Type of link'), self.on_action_typeoflink),
('TypeOfDev', Gtk.STOCK_EDIT, _('Type of device'),None, _('Type of device'), self.on_action_typeofdev),
@@ -269,6 +261,14 @@ class Gevice:
('Location', Gtk.STOCK_EDIT, _('Locations of devices'),None, _('Locations of devices'),self.on_action_location),
('Edifice', Gtk.STOCK_EDIT, _('Edifices of campus'),None, _('Edifices of campus'), self.on_action_edifice),
])
+
+ self.actiongroup_device.add_actions([
+ ('RemoveDevice', Gtk.STOCK_REMOVE, _('Remove'), None, _('Remove device selected'), self.on_action_removedevice),
+ ('EditDevice', Gtk.STOCK_EDIT, _('Edit'), None, _('Edit data of device selected'), self.on_action_editdevice),
+ ('Expand', Gtk.STOCK_INDENT, _('Expand'), None, _('Expand tree of device selected'), self.on_action_expand),
+ ('Decrease', Gtk.STOCK_UNINDENT, _('Decrease'), None, _('Decrease tree of device selected'), self.on_action_decrease),
+ ('Diagram', Gtk.STOCK_CONVERT, _('Generate Diagram'),None, _('Generate diagram of devices'), self.on_action_diagram),
+ ])
self.actiongroup_window.add_toggle_actions([
('Tree', None, _('Tree'),None, _('Show tree'), self.on_toggle_tree, True),
diff --git a/src/geviceprefer.py b/src/geviceprefer.py
index 2f9045c..49ec1e3 100644
--- a/src/geviceprefer.py
+++ b/src/geviceprefer.py
@@ -11,294 +11,288 @@ 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 load_interface (self,gevice):
- builder = Gtk.Builder()
- builder.add_from_file(os.path.join (config.UIDIR, "pref.xml"))
-
- 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")
-
- 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)
- 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.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)
-
- # 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.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)
- 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):
- 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.save_preferences(gevice)
- 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;
-
-
- def show_interface (self):
- self.window_prefer.show_all()
-
- def close_window (self,window):
- window.destroy()
-
- def on_button_add_user_clicked (self,button,gevice):
- 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)
-
- self.save_preferences(gevice)
-
-
- def on_button_rem_user_clicked (self,button,gevice):
- 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)
- self.save_preferences(gevice)
-
-
- def on_button_background_clicked (self,button,entry):
- self.create_color_selection_dialog(_("Select background color"),entry)
-
- def on_button_foreground_clicked (self,button,entry):
- self.create_color_selection_dialog(_("Select text color"),entry)
-
- def create_color_selection_dialog (self,title,entry):
- # current color
- colorstr = entry.get_text()
- status, colorgdk = Gdk.color_parse(colorstr)
-
- colord = Gtk.ColorSelectionDialog(title)
- colorselection = colord.get_color_selection()
- colorselection.set_current_color(colorgdk)
-
- response = colord.run()
-
- if response == Gtk.ResponseType.OK:
- gdkcolor = colorselection.get_current_color()
- color = gdkcolor.to_string()
- entry.set_text(color)
- print "Colour selected: %s" % color
-
- colord.destroy()
-
- def on_button_close_prefer_clicked (self,button):
- self.close_window (self.window_prefer)
-
- 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):
- self.save_preferences(gevice)
-
- def on_entry_csvseparator_changed (self,editable,gevice):
- self.save_preferences(gevice)
-
- def on_entry_forecolor_changed (self,editable,gevice):
- 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
-
- 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)
-
- # 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):
- st = checkbutton.get_active()
- tcl = gevice.gmodel.treeview.get_column (column)
-
- if (st):
- tcl.set_visible (True)
- else:
- tcl.set_visible (False)
-
- self.save_preferences(gevice)
+ 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 load_interface (self,gevice):
+ builder = Gtk.Builder()
+ builder.add_from_file(os.path.join (config.UIDIR, "pref.xml"))
+
+ 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")
+
+ 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)
+ 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.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)
+
+ # 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.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)
+ 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):
+ 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.save_preferences(gevice)
+ 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
- def change_estatus_on_diagram (self,checkbutton,gevice):
- self.save_preferences(gevice)
+ return False;
+
+ def show_interface (self):
+ self.window_prefer.show_all()
+
+ def close_window (self,window):
+ window.destroy()
+
+ def on_button_add_user_clicked (self,button,gevice):
+ 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)
+
+ self.save_preferences(gevice)
+
+ def on_button_rem_user_clicked (self,button,gevice):
+ 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)
+ self.save_preferences(gevice)
+
+ def on_button_background_clicked (self,button,entry):
+ self.create_color_selection_dialog(_("Select background color"),entry)
+
+ def on_button_foreground_clicked (self,button,entry):
+ self.create_color_selection_dialog(_("Select text color"),entry)
+
+ def create_color_selection_dialog (self,title,entry):
+ # current color
+ colorstr = entry.get_text()
+ status, colorgdk = Gdk.color_parse(colorstr)
+
+ colord = Gtk.ColorSelectionDialog(title)
+ colorselection = colord.get_color_selection()
+ colorselection.set_current_color(colorgdk)
+
+ response = colord.run()
+
+ if response == Gtk.ResponseType.OK:
+ gdkcolor = colorselection.get_current_color()
+ color = gdkcolor.to_string()
+ entry.set_text(color)
+ print "Colour selected: %s" % color
+
+ colord.destroy()
+
+ def on_button_close_prefer_clicked (self,button):
+ self.close_window (self.window_prefer)
+
+ 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):
+ self.save_preferences(gevice)
+
+ def on_entry_csvseparator_changed (self,editable,gevice):
+ self.save_preferences(gevice)
+
+ def on_entry_forecolor_changed (self,editable,gevice):
+ 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
+
+ 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)
+
+ # 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):
+ st = checkbutton.get_active()
+ tcl = gevice.gmodel.treeview.get_column (column)
+
+ if (st):
+ tcl.set_visible (True)
+ else:
+ tcl.set_visible (False)
+
+ self.save_preferences(gevice)
+
+ def change_estatus_on_diagram (self,checkbutton,gevice):
+ self.save_preferences(gevice)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]