]> saetta.ns0.it Git - zakaudit/libzakaudit/commitdiff
GUI to show changes: now it shows the first (last) action. master
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 30 Jan 2014 16:05:47 +0000 (17:05 +0100)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 30 Jan 2014 16:05:47 +0000 (17:05 +0100)
data/libzakaudit/gui/libzakaudit.ui
src/audit.c
tests/test1.c

index 489a408a8d54dd7eecb72da39cd1e2970bea2305..395822ae6e49cc4b150716896f028268ac667ff3 100644 (file)
@@ -6,6 +6,8 @@
     <property name="can_focus">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
+    <property name="default_width">600</property>
+    <property name="default_height">400</property>
     <property name="destroy_with_parent">True</property>
     <child>
       <object class="GtkVBox" id="vbox1">
index 9e6a523ca95779f9a34405e1c49c5482b7e9a9ad..4e2ff903e7a0c30c2659c8590cebdc44665a467b 100644 (file)
@@ -1315,6 +1315,8 @@ GtkWidget
                                                       "|", -1),
                                           &error);
 
+       ret = GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "w_changes"));
+
        sql_where = g_string_new ("");
 
        for (strpart = 0; strpart < l; strpart++)
@@ -1357,6 +1359,7 @@ GtkWidget
                        gtk_tree_view_column_pack_start (vcolumn, renderer, TRUE);
                        gtk_tree_view_column_set_title (vcolumn, "ID");
                        gtk_tree_view_column_add_attribute (vcolumn, renderer, "text", COL_CHANGES_ID);
+                       gtk_tree_view_append_column (tview, vcolumn);
 
                        gtype[COL_CHANGES_DATE] = G_TYPE_STRING;        /* date */
                        renderer = gtk_cell_renderer_text_new ();
@@ -1364,6 +1367,7 @@ GtkWidget
                        gtk_tree_view_column_pack_start (vcolumn, renderer, TRUE);
                        gtk_tree_view_column_set_title (vcolumn, "Date");
                        gtk_tree_view_column_add_attribute (vcolumn, renderer, "text", COL_CHANGES_DATE);
+                       gtk_tree_view_append_column (tview, vcolumn);
 
                        gtype[COL_CHANGES_OPERATION] = G_TYPE_STRING;   /* type */
                        renderer = gtk_cell_renderer_text_new ();
@@ -1371,6 +1375,7 @@ GtkWidget
                        gtk_tree_view_column_pack_start (vcolumn, renderer, TRUE);
                        gtk_tree_view_column_set_title (vcolumn, "Operation");
                        gtk_tree_view_column_add_attribute (vcolumn, renderer, "text", COL_CHANGES_OPERATION);
+                       gtk_tree_view_append_column (tview, vcolumn);
 
                        gtype[COL_CHANGES_USER] = G_TYPE_STRING;        /* username */
                        renderer = gtk_cell_renderer_text_new ();
@@ -1378,6 +1383,7 @@ GtkWidget
                        gtk_tree_view_column_pack_start (vcolumn, renderer, TRUE);
                        gtk_tree_view_column_set_title (vcolumn, "User");
                        gtk_tree_view_column_add_attribute (vcolumn, renderer, "text", COL_CHANGES_USER);
+                       gtk_tree_view_append_column (tview, vcolumn);
 
                        for (row = 0; row < rows; row++)
                                {
@@ -1393,6 +1399,14 @@ GtkWidget
                                         * column->field_value =
                                         */
 
+                                       gtype[CHANGES_STATIC_COLUMNS + row] = G_TYPE_STRING;
+                                       renderer = gtk_cell_renderer_text_new ();
+                                       vcolumn = gtk_tree_view_column_new ();
+                                       gtk_tree_view_column_pack_start (vcolumn, renderer, TRUE);
+                                       gtk_tree_view_column_set_title (vcolumn, column->field_name);
+                                       gtk_tree_view_column_add_attribute (vcolumn, renderer, "text", CHANGES_STATIC_COLUMNS + row);
+                                       gtk_tree_view_append_column (tview, vcolumn);
+
                                        g_hash_table_insert (ht_columns, (gpointer)column->field_name, (gpointer)column);
 
                                        gtype[CHANGES_STATIC_COLUMNS + row] = G_TYPE_STRING;
@@ -1412,7 +1426,7 @@ GtkWidget
                        g_object_unref (dm);
                }
 
-       lstore = GTK_LIST_STORE (gtk_list_store_newv (4 + rows, gtype));
+       lstore = GTK_LIST_STORE (gtk_list_store_newv (CHANGES_STATIC_COLUMNS + rows, gtype));
        gtk_tree_view_set_model (tview, GTK_TREE_MODEL (lstore));
 
        /* find the last action
@@ -1447,14 +1461,14 @@ GtkWidget
 
                        /* TODO check if key field value is changed */
 
-                       /* TODO i could find field that there's not in columns (the dm passed)*/
+                       /* TODO i could find field that there's not in columns (the dm passed) */
 
                        if (gdaex_data_model_get_field_value_integer_at (dm, 0, "type") == ZAK_AUDIT_ACTION_DELETE)
                                {
                                        /* last values are stored in zakaudit tables */
                                        sql = g_strdup_printf ("SELECT v.*, f.name"
                                                               " FROM values AS v"
-                                                              " INNSER JOIN fields AS f ON v.id_fields = f.id"
+                                                              " INNER JOIN fields AS f ON v.id_fields = f.id"
                                                               " WHERE v.id_actions = %d",
                                                               gdaex_data_model_get_field_value_integer_at (dm, 0, "id"));
                                        dm = gdaex_query (priv->gdaex, sql);
@@ -1508,7 +1522,6 @@ GtkWidget
                        g_object_unref (dm);
                }
 
-       ret = NULL;
        g_warning ("The function is still to be implemented");
 
        return ret;
index 2e7d512cb10847976394ad59ba81532e1dee950f..445b8e06ca861e2c84a3c5d4e7ba0af6b7cde8c9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * test1.c
  *
- * Copyright (C) 2005-2013 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2014 Andrea Zagli <azagli@libero.it>
  *
  *  This file is part of libaudit.
  *  
@@ -34,6 +34,14 @@ static GOptionEntry entries[] =
        { NULL }
 };
 
+gboolean
+on_w_delete_event (GtkWidget *widget,
+                   GdkEvent *event,
+                   gpointer user_data)
+{
+       return FALSE;
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -51,7 +59,9 @@ main (int argc, char *argv[])
        cnc_zakaudit = NULL;
        cnc_db = NULL;
 
-       g_type_init ();
+       GtkWidget *w;
+
+       gtk_init (&argc, &argv);
 
        ctx = g_option_context_new ("");
        g_option_context_add_main_entries (ctx, entries, "audit_test1");
@@ -132,6 +142,15 @@ main (int argc, char *argv[])
        g_warning ("User insertion: %s",
                   zak_audit_get_user_insertion (audit, "audit_test1", "test1", (const gchar **)g_strsplit ("id|2", "|", -1)));
 
+       w = zak_audit_get_changes_widget (audit, "audit_test1", "test1", (const gchar **)g_strsplit ("id|2", "|", -1));
+
+       g_signal_connect (w, "delete-event", G_CALLBACK (on_w_delete_event), NULL);
+       g_signal_connect (w, "destroy", gtk_main_quit, NULL);
+
+       gtk_widget_show_all (w);
+
+       gtk_main ();
+
        zak_audit_destroy (audit);
 
        return 0;