[gevice] src/gevice.py: rewrite some code.
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gevice] src/gevice.py: rewrite some code.
- Date: Tue, 26 Jul 2011 16:37:23 +0000 (UTC)
commit 395c755433fe5768bfc61e3fd91509f73a5237f6
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date: Tue Jul 26 12:31:18 2011 -0400
src/gevice.py: rewrite some code.
ChangeLog | 4 +
TODO | 3 +-
src/gevice.py | 1112 ++++++++++++++++++++++++++++-----------------------------
3 files changed, 555 insertions(+), 564 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dfaef16..9037ed7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-07-26 Alejandro Valdes Jimenez <avaldes gnome org>
+ * TODO: update.
+ * src/gevice.py: rewrite some code.
+
2011-07-25 Alejandro Valdes Jimenez <avaldes gnome org>
* removed gtk.glade dependences.
* README:
diff --git a/TODO b/TODO
index babf5ba..2b5d1fd 100644
--- a/TODO
+++ b/TODO
@@ -1,2 +1 @@
-- change to GtkBuilder.
-- move UI interfaz from string to file.
+- Migrate from GCong to GSettings
diff --git a/src/gevice.py b/src/gevice.py
index d494f31..9997f62 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -45,573 +45,561 @@ gettext.textdomain(config.PACKAGE)
from gettext import gettext as _
class Gevice:
- def __init__ (self):
- self.list_models = None
- self.list_links = None
- self.list_location = None
- self.connected_to_database = False
- self.context_id = None
-
- # model for users
- self.modelusers = gtk.ListStore(gobject.TYPE_STRING)
-
- # model for devices
- self.gmodel = gevicemodel.GeviceModel(self)
-
- # get widgets of main app
- builder = gtk.Builder()
- builder.add_from_file(os.path.join (config.UIDIR, "main.xml"))
-
- self.window_main = builder.get_object ("window_main")
- self.vbox_main = builder.get_object ("vbox_main")
- self.hpaned = builder.get_object ("hpaned")
- self.vboxtreeview = builder.get_object ("vboxtreeview")
- self.vboxterminal = builder.get_object ("vboxterminal")
- self.notebook = builder.get_object ("notebook")
- self.statusbar = builder.get_object ("statusbar")
-
- self.window_main.set_icon (gtk.gdk.pixbuf_new_from_file(os.path.join (config.ARTDIR,"gevice.png")))
- self.window_main.set_title(config.PACKAGE)
- self.window_main.connect ("delete_event",self.on_delete_event)
-
- self.context_id = self.statusbar.get_context_id("status")
-
- # create UIManager instance
- self.uimanager = gtk.UIManager()
- self.uimanager.add_ui_from_file (os.path.join (config.UIDIR, "menu.xml"))
-
- # create ActionGroup and add to unimanager
- self.create_actionsgroups ()
-
- # add the actiongroup to the uimanager
- self.uimanager.insert_action_group (self.actiongroup_window,0)
- self.uimanager.insert_action_group (self.actiongroup_model,0)
- self.uimanager.insert_action_group (self.actiongroup_device,0)
-
- # create MenuBar
- self.menubar = self.uimanager.get_widget ('/MainMenu')
- self.vbox_main.pack_start (self.menubar,False,False,0)
-
- # create a Toolbar
- self.maintoolbar = self.uimanager.get_widget ('/MainToolbar')
- self.maintoolbar.set_style(gtk.TOOLBAR_ICONS)
-
- # create horizontal container for toolbar and users combobox
- self.hbox = gtk.HBox(False,0)
- self.vbox_main.pack_start (self.hbox,False,False,0)
-
- # create users combobox
- self.separator_user = gtk.SeparatorToolItem()
- self.toolitem_user = gtk.ToolItem()
- self.maintoolbar.insert(self.toolitem_user,12)
-
- self.vboxcombo = gtk.VBox(False,0)
- self.combobox_user = gtk.combo_box_entry_new_with_model(self.modelusers,0)
- self.vboxcombo.pack_end (self.combobox_user,True,False)
- self.toolitem_user.add(self.vboxcombo)
-
- self.hbox.pack_start (self.maintoolbar,True,True)
-
- # add treeview to vboxtreeview
- self.scroll = gtk.ScrolledWindow()
- self.scroll.set_shadow_type("GTK_SHADOW_ETCHED_IN")
- self.scroll.set_policy("GTK_POLICY_AUTOMATIC","GTK_POLICY_AUTOMATIC")
- self.scroll.add (self.gmodel.treeview)
- self.vboxtreeview.add (self.scroll)
-
- # setting notebook properties
- self.notebook.set_scrollable (True)
- self.notebook.set_show_border (False)
- self.notebook.set_show_tabs (True)
- self.notebook.set_group_id(1)
-
- self.hpaned.add2 (self.notebook)
- # a negative value means that the position is unset.
- self.hpaned.set_position (-1)
-
- # load preferences
- self.gpref = geviceprefer.GevicePrefer(self)
- self.gpref.load_preferences(self)
- self.gpref.load_interface (self)
- self.set_listusers_on_combobox()
-
- # show all
- self.window_main.show_all()
- return
-
- def create_actionsgroups (self):
- self.actiongroup_window = gtk.ActionGroup ('Window Actions')
- self.actiongroup_model = gtk.ActionGroup ('Model Actions')
- self.actiongroup_device = gtk.ActionGroup ('Device Actions')
-
- # add the accelerator group to the toplevel window
- self.accelgroup = self.uimanager.get_accel_group()
- self.window_main.add_accel_group (self.accelgroup)
-
- self.actiongroup_window.add_toggle_actions([('Dual', None, '_Dual', None,
- _('Dual terminal'), None)])
-
- # creat actions
- self.actiongroup_window.add_actions([
- ('FileMenu', None, _('_File')),
- ('EditMenu', None, _('_Edit')),
- ('ViewMenu', None, _('_View')),
- ('Protocol', None, _('_Protocol')),
- ('HelpMenu', None, _('_Help')),
- ('Maintainer', None, _('_Maintainer')),
- ('ActionsMenu', None, _('_Actions')),
- ('Open', gtk.STOCK_DISCONNECT, _('Connect'), None, _('Connect to database'), self.on_action_open),
- ('OpenLocalTerminal', gtk.STOCK_HOME, _('Local'), None, _('Open local terminal'), self.on_action_open_local_terminal),
- ('Quit', gtk.STOCK_QUIT, _('_Quit'), None, _('Quit the program'), self.on_action_quit),
- ('Prefer', gtk.STOCK_PREFERENCES, _('Preferences'), None, _('Setting preferences'), self.on_action_preferences),
- ('About', gtk.STOCK_ABOUT, None, None, None, self.on_action_about),
- ])
-
- self.actiongroup_model.add_actions([
- ('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),
- ('Refresh', gtk.STOCK_REFRESH, _('Refresh'), None, _('Refresh model'), self.on_action_refresh),
- ('Export', gtk.STOCK_SELECT_ALL, _('Export to CSV'), None, _('Export to CSV'), self.on_action_export),
- ])
-
- self.actiongroup_device.add_actions([
- ('AddDevice', gtk.STOCK_ADD, _('Add'),None, _('Add a device'), self.on_action_adddevice),
- ('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),
- ('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),
- ('Model', gtk.STOCK_EDIT, _('Model of device'),None, _('Model of device'), self.on_action_model),
- ('Level', gtk.STOCK_EDIT, _('Levels of locations'),None, _('Levels of locations'), self.on_action_level),
- ('Campus', gtk.STOCK_EDIT, _('Campus of organization'),None, _('Campus of organization'), self.on_action_campus),
- ('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_window.add_toggle_actions([
- ('Tree', None, _('Tree'),None, _('Show tree'), self.on_toggle_tree, True),
- ('Terminal', None, _('Terminal'),None, _('Show terminal'), self.on_toggle_terminal, True)
- ])
-
- self.actiongroup_window.add_radio_actions([
- ('ssh', None, _('ssh'),None, _('Use ssh protocol'), 0),
- ('telnet', None, _('telnet'),None, _('Use telnet protocol'), 1),
- ('local', None, _('local'),None, _('Open local terminal'), 2),
- ],0, self.on_action_radio)
-
- self.actiongroup_window.add_actions([
- ('Connect', gtk.STOCK_JUMP_TO, _('Connect'), None, _('Connect to'), self.on_action_connect),
- ])
-
- self.actiongroup_model.set_sensitive (False)
- self.actiongroup_window.set_sensitive (True)
- self.actiongroup_device.set_sensitive (False)
-
- def set_listusers_on_combobox (self):
- self.modelusers.clear()
- for user in self.gpref.listusers:
- self.combobox_user.append_text(user)
-
- self.combobox_user.set_active (0)
-
-
- def main(self):
- gtk.main()
-
- def show_message (self,msg,type_msg,buttons):
- dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL,type_msg,buttons,msg)
- result = dialog.run()
- dialog.destroy()
- return result
-
- def close_page_of_notebook(self,widget,vpaned):
- "close page of notebook"
-
- page = self.notebook.page_num(vpaned)
- self.notebook.remove_page(page)
-
- def remove_all_page_of_notebook (self):
- n = self.notebook.get_n_pages()
- i = n
- while i >= 0:
- self.notebook.remove_page(i)
- i = i - 1
-
- def connect_to_device (self,local=None):
- if (self.actiongroup_window.get_action("Dual").get_active()):
- isdual = True
- else:
- isdual = False
-
- vpaned = gtk.VPaned()
- vpaned.set_position (-1)
-
- label = gtk.Label()
- button_close = self.create_button_with_image ('gtk-close',True)
- hbox_label = gtk.HBox(False,0)
- hbox_label.pack_start(label,False,False,1)
- hbox_label.pack_start(button_close,True,False,0)
-
- gvte = gevicevte.GeviceVte()
-
- hbox_term,terminal = gvte.new_terminal (self)
- vpaned.add1 (hbox_term)
-
- button_close.connect('clicked',self.close_page_of_notebook,vpaned)
-
- if local:
- label.set_text(_("Local"))
- terminal.fork_command ()
-
- if isdual:
- hbox_term2,terminal2 = gvte.new_terminal (self)
- vpaned.add2 (hbox_term2)
- terminal2.fork_command ()
-
- else:
- i = self.gmodel.get_iter_selected (self.gmodel.treeview)
- if i["iter"]:
- # get data from device selected
- data = self.gmodel.get_data_of_device_from_model(self.gmodel.treeview)
- label.set_text(data[0])
- proto = self.get_protocol_selected()
- user = self.combobox_user.get_active_text()
-
- terminal.fork_command (proto,['bash','-l',user,data[2]],[],config.DEFAULT_TMP)
-
- if isdual:
- hbox_term2,terminal2 = gvte.new_terminal (self)
- vpaned.add2 (hbox_term2)
- terminal2.fork_command (proto,['bash','-l',user,data[2]],[],config.DEFAULT_TMP)
-
- page = self.notebook.append_page(vpaned,hbox_label)
- self.notebook.set_tab_reorderable(vpaned,True)
- self.notebook.set_tab_detachable(vpaned,True)
-
- hbox_label.show_all()
- vpaned.show_all()
- self.notebook.set_current_page(page)
-
-
- def create_button_with_image (self,id_stock,sensitive):
- "return a button with image, utilized in tool of browser"
-
- hbox_image = gtk.HBox(False,0)
- image = gtk.Image()
- image.set_from_stock(id_stock,'GTK_ICON_SIZE_MENU')
- hbox_image.pack_start(image,True,False,False)
-
- button = gtk.Button()
- button.set_relief('GTK_RELIEF_NONE')
-
- button.add(hbox_image)
- button.set_sensitive (sensitive)
-
- return button
-
- def on_action_model (gevice,action):
- sql_select = "select modelo.id_modelo,tipo_disp.nom_tipo_disp || ' ' || marca.nom_marca,modelo.nom_modelo "
- sql_select = sql_select + "from modelo inner join marca on modelo.id_marca = marca.id_marca inner join tipo_disp "
- sql_select = sql_select + "on modelo.id_tipo_disp = tipo_disp.id_tipo_disp order by 2;"
-
- sql = {"select":sql_select,
- "update1":"update modelo set nom_modelo=",
- "update2":" where id_modelo=",
- "delete":"delete from modelo where id_modelo=",
- "max_id":"select max(id_modelo) + 1 from modelo;",
- "insert":"insert into modelo values ",
- "sql_mark":"select nom_marca,id_marca from marca;",
- "sql_tipo_disp":"select nom_tipo_disp,id_tipo_disp from tipo_disp"}
-
- dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
- dialogmaintainer.load_interface1 (gevice,_("Model of device"),sql)
- dialogmaintainer.load_data1 (gevice,sql)
- dialogmaintainer.show_interface ()
-
- def on_action_location (gevice,action):
- sql_select = "select rack.id_rack,'[' || campus.nom_campus || '][' || edificio.nom_edif || '][' || nivel.nom_nivel || ']',rack.detalle "
- sql_select = sql_select + "from rack inner join nivel on rack.id_nivel = nivel.id_nivel "
- sql_select = sql_select + "inner join edificio on rack.id_edif = edificio.id_edif "
- sql_select = sql_select + "inner join campus on edificio.id_campus = campus.id_campus order by 2;"
-
- sql = {"select":sql_select,
- "update1":"update rack set detalle=",
- "update2":" where id_rack=",
- "delete":"delete from rack where id_rack=",
- "max_id":"select max(id_rack) + 1 from rack;",
- "insert":"insert into rack values ",
- "sql_level":"select nom_nivel,id_nivel from nivel;",
- "sql_edifice":"select '[' || campus.nom_campus || '][' || edificio.nom_edif || ']', edificio.id_edif from edificio inner join campus on edificio.id_campus = campus.id_campus order by campus.nom_campus,edificio.nom_edif "}
-
- dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
- dialogmaintainer.load_interface2 (gevice,_("Locations of devices"),sql)
- dialogmaintainer.load_data1 (gevice,sql)
- dialogmaintainer.show_interface ()
-
- def on_action_edifice (gevice,action):
- sql_select = "select edificio.id_edif, campus.nom_campus, edificio.nom_edif "
- sql_select = sql_select + "from edificio inner join campus on edificio.id_campus = campus.id_campus "
- sql_select = sql_select + "order by 2,3"
-
- sql = {"select":sql_select,
- "update1":"update edificio set nom_edif=",
- "update2":" where id_edif=",
- "delete":"delete from edificio where id_edif=",
- "max_id":"select max(id_edif) + 1 from edificio;",
- "insert":"insert into edificio values ",
- "sql_campus":"select nom_campus, id_campus from campus;"}
-
- dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
- dialogmaintainer.load_interface3 (gevice,_("Edifices of campus"),sql)
- dialogmaintainer.load_data1 (gevice,sql)
- dialogmaintainer.show_interface ()
-
- def on_action_level (gevice,action):
- sql = {"select":"select * from nivel order by 1",
- "insert":"insert into nivel values ",
- "delete":"delete from nivel where id_nivel=",
- "update1":"update nivel set nom_nivel=",
- "update2":" where id_nivel=",
- "max_id":"select max(id_nivel)+1 from nivel;"}
- dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
- dialogmaintainer.load_interface (gevice,_("Level"),sql)
- dialogmaintainer.load_data (gevice,sql)
- dialogmaintainer.show_interface ()
-
- def on_action_campus (gevice,action):
- sql = {"select":"select * from campus order by 1",
- "insert":"insert into campus values ",
- "delete":"delete from campus where id_campus=",
- "update1":"update campus set nom_campus=",
- "update2":" where id_campus=",
- "max_id":"select max(id_campus)+1 from campus;"}
- dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
- dialogmaintainer.load_interface (gevice,_("Campus"),sql)
- dialogmaintainer.load_data (gevice,sql)
- dialogmaintainer.show_interface ()
-
-
- def on_action_mark (gevice,action):
- sql = {"select":"select * from marca order by 1",
- "insert":"insert into marca values ",
- "delete":"delete from marca where id_marca=",
- "update1":"update marca set nom_marca=",
- "update2":" where id_marca=",
- "max_id":"select max(id_marca)+1 from marca;"}
- dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
- dialogmaintainer.load_interface (gevice,_("Mark"),sql)
- dialogmaintainer.load_data (gevice,sql)
- dialogmaintainer.show_interface ()
-
-
- def on_action_typeofdev (gevice,action):
- sql = {"select":"select * from tipo_disp order by 1",
- "insert":"insert into tipo_disp values ",
- "delete":"delete from tipo_disp where id_tipo_disp=",
- "update1":"update tipo_disp set nom_tipo_disp=",
- "update2":" where id_tipo_disp=",
- "max_id":"select max(id_tipo_disp)+1 from tipo_disp;"}
- dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
- dialogmaintainer.load_interface (gevice,_("Type of device"),sql)
- dialogmaintainer.load_data (gevice,sql)
- dialogmaintainer.show_interface ()
-
-
- def on_action_typeoflink (gevice,action):
- sql = {"select":"select * from tipo_enlace order by 1",
- "insert":"insert into tipo_enlace values ",
- "delete":"delete from tipo_enlace where id_tipo_enlace=",
- "update1":"update tipo_enlace set nom_tipo_enlace=",
- "update2":" where id_tipo_enlace=",
- "max_id":"select max(id_tipo_enlace)+1 from tipo_enlace;"}
- dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
- dialogmaintainer.load_interface (gevice,_("Type of link"),sql)
- dialogmaintainer.load_data (gevice,sql)
- dialogmaintainer.show_interface ()
-
-
- def on_action_export (gevice,action):
- dialogexport = geviceexport.GeviceExport ()
- dialogexport.load_interface (gevice)
- dialogexport.save_file (gevice)
+ def __init__ (self):
+ self.list_models = None
+ self.list_links = None
+ self.list_location = None
+ self.connected_to_database = False
+ self.context_id = None
-
- def on_action_refresh (gevice,action):
- gevice.gdbase.cur = gevice.gdbase.conn.cursor()
- gevice.gdbase.load_data_from_database(gevice)
-
-
- def on_delete_event (self,data1=None,data2=None):
- gtk.main_quit()
-
- def on_action_about (self,action):
- self.create_about_dialog()
-
- def on_action_quit (self,action):
- self.on_delete_event ()
-
- def on_action_preferences (gevice,action):
- gevice.gpref.load_preferences(gevice)
- gevice.gpref.load_interface(gevice)
- gevice.gpref.show_interface()
-
- def on_action_find (gevice,action):
- gevice.gevicefind = gevicefind.GeviceFind ()
- gevice.gevicefind.load_interface(gevice)
- gevice.gevicefind.show_interface()
-
- def on_action_diagram (gevice,action):
- i = gevice.gmodel.get_iter_selected(gevice.gmodel.treeview)
-
- #check if the user have selected some device
- if (i["iter"]):
- gevice.gdiagram = gevicediagram.GeviceDiagram ()
- gevice.gdiagram.load_interface (gevice)
- gevice.gdiagram.show_interface ()
- else:
- result = gevice.show_message (_("You need choose some device to generate the diagram."),gtk.MESSAGE_WARNING,gtk.BUTTONS_OK)
-
- def on_action_print (gevice,action):
- gprint = geviceprint.GevicePrint()
- gprint.load_interface(gevice)
- gprint.show_interface()
-
- def on_action_expand (gevice,action):
- gevice.gmodel.expand_treeview (True)
-
- def on_action_decrease (gevice,action):
- gevice.gmodel.expand_treeview (False)
-
- def on_action_adddevice (gevice,action):
- gevice.gdevice = gevicedevice.GeviceDevice ()
- gevice.gdevice.load_interface (gevice)
- gevice.gdevice.add_device()
- gevice.gdevice.show_interface ()
-
- def on_action_removedevice (gevice,action):
- gevice.gdevice = gevicedevice.GeviceDevice ()
- gevice.gdevice.remove_device(gevice)
-
-
- def on_action_editdevice (gevice,action):
- gevice.gdevice = gevicedevice.GeviceDevice ()
- gevice.gdevice.load_interface (gevice)
- gevice.gdevice.modify_device(gevice)
- gevice.gdevice.show_interface ()
-
-
- def on_action_open (gevice,action):
- if (not gevice.connected_to_database):
- gevice.gdbase = gevicedatabase.GeviceDatabase ()
- gevice.gdbase.load_interface (gevice)
- gevice.gdbase.label_host.set_text (gevice.gpref.host)
- gevice.gdbase.label_dbase.set_text (gevice.gpref.dbase)
- gevice.gdbase.label_user_dbase.set_text (gevice.gpref.user_dbase)
-
- gevice.gdbase.show_interface ()
- else:
- gevice.gmodel.treestore.clear()
- gevice.gmodel.treeview.set_model(None)
-
- action_open = gevice.actiongroup_window.get_action("Open")
- action_open.set_property ("stock-id",gtk.STOCK_DISCONNECT)
- action_open.set_property ("tooltip",_("Connect to database"))
- action_open.set_property ("label",_("Connect"))
-
- gevice.actiongroup_window.set_sensitive (True)
- gevice.actiongroup_model.set_sensitive (False)
- gevice.actiongroup_device.set_sensitive (False)
- gevice.connected_to_database = False
-
-
- def on_action_save (gevice,action):
- gevice.gdbase = gevicedatabase.GeviceDatabase ()
-
- gevice.gdbase.load_interface (gevice,"save")
- gevice.gdbase.label_host.set_text (gevice.gpref.host)
- gevice.gdbase.label_dbase.set_text (gevice.gpref.dbase)
- gevice.gdbase.label_user_dbase.set_text (gevice.gpref.user_dbase)
-
- gevice.gdbase.show_interface()
-
- def on_action_connect(self,action):
- flag = True
+ # model for users
+ self.modelusers = gtk.ListStore(gobject.TYPE_STRING)
+
+ # model for devices
+ self.gmodel = gevicemodel.GeviceModel(self)
+
+ # get widgets of main app
+ builder = gtk.Builder()
+ builder.add_from_file(os.path.join (config.UIDIR, "main.xml"))
+
+ self.window_main = builder.get_object ("window_main")
+ self.vbox_main = builder.get_object ("vbox_main")
+ self.hpaned = builder.get_object ("hpaned")
+ self.vboxtreeview = builder.get_object ("vboxtreeview")
+ self.vboxterminal = builder.get_object ("vboxterminal")
+ self.notebook = builder.get_object ("notebook")
+ self.statusbar = builder.get_object ("statusbar")
+
+ self.window_main.set_icon (gtk.gdk.pixbuf_new_from_file(os.path.join (config.ARTDIR,"gevice.png")))
+ self.window_main.set_title(config.PACKAGE)
+ self.window_main.connect ("delete_event",self.on_delete_event)
+
+ self.context_id = self.statusbar.get_context_id("status")
+
+ # create UIManager instance
+ self.uimanager = gtk.UIManager()
+ self.uimanager.add_ui_from_file (os.path.join (config.UIDIR, "menu.xml"))
+
+ # create ActionGroup and add to unimanager
+ self.create_actionsgroups ()
+
+ # add the actiongroup to the uimanager
+ self.uimanager.insert_action_group (self.actiongroup_window,0)
+ self.uimanager.insert_action_group (self.actiongroup_model,0)
+ self.uimanager.insert_action_group (self.actiongroup_device,0)
+
+ # create MenuBar
+ self.menubar = self.uimanager.get_widget ('/MainMenu')
+ self.vbox_main.pack_start (self.menubar,False,False,0)
+
+ # create a Toolbar
+ self.maintoolbar = self.uimanager.get_widget ('/MainToolbar')
+ self.maintoolbar.set_style(gtk.TOOLBAR_ICONS)
+
+ # create horizontal container for toolbar and users combobox
+ self.hbox = gtk.HBox(False,0)
+ self.vbox_main.pack_start (self.hbox,False,False,0)
+
+ # create users combobox
+ self.separator_user = gtk.SeparatorToolItem()
+ self.toolitem_user = gtk.ToolItem()
+ self.maintoolbar.insert(self.toolitem_user,12)
+
+ self.vboxcombo = gtk.VBox(False,0)
+ self.combobox_user = gtk.combo_box_entry_new_with_model(self.modelusers,0)
+ self.vboxcombo.pack_end (self.combobox_user,True,False)
+ self.toolitem_user.add(self.vboxcombo)
+
+ self.hbox.pack_start (self.maintoolbar,True,True)
+
+ # add treeview to vboxtreeview
+ self.scroll = gtk.ScrolledWindow()
+ self.scroll.set_shadow_type("GTK_SHADOW_ETCHED_IN")
+ self.scroll.set_policy("GTK_POLICY_AUTOMATIC","GTK_POLICY_AUTOMATIC")
+ self.scroll.add (self.gmodel.treeview)
+ self.vboxtreeview.add (self.scroll)
+
+ # setting notebook properties
+ self.notebook.set_scrollable (True)
+ self.notebook.set_show_border (False)
+ self.notebook.set_show_tabs (True)
+ self.notebook.set_group_id(1)
+
+ self.hpaned.add2 (self.notebook)
+ # a negative value means that the position is unset.
+ self.hpaned.set_position (-1)
+
+ # load preferences
+ self.gpref = geviceprefer.GevicePrefer(self)
+ self.gpref.load_preferences(self)
+ self.gpref.load_interface (self)
+ self.set_listusers_on_combobox()
+
+ # show all
+ self.window_main.show_all()
+ return
+
+ def create_actionsgroups (self):
+ self.actiongroup_window = gtk.ActionGroup ('Window Actions')
+ self.actiongroup_model = gtk.ActionGroup ('Model Actions')
+ self.actiongroup_device = gtk.ActionGroup ('Device Actions')
+
+ # add the accelerator group to the toplevel window
+ self.accelgroup = self.uimanager.get_accel_group()
+ self.window_main.add_accel_group (self.accelgroup)
+ self.actiongroup_window.add_toggle_actions([('Dual', None, '_Dual', None,_('Dual terminal'), None)])
+
+ # creat actions
+ self.actiongroup_window.add_actions([
+ ('FileMenu', None, _('_File')),
+ ('EditMenu', None, _('_Edit')),
+ ('ViewMenu', None, _('_View')),
+ ('Protocol', None, _('_Protocol')),
+ ('HelpMenu', None, _('_Help')),
+ ('Maintainer', None, _('_Maintainer')),
+ ('ActionsMenu', None, _('_Actions')),
+ ('Open', gtk.STOCK_DISCONNECT, _('Connect'), None, _('Connect to database'), self.on_action_open),
+ ('OpenLocalTerminal', gtk.STOCK_HOME, _('Local'), None, _('Open local terminal'), self.on_action_open_local_terminal),
+ ('Quit', gtk.STOCK_QUIT, _('_Quit'), None, _('Quit the program'), self.on_action_quit),
+ ('Prefer', gtk.STOCK_PREFERENCES, _('Preferences'), None, _('Setting preferences'), self.on_action_preferences),
+ ('About', gtk.STOCK_ABOUT, None, None, None, self.on_action_about),
+ ])
+
+ self.actiongroup_model.add_actions([
+ ('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),
+ ('Refresh', gtk.STOCK_REFRESH, _('Refresh'), None, _('Refresh model'), self.on_action_refresh),
+ ('Export', gtk.STOCK_SELECT_ALL, _('Export to CSV'), None, _('Export to CSV'), self.on_action_export),
+ ])
+
+ self.actiongroup_device.add_actions([
+ ('AddDevice', gtk.STOCK_ADD, _('Add'),None, _('Add a device'), self.on_action_adddevice),
+ ('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),
+ ('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),
+ ('Model', gtk.STOCK_EDIT, _('Model of device'),None, _('Model of device'), self.on_action_model),
+ ('Level', gtk.STOCK_EDIT, _('Levels of locations'),None, _('Levels of locations'), self.on_action_level),
+ ('Campus', gtk.STOCK_EDIT, _('Campus of organization'),None, _('Campus of Organization'), self.on_action_campus),
+ ('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_window.add_toggle_actions([
+ ('Tree', None, _('Tree'),None, _('Show tree'), self.on_toggle_tree, True),
+ ('Terminal', None, _('Terminal'),None, _('Show terminal'), self.on_toggle_terminal, True)
+ ])
+
+ self.actiongroup_window.add_radio_actions([
+ ('ssh', None, _('ssh'),None, _('Use ssh protocol'), 0),
+ ('telnet', None, _('telnet'),None, _('Use telnet protocol'), 1),
+ ('local', None, _('local'),None, _('Open local terminal'), 2),
+ ],0, self.on_action_radio)
+
+ self.actiongroup_window.add_actions([
+ ('Connect', gtk.STOCK_JUMP_TO, _('Connect'), None, _('Connect to'), self.on_action_connect),
+ ])
+
+ self.actiongroup_model.set_sensitive (False)
+ self.actiongroup_window.set_sensitive (True)
+ self.actiongroup_device.set_sensitive (False)
+
+ def set_listusers_on_combobox (self):
+ self.modelusers.clear()
+
+ for user in self.gpref.listusers:
+ self.combobox_user.append_text(user)
+
+ self.combobox_user.set_active (0)
+
+ def main(self):
+ gtk.main()
+
+ def show_message (self,msg,type_msg,buttons):
+ dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL,type_msg,buttons,msg)
+ result = dialog.run()
+ dialog.destroy()
+ return result
+
+ def close_page_of_notebook(self,widget,vpaned):
+ "close page of notebook"
+
+ page = self.notebook.page_num(vpaned)
+ self.notebook.remove_page(page)
+
+ def remove_all_page_of_notebook (self):
+ n = self.notebook.get_n_pages()
+ i = n
+
+ while i >= 0:
+ self.notebook.remove_page(i)
+ i = i - 1
+
+ def connect_to_device (self,local=None):
+ if (self.actiongroup_window.get_action("Dual").get_active()):
+ isdual = True
+ else:
+ isdual = False
+
+ vpaned = gtk.VPaned()
+ vpaned.set_position (-1)
+
+ label = gtk.Label()
+ button_close = self.create_button_with_image ('gtk-close',True)
+ hbox_label = gtk.HBox(False,0)
+ hbox_label.pack_start(label,False,False,1)
+ hbox_label.pack_start(button_close,True,False,0)
+
+ gvte = gevicevte.GeviceVte()
+
+ hbox_term,terminal = gvte.new_terminal (self)
+ vpaned.add1 (hbox_term)
+
+ button_close.connect('clicked',self.close_page_of_notebook,vpaned)
+
+ if local:
+ label.set_text(_("Local"))
+ terminal.fork_command ()
+
+ if isdual:
+ hbox_term2,terminal2 = gvte.new_terminal (self)
+ vpaned.add2 (hbox_term2)
+ terminal2.fork_command ()
+
+ else:
+ i = self.gmodel.get_iter_selected (self.gmodel.treeview)
+
+ if i["iter"]:
+ # get data from device selected
+ data = self.gmodel.get_data_of_device_from_model(self.gmodel.treeview)
+ label.set_text(data[0])
proto = self.get_protocol_selected()
-
- if (proto != "local"):
- flag = False
+ user = self.combobox_user.get_active_text()
+ terminal.fork_command (proto,['bash','-l',user,data[2]],[],config.DEFAULT_TMP)
- self.connect_to_device(flag)
-
- def on_action_open_local_terminal(self,action):
- self.connect_to_device(True)
-
- def on_action_radio(action,current,gevice):
- # get the actionradio selected
- gevice.action_radio = action
-
- def on_toggle_tree (gevice,action):
- if (action.get_active() == True):
- gevice.vboxtreeview.show()
- else:
- gevice.vboxtreeview.hide ()
-
- def on_toggle_terminal (gevice,action):
- if (action.get_active() == True):
- gevice.vboxterminal.show()
- else:
- gevice.vboxterminal.hide ()
-
- def get_ips(self,model,path,iter,pinglist):
- data = model.get(iter,config.COLUMN_NAME_DEV,config.COLUMN_IP_DEV,config.COLUMN_SERIAL_DEV)
- current = geviceping.GevicePing(data[1])
- pinglist.append(current)
- current.start()
-
- def create_about_dialog (self):
- authors = ('Alejandro Valdes Jimenez [avaldes gnome org]','')
- translator_credits = ('Alejandro Valdes Jimenez [avaldes gnome org]')
- logo = gtk.gdk.pixbuf_new_from_file (os.path.join (config.ARTDIR,"gevice.png"))
-
- ad = gtk.AboutDialog()
- ad.set_name(config.PACKAGE)
- ad.set_version(config.VERSION)
- ad.set_authors(authors)
- ad.set_translator_credits(translator_credits)
- ad.set_logo(logo)
-
- ad.connect ("delete-event", self.about_delete)
- ad.connect ("response", self.about_delete)
- ad.show()
-
- def about_delete (self,about,event):
- about.destroy()
- return True
-
-
- def get_protocol_selected (self):
- if (self.actiongroup_window.get_action("ssh").get_active()):
- proto = "ssh"
- elif (self.actiongroup_window.get_action("telnet").get_active()):
- proto = "telnet"
- elif (self.actiongroup_window.get_action("local").get_active()):
- proto = "local"
+ if isdual:
+ hbox_term2,terminal2 = gvte.new_terminal (self)
+ vpaned.add2 (hbox_term2)
+ terminal2.fork_command (proto,['bash','-l',user,data[2]],[],config.DEFAULT_TMP)
- return proto
+ page = self.notebook.append_page(vpaned,hbox_label)
+ self.notebook.set_tab_reorderable(vpaned,True)
+ self.notebook.set_tab_detachable(vpaned,True)
- def update_statusbar (self):
- msg = _("[Host: ") + self.gpref.host + " "
- msg+= _("Database: ") + self.gpref.dbase + " "
- msg+= _("User: ") + self.gpref.user_dbase + "]"
-
- self.statusbar.push (self.context_id,msg)
+ hbox_label.show_all()
+ vpaned.show_all()
+ self.notebook.set_current_page(page)
+
+ def create_button_with_image (self,id_stock,sensitive):
+ "return a button with image, utilized in tool of browser"
+
+ hbox_image = gtk.HBox(False,0)
+ image = gtk.Image()
+ image.set_from_stock(id_stock,'GTK_ICON_SIZE_MENU')
+ hbox_image.pack_start(image,True,False,False)
+
+ button = gtk.Button()
+ button.set_relief('GTK_RELIEF_NONE')
+
+ button.add(hbox_image)
+ button.set_sensitive (sensitive)
+
+ return button
+
+ def on_action_model (gevice,action):
+ sql_select = "select modelo.id_modelo,tipo_disp.nom_tipo_disp || ' ' || marca.nom_marca,modelo.nom_modelo "
+ sql_select = sql_select + "from modelo inner join marca on modelo.id_marca = marca.id_marca inner join tipo_disp "
+ sql_select = sql_select + "on modelo.id_tipo_disp = tipo_disp.id_tipo_disp order by 2;"
+
+ sql = {"select":sql_select,
+ "update1":"update modelo set nom_modelo=",
+ "update2":" where id_modelo=",
+ "delete":"delete from modelo where id_modelo=",
+ "max_id":"select max(id_modelo) + 1 from modelo;",
+ "insert":"insert into modelo values ",
+ "sql_mark":"select nom_marca,id_marca from marca;",
+ "sql_tipo_disp":"select nom_tipo_disp,id_tipo_disp from tipo_disp"}
+
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface1 (gevice,_("Model of device"),sql)
+ dialogmaintainer.load_data1 (gevice,sql)
+ dialogmaintainer.show_interface ()
+
+ def on_action_location (gevice,action):
+ sql_select = "select rack.id_rack,'[' || campus.nom_campus || '][' || edificio.nom_edif || '][' || nivel.nom_nivel || ']',rack.detalle "
+ sql_select = sql_select + "from rack inner join nivel on rack.id_nivel = nivel.id_nivel "
+ sql_select = sql_select + "inner join edificio on rack.id_edif = edificio.id_edif "
+ sql_select = sql_select + "inner join campus on edificio.id_campus = campus.id_campus order by 2;"
+
+ sql = {"select":sql_select,
+ "update1":"update rack set detalle=",
+ "update2":" where id_rack=",
+ "delete":"delete from rack where id_rack=",
+ "max_id":"select max(id_rack) + 1 from rack;",
+ "insert":"insert into rack values ",
+ "sql_level":"select nom_nivel,id_nivel from nivel;",
+ "sql_edifice":"select '[' || campus.nom_campus || '][' || edificio.nom_edif || ']', edificio.id_edif from edificio inner join campus on edificio.id_campus = campus.id_campus order by campus.nom_campus,edificio.nom_edif "}
+
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface2 (gevice,_("Locations of devices"),sql)
+ dialogmaintainer.load_data1 (gevice,sql)
+ dialogmaintainer.show_interface ()
+
+ def on_action_edifice (gevice,action):
+ sql_select = "select edificio.id_edif, campus.nom_campus, edificio.nom_edif "
+ sql_select = sql_select + "from edificio inner join campus on edificio.id_campus = campus.id_campus "
+ sql_select = sql_select + "order by 2,3"
+
+ sql = {"select":sql_select,
+ "update1":"update edificio set nom_edif=",
+ "update2":" where id_edif=",
+ "delete":"delete from edificio where id_edif=",
+ "max_id":"select max(id_edif) + 1 from edificio;",
+ "insert":"insert into edificio values ",
+ "sql_campus":"select nom_campus, id_campus from campus;"}
+
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface3 (gevice,_("Edifices of campus"),sql)
+ dialogmaintainer.load_data1 (gevice,sql)
+ dialogmaintainer.show_interface ()
+
+ def on_action_level (gevice,action):
+ sql = {"select":"select * from nivel order by 1",
+ "insert":"insert into nivel values ",
+ "delete":"delete from nivel where id_nivel=",
+ "update1":"update nivel set nom_nivel=",
+ "update2":" where id_nivel=",
+ "max_id":"select max(id_nivel)+1 from nivel;"}
+
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface (gevice,_("Level"),sql)
+ dialogmaintainer.load_data (gevice,sql)
+ dialogmaintainer.show_interface ()
+
+ def on_action_campus (gevice,action):
+ sql = {"select":"select * from campus order by 1",
+ "insert":"insert into campus values ",
+ "delete":"delete from campus where id_campus=",
+ "update1":"update campus set nom_campus=",
+ "update2":" where id_campus=",
+ "max_id":"select max(id_campus)+1 from campus;"}
+
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface (gevice,_("Campus"),sql)
+ dialogmaintainer.load_data (gevice,sql)
+ dialogmaintainer.show_interface ()
+
+ def on_action_mark (gevice,action):
+ sql = {"select":"select * from marca order by 1",
+ "insert":"insert into marca values ",
+ "delete":"delete from marca where id_marca=",
+ "update1":"update marca set nom_marca=",
+ "update2":" where id_marca=",
+ "max_id":"select max(id_marca)+1 from marca;"}
+
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface (gevice,_("Mark"),sql)
+ dialogmaintainer.load_data (gevice,sql)
+ dialogmaintainer.show_interface ()
+
+ def on_action_typeofdev (gevice,action):
+ sql = {"select":"select * from tipo_disp order by 1",
+ "insert":"insert into tipo_disp values ",
+ "delete":"delete from tipo_disp where id_tipo_disp=",
+ "update1":"update tipo_disp set nom_tipo_disp=",
+ "update2":" where id_tipo_disp=",
+ "max_id":"select max(id_tipo_disp)+1 from tipo_disp;"}
+
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface (gevice,_("Type of device"),sql)
+ dialogmaintainer.load_data (gevice,sql)
+ dialogmaintainer.show_interface ()
+
+ def on_action_typeoflink (gevice,action):
+ sql = {"select":"select * from tipo_enlace order by 1",
+ "insert":"insert into tipo_enlace values ",
+ "delete":"delete from tipo_enlace where id_tipo_enlace=",
+ "update1":"update tipo_enlace set nom_tipo_enlace=",
+ "update2":" where id_tipo_enlace=",
+ "max_id":"select max(id_tipo_enlace)+1 from tipo_enlace;"}
+
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface (gevice,_("Type of link"),sql)
+ dialogmaintainer.load_data (gevice,sql)
+ dialogmaintainer.show_interface ()
+
+ def on_action_export (gevice,action):
+ dialogexport = geviceexport.GeviceExport ()
+ dialogexport.load_interface (gevice)
+ dialogexport.save_file (gevice)
+
+ def on_action_refresh (gevice,action):
+ gevice.gdbase.cur = gevice.gdbase.conn.cursor()
+ gevice.gdbase.load_data_from_database(gevice)
+
+ def on_delete_event (self,data1=None,data2=None):
+ gtk.main_quit()
+
+ def on_action_about (self,action):
+ self.create_about_dialog()
+
+ def on_action_quit (self,action):
+ self.on_delete_event ()
+
+ def on_action_preferences (gevice,action):
+ gevice.gpref.load_preferences(gevice)
+ gevice.gpref.load_interface(gevice)
+ gevice.gpref.show_interface()
+
+ def on_action_find (gevice,action):
+ gevice.gevicefind = gevicefind.GeviceFind ()
+ gevice.gevicefind.load_interface(gevice)
+ gevice.gevicefind.show_interface()
+
+ def on_action_diagram (gevice,action):
+ i = gevice.gmodel.get_iter_selected(gevice.gmodel.treeview)
+
+ #check if the user have selected some device
+ if (i["iter"]):
+ gevice.gdiagram = gevicediagram.GeviceDiagram ()
+ gevice.gdiagram.load_interface (gevice)
+ gevice.gdiagram.show_interface ()
+ else:
+ result = gevice.show_message (_("You need choose some device to generate the diagram."),gtk.MESSAGE_WARNING,gtk.BUTTONS_OK)
+
+ def on_action_print (gevice,action):
+ gprint = geviceprint.GevicePrint()
+ gprint.load_interface(gevice)
+ gprint.show_interface()
+
+ def on_action_expand (gevice,action):
+ gevice.gmodel.expand_treeview (True)
+
+ def on_action_decrease (gevice,action):
+ gevice.gmodel.expand_treeview (False)
+
+ def on_action_adddevice (gevice,action):
+ gevice.gdevice = gevicedevice.GeviceDevice ()
+ gevice.gdevice.load_interface (gevice)
+ gevice.gdevice.add_device()
+ gevice.gdevice.show_interface ()
+
+ def on_action_removedevice (gevice,action):
+ gevice.gdevice = gevicedevice.GeviceDevice ()
+ gevice.gdevice.remove_device(gevice)
+
+ def on_action_editdevice (gevice,action):
+ gevice.gdevice = gevicedevice.GeviceDevice ()
+ gevice.gdevice.load_interface (gevice)
+ gevice.gdevice.modify_device(gevice)
+ gevice.gdevice.show_interface ()
+
+ def on_action_open (gevice,action):
+ if (not gevice.connected_to_database):
+ gevice.gdbase = gevicedatabase.GeviceDatabase ()
+ gevice.gdbase.load_interface (gevice)
+ gevice.gdbase.label_host.set_text (gevice.gpref.host)
+ gevice.gdbase.label_dbase.set_text (gevice.gpref.dbase)
+ gevice.gdbase.label_user_dbase.set_text (gevice.gpref.user_dbase)
+ gevice.gdbase.show_interface ()
+ else:
+ gevice.gmodel.treestore.clear()
+ gevice.gmodel.treeview.set_model(None)
+
+ action_open = gevice.actiongroup_window.get_action("Open")
+ action_open.set_property ("stock-id",gtk.STOCK_DISCONNECT)
+ action_open.set_property ("tooltip",_("Connect to database"))
+ action_open.set_property ("label",_("Connect"))
+
+ gevice.actiongroup_window.set_sensitive (True)
+ gevice.actiongroup_model.set_sensitive (False)
+ gevice.actiongroup_device.set_sensitive (False)
+ gevice.connected_to_database = False
+
+ def on_action_save (gevice,action):
+ gevice.gdbase = gevicedatabase.GeviceDatabase ()
+ gevice.gdbase.load_interface (gevice,"save")
+ gevice.gdbase.label_host.set_text (gevice.gpref.host)
+ gevice.gdbase.label_dbase.set_text (gevice.gpref.dbase)
+ gevice.gdbase.label_user_dbase.set_text (gevice.gpref.user_dbase)
+ gevice.gdbase.show_interface()
+
+ def on_action_connect(self,action):
+ flag = True
+ proto = self.get_protocol_selected()
+
+ if (proto != "local"):
+ flag = False
+ self.connect_to_device(flag)
+
+ def on_action_open_local_terminal(self,action):
+ self.connect_to_device(True)
+
+ def on_action_radio(action,current,gevice):
+ # get the actionradio selected
+ gevice.action_radio = action
+
+ def on_toggle_tree (gevice,action):
+ if (action.get_active() == True):
+ gevice.vboxtreeview.show()
+ else:
+ gevice.vboxtreeview.hide ()
+
+ def on_toggle_terminal (gevice,action):
+ if (action.get_active() == True):
+ gevice.vboxterminal.show()
+ else:
+ gevice.vboxterminal.hide ()
+
+ def get_ips(self,model,path,iter,pinglist):
+ data = model.get(iter,config.COLUMN_NAME_DEV,config.COLUMN_IP_DEV,config.COLUMN_SERIAL_DEV)
+ current = geviceping.GevicePing(data[1])
+ pinglist.append(current)
+ current.start()
+
+ def create_about_dialog (self):
+ authors = ('Alejandro Valdes Jimenez [avaldes gnome org]','')
+ translator_credits = ('Alejandro Valdes Jimenez [avaldes gnome org]')
+ logo = gtk.gdk.pixbuf_new_from_file (os.path.join (config.ARTDIR,"gevice.png"))
+
+ ad = gtk.AboutDialog()
+ ad.set_name(config.PACKAGE)
+ ad.set_version(config.VERSION)
+ ad.set_authors(authors)
+ ad.set_translator_credits(translator_credits)
+ ad.set_logo(logo)
+
+ ad.connect ("delete-event", self.about_delete)
+ ad.connect ("response", self.about_delete)
+ ad.show()
+
+ def about_delete (self,about,event):
+ about.destroy()
+ return True
+
+ def get_protocol_selected (self):
+ if (self.actiongroup_window.get_action("ssh").get_active()):
+ proto = "ssh"
+ elif (self.actiongroup_window.get_action("telnet").get_active()):
+ proto = "telnet"
+ elif (self.actiongroup_window.get_action("local").get_active()):
+ proto = "local"
+
+ return proto
+
+ def update_statusbar (self):
+ msg = _("[Host: ") + self.gpref.host + " "
+ msg+= _("Database: ") + self.gpref.dbase + " "
+ msg+= _("User: ") + self.gpref.user_dbase + "]"
+ self.statusbar.push (self.context_id,msg)
if __name__ == "__main__":
- gnome.init(config.PACKAGE,config.VERSION)
- pynotify.init(config.PACKAGE)
- gevice = Gevice()
- gevice.main()
+ gnome.init(config.PACKAGE,config.VERSION)
+ pynotify.init(config.PACKAGE)
+ gevice = Gevice()
+ gevice.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]