[gevice] add support to conect to VNC, RDP remote desktop.
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gevice] add support to conect to VNC, RDP remote desktop.
- Date: Thu, 6 Oct 2011 03:12:50 +0000 (UTC)
commit ac39dadcdcd8af2b888cce605e14e7fbea1a7a36
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date: Thu Oct 6 00:12:36 2011 -0300
add support to conect to VNC, RDP remote desktop.
ChangeLog | 7 +++
data/ui/menu.xml | 7 +--
src/gevice.py | 119 +++++++++++++++++++++++++++++++++-------------
src/gevicedevice.py | 8 ++--
src/gevicemaintainer.py | 113 ++++++++++++++++++++++----------------------
src/geviceprefer.py | 5 +-
6 files changed, 156 insertions(+), 103 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e0fc02f..535ab36 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-06 Alejandro Valdes Jimenez <avaldes gnome org>
+ * data/ui/menu.xml: replace toolitem (ssh,telnet,local) for combobox)
+ * src/gevice.py: add support to conect to VNC, RDP remote desktop.
+ * src/gevicedevice.py:
+ * src/gevicemaintainer.py:
+ * src/geviceprefer.py:
+
2011-10-04 Alejandro Valdes Jimenez <avaldes gnome org>
* src/gevice.py:
* src/gevicediagram.py: on_button_diagram_generate_clicked(). method is rewritten to read selections.
diff --git a/data/ui/menu.xml b/data/ui/menu.xml
index 9565ecd..d98eb08 100644
--- a/data/ui/menu.xml
+++ b/data/ui/menu.xml
@@ -54,13 +54,10 @@
<toolitem action="Expand" />
<toolitem action="Decrease" />
<separator/>
- <toolitem action="ssh" />
- <toolitem action="telnet" />
- <toolitem action="local" />
- <toolitem action="Connect" />
- <separator/>
<toolitem action="Dual" />
<separator/>
+ <toolitem action="Connect" />
+ <separator/>
<toolitem action="Quit" />
</placeholder>
</toolbar>
diff --git a/src/gevice.py b/src/gevice.py
index b8b7c91..38e8c51 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -32,8 +32,7 @@ import gevicedevice
import gevicemodel
import gevicedatabase
import geviceexport
-#import gevicemaintainer
-
+import gevicemaintainer
import gettext
gettext.textdomain(config.PACKAGE)
@@ -50,6 +49,15 @@ class Gevice:
# model for list of users for SSH session
self.modelusers = Gtk.ListStore(str)
+ # model for protocol
+ self.modelproto = Gtk.ListStore(str)
+ self.modelproto.append (["ssh"])
+ self.modelproto.append (["telnet"])
+ self.modelproto.append (["local"])
+ self.modelproto.append (["vnc"])
+ self.modelproto.append (["rdp"])
+ self.modelproto.append (["xdmcp"])
+
# model for devices
self.gmodel = gevicemodel.GeviceModel(self)
@@ -75,7 +83,7 @@ class Gevice:
self.uimanager = Gtk.UIManager()
self.uimanager.add_ui_from_file (os.path.join (config.UIDIR, "menu.xml"))
- # create ActionGroup and add to unimanager
+ # create ActionGroup
self.create_actionsgroups ()
# add the actiongroup to the uimanager
@@ -95,11 +103,13 @@ class Gevice:
self.hbox = Gtk.HBox(homogeneous=False, spacing=0)
self.vbox_main.pack_start (self.hbox,False,False,0)
- # create users combobox for SSH session
- self.separator_user = Gtk.SeparatorToolItem()
+ # create toolitem for combobox for SSH user session
+ separator_user = Gtk.SeparatorToolItem()
self.toolitem_user = Gtk.ToolItem()
+ self.maintoolbar.insert(separator_user,11)
self.maintoolbar.insert(self.toolitem_user,12)
+ # create combobox_user
self.vboxcombo = Gtk.VBox(homogeneous=False,spacing=0)
self.combobox_user = Gtk.ComboBox(model=self.modelusers,has_entry=False)
self.vboxcombo.pack_end (self.combobox_user,True,False,0)
@@ -109,6 +119,24 @@ class Gevice:
self.combobox_user.pack_start(cell, True)
self.combobox_user.add_attribute(cell, "text", 0)
+ # create toolitem for combobox protocol
+ separator_user = Gtk.SeparatorToolItem()
+ self.toolitem_proto = Gtk.ToolItem()
+ self.maintoolbar.insert(separator_user,13)
+ self.maintoolbar.insert(self.toolitem_proto,14)
+
+
+ # create combobox_proto
+ self.vboxproto = Gtk.VBox(homogeneous=False,spacing=0)
+ self.combobox_proto = Gtk.ComboBox(model=self.modelproto,has_entry=False)
+ self.vboxproto.pack_end (self.combobox_proto,True,False,0)
+ self.toolitem_proto.add(self.vboxproto)
+ self.combobox_proto.set_active(0)
+
+ cell = Gtk.CellRendererText()
+ self.combobox_proto.pack_start(cell, True)
+ self.combobox_proto.add_attribute(cell, "text", 0)
+
self.hbox.pack_start (self.maintoolbar,True,True,0)
# add treeview to vboxtreeview
@@ -143,7 +171,7 @@ class Gevice:
# 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', Gtk.STOCK_ADD, '_Dual', None,_('Dual terminal'), None)])
+ self.actiongroup_window.add_toggle_actions([('Dual', Gtk.STOCK_NETWORK, '_Dual', None,_('Dual terminal'), None)])
# creat actions
self.actiongroup_window.add_actions([
@@ -165,7 +193,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),
('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),
+ ('Export', Gtk.STOCK_SELECT_ALL, _('Export all to CSV'), None, _('Export all to CSV'), self.on_action_export),
])
self.actiongroup_device.add_actions([
@@ -190,14 +218,14 @@ class Gevice:
('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', Gtk.STOCK_ADD, _('telnet'),None, _('Use telnet protocol'), 1),
- ('local', Gtk.STOCK_ADD, _('local'),None, _('Open local terminal'), 2),
- ],0, self.on_action_radio)
+ #self.actiongroup_window.add_radio_actions([
+ #('ssh', None, _('ssh'),None, _('Use ssh protocol'), 0),
+ #('telnet', Gtk.STOCK_ADD, _('telnet'),None, _('Use telnet protocol'), 1),
+ #('local', Gtk.STOCK_ADD, _('local'),None, _('Open local terminal'), 2),
+ #],0, self.on_action_radio)
self.actiongroup_window.add_actions([
- ('Connect', Gtk.STOCK_NETWORK, _('Open terminal'), None, _('Open terminal'), self.on_action_connect),
+ ('Connect', Gtk.STOCK_JUMP_TO, _('Open terminal'), None, _('Open terminal'), self.on_action_connect),
])
self.actiongroup_model.set_sensitive (False)
@@ -265,8 +293,9 @@ class Gevice:
button_close.connect('clicked',self.close_page_of_notebook,vpaned)
+
+
if local:
-
label.set_text(_("Local"))
terminal.fork_command_full (Vte.PtyFlags.DEFAULT, None, [Vte.get_user_shell()], None, GLib.SpawnFlags.SEARCH_PATH, None, None)
@@ -274,18 +303,45 @@ class Gevice:
hbox_term2,terminal2 = gvte.new_terminal (self)
vpaned.add2 (hbox_term2)
terminal2.fork_command_full (Vte.PtyFlags.DEFAULT, None, [Vte.get_user_shell()], None, GLib.SpawnFlags.SEARCH_PATH, None, None)
+
else:
i = self.gmodel.get_iter_selected (self.gmodel.treeview)
+
if i["iter"]:
# get data from device selected (devicename, IP)
data = self.gmodel.get_data_of_device_from_model(self.gmodel.treeview)
- label.set_text(data[0])
- proto = self.get_protocol_selected()
+ label.set_text(data[0])
# get name of user selected (for ssh session)
model_user = self.combobox_user.get_model()
iter_user = self.combobox_user.get_active_iter()
user = model_user.get(iter_user,0)
+
+ proto = self.get_protocol_selected()
+ if (proto == "rdp"):
+ cmd = "rdesktop "
+ cmd += "-T'" + data[2] + "' "
+ cmd += "-u" + user[0]
+ cmd += " -g800x600 "
+ cmd += "-rsound:local "
+ cmd += "-rclipboard:PRIMARYCLIPBOARD "
+ cmd += "-b -4 "
+ cmd += data[2]
+ cmd += " &"
+
+ os.system(cmd)
+ return
+
+ if (proto == "vnc"):
+ cmd = "vncviewer "
+ cmd += "-geometry 800x600 "
+ cmd += "-Xdialog "
+ cmd += data[2]
+ cmd += ":1 "
+ cmd += " &"
+
+ os.system(cmd)
+ return
terminal.fork_command_full (Vte.PtyFlags.DEFAULT, None, [proto,'-l',user[0],data[2]], [], GLib.SpawnFlags.SEARCH_PATH, None, None)
@@ -317,7 +373,7 @@ class Gevice:
return button
- def on_action_model (gevice,action):
+ def on_action_model (gevice,action,data):
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;"
@@ -336,7 +392,7 @@ class Gevice:
dialogmaintainer.load_data1 (gevice,sql)
dialogmaintainer.show_interface ()
- def on_action_location (gevice,action):
+ def on_action_location (gevice,action,data):
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 "
@@ -356,7 +412,7 @@ class Gevice:
dialogmaintainer.load_data1 (gevice,sql)
dialogmaintainer.show_interface ()
- def on_action_edifice (gevice,action):
+ def on_action_edifice (gevice,action,data):
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"
@@ -374,7 +430,7 @@ class Gevice:
dialogmaintainer.load_data1 (gevice,sql)
dialogmaintainer.show_interface ()
- def on_action_level (gevice,action):
+ def on_action_level (gevice,action,data):
sql = {"select":"select * from nivel order by 1",
"insert":"insert into nivel values ",
"delete":"delete from nivel where id_nivel=",
@@ -387,7 +443,7 @@ class Gevice:
dialogmaintainer.load_data (gevice,sql)
dialogmaintainer.show_interface ()
- def on_action_campus (gevice,action):
+ def on_action_campus (gevice,action,data):
sql = {"select":"select * from campus order by 1",
"insert":"insert into campus values ",
"delete":"delete from campus where id_campus=",
@@ -400,7 +456,7 @@ class Gevice:
dialogmaintainer.load_data (gevice,sql)
dialogmaintainer.show_interface ()
- def on_action_mark (gevice,action):
+ def on_action_mark (gevice,action,data):
sql = {"select":"select * from marca order by 1",
"insert":"insert into marca values ",
"delete":"delete from marca where id_marca=",
@@ -413,7 +469,7 @@ class Gevice:
dialogmaintainer.load_data (gevice,sql)
dialogmaintainer.show_interface ()
- def on_action_typeofdev (gevice,action):
+ def on_action_typeofdev (gevice,action,data):
sql = {"select":"select * from tipo_disp order by 1",
"insert":"insert into tipo_disp values ",
"delete":"delete from tipo_disp where id_tipo_disp=",
@@ -426,7 +482,7 @@ class Gevice:
dialogmaintainer.load_data (gevice,sql)
dialogmaintainer.show_interface ()
- def on_action_typeoflink (gevice,action):
+ def on_action_typeoflink (gevice,action,data):
sql = {"select":"select * from tipo_enlace order by 1",
"insert":"insert into tipo_enlace values ",
"delete":"delete from tipo_enlace where id_tipo_enlace=",
@@ -543,9 +599,8 @@ class Gevice:
def on_action_open_local_terminal(self,action):
self.connect_to_device(True)
- def on_action_radio(gevice,action,current,data):
- # get the actionradio selected
- gevice.action_radio = action
+ #def on_action_radio(gevice,action,current,data):
+ #gevice.action_radio = action
def on_toggle_tree (gevice,action,data):
if (action.get_active() == True):
@@ -585,13 +640,9 @@ class Gevice:
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"
+ def get_protocol_selected (self):
+ iter = self.combobox_proto.get_active_iter()
+ proto = self.modelproto.get_value(iter,0)
return proto
diff --git a/src/gevicedevice.py b/src/gevicedevice.py
index 09c59ba..1587fad 100644
--- a/src/gevicedevice.py
+++ b/src/gevicedevice.py
@@ -171,7 +171,6 @@ class GeviceDevice:
self.close_window (window)
def verify_serial(self,model,path,iter,serial):
- #print serial
data = model.get(
iter,
config.COLUMN_NAME_DEV,
@@ -198,17 +197,18 @@ class GeviceDevice:
if (not name.strip()):
alldata = False
- result = gevice.show_message (_("Enter name of device"),Gtk.MESSAGE_ERROR,Gtk.BUTTONS_OK,None)
+ result = gevice.show_message (_("Enter name of device"),None,(Gtk.STOCK_OK, Gtk.ResponseType.OK),self.window_device)
elif (not serial.strip()):
alldata = False
- result = gevice.show_message (_("Enter serial number of device"),Gtk.MESSAGE_ERROR,Gtk.BUTTONS_OK,None)
+ result = gevice.show_message (_("Enter serial number of device"),None,(Gtk.STOCK_OK, Gtk.ResponseType.OK),self.window_device)
gevice.gmodel.treestore.foreach(self.verify_serial,serial)
if self.action == "add":
if (self.exists_serial):
alldata = False
- result = gevice.show_message (_("Serial number exist, view device: " + self.exists_serial_name),Gtk.MESSAGE_ERROR,Gtk.BUTTONS_OK,None)
+ result = gevice.show_message (_("Serial number exist, view device: " + self.exists_serial_name),None,(Gtk.STOCK_OK, Gtk.ResponseType.OK),self.window_device)
+
if alldata:
iter_model = self.combo_model.get_active_iter()
diff --git a/src/gevicemaintainer.py b/src/gevicemaintainer.py
index 2360178..aa13c66 100644
--- a/src/gevicemaintainer.py
+++ b/src/gevicemaintainer.py
@@ -1,8 +1,7 @@
-import pygtk
-pygtk.require('2.0')
-import gtk
+from gi.repository import Gtk
+
import os
-import gobject
+#import gobject
import psycopg2
import config
@@ -21,7 +20,7 @@ class GeviceMaintainer:
def load_interface (self,gevice,title,sql):
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(os.path.join (config.UIDIR, "maintainer.xml"))
self.window_maintainer = builder.get_object ("window_maintainer")
@@ -34,18 +33,18 @@ class GeviceMaintainer:
self.window_maintainer.set_title (title)
# create columns
- col = gtk.TreeViewColumn (_("ID"))
+ col = Gtk.TreeViewColumn (_("ID"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',False)
col.pack_start (cell,True)
col.add_attribute (cell,"text",0)
- col = gtk.TreeViewColumn (_("Name"))
+ col = Gtk.TreeViewColumn (_("Name"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',True)
cell.connect('edited', self.on_name_edited,gevice,sql)
col.pack_start (cell,True)
@@ -56,7 +55,7 @@ class GeviceMaintainer:
self.button_rem.connect ("clicked",self.on_button_rem_clicked,gevice,sql)
def load_interface1 (self,gevice,title,sql):
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(os.path.join (config.UIDIR, "maintainer1.xml"))
self.window_maintainer = builder.get_object ("window_maintainer1")
@@ -67,29 +66,29 @@ class GeviceMaintainer:
self.window_maintainer.set_title (title)
- self.modelcell = gtk.ListStore(int, gobject.TYPE_STRING)
+ self.modelcell = Gtk.ListStore(int,str)
# create columns
- col = gtk.TreeViewColumn (_("ID"))
+ col = Gtk.TreeViewColumn (_("ID"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',False)
col.pack_start (cell,True)
col.add_attribute (cell,"text",0)
- col = gtk.TreeViewColumn (_("Device"))
+ col = Gtk.TreeViewColumn (_("Device"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',False)
col.pack_start (cell,True)
col.add_attribute (cell,"text",1)
- col = gtk.TreeViewColumn (_("Model"))
+ col = Gtk.TreeViewColumn (_("Model"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',True)
cell.connect('edited', self.on_model_edited,gevice,sql)
col.pack_start (cell,True)
@@ -100,7 +99,7 @@ class GeviceMaintainer:
self.button_add.connect ("clicked",self.on_button_add_model_clicked,gevice,sql)
def load_interface2 (self,gevice,title,sql):
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(os.path.join (config.UIDIR, "maintainer1.xml"))
self.window_maintainer = builder.get_object ("window_maintainer1")
@@ -111,29 +110,29 @@ class GeviceMaintainer:
self.window_maintainer.set_title (title)
- self.modelcell = gtk.ListStore(int, gobject.TYPE_STRING)
+ self.modelcell = Gtk.ListStore(int,str)
# create columns
- col = gtk.TreeViewColumn (_("ID"))
+ col = Gtk.TreeViewColumn (_("ID"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',False)
col.pack_start (cell,True)
col.add_attribute (cell,"text",0)
- col = gtk.TreeViewColumn (_("Edifice"))
+ col = Gtk.TreeViewColumn (_("Edifice"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',False)
col.pack_start (cell,True)
col.add_attribute (cell,"text",1)
- col = gtk.TreeViewColumn (_("Location"))
+ col = Gtk.TreeViewColumn (_("Location"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',True)
cell.connect('edited', self.on_model_edited,gevice,sql)
col.pack_start (cell,True)
@@ -144,7 +143,7 @@ class GeviceMaintainer:
self.button_add.connect ("clicked",self.on_button_add_location_clicked,gevice,sql)
def load_interface3 (self,gevice,title,sql):
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(os.path.join (config.UIDIR, "maintainer1.xml"))
self.window_maintainer = builder.get_object ("window_maintainer1")
@@ -155,29 +154,29 @@ class GeviceMaintainer:
self.window_maintainer.set_title (title)
- self.modelcell = gtk.ListStore(int, gobject.TYPE_STRING)
+ self.modelcell = Gtk.ListStore(int,str)
# create columns
- col = gtk.TreeViewColumn (_("ID"))
+ col = Gtk.TreeViewColumn (_("ID"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',False)
col.pack_start (cell,True)
col.add_attribute (cell,"text",0)
- col = gtk.TreeViewColumn (_("Campus"))
+ col = Gtk.TreeViewColumn (_("Campus"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',False)
col.pack_start (cell,True)
col.add_attribute (cell,"text",1)
- col = gtk.TreeViewColumn (_("Edifice"))
+ col = Gtk.TreeViewColumn (_("Edifice"))
col.set_resizable (True)
self.treeview.append_column (col)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property('editable',True)
cell.connect('edited', self.on_model_edited,gevice,sql)
col.pack_start (cell,True)
@@ -188,7 +187,7 @@ class GeviceMaintainer:
self.button_add.connect ("clicked",self.on_button_add_edifice_clicked,gevice,sql)
def load_interface_model (self,gevice,sql):
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(os.path.join (config.UIDIR, "model.xml"))
self.window_model = builder.get_object ("window_model")
@@ -203,13 +202,13 @@ class GeviceMaintainer:
self.list_type = gevice.gdbase.get_list_of_data(gevice,sql["sql_tipo_disp"])
self.combobox_type.set_model(self.list_type)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
self.combobox_type.pack_start(cell, True)
self.combobox_type.add_attribute(cell, 'text', 0)
self.list_mark = gevice.gdbase.get_list_of_data(gevice,sql["sql_mark"])
self.combobox_mark.set_model (self.list_mark)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
self.combobox_mark.pack_start(cell, True)
self.combobox_mark.add_attribute(cell, 'text', 0)
@@ -220,7 +219,7 @@ class GeviceMaintainer:
self.window_model.show_all()
def load_interface_location (self,gevice,sql):
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(os.path.join (config.UIDIR, "location.xml"))
self.window_location = builder.get_object ("window_location")
@@ -235,13 +234,13 @@ class GeviceMaintainer:
self.list_level = gevice.gdbase.get_list_of_data(gevice,sql["sql_level"])
self.combobox_level.set_model(self.list_level)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
self.combobox_level.pack_start(cell, True)
self.combobox_level.add_attribute(cell, 'text', 0)
self.list_edifice = gevice.gdbase.get_list_of_data(gevice,sql["sql_edifice"])
self.combobox_edifice.set_model (self.list_edifice)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
self.combobox_edifice.pack_start(cell, True)
self.combobox_edifice.add_attribute(cell, 'text', 0)
@@ -252,7 +251,7 @@ class GeviceMaintainer:
self.window_location.show_all()
def load_interface_edifice (self,gevice,sql):
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(os.path.join (config.UIDIR, "edifice.xml"))
self.window_edifice = builder.get_object ("window_edifice")
@@ -266,7 +265,7 @@ class GeviceMaintainer:
self.list_campus = gevice.gdbase.get_list_of_data(gevice,sql["sql_campus"])
self.combobox_campus.set_model(self.list_campus)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
self.combobox_campus.pack_start(cell, True)
self.combobox_campus.add_attribute(cell, 'text', 0)
@@ -289,9 +288,7 @@ class GeviceMaintainer:
def load_data (self,gevice,sql):
- liststore = gtk.ListStore(
- gobject.TYPE_INT,
- gobject.TYPE_STRING)
+ liststore = Gtk.ListStore(int,str)
self.treeview.set_model (None)
self.treeview.set_model (liststore)
@@ -301,17 +298,12 @@ class GeviceMaintainer:
if rows:
for row in rows:
iter = liststore.append ()
- liststore.set (
- iter,
- 0,row[0],
- 1,row[1])
+ liststore.set_value (iter,0,int(row[0]))
+ liststore.set_value (iter,1,str(row[1]))
def load_data1 (self,gevice,sql):
- liststore = gtk.ListStore(
- gobject.TYPE_INT,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING)
+ liststore = Gtk.ListStore(int,str,str)
self.treeview.set_model (None)
self.treeview.set_model (liststore)
@@ -357,7 +349,9 @@ class GeviceMaintainer:
else:
#show error message and delete the row.
- result = gevice.show_message (_("Name exist: ") + newname,gtk.MESSAGE_INFO,gtk.BUTTONS_OK)
+ #result = gevice.show_message (_("Name exist: ") + newname,Gtk.MESSAGE_INFO,Gtk.BUTTONS_OK)
+ print self
+ result = gevice.show_message (_("Name exist: ") + newname,None,(Gtk.STOCK_OK, Gtk.ResponseType.OK),None)
def is_newname_in_list(self,model,path,iter,newname):
@@ -423,9 +417,11 @@ class GeviceMaintainer:
delete = sql["delete"] + str(id)
- result = gevice.show_message (_("Do you want to remove: ") + name,gtk.MESSAGE_QUESTION,gtk.BUTTONS_YES_NO)
+ #result = gevice.show_message (_("Do you want to remove: ") + name,Gtk.MESSAGE_QUESTION,Gtk.BUTTONS_YES_NO)
+ result = gevice.show_message (_("Do you want to remove: ") + name,
+ None,(Gtk.STOCK_YES, Gtk.ResponseType.YES, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL),None)
- if result == gtk.RESPONSE_YES:
+ if result == Gtk.RESPONSE_YES:
if (gevice.gdbase.execute_sql_delete (gevice,delete)):
model.remove(iter)
@@ -443,9 +439,12 @@ class GeviceMaintainer:
delete = sql["delete"] + str(id)
- result = gevice.show_message (_("Do you want to remove: ") + name,gtk.MESSAGE_QUESTION,gtk.BUTTONS_YES_NO)
+ #result = gevice.show_message (_("Do you want to remove: ") + name,Gtk.MESSAGE_QUESTION,Gtk.BUTTONS_YES_NO)
+ result = gevice.show_message (_("Do you want to remove: ") + name,
+ None,(Gtk.STOCK_YES, Gtk.ResponseType.YES, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL),None)
+
- if result == gtk.RESPONSE_YES:
+ if result == Gtk.RESPONSE_YES:
if (gevice.gdbase.execute_sql_delete (gevice,delete)):
model.remove(iter)
diff --git a/src/geviceprefer.py b/src/geviceprefer.py
index f08dc24..07fe19a 100644
--- a/src/geviceprefer.py
+++ b/src/geviceprefer.py
@@ -136,7 +136,7 @@ class GevicePrefer:
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))
+ 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):
@@ -173,8 +173,7 @@ class GevicePrefer:
name = model.get(iter,0)[0]
result = gevice.show_message (_("Do you want to remove: ") + name,
- None,
- (Gtk.STOCK_YES, Gtk.ResponseType.YES, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
+ None, (Gtk.STOCK_YES, Gtk.ResponseType.YES, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL),self.window_prefer)
if result == Gtk.ResponseType.YES:
model.remove(iter)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]