[gevice] add mantainer edifices



commit 1ca64171cdb23c0026a932976be4ec95d92df463
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date:   Thu Jul 8 17:52:45 2010 -0400

    add mantainer edifices

 ChangeLog               |    6 +++
 data/glade/gevice.glade |  108 +++++++++++++++++++++++++++++++++++++++++++++++
 src/gevice.py           |   20 +++++++++
 src/gevicemaintainer.py |   85 +++++++++++++++++++++++++++++++++++++
 4 files changed, 219 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 086788e..b940277 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-07-08  Alejandro Valdes Jimenez  <avaldes gnome org>
 
+	* data/glade/gevice.glade: add new window mantainer edifices
+	* src/gevice.py: add mantainer edifices
+	* src/gevicemaintainer.py: add mantainer edifices
+
+2010-07-08  Alejandro Valdes Jimenez  <avaldes gnome org>
+
 	* data/glade/gevice.glade: New mantainer for locations.
 	* src/gevice.py:add mantainer for levels, locations and campus.
 	* src/gevicedatabase.py: add mantainer for levels, locations and campus.
diff --git a/data/glade/gevice.glade b/data/glade/gevice.glade
index 3075fda..072fe66 100644
--- a/data/glade/gevice.glade
+++ b/data/glade/gevice.glade
@@ -1876,4 +1876,112 @@ svg</property>
       </widget>
     </child>
   </widget>
+  <widget class="GtkWindow" id="window_edifice">
+    <property name="title" translatable="yes" context="yes">New Edifice</property>
+    <property name="modal">True</property>
+    <property name="window_position">center</property>
+    <child>
+      <widget class="GtkVBox" id="vbox10">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">5</property>
+        <child>
+          <widget class="GtkTable" id="table5">
+            <property name="visible">True</property>
+            <property name="n_rows">2</property>
+            <property name="n_columns">2</property>
+            <property name="column_spacing">5</property>
+            <property name="row_spacing">2</property>
+            <child>
+              <widget class="GtkComboBox" id="combobox_campus">
+                <property name="visible">True</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkEntry" id="entry_edifice">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="invisible_char">&#x25CF;</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="x_options"></property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label18">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes" context="yes">Campus</property>
+              </widget>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label17">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes" context="yes">Edifice</property>
+              </widget>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkHBox" id="hbox13">
+            <property name="visible">True</property>
+            <child>
+              <widget class="GtkButton" id="button_cancel">
+                <property name="label" context="yes">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="pack_type">end</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkButton" id="button_ok">
+                <property name="label" context="yes">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="pack_type">end</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>
diff --git a/src/gevice.py b/src/gevice.py
index 5729a87..331bb2c 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -79,6 +79,7 @@ UI = '''<ui>
       <menuitem action="Model"/>
       <menuitem action="Level"/>      
       <menuitem action="Campus"/>            
+      <menuitem action="Edifice"/>           
       <menuitem action="Location"/>                  
     </menu>
     <menu action="ActionsMenu">
@@ -203,6 +204,7 @@ class Gevice:
             ('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([
@@ -447,6 +449,24 @@ class Gevice:
         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 ",
diff --git a/src/gevicemaintainer.py b/src/gevicemaintainer.py
index 63098eb..71ac151 100644
--- a/src/gevicemaintainer.py
+++ b/src/gevicemaintainer.py
@@ -18,6 +18,7 @@ class GeviceMaintainer:
         self.list_type = None
         self.list_level = None
         self.list_edifice = None
+        self.list_campus = None
 
     
     def load_interface (self,gevice,title,sql):
@@ -136,6 +137,48 @@ class GeviceMaintainer:
         self.button_close.connect ("clicked",self.on_button_close_clicked,)
         self.button_rem.connect ("clicked",self.on_button_rem_model_clicked,gevice,sql)
         self.button_add.connect ("clicked",self.on_button_add_location_clicked,gevice,sql)        
+        
+    def load_interface3 (self,gevice,title,sql):
+        glade_file = gtk.glade.XML (os.path.join (config.GLADEDIR, "gevice.glade"),"window_maintainer1",None)
+        self.window_maintainer = glade_file.get_widget ("window_maintainer1")
+        self.button_add = glade_file.get_widget ("button_add1")
+        self.button_rem = glade_file.get_widget ("button_rem1")
+        self.button_close = glade_file.get_widget ("button_close1")
+        self.treeview = glade_file.get_widget ("treeview1")        
+        
+        self.window_maintainer.set_title (title)
+
+        self.modelcell = gtk.ListStore(int, gobject.TYPE_STRING)
+        
+        # create columns
+        col = gtk.TreeViewColumn (_("ID"))
+        col.set_resizable (True)
+        self.treeview.append_column (col)
+        cell =  gtk.CellRendererText()
+        cell.set_property('editable',False)
+        col.pack_start (cell,True)
+        col.add_attribute (cell,"text",0)
+        
+        col = gtk.TreeViewColumn (_("Campus"))
+        col.set_resizable (True)
+        self.treeview.append_column (col)
+        cell =  gtk.CellRendererText()
+        cell.set_property('editable',False)
+        col.pack_start (cell,True)
+        col.add_attribute (cell,"text",1)
+
+        col = gtk.TreeViewColumn (_("Edifice"))
+        col.set_resizable (True)
+        self.treeview.append_column (col)
+        cell =  gtk.CellRendererText()
+        cell.set_property('editable',True)
+        cell.connect('edited', self.on_model_edited,gevice,sql)        
+        col.pack_start (cell,True)
+        col.add_attribute (cell,"text",2)
+		
+        self.button_close.connect ("clicked",self.on_button_close_clicked,)
+        self.button_rem.connect ("clicked",self.on_button_rem_model_clicked,gevice,sql)
+        self.button_add.connect ("clicked",self.on_button_add_edifice_clicked,gevice,sql)                
 
 
     def load_interface_model (self,gevice,sql):
@@ -198,6 +241,27 @@ class GeviceMaintainer:
         
         self.window_location.show_all()        
 
+    def load_interface_edifice (self,gevice,sql):
+        glade_file = gtk.glade.XML (os.path.join (config.GLADEDIR, "gevice.glade"),"window_edifice",None)
+        self.window_edifice = glade_file.get_widget ("window_edifice")
+        self.button_ok = glade_file.get_widget ("button_ok")
+        self.button_cancel = glade_file.get_widget ("button_cancel")
+        self.combobox_campus = glade_file.get_widget ("combobox_campus")
+        self.entry_edifice = glade_file.get_widget ("entry_edifice")
+        
+        self.button_cancel.connect ("clicked",self.on_button_edifice_cancel_clicked)
+        self.button_ok.connect ("clicked",self.on_button_edifice_ok_clicked,gevice,sql)
+        
+        self.list_campus = gevice.gdbase.get_list_of_data(gevice,sql["sql_campus"])
+        self.combobox_campus.set_model(self.list_campus)
+        cell = gtk.CellRendererText()
+        self.combobox_campus.pack_start(cell, True)
+        self.combobox_campus.add_attribute(cell, 'text', 0)  
+        
+        self.entry_edifice.set_text("")
+        self.combobox_campus.set_active(0)
+        
+        self.window_edifice.show_all()        
 
     def on_button_model_cancel_clicked (self,button):
         self.close_window (self.window_model)    
@@ -205,6 +269,8 @@ class GeviceMaintainer:
     def on_button_location_cancel_clicked (self,button):
         self.close_window (self.window_location)            
 
+    def on_button_edifice_cancel_clicked (self,button):
+        self.close_window (self.window_edifice)            
 
     def show_interface (self):
     	self.window_maintainer.show_all()
@@ -332,6 +398,9 @@ class GeviceMaintainer:
 
     def on_button_add_location_clicked(self,button,gevice,sql):
         self.load_interface_location(gevice,sql)         
+
+    def on_button_add_edifice_clicked(self,button,gevice,sql):
+        self.load_interface_edifice(gevice,sql)                 
          
     
     def on_button_rem_clicked(self,button,gevice,sql):
@@ -411,3 +480,19 @@ class GeviceMaintainer:
         
             self.load_data1(gevice,sql)
             self.on_button_location_cancel_clicked(None)
+
+    def on_button_edifice_ok_clicked (self,button,gevice,sql):
+        nedifice = self.entry_edifice.get_text()
+        
+        iter_campus = self.combobox_campus.get_active_iter()
+        id_campus = self.list_campus.get_value(iter_campus,1)
+        
+        row = gevice.gdbase.execute_sql_select (gevice,sql["max_id"])
+
+        insert = sql["insert"] + " (" + str(row[0][0]) + "," + str(id_campus) + ",'" + nedifice + "')"
+        
+        if (gevice.gdbase.execute_sql_insert (gevice,insert)):        
+            gevice.gdbase.conn.commit()        
+        
+            self.load_data1(gevice,sql)
+            self.on_button_edifice_cancel_clicked(None)



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