From: Andrea Zagli Date: Sat, 12 Nov 2016 09:55:09 +0000 (+0100) Subject: Migrazione a GdaExGrid di elenco strutture (refs #833). X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=f1af6c540db4d95622f36667cd8c3f63baf1c37d;p=solipa%2Forganigramma Migrazione a GdaExGrid di elenco strutture (refs #833). --- diff --git a/configure.ac b/configure.ac index e37313f..2003879 100644 --- a/configure.ac +++ b/configure.ac @@ -45,6 +45,7 @@ AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal) PKG_CHECK_MODULES(ORGANIGRAMMA, [gio-2.0 >= 2.36 gtk+-3.0 >= 3.0 libzakutils + libgdaexgrid libgtkform >= 0.5.0 libzakconfi >= 0.10.0 libzakauthe >= 0.5.99 diff --git a/data/organigramma/gui/organigramma.gui b/data/organigramma/gui/organigramma.gui index e79be26..a09be9e 100644 --- a/data/organigramma/gui/organigramma.gui +++ b/data/organigramma/gui/organigramma.gui @@ -2004,163 +2004,6 @@ - - - - - - - - - - False - Strutture - Gestione organigramma - True - center-on-parent - 500 - 400 - True - - - True - False - 5 - vertical - 5 - - - True - False - <b>Strutture</b> - True - - - False - True - 0 - - - - - True - True - etched-in - - - True - True - lstore_strutture - False - 0 - - - - - - Nome - - - - 1 - - - - - - - - - True - True - 1 - - - - - True - False - 5 - end - - - gtk-new - True - True - True - True - - - False - False - 0 - - - - - gtk-edit - True - True - True - True - - - False - False - 1 - - - - - gtk-delete - True - True - True - True - - - False - False - 2 - - - - - gtk-cancel - True - True - True - True - - - False - False - 3 - - - - - gtk-ok - True - True - True - True - - - False - False - 4 - - - - - False - True - 2 - - - - - @@ -9358,6 +9201,135 @@ + + False + Strutture - Gestione organigramma + True + center-on-parent + 500 + 400 + True + + + True + False + 5 + vertical + 5 + + + True + False + <b>Strutture</b> + True + + + False + True + 0 + + + + + True + True + etched-in + + + + + + True + True + 1 + + + + + True + False + 5 + end + + + gtk-new + True + True + True + True + + + False + False + 0 + + + + + gtk-edit + True + True + True + True + + + False + False + 1 + + + + + gtk-delete + True + True + True + True + + + False + False + 2 + + + + + gtk-cancel + True + True + True + True + + + False + False + 3 + + + + + gtk-ok + True + True + True + True + + + False + False + 4 + + + + + False + True + 2 + + + + + False Tipo nodo - Gestione organigramma diff --git a/libreria/Makefile.am b/libreria/Makefile.am index 8ccdba6..34b27a3 100644 --- a/libreria/Makefile.am +++ b/libreria/Makefile.am @@ -4,7 +4,8 @@ formdir = $(datadir)/$(PACKAGE)/form AM_CPPFLAGS = $(ORGANIGRAMMA_CFLAGS) \ -DGUIDIR=\""$(guidir)"\" \ -DFORMDIR=\""$(formdir)"\" \ - -DG_LOG_DOMAIN=\"Organigramma\" + -DG_LOG_DOMAIN=\"Organigramma\" \ + -DSOLIPA_FOUND=1 LIBS = $(ORGANIGRAMMA_LIBS) \ -export-dynamic diff --git a/src/Makefile.am b/src/Makefile.am index 9d60c4b..ce5622e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,7 +3,8 @@ formdir = $(datadir)/$(PACKAGE)/form AM_CPPFLAGS = $(ORGANIGRAMMA_CFLAGS) \ -DGUIDIR=\""$(guidir)"\" \ - -DFORMDIR=\""$(formdir)"\" + -DFORMDIR=\""$(formdir)"\" \ + -DSOLIPA_FOUND=1 LIBS = $(ORGANIGRAMMA_LIBS) \ -export-dynamic diff --git a/src/strutture.c b/src/strutture.c index 2ce6524..2a6d092 100644 --- a/src/strutture.c +++ b/src/strutture.c @@ -17,6 +17,7 @@ * */ +#include #include #include @@ -71,8 +72,10 @@ struct _OrganigrammaStrutturePrivate OrganigrammaCommons *commons; GtkWidget *widget; + GdaExGrid *grid; + GtkWidget *wgrid; GtkTreeSelection *selection; - GtkListStore *lstore_strutture; + GtkTreeStore *tstore_strutture; gboolean selezione; GtkWindow *wtransient; @@ -125,6 +128,8 @@ OrganigrammaStrutture GError *error; ZakAuthoIResource *ires1; + GdaExGridColumn *gcol; + OrganigrammaStrutture *a = ORGANIGRAMMA_STRUTTURE (g_object_new (organigramma_strutture_get_type (), NULL)); OrganigrammaStrutturePrivate *priv = ORGANIGRAMMA_STRUTTURE_GET_PRIVATE (a); @@ -134,9 +139,8 @@ OrganigrammaStrutture error = NULL; gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile, - g_strsplit (g_strconcat ("lstore_strutture|", - (selezione ? "w_strutture" : "vbx_strutture"), - NULL), "|", -1), + g_strsplit (g_strconcat ((selezione ? "w_strutture" : "vbx_strutture"), + NULL), "|", -1), &error); if (error != NULL) { @@ -145,8 +149,6 @@ OrganigrammaStrutture } priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, (selezione ? "w_strutture" : "vbx_strutture"))); - priv->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview5"))); - priv->lstore_strutture = GTK_LIST_STORE (gtk_builder_get_object (priv->commons->gtkbuilder, "lstore_strutture")); if (priv->selezione) { @@ -157,13 +159,33 @@ OrganigrammaStrutture priv->wtransient = GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")); } + /* creo la gdaexgrid */ + priv->grid = gdaex_grid_new (); + gdaex_grid_set_solipa (priv->grid, priv->commons->solipa); + gdaex_grid_set_title (priv->grid, gtk_label_get_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label26")))); + + gcol = gdaex_grid_column_new ("ID", "id", G_TYPE_INT, TRUE, TRUE, TRUE, FALSE, -1); + gdaex_grid_add_column (priv->grid, gcol); + + gcol = gdaex_grid_column_new_defaults ("Nome", "nome", G_TYPE_STRING); + gdaex_grid_add_column (priv->grid, gcol); + + priv->wgrid = gdaex_grid_get_widget (priv->grid); + + gtk_tree_view_set_search_column (GTK_TREE_VIEW (priv->wgrid), 1); + gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (priv->commons->gtkbuilder, "scrolledwindow7")), priv->wgrid); + gtk_widget_show (priv->wgrid); + + priv->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->wgrid)); + priv->tstore_strutture = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->wgrid))); + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button32"), "clicked", G_CALLBACK (organigramma_strutture_on_btn_nuovo_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button33"), "clicked", G_CALLBACK (organigramma_strutture_on_btn_modifica_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button34"), "clicked", G_CALLBACK (organigramma_strutture_on_btn_elimina_clicked), (gpointer)a); - g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview5"), + g_signal_connect (priv->wgrid, "row-activated", G_CALLBACK (organigramma_strutture_on_trv_organigramma_strutture_row_activated), (gpointer)a); if (priv->selezione) @@ -219,28 +241,14 @@ organigramma_strutture_carica (OrganigrammaStrutture *strutture) OrganigrammaStrutturePrivate *priv = ORGANIGRAMMA_STRUTTURE_GET_PRIVATE (strutture); - gtk_list_store_clear (priv->lstore_strutture); + gtk_tree_store_clear (priv->tstore_strutture); sql = g_strdup_printf ("SELECT c.id, c.nome" " FROM strutture AS c" " WHERE c.status <> 'E'" " ORDER BY c.nome"); - dm = gdaex_query (priv->commons->gdaex, sql); + gdaex_fill_treemodel_from_sql (priv->commons->gdaex, GTK_TREE_MODEL (priv->tstore_strutture), sql, NULL, NULL); g_free (sql); - if (dm != NULL) - { - rows = gda_data_model_get_n_rows (dm); - for (row = 0; row < rows; row++) - { - gtk_list_store_append (priv->lstore_strutture, &iter); - gtk_list_store_set (priv->lstore_strutture, &iter, - COL_ID, gdaex_data_model_get_field_value_integer_at (dm, row, "id"), - COL_NOME, gdaex_data_model_get_field_value_stringify_at (dm, row, "nome"), - -1); - } - - g_object_unref (dm); - } } static void @@ -255,7 +263,7 @@ organigramma_strutture_modifica (OrganigrammaStrutture *strutture) { GtkWidget *w; - gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_strutture), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_strutture), &iter, COL_ID, &id, -1); @@ -288,7 +296,7 @@ organigramma_strutture_selezionato (OrganigrammaStrutture *strutture) if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) { - gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_strutture), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_strutture), &iter, COL_ID, &id, -1); @@ -384,7 +392,7 @@ organigramma_strutture_on_btn_elimina_clicked (GtkButton *button, GTK_BUTTONS_YES_NO, "Sicuro di voler eliminare la struttura selezionata?") == GTK_RESPONSE_YES) { - gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_strutture), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_strutture), &iter, COL_ID, &id, -1); @@ -399,7 +407,7 @@ organigramma_strutture_on_btn_elimina_clicked (GtkButton *button, solipa_message_dialog (GTK_WIDGET (priv->wtransient), GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, - "Occorre prima selezionare una struttura"); + "Occorre prima selezionare una struttura."); } }