[gevice] now, serial number is verified.



commit ce283871fac6a07b778b77ca0a19eee927b48078
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date:   Wed Dec 30 12:31:48 2009 -0300

    now, serial number is verified.

 ChangeLog           |    8 +++++++
 src/config.py.in    |    8 -------
 src/gevice.py       |   23 +++++++++-----------
 src/gevicedevice.py |   56 +++++++++++++++++++++++++++++++++++++++++----------
 src/gevicevte.py    |   12 +++++++++-
 5 files changed, 73 insertions(+), 34 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4a0307c..77c7e3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-12-30  Alejandro Valdes Jimenez  <avaldes gnome org>
+
+	* src/config.py.in:
+	* src/gevice.py: 
+	* src/gevicedevice.py: now, serial number is verified.
+	* src/gevicevte.py:
+	Fixed bug #605693
+
 2009-11-12  Alejandro Valdes Jimenez  <avaldes gnome org>
 
 	* src/Makefile.am:
diff --git a/src/config.py.in b/src/config.py.in
index 2a6b5a8..cac251c 100644
--- a/src/config.py.in
+++ b/src/config.py.in
@@ -69,11 +69,3 @@ DEFAULT_TMP = "/tmp/"
 # width and high of main window
 DEFAULT_WIDTH = 800
 DEFAULT_HIGH = 600
-
-# printer
-XINI = 25
-YINI = 700
-XLIN = 580
-YLIN_END = 35
-MAX_LINES_FOR_PAGE = 40
-
diff --git a/src/gevice.py b/src/gevice.py
index be0f110..f4360a2 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -39,7 +39,7 @@ import gevicemodel
 import gevicedatabase
 import geviceexport
 import gevicemaintainer
-import geviceping
+#import geviceping
 
 import gettext
 gettext.textdomain(config.PACKAGE)
@@ -277,6 +277,7 @@ class Gevice:
         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)
 
         self.vbox.pack_start (self.vbox_main, False)
@@ -351,21 +352,20 @@ class Gevice:
             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)
-        
-        hbox_term = gtk.HBox(False,0)
-        vpaned.add1 (hbox_term)
-        
+
         gvte = gevicevte.GeviceVte()
-        terminal = gvte.new_terminal (self)
-        scroll = gtk.VScrollbar(terminal.get_adjustment())
-        hbox_term.pack_start(terminal,True,True,0)
+                
+        hbox_term = gtk.HBox(False,0)        
+        terminal,scroll = gvte.new_terminal (self)
         hbox_term.pack_start(scroll,True,True,0)
+        vpaned.add1 (hbox_term)
 
         button_close.connect('clicked',self.close_page_of_notebook,vpaned)
         
@@ -375,11 +375,8 @@ class Gevice:
 
             if isdual:               
                 hbox_term2 = gtk.HBox(False,0) 
-                terminal2 = gvte.new_terminal (self)
-                scroll2 = gtk.VScrollbar(terminal2.get_adjustment())
-                hbox_term2.pack_start(terminal2,True,True,0)
-                hbox_term2.pack_start(scroll2,True,True,0)
-                
+                terminal2,scroll2 = gvte.new_terminal (self)
+                hbox_term2.pack_start(scroll2,True,True,0)                
                 vpaned.add2 (hbox_term2)
                 terminal2.fork_command ()            
         else:
diff --git a/src/gevicedevice.py b/src/gevicedevice.py
index 249462c..75577ad 100644
--- a/src/gevicedevice.py
+++ b/src/gevicedevice.py
@@ -12,6 +12,8 @@ import config
 class GeviceDevice:
     def __init__ (self):
         self.action = "add"
+        self.exists_serial = False
+        self.exists_serial_name = ""
         
         self.window_device = None
         self.entry_name_device = None
@@ -27,7 +29,7 @@ class GeviceDevice:
         self.action = "add"
         
         self.entry_name_device.set_text("")
-        self.entry_ip_device.set_text("")
+        self.entry_ip_device.set_text("127.0.0.1")
         self.entry_serial_device.set_text("")
         self.entry_comment_device.set_text("")
         self.combo_model.set_active(0)
@@ -137,29 +139,61 @@ class GeviceDevice:
     def on_window_device_delete_event (self,window,event):
         self.close_window (window)
 
+    def verify_serial(self,model,path,iter,serial):
+        #print serial
+        data = model.get(
+            iter,
+            config.COLUMN_NAME_DEV,
+            config.COLUMN_ID_MODEL_DEV,
+            config.COLUMN_IP_DEV,
+            config.COLUMN_SERIAL_DEV,
+            config.COLUMN_OBS_DEV,
+            config.COLUMN_ID_TYPE_LINK_DEV)
+        
+        if (serial.strip() == data[3].strip()):
+            self.exists_serial = True
+            self.exists_serial_name = data[0]
+            return
+            
+
     def on_button_accept_device_clicked (self,button,gevice):        
-        name = self.entry_name_device.get_text()
-        ip = self.entry_ip_device.get_text()
+        alldata = True
+        
         serial = self.entry_serial_device.get_text()
+        name = self.entry_name_device.get_text()
+        ip = self.entry_ip_device.get_text()        
         comment = self.entry_comment_device.get_text()
+        
+        if (not name.strip()):
+            alldata = False
+            result = gevice.show_message (_("Enter name of device"),gtk.MESSAGE_ERROR,gtk.BUTTONS_OK)
+        elif (not serial.strip()):
+            alldata = False
+            result = gevice.show_message (_("Enter serial number of device"),gtk.MESSAGE_ERROR,gtk.BUTTONS_OK)
+
+        gevice.gmodel.treestore.foreach(self.verify_serial,serial)
+
+        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)
 
-        iter_model = self.combo_model.get_active_iter()
-        id_model = gevice.list_models.get_value(iter_model,config.COLUMN_ID_MODEL_DEV2)
-        name_model = gevice.list_models.get_value(iter_model,config.COLUMN_NAME_MODEL_DEV2)
+        if alldata:        
+            iter_model = self.combo_model.get_active_iter()
+            id_model = gevice.list_models.get_value(iter_model,config.COLUMN_ID_MODEL_DEV2)
+            name_model = gevice.list_models.get_value(iter_model,config.COLUMN_NAME_MODEL_DEV2)
 
-        iter_type_link = self.combo_link.get_active_iter()
-        id_link = gevice.list_links.get_value(iter_type_link,config.COLUMN_ID_TYPE_LINK_DEV2)
+            iter_type_link = self.combo_link.get_active_iter()
+            id_link = gevice.list_links.get_value(iter_type_link,config.COLUMN_ID_TYPE_LINK_DEV2)
 
-        i = gevice.gmodel.get_iter_selected(gevice.gmodel.treeview)
+            i = gevice.gmodel.get_iter_selected(gevice.gmodel.treeview)
 
-        if name:
             if self.action == "add":
                 newiter = gevice.gmodel.treestore.append(i["iter"])
             else:
                 newiter = i["iter"]
 
             gevice.gmodel.treestore.set (newiter,
-                config.COLUMN_NAME_DEV,name,
+                config.COLUMN_NAME_DEV,name.strip(),
                 config.COLUMN_ID_MODEL_DEV,id_model,
                 config.COLUMN_NAME_MODEL_DEV,name_model,   
                 config.COLUMN_IP_DEV,ip,
diff --git a/src/gevicevte.py b/src/gevicevte.py
index cd47a93..d3e150d 100644
--- a/src/gevicevte.py
+++ b/src/gevicevte.py
@@ -13,11 +13,19 @@ class GeviceVte:
     def __init__ (self):
         pass
 
-    def new_terminal (self,gevice):        
+    def new_terminal (self,gevice):            
         terminal = vte.Terminal()
         terminal.set_mouse_autohide(True)       
         terminal.set_default_colors()
         terminal.set_color_background(gtk.gdk.color_parse(gevice.gpref.backcolor))
         terminal.set_color_foreground(gtk.gdk.color_parse(gevice.gpref.forecolor))
         
-        return terminal
+        #scroll = gtk.ScrolledWindow()
+        #scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        #scroll.add_with_viewport (terminal)
+        
+        scroll = gtk.VScrollbar (terminal.get_adjustment())
+        scroll.show_all()
+        
+       
+        return terminal,scroll



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