Commits

Santiago Payà Miralta committed 9edf825

First steps in drop schema, levels and types.

Comments (0)

Files changed (5)

control/genet_browser.py

     """
     st = "SELECT description, id FROM gn____levels;"
     return db.query(st).getresult()
+
+def listNodeTypes():
+    """
+    List node type from db.
+
+    @returns list the node types
+    """
+    st = "SELECT description, id FROM gn____node_types;"
+    return db.query(st).getresult()
+
+def listEdgeTypes():
+    """
+    List node type from db.
+
+    @returns list the node types
+    """
+    st = "SELECT description, id FROM gn____edge_types;"
+    return db.query(st).getresult()

control/genet_creator.py

     level = db.query(st).getresult()[0][0]
     tag_level = genet_global.tagName(level)
     
-    # This should not be necessary.
+    # Create the layer tables.
+    ret = db_schema.createLevelTables(tag_level)
+    return ret
+
+def dropLevel(level):
+    """
+    @param level id to delete.
+    """
+    # Drop the layer tables.
+    tag_level = genet_global.tagName(level)
     ret = db_schema.dropLevelTables(tag_level)
+    
+    # Drop all type tables in the level.
+    # Edges.
+    st = "SELECT id " \
+        "FROM gn____edge_types " \
+        "WHERE level = " + level + ";"
+    ids = db.query(st).getresult()[0]
+    for i in ids:
+        dropEdgeType(i)        
 
-    # Create the layer tables.
-    ret = ret, db_schema.createLevelTables(tag_level)
+    # Nodes.
+    st = "SELECT id " \
+        "FROM gn____node_types " \
+        "WHERE level = " + level + ";"
+    ids = db.query(st).getresult()[0]
+    for i in ids:
+        dropNodeType(i)        
+
+    # Delete entry into the levels table.
+    st = "DELETE FROM gn____levels " \
+        "WHERE id = " + level + ";"
+    ret = ret, db.query(st)
     return ret
 
 def createEdgeType(level, description):
     ret = ret, db_schema.createEdgeTypeTable(tag_level, tablename)
     
     return ret
+
+def dropEdgeType(id):
+    """
+    @param id the type id into the table.
+    """
+    st = "SELECT tablename " \
+        "FROM gn____edge_types " \
+        "WHERE id = " + id + ";"
+    tablename = db.query(st).getresult()[0][0]
+
+    # Drop the table.
+    st = "DROP TABLE IF EXISTS " + tablename + " CASCADE;"
+    ret = db.query(st)
+
+    # Delete entry into the types table.
+    st = "DELETE FROM gn____edge_types " \
+        "WHERE id = " + level + ";"
+    ret = ret, db.query(st)
+
+    return ret
     
 def createNodeType(level, description):
     """
     
     return ret
     
+def dropNodeType(id):
+    """
+    @param id the type id into the table.
+    """
+    st = "SELECT tablename " \
+        "FROM gn____node_types " \
+        "WHERE id = " + id + ";"
+    tablename = db.query(st).getresult()[0][0]
+
+    # Drop the table.
+    st = "DROP TABLE IF EXISTS " + tablename + " CASCADE;"
+    ret = db.query(st)
+
+    # Delete entry into the types table.
+    st = "DELETE FROM gn____node_types " \
+        "WHERE id = " + level + ";"
+    ret = ret, db.query(st)
+
+    return ret
+
 def connectNodes(level, idnA, idnB):
     """
     TODO

model/db_schema.py

         ADD CONSTRAINT "gn____node_types_level" 
         FOREIGN KEY ("level")
         REFERENCES "gn____levels"("id") 
-        ON UPDATE RESTRICT ON DELETE RESTRICT;
+        ON UPDATE CASCADE ON DELETE CASCADE;
     
     CREATE TABLE "gn____edge_types" (
         "id" integer NOT NULL DEFAULT nextval('gn____aux_seq'),
         ADD CONSTRAINT "gn____edge_types_level" 
         FOREIGN KEY ("level")
         REFERENCES "gn____levels"("id") 
-        ON UPDATE RESTRICT ON DELETE RESTRICT;
+        ON UPDATE CASCADE ON DELETE CASCADE;
     """
     ret = ret, st, db.query(st)
 
                   <placeholder/>
                 </child>
                 <child>
-                  <widget class="GtkButton" id="button_connect_nodes">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Connect</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_connect_nodes_clicked"/>
-                  </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>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="label_browser_level">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">Level</property>
-                  </widget>
-                </child>
-                <child>
-                  <widget class="GtkComboBoxEntry" id="comboboxentry_browser_level">
+                  <widget class="GtkComboBoxEntry" id="comboboxentry_browser_nB">
                     <property name="visible">True</property>
                     <child internal-child="entry">
-                      <widget class="GtkEntry" id="comboboxentry-entry6">
+                      <widget class="GtkEntry" id="comboboxentry-entry4">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                       </widget>
                     </child>
                   </widget>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
                   </packing>
                 </child>
                 <child>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkComboBoxEntry" id="comboboxentry_browser_nB">
+                  <widget class="GtkComboBoxEntry" id="comboboxentry_browser_level">
                     <property name="visible">True</property>
                     <child internal-child="entry">
-                      <widget class="GtkEntry" id="comboboxentry-entry4">
+                      <widget class="GtkEntry" id="comboboxentry-entry6">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                       </widget>
                     </child>
                   </widget>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label_browser_level">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Level</property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_connect_nodes">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Connect</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_connect_nodes_clicked"/>
+                  </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>
                   </packing>
                 <property name="n_rows">5</property>
                 <property name="n_columns">5</property>
                 <child>
-                  <widget class="GtkButton" id="button_create_node">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Create</property>
-                    <property name="response_id">0</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">3</property>
-                    <property name="right_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_node_type">
-                    <property name="visible">True</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_level">
-                    <property name="visible">True</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="label_creator_node">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">Node</property>
-                  </widget>
-                </child>
-                <child>
                   <placeholder/>
                 </child>
                 <child>
                 <child>
                   <placeholder/>
                 </child>
+                <child>
+                  <widget class="GtkLabel" id="label_creator_node">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Node</property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_node_level">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_node_type">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_create_node">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Create</property>
+                    <property name="response_id">0</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                  </packing>
+                </child>
               </widget>
               <packing>
                 <property name="position">1</property>
               <widget class="GtkTable" id="table_creator">
                 <property name="visible">True</property>
                 <property name="n_rows">5</property>
-                <property name="n_columns">6</property>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_levels_types">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="items" translatable="yes"></property>
-                    <signal name="focus" handler="on_combobox_creator_levels_types_focus"/>
-                  </widget>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
+                <property name="n_columns">5</property>
                 <child>
                   <placeholder/>
                 </child>
                   <placeholder/>
                 </child>
                 <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_admin_reset">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Reset</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_admin_reset_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_drop_edge_type">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Delete</property>
-                    <property name="response_id">0</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">5</property>
-                    <property name="right_attach">6</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_drop_node_type">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Delete</property>
-                    <property name="response_id">0</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">5</property>
-                    <property name="right_attach">6</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_edge_types">
-                    <property name="visible">True</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">4</property>
-                    <property name="right_attach">5</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_node_types">
-                    <property name="visible">True</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">4</property>
-                    <property name="right_attach">5</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_creator_edge_types_refresh">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Refresh</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_creator_edge_types_refresh_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">3</property>
-                    <property name="right_attach">4</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_creator_node_types_refresh">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Refresh</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_creator_node_types_refresh_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">3</property>
-                    <property name="right_attach">4</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
                   <widget class="GtkButton" id="button_drop_level">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <signal name="clicked" handler="on_button_drop_level_clicked"/>
                   </widget>
                   <packing>
-                    <property name="left_attach">5</property>
-                    <property name="right_attach">6</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_levels">
-                    <property name="visible">True</property>
-                    <property name="items" translatable="yes"></property>
-                    <signal name="changed" handler="on_combobox_creator_levels_changed"/>
-                  </widget>
-                  <packing>
                     <property name="left_attach">4</property>
                     <property name="right_attach">5</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkButton" id="button_creator_levels_refresh">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Refresh</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_creator_levels_refresh_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">3</property>
-                    <property name="right_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="label_creator_node_type">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">Node type</property>
-                  </widget>
-                  <packing>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_create_node_type">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Create</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_create_node_type_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkEntry" id="entry_creator_node_type">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkEntry" id="entry_creator_edge_type">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_create_edge_type">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Create</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_create_edge_type_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="label_creator_edge_type">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">Edge type</property>
-                  </widget>
-                  <packing>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
                   <widget class="GtkLabel" id="label_creator_level">
                     <property name="visible">True</property>
                     <property name="label" translatable="yes">Level</property>
                     <property name="right_attach">3</property>
                   </packing>
                 </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_levels">
+                    <property name="visible">True</property>
+                    <property name="items" translatable="yes"></property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_edge_types">
+                    <property name="visible">True</property>
+                    <property name="items" translatable="yes"></property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_node_types">
+                    <property name="visible">True</property>
+                    <property name="items" translatable="yes"></property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_admin_refresh">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Refresh</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_admin_refresh_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_levels_types">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="has_focus">True</property>
+                    <property name="is_focus">True</property>
+                    <property name="items" translatable="yes"></property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="entry_creator_node_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_admin_reset">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Reset</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_admin_reset_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">4</property>
+                    <property name="right_attach">5</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label_creator_edge_type">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Edge type</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_create_edge_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Create</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_create_edge_type_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="entry_creator_edge_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_create_node_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Create</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_create_node_type_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label_creator_node_type">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Node type</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_drop_node_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Delete</property>
+                    <property name="response_id">0</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">4</property>
+                    <property name="right_attach">5</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_drop_edge_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Delete</property>
+                    <property name="response_id">0</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">4</property>
+                    <property name="right_attach">5</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
               </widget>
               <packing>
                 <property name="position">2</property>

view/genet_window.py

 class window:
     def __init__(self):
         """
-        Starting window.
+        The window.
         
         """
         gladefile = "genet.glade"
         windowname = "genet"
         self.wTree = gtk.glade.XML (gladefile,windowname)
         
-        # Add data to combos.
-        # Levels
-        self.button_creator_levels_refresh_clicked(None)
- 
         # Declare dictionary.
         dic = {
             "on_button_connect_nodes_clicked" : 
             self.button_create_level_clicked,
             "on_button_drop_level_clicked" : 
             self.button_drop_level_clicked,
-            "on_combobox_creator_levels_changed" : 
-            self.combobox_creator_levels_changed,
-            "on_button_creator_levels_refresh_clicked" :
-            self.button_creator_levels_refresh_clicked,
             "on_button_create_node_type_clicked" :
             self.button_create_node_type_clicked,
             "on_button_create_edge_type_clicked" :
             self.button_create_edge_type_clicked,
+            "on_button_admin_refresh_clicked" :
+            self.button_admin_refresh_clicked,
             "on_button_admin_reset_clicked" :
             self.button_admin_reset_clicked,
             "on_genet_destroy" : (gtk.main_quit) }
         self.wTree.signal_autoconnect (dic)
         return
 
+    ############################################################################
+    # Browser tab.
+    #
     def button_connect_nodes_clicked(self,widget):
         print 'Clicked!'
         
+    ############################################################################
+    # Creator tab.
+    #
+
+    ############################################################################
+    # Admin tab.
+    #
     def button_create_level_clicked(self,widget):
         description = self.wTree.get_widget("entry_creator_level").get_text()
         genet_creator.createLevel(description)
 
+        # TODO Refresh the combo when touched.    
+        self.refreshCombo("combobox_creator_levels", 'levels')
+        self.refreshCombo("combobox_creator_levels_types", 'levels')
+
     def button_drop_level_clicked(self,widget):
         combo = self.wTree.get_widget("combobox_creator_levels")
         combo_model = combo.get_model()
         combo_index = combo.get_active()
         level = combo_model[combo_index][1]
-        print level
+        genet_creator.dropLevel(level)
 
-    def combobox_creator_levels_changed(self,widget):
-        model = widget.get_model()
-        index = widget.get_active()
-        print model[index][0]
-
-    # TODO Refresh the combo when level added or dropped.    
-    def button_creator_levels_refresh_clicked(self,widget):
-        combo = self.wTree.get_widget("combobox_creator_levels")
-        levels = genet_browser.listLevels()
-        model = gtk.ListStore(str, str)
-        for i in levels:
-            model.append([i[0], i[1]])
-        combo.set_model(model)
-        cell = gtk.CellRendererText()
-        combo.pack_start(cell, True)
+        # TODO Refresh the combo when touched.    
+        self.refreshCombo("combobox_creator_levels", 'levels')
+        self.refreshCombo("combobox_creator_levels_types", 'levels')
 
     def button_create_node_type_clicked(self, widget):
         # Get level
 
         # Create type
         genet_creator.createNodeType(level, description)
+
+        # TODO Refresh the combo when touched.    
+        self.refreshCombo("combobox_creator_node_types", 'node_types')
        
     def button_create_edge_type_clicked(self, widget):
         # Get level
         # Create type
         genet_creator.createEdgeType(level, description)
 
+        # TODO Refresh the combo when touched.    
+        self.refreshCombo("combobox_creator_edge_types", 'edge_types')
+
+    def button_admin_refresh_clicked(self, widget):
+        # TODO Refresh the combo when touched.    
+        self.refreshCombo("combobox_creator_levels", 'levels')
+        self.refreshCombo("combobox_creator_levels_types", 'levels')
+        self.refreshCombo("combobox_creator_node_types", 'node_types')
+        self.refreshCombo("combobox_creator_edge_types", 'edge_types')
+
     def button_admin_reset_clicked(self, widget):
         genet_global.restartDatabase()
- 
+        
+    ############################################################################
+    # Auxiliary functions.
+    #
     def main(self):
         gtk.main()
 
+    def refreshCombo(self, name, function):
+        combo = self.wTree.get_widget(name)
+
+        if function == 'levels':
+            list = genet_browser.listLevels()
+        elif function == 'node_types':
+            list = genet_browser.listNodeTypes()
+        elif function == 'edge_types':
+            list = genet_browser.listEdgeTypes()
+
+        model = gtk.ListStore(str, str)
+        for i in list:
+            model.append([i[0], i[1]])
+        combo.set_model(model)
+        cell = gtk.CellRendererText()
+        combo.pack_start(cell, True)
+
+        combo.set_active(0)
+
 app = window()
 app.main()