]> saetta.ns0.it Git - zakaudit/gui/commitdiff
Bugfixes.
authorAndrea Zagli <azagli@libero.it>
Sun, 15 Aug 2010 09:40:25 +0000 (11:40 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 15 Aug 2010 09:40:25 +0000 (11:40 +0200)
Add select and unselect all fields in table form.

data/audit-gui/gui/audit-gui.gui
src/table.c

index 3f5eec8f1b5de4f691eb2b951f96aeb9b0609fe9..b65e125fbeee22d7523020fd0b022765bd68c25f 100644 (file)
           </packing>
         </child>
         <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow1">
+          <object class="GtkHBox" id="hbox2">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">etched-in</property>
+            <property name="spacing">5</property>
             <child>
-              <object class="GtkTreeView" id="treeview1">
+              <object class="GtkScrolledWindow" id="scrolledwindow1">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="model">lstore_fields</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <property name="shadow_type">etched-in</property>
                 <child>
-                  <object class="GtkTreeViewColumn" id="treeviewcolumn2">
-                    <property name="title">Fields</property>
+                  <object class="GtkTreeView" id="treeview1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="model">lstore_fields</property>
+                    <property name="headers_clickable">False</property>
+                    <property name="search_column">0</property>
                     <child>
-                      <object class="GtkCellRendererText" id="cellrenderertext2"/>
-                      <attributes>
-                        <attribute name="text">1</attribute>
-                      </attributes>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                        <property name="title">Fields</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                          <attributes>
+                            <attribute name="text">1</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                        <property name="title">Under audit</property>
+                        <child>
+                          <object class="GtkCellRendererToggle" id="cellrenderertoggle1"/>
+                          <attributes>
+                            <attribute name="active">2</attribute>
+                          </attributes>
+                        </child>
+                      </object>
                     </child>
                   </object>
                 </child>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVButtonBox" id="vbuttonbox1">
+                <property name="visible">True</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">5</property>
+                <property name="layout_style">spread</property>
                 <child>
-                  <object class="GtkTreeViewColumn" id="treeviewcolumn1">
-                    <property name="title">Under audit</property>
-                    <child>
-                      <object class="GtkCellRendererToggle" id="cellrenderertoggle1"/>
-                      <attributes>
-                        <attribute name="active">2</attribute>
-                      </attributes>
-                    </child>
+                  <object class="GtkButton" id="button11">
+                    <property name="label" translatable="yes">_Select all</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_underline">True</property>
                   </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="button12">
+                    <property name="label" translatable="yes">_Unselect all</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">1</property>
+              </packing>
             </child>
           </object>
           <packing>
index 0b8dd51b48be51d8d2282f1aea8d5cd25d22ccd6..09a67a2c875d3c417e03c29bedf27299be8f1ba0 100644 (file)
@@ -45,6 +45,11 @@ static void fixed_toggled (GtkCellRendererToggle *cell,
 static void table_on_cb_tables_changed (GtkComboBox *widget,
                                         gpointer user_data);
 
+static void table_on_btn_select_all_clicked (GtkButton *button,
+                                    gpointer user_data);
+static void table_on_btn_unselect_all_clicked (GtkButton *button,
+                                    gpointer user_data);
+
 static void table_on_btn_cancel_clicked (GtkButton *button,
                                     gpointer user_data);
 static void table_on_btn_save_clicked (GtkButton *button,
@@ -136,6 +141,11 @@ Table
                           "toggled", G_CALLBACK (fixed_toggled),
                           priv->lstore_fields);
 
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button11"),
+                         "clicked", G_CALLBACK (table_on_btn_select_all_clicked), (gpointer *)a);
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button12"),
+                         "clicked", G_CALLBACK (table_on_btn_unselect_all_clicked), (gpointer *)a);
+
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button5"),
                          "clicked", G_CALLBACK (table_on_btn_cancel_clicked), (gpointer *)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button6"),
@@ -372,11 +382,12 @@ table_save (Table *table)
                        new_id++;
 
                        sql = g_strdup_printf ("INSERT INTO %stables"
-                                              " (id, name)"
-                                              " VALUES (%d, '%s')",
+                                              " (id, name, id_datasources)"
+                                              " VALUES (%d, '%s', %d)",
                                               priv->commons->prefix,
                                               new_id,
-                                              table_name);
+                                              table_name,
+                                              strtol (gtk_label_get_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label8"))), NULL, 10));
                        stmt = gda_sql_parser_parse_string (priv->commons->gdaparser, sql, NULL, NULL);
                }
        else
@@ -419,10 +430,8 @@ table_save (Table *table)
                                                                        if (id_field == 0)
                                                                                {
                                                                                        error = NULL;
-                                                                                       sql = g_strdup_printf ("SELECT COALESCE (MAX (id), 0) FROM %sfields"
-                                                                                                              " WHERE id_tables = %d",
-                                                                                                              priv->commons->prefix,
-                                                                                                              priv->id);
+                                                                                       sql = g_strdup_printf ("SELECT COALESCE (MAX (id), 0) FROM %sfields",
+                                                                                                              priv->commons->prefix);
                                                                                        stmt = gda_sql_parser_parse_string (priv->commons->gdaparser, sql, NULL, NULL);
                                                                                        dm = gda_connection_statement_execute_select (priv->commons->gdacon, stmt, NULL, &error);
                                                                                        if (dm != NULL && gda_data_model_get_n_rows (dm) == 1)
@@ -449,7 +458,7 @@ table_save (Table *table)
                                                                                        gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error);
                                                                                        if (error != NULL)
                                                                                                {
-                                                                                                       g_warning ("Error save new field: %s",
+                                                                                                       g_warning ("Error saving new field: %s",
                                                                                                                   (error->message != NULL ? error->message : "No details."));
                                                                                                }
                                                                                        g_object_unref (stmt);
@@ -459,26 +468,23 @@ table_save (Table *table)
                                                } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->lstore_fields), &iter));
                                }
 
-                       if (g_strcmp0 (id_saved, "") != 0)
+                       /* removing fields not saved */
+                       error = NULL;
+                       id_saved[strlen (id_saved) - 1] = '\0';
+                       sql = g_strdup_printf ("DELETE FROM %sfields"
+                                                      " WHERE id_tables = %d"
+                                                      "%s",
+                                                      priv->commons->prefix,
+                                                      priv->id,
+                                                      (g_strcmp0 (id_saved, "") != 0 ? g_strdup_printf (" AND id NOT IN (%s)", id_saved) : ""));
+                       stmt = gda_sql_parser_parse_string (priv->commons->gdaparser, sql, NULL, NULL);
+                       gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error);
+                       if (error != NULL)
                                {
-                                       /* removing fields not saved */
-                                       error = NULL;
-                                       id_saved[strlen (id_saved) - 1] = '\0';
-                                       sql = g_strdup_printf ("DELETE FROM %sfields"
-                                                                      " WHERE id_tables = %d"
-                                                                      " AND id NOT IN (%s)",
-                                                                      priv->commons->prefix,
-                                                                      priv->id,
-                                                                      id_saved);
-                                       stmt = gda_sql_parser_parse_string (priv->commons->gdaparser, sql, NULL, NULL);
-                                       gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error);
-                                       if (error != NULL)
-                                               {
-                                                       g_warning ("Error removing old fields: %s",
-                                                                      (error->message != NULL ? error->message : "No details."));
-                                               }
-                                       g_object_unref (stmt);
+                                       g_warning ("Error removing old fields: %s",
+                                                      (error->message != NULL ? error->message : "No details."));
                                }
+                       g_object_unref (stmt);
 
                        g_signal_emit (table, klass->updated_signal_id, 0);
 
@@ -657,6 +663,48 @@ table_on_cb_tables_changed (GtkComboBox *widget,
 
 }
 
+static void
+table_on_btn_select_all_clicked (GtkButton *button,
+                             gpointer user_data)
+{
+       Table *table = (Table *)user_data;
+
+       TablePrivate *priv = TABLE_GET_PRIVATE (table);
+
+       GtkTreeIter iter;
+
+       if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->lstore_fields), &iter))
+               {
+                       do
+                               {
+                                       gtk_list_store_set (priv->lstore_fields, &iter,
+                                                           2, TRUE,
+                                                           -1);
+                               } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->lstore_fields), &iter));
+               }
+}
+
+static void
+table_on_btn_unselect_all_clicked (GtkButton *button,
+                             gpointer user_data)
+{
+       Table *table = (Table *)user_data;
+
+       TablePrivate *priv = TABLE_GET_PRIVATE (table);
+
+       GtkTreeIter iter;
+
+       if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->lstore_fields), &iter))
+               {
+                       do
+                               {
+                                       gtk_list_store_set (priv->lstore_fields, &iter,
+                                                           2, FALSE,
+                                                           -1);
+                               } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->lstore_fields), &iter));
+               }
+}
+
 static void
 table_on_btn_cancel_clicked (GtkButton *button,
                              gpointer user_data)