#include <libgda/sql-parser/gda-sql-parser.h>
+#include <libgdaexgrid/libgdaexgrid.h>
+
#include "libzakaudit.h"
static guint debug;
guint rows;
ChangesColumn *column;
GHashTable *ht_columns;
- GType *gtype;
gchar *sql;
GString *sql_where;
GdaDataModel *dm;
GdaDataModel *dm_tmp;
- GtkTreeView *tview;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *vcolumn;
- GtkListStore *lstore;
+ GtkWidget *wgrid;
+ GdaExGrid *gdaexgrid;
+ GdaExGridColumn *gdaexgridcolumn;
+ GtkTreeStore *tstore;
+
GtkTreeIter iter;
GtkTreeIter *iter_prev;
strtol (field_value, NULL, 10));
}
- tview = GTK_TREE_VIEW (gtk_builder_get_object (priv->gtkbuilder, "treeview1"));
+ gdaexgrid = gdaex_grid_new ();
sql = g_strdup_printf ("SELECT *"
" FROM fields"
- " WHERE id_tables = %d",
+ " WHERE id_tables = %d"
+ " ORDER BY id",
table->id);
dm = gdaex_query (priv->gdaex, sql);
if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
{
rows = gda_data_model_get_n_rows (dm);
- gtype = g_new0 (GType, CHANGES_STATIC_COLUMNS + rows);
-
- gtype[COL_CHANGES_ID] = G_TYPE_INT; /* id */
- renderer = gtk_cell_renderer_spin_new ();
- gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
- vcolumn = gtk_tree_view_column_new ();
- 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 ();
- vcolumn = gtk_tree_view_column_new ();
- 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 ();
- vcolumn = gtk_tree_view_column_new ();
- 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 ();
- vcolumn = gtk_tree_view_column_new ();
- 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);
+ gdaexgridcolumn = gdaex_grid_column_new (_("ID"), "id", G_TYPE_INT, TRUE, TRUE, TRUE, TRUE, -1);
+ gdaex_grid_add_column (gdaexgrid, gdaexgridcolumn);
+
+ gdaexgridcolumn = gdaex_grid_column_new_defaults (_("Date"), "date", G_TYPE_STRING);
+ gdaex_grid_add_column (gdaexgrid, gdaexgridcolumn);
+
+ gdaexgridcolumn = gdaex_grid_column_new_defaults (_("Operation"), NULL, G_TYPE_STRING);
+ gdaex_grid_add_column (gdaexgrid, gdaexgridcolumn);
+
+ gdaexgridcolumn = gdaex_grid_column_new_defaults (_("User"), NULL, G_TYPE_STRING);
+ gdaex_grid_add_column (gdaexgrid, gdaexgridcolumn);
for (row = 0; row < rows; row++)
{
* 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);
+ gdaexgridcolumn = gdaex_grid_column_new_defaults (column->field_name, NULL, G_TYPE_STRING);
+ gdaex_grid_add_column (gdaexgrid, gdaexgridcolumn);
g_hash_table_insert (ht_columns, (gpointer)column->field_name, (gpointer)column);
-
- gtype[CHANGES_STATIC_COLUMNS + row] = G_TYPE_STRING;
}
}
else
g_object_unref (dm);
}
- lstore = GTK_LIST_STORE (gtk_list_store_newv (CHANGES_STATIC_COLUMNS + rows, gtype));
- gtk_tree_view_set_model (tview, GTK_TREE_MODEL (lstore));
+ wgrid = gdaex_grid_get_widget (gdaexgrid);
+ gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (priv->gtkbuilder, "scrolledwindow1")), wgrid);
+ gtk_widget_show (wgrid);
+ tstore = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (wgrid)));
/* find the last action
* go backward
if (gdaex_data_model_get_field_value_integer_at (dm, row_action, "type") == ZAK_AUDIT_ACTION_DELETE)
{
- gtk_list_store_append (lstore, &iter);
- gtk_list_store_set (lstore, &iter,
+ gtk_tree_store_append (tstore, &iter, NULL);
+ gtk_tree_store_set (tstore, &iter,
COL_CHANGES_ID, gdaex_data_model_get_field_value_integer_at (dm, row_action, "id"),
COL_CHANGES_DATE, g_date_time_format (gdaex_data_model_get_field_value_gdatetime_at (dm, row_action, "date"), "%d/%m/%Y %H.%M.%S"),
COL_CHANGES_OPERATION, _("Deleted"),
COL_CHANGES_USER, gdaex_data_model_get_field_value_stringify_at (dm, row_action, "username"),
-1);
- gtk_list_store_append (lstore, &iter);
+ gtk_tree_store_append (tstore, &iter, NULL);
/* last values are stored in zakaudit tables */
sql = g_strdup_printf ("SELECT v.*, f.name"
if (column != NULL)
{
column->field_value = gdaex_data_model_get_field_value_stringify_at (dm_tmp, row, "value");
- gtk_list_store_set (lstore, &iter,
+ gtk_tree_store_set (tstore, &iter,
column->col, column->field_value,
-1);
}
}
else
{
- gtk_list_store_append (lstore, &iter);
+ gtk_tree_store_append (tstore, &iter, NULL);
/* last values are stored in datasource audited */
sql = g_strdup_printf ("SELECT *"
if (column != NULL)
{
column->field_value = gdaex_data_model_get_value_stringify_at (dm_tmp, 0, col);
- gtk_list_store_set (lstore, &iter,
+ gtk_tree_store_set (tstore, &iter,
column->col, column->field_value,
-1);
}
}
}
- gtk_list_store_set (lstore, &iter,
+ gtk_tree_store_set (tstore, &iter,
COL_CHANGES_ID, gdaex_data_model_get_field_value_integer_at (dm, row_action, "id"),
COL_CHANGES_DATE, g_date_time_format (gdaex_data_model_get_field_value_gdatetime_at (dm, row_action, "date"), "%d/%m/%Y %H.%M.%S"),
COL_CHANGES_OPERATION, gdaex_data_model_get_field_value_integer_at (dm, row_action, "type") == ZAK_AUDIT_ACTION_AFTER_UPDATE ? _("Edited") :
continue;
}
- gtk_list_store_append (lstore, &iter);
+ gtk_tree_store_append (tstore, &iter, NULL);
/* copy iter_prev to iter */
gchar *field_value;
for (col = 0; col < g_list_length (table->fields); col++)
{
- gtk_tree_model_get (GTK_TREE_MODEL (lstore), iter_prev,
+ gtk_tree_model_get (GTK_TREE_MODEL (tstore), iter_prev,
col + CHANGES_STATIC_COLUMNS, &field_value,
-1);
- gtk_list_store_set (lstore, &iter,
+ gtk_tree_store_set (tstore, &iter,
col + CHANGES_STATIC_COLUMNS, field_value,
-1);
}
{
column->field_value = gdaex_data_model_get_field_value_stringify_at (dm_tmp, row, "value");
}
- gtk_list_store_set (lstore, &iter,
+ gtk_tree_store_set (tstore, &iter,
column->col, column->field_value,
-1);
}