]> saetta.ns0.it Git - zakaudit/gui/commitdiff
Started developing of "add all tables" utility.
authorAndrea Zagli <azagli@libero.it>
Wed, 1 Jun 2011 16:30:28 +0000 (18:30 +0200)
committerAndrea Zagli <azagli@libero.it>
Wed, 1 Jun 2011 16:30:28 +0000 (18:30 +0200)
data/audit-gui/gui/audit-gui.gui
src/datasource.h
src/datasources.c
src/datasources.h
src/main.c
src/openauditds.h
src/table.h

index 83ac71ff0c41d9bffc440ea6f314fa505735da50..af5329bc12ec6f4c9e4c6834794b9d939d474939 100644 (file)
                 </child>
               </object>
             </child>
+            <child>
+              <object class="GtkMenuItem" id="menuitem3">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Utilities</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu2">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkMenuItem" id="menuitem5">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Add _all tables</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="on_mnu_utilities_add_all_tables_activate"/>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
             <child>
               <object class="GtkMenuItem" id="menuitem4">
                 <property name="visible">True</property>
     <property name="type_hint">normal</property>
     <property name="program_name">Audit GUI</property>
     <property name="version">0.0.1</property>
-    <property name="copyright" translatable="yes">Andrea Zagli 2010</property>
+    <property name="copyright" translatable="yes">Andrea Zagli 2010-2011</property>
     <property name="authors">Andrea Zagli &lt;azagli@libero.it&gt;</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox1">
       </object>
     </child>
   </object>
+  <object class="GtkWindow" id="w_progress">
+    <property name="title" translatable="yes">Audit GUI</property>
+    <property name="modal">True</property>
+    <property name="window_position">center-on-parent</property>
+    <property name="default_width">550</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="decorated">False</property>
+    <child>
+      <object class="GtkVBox" id="vbox6">
+        <property name="visible">True</property>
+        <property name="border_width">5</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">5</property>
+        <child>
+          <object class="GtkLabel" id="label10">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">label</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkProgressBar" id="progressbar1">
+            <property name="visible">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
 </interface>
index 32a9998a0cace26ef0b1966c693e3fa75f1b9da8..031d32abcef793d08b041f231a3c9ca700715784 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2011 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,6 @@
 #include <glib-object.h>
 
 #include <gtk/gtk.h>
-#include <libgdaex.h>
 
 #include "commons.h"
 
index fb6aa7af0604d3601a80c7deedc285a4b4dfd627..9bbf444bd0a3c795f7c4f5343b9fcfc4a7463e96 100644 (file)
@@ -114,9 +114,10 @@ Datasources
 
        error = NULL;
        gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile,
-                                          g_strsplit (g_strconcat ("tstore_ds_tables_fields|", 
-                                          "vbox5",
-                                          NULL), "|", -1),
+                                          g_strsplit ("tstore_ds_tables_fields"
+                                                      "|w_progress"
+                                                      "|vbox5",
+                                                      "|", -1),
                                           &error);
        if (error != NULL)
                {
@@ -152,11 +153,116 @@ Datasources
 GtkWidget
 *datasources_get_widget (Datasources *datasources)
 {
-       DatasourcesPrivate *priv = DATASOURCES_GET_PRIVATE (datasources);
+       DatasourcesPrivate *priv;
+
+       g_return_val_if_fail (IS_DATASOURCES (datasources), NULL);
+
+       priv = DATASOURCES_GET_PRIVATE (datasources);
 
        return priv->widget;
 }
 
+/**
+ * datasources_add_all_tables:
+ * @datasources:
+ *
+ */
+void
+datasources_add_all_tables (Datasources *datasources)
+{
+       DatasourcesPrivate *priv;
+
+       GtkWidget *dialog;
+       GtkTreeIter iter;
+
+       guint id_ds;
+       guint depth;
+       GtkTreePath *path;
+
+       g_return_if_fail (IS_DATASOURCES (datasources));
+
+       priv = DATASOURCES_GET_PRIVATE (datasources);
+
+       if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter))
+               {
+                       gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_datasources), &iter,
+                                           COL_ID_DS, &id_ds,
+                                           -1);
+
+                       if (id_ds == 0)
+                               {
+                                       path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tstore_datasources), &iter);
+                                       if (path != NULL)
+                                               {
+                                                       depth = gtk_tree_path_get_depth (path);
+
+                                                       if (depth >= 2) gtk_tree_path_up (path);
+                                                       if (depth >= 3) gtk_tree_path_up (path);
+
+                                                       if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->tstore_datasources), &iter, path))
+                                                               {
+                                                                       gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_datasources), &iter,
+                                                                                           COL_ID_DS, &id_ds,
+                                                                                           -1);
+                                                               }
+                                               }
+                               }
+
+                       if (id_ds != 0)
+                               {
+                                       dialog = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_progress"));
+                                       gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label10")),
+                                                           "Updating data store");
+                                       gtk_widget_show_all (dialog);
+                                       gtk_widget_show_now (dialog);
+                                       while (gtk_events_pending ()) gtk_main_iteration ();
+                                       g_usleep (3000000);
+                                       gtk_progress_bar_pulse (GTK_PROGRESS_BAR (gtk_builder_get_object (priv->commons->gtkbuilder, "progressbar1")));
+                                       while (gtk_events_pending ()) gtk_main_iteration ();
+                                       g_usleep (3000000);
+                                       gtk_progress_bar_pulse (GTK_PROGRESS_BAR (gtk_builder_get_object (priv->commons->gtkbuilder, "progressbar1")));
+                                       while (gtk_events_pending ()) gtk_main_iteration ();
+                                       g_usleep (3000000);
+                                       gtk_progress_bar_pulse (GTK_PROGRESS_BAR (gtk_builder_get_object (priv->commons->gtkbuilder, "progressbar1")));
+                                       while (gtk_events_pending ()) gtk_main_iteration ();
+                                       g_usleep (3000000);
+                                       gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label10")),
+                                                           "Adding table «table_name»");
+                                       while (gtk_events_pending ()) gtk_main_iteration ();
+                                       g_usleep (3000000);
+                                       gtk_progress_bar_pulse (GTK_PROGRESS_BAR (gtk_builder_get_object (priv->commons->gtkbuilder, "progressbar1")));
+                                       while (gtk_events_pending ()) gtk_main_iteration ();
+                                       g_usleep (3000000);
+                                       gtk_progress_bar_pulse (GTK_PROGRESS_BAR (gtk_builder_get_object (priv->commons->gtkbuilder, "progressbar1")));
+                                       while (gtk_events_pending ()) gtk_main_iteration ();
+                                       g_usleep (3000000);
+                                       gtk_progress_bar_pulse (GTK_PROGRESS_BAR (gtk_builder_get_object (priv->commons->gtkbuilder, "progressbar1")));
+                                       while (gtk_events_pending ()) gtk_main_iteration ();
+                                       gtk_widget_hide_all (dialog);
+                               }
+                       else
+                               {
+                                       dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
+                                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                                        GTK_MESSAGE_WARNING,
+                                                                        GTK_BUTTONS_OK,
+                                                                        "Select a datasource.");
+                                       gtk_dialog_run (GTK_DIALOG (dialog));
+                                       gtk_widget_destroy (dialog);
+                               }
+               }
+       else
+               {
+                       dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_MESSAGE_WARNING,
+                                                        GTK_BUTTONS_OK,
+                                                        "Select a datasource.");
+                       gtk_dialog_run (GTK_DIALOG (dialog));
+                       gtk_widget_destroy (dialog);
+               }
+}
+
 /* PRIVATE */
 static void
 datasources_load_fields (Datasources *datasources, guint id_table, GtkTreeIter *iter_parent)
index 92d61d66d22334b4dc79d377dd24e2f01d7c37e5..4431eec02119e2fccd43622edad99f91b338ea26 100644 (file)
@@ -24,7 +24,6 @@
 #include <glib-object.h>
 
 #include <gtk/gtk.h>
-#include <libgdaex.h>
 
 #include "commons.h"
 
@@ -58,6 +57,8 @@ Datasources *datasources_new (Commons *commons);
 
 GtkWidget *datasources_get_widget (Datasources *datasources);
 
+void datasources_add_all_tables (Datasources *datasources);
+
 
 G_END_DECLS
 
index ec52227c49c61cc5d3d990e2ece07210456095c9..3de62ab4c939567cb90e79775cb060438700635f 100644 (file)
@@ -40,6 +40,8 @@ static GtkWidget *w;
 static GtkWidget *vbx_body;
 static GtkWidget *vbx_body_child;
 
+static Datasources *datasources;
+
 static void
 main_set_vbx_body_child (GtkWidget *child)
 {
@@ -62,8 +64,6 @@ main_on_ds_opened (gpointer instance, const gchar *arg1, gpointer user_data)
        gchar *cnc;
        gchar *pos;
 
-       Datasources *m;
-
        if (arg1 == NULL)
                {
                        return;
@@ -112,12 +112,13 @@ main_on_ds_opened (gpointer instance, const gchar *arg1, gpointer user_data)
                        commons->gdaparser = gda_sql_parser_new ();
                }
 
-       m = datasources_new (commons);
+       datasources = datasources_new (commons);
 
-       vbx = datasources_get_widget (m);
+       vbx = datasources_get_widget (datasources);
 
        main_set_vbx_body_child (vbx);
        gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "menuitem2")), TRUE);
+       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "menuitem5")), TRUE);
 
        g_free (cnc);
 }
@@ -150,7 +151,17 @@ on_mnu_file_close_activate (GtkMenuItem *menuitem,
 {
        gtk_widget_destroy (vbx_body_child);
        vbx_body_child = NULL;
+
        gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "menuitem2")), FALSE);
+       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "menuitem5")), FALSE);
+       g_object_unref (datasources);
+}
+
+G_MODULE_EXPORT void
+on_mnu_utilities_add_all_tables_activate (GtkMenuItem *menuitem,
+                            gpointer user_data)
+{
+       datasources_add_all_tables (datasources);
 }
 
 G_MODULE_EXPORT void
@@ -235,6 +246,7 @@ main (int argc, char *argv[])
        gtk_widget_show (w);
 
        gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "menuitem2")), FALSE);
+       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "menuitem5")), FALSE);
 
        if (argc > 0)
                {
index f5b83855437fb79078ceff8b87ae5ffa1e23101c..dced370ddb2edabeaa2ab7fea54bceb7b8a3716d 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2011 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,6 @@
 #include <glib-object.h>
 
 #include <gtk/gtk.h>
-#include <libgdaex.h>
 
 #include "commons.h"
 
index 95130ff517125236b104afbfa831fb211024ba66..f2017232e4f16e093c6a039cb96b84a96c6d0950 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2011 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,6 @@
 #include <glib-object.h>
 
 #include <gtk/gtk.h>
-#include <libgdaex.h>
 
 #include "commons.h"