From: Andrea Zagli Date: Sun, 13 Nov 2016 11:40:47 +0000 (+0100) Subject: Migrato l'elenco tipi nodo a GdaExGrid (refs #833). X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=0af99af63702de129eae1a67e92f008f5d8f86f1;p=solipa%2Forganigramma Migrato l'elenco tipi nodo a GdaExGrid (refs #833). --- diff --git a/data/organigramma/gui/organigramma.gui b/data/organigramma/gui/organigramma.gui index b707f15..d315d89 100644 --- a/data/organigramma/gui/organigramma.gui +++ b/data/organigramma/gui/organigramma.gui @@ -2668,425 +2668,6 @@ - - - - - - - - - - False - Gestione organigramma - True - center-on-parent - True - - - True - False - 5 - vertical - 5 - - - True - False - 5 - 5 - - - True - False - start - Tipo - - - 0 - 2 - - - - - True - False - True - lstore_tipi_nodo - - - - 1 - - - - - 1 - 2 - - - - - True - False - start - Nome - - - 0 - 3 - - - - - True - True - True - 200 - ● - False - False - - - 1 - 3 - - - - - True - False - start - start - Descrizione - - - 0 - 4 - - - - - True - True - True - True - etched-in - - - True - True - - - - - 1 - 4 - - - - - True - False - start - Nodo superiore - - - 0 - 1 - - - - - True - False - True - 5 - - - True - True - True - False - ● - gtk-clear - False - - - True - True - 0 - - - - - ... - True - True - True - - - False - True - 1 - - - - - False - lbl_id_nodi - - - False - True - 2 - - - - - 1 - 1 - - - - - True - False - start - True - lbl_id - - - 1 - 0 - - - - - True - False - start - ID - - - 0 - 0 - - - - - True - True - 0 - - - - - True - False - 5 - end - - - gtk-cancel - True - True - True - True - - - False - False - 0 - - - - - gtk-save - True - True - True - True - - - False - False - 1 - - - - - Salva e _chiudi - True - True - True - True - - - False - False - 2 - - - - - False - True - 1 - - - - - - - False - Tipi nodo - Gestione organigramma - True - center-on-parent - 500 - 400 - True - - - True - False - 5 - vertical - 5 - - - True - False - <b>Tipi nodo</b> - True - - - False - True - 0 - - - - - True - True - etched-in - - - True - True - lstore_tipi_nodo - 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 - - - - - @@ -4913,60 +4494,321 @@ - + + True + False + A_iuto + True + + + True + False + + + gtk-about + True + False + True + True + + + + + + + + + + False + True + 0 + + + + + True + False + + + + + + True + True + 1 + + + + + True + False + 2 + + + False + True + 2 + + + + + + + False + Gestione organigramma + True + center-on-parent + True + + + True + False + 5 + vertical + 5 + + + True + False + 5 + 5 + + + True + False + start + Tipo + + + 0 + 2 + + + + + True + False + True + + + + 1 + + + + + 1 + 2 + + + + + True + False + start + Nome + + + 0 + 3 + + + + + True + True + True + 200 + ● + False + False + + + 1 + 3 + + + + + True + False + start + start + Descrizione + + + 0 + 4 + + + + + True + True + True + True + etched-in + + + True + True + + + + + 1 + 4 + + + + + True + False + start + Nodo superiore + + + 0 + 1 + + + + + True + False + True + 5 + + + True + True + True + False + ● + gtk-clear + False + + + True + True + 0 + + + + + ... + True + True + True + + + False + True + 1 + + + + + False + lbl_id_nodi + + + False + True + 2 + + + + + 1 + 1 + + + + True False - A_iuto - True - - - True - False - - - gtk-about - True - False - True - True - - - - - + start + True + lbl_id + + 1 + 0 + - - - False - True - 0 - - - - - True - False - + + True + False + start + ID + + + 0 + 0 + True True - 1 + 0 - + True False - 2 + 5 + end + + + gtk-cancel + True + True + True + True + + + False + False + 0 + + + + + gtk-save + True + True + True + True + + + False + False + 1 + + + + + Salva e _chiudi + True + True + True + True + + + False + False + 2 + + False True - 2 + 1 @@ -8315,6 +8157,135 @@ + + False + Tipi nodo - Gestione organigramma + True + center-on-parent + 500 + 400 + True + + + True + False + 5 + vertical + 5 + + + True + False + <b>Tipi nodo</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 Tipi prestazione - Gestione organigramma diff --git a/src/persone.c b/src/persone.c index d6c5ecd..40e7a53 100644 --- a/src/persone.c +++ b/src/persone.c @@ -17,6 +17,10 @@ * */ +#ifdef HAVE_CONFIG_H + #include +#endif + #include #include #include diff --git a/src/tipinodo.c b/src/tipinodo.c index 7733baa..118ce16 100644 --- a/src/tipinodo.c +++ b/src/tipinodo.c @@ -17,6 +17,11 @@ * */ +#ifdef HAVE_CONFIG_H + #include +#endif + +#include #include #include @@ -74,8 +79,10 @@ struct _OrganigrammaTipiNodoPrivate OrganigrammaCommons *commons; GtkWidget *widget; + GdaExGrid *grid; + GtkWidget *wgrid; GtkTreeSelection *selection; - GtkListStore *lstore_tipi_nodo; + GtkTreeStore *tstore_tipi_nodo; gboolean selezione; }; @@ -127,6 +134,8 @@ OrganigrammaTipiNodo GError *error; ZakAuthoIResource *ires1; + GdaExGridColumn *gcol; + OrganigrammaTipiNodo *a = ORGANIGRAMMA_TIPI_NODO (g_object_new (organigramma_tipi_nodo_get_type (), NULL)); OrganigrammaTipiNodoPrivate *priv = ORGANIGRAMMA_TIPI_NODO_GET_PRIVATE (a); @@ -147,8 +156,26 @@ OrganigrammaTipiNodo } priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, (selezione ? "w_tipi_nodo" : "vbx_tipi_nodo"))); - priv->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview2"))); - priv->lstore_tipi_nodo = GTK_LIST_STORE (gtk_builder_get_object (priv->commons->gtkbuilder, "lstore_tipi_nodo")); + + /* 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, "label7")))); + + 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, "scrolledwindow3")), priv->wgrid); + gtk_widget_show (priv->wgrid); + + priv->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->wgrid)); + priv->tstore_tipi_nodo = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->wgrid))); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button7"), "clicked", G_CALLBACK (organigramma_tipi_nodo_on_btn_nuovo_clicked), (gpointer)a); @@ -156,7 +183,7 @@ OrganigrammaTipiNodo "clicked", G_CALLBACK (organigramma_tipi_nodo_on_btn_modifica_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button11"), "clicked", G_CALLBACK (organigramma_tipi_nodo_on_btn_elimina_clicked), (gpointer)a); - g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview2"), + g_signal_connect (priv->wgrid, "row-activated", G_CALLBACK (organigramma_tipi_nodo_on_trv_organigramma_tipi_nodo_row_activated), (gpointer)a); if (priv->selezione) @@ -216,7 +243,7 @@ organigramma_tipi_nodo_carica (OrganigrammaTipiNodo *tipi_nodo) OrganigrammaTipiNodoPrivate *priv = ORGANIGRAMMA_TIPI_NODO_GET_PRIVATE (tipi_nodo); - gtk_list_store_clear (priv->lstore_tipi_nodo); + gtk_tree_store_clear (priv->tstore_tipi_nodo); sql_where = g_strdup (""); @@ -261,30 +288,16 @@ organigramma_tipi_nodo_carica (OrganigrammaTipiNodo *tipi_nodo) "%s" " ORDER BY c.nome", sql_where); dm = gdaex_query (priv->commons->gdaex, sql); + gdaex_fill_treemodel_from_sql (priv->commons->gdaex, GTK_TREE_MODEL (priv->tstore_tipi_nodo), sql, NULL, NULL); g_free (sql_where); 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_tipi_nodo, &iter); - - gtk_list_store_set (priv->lstore_tipi_nodo, &iter, - COL_ID, gdaex_data_model_get_field_value_stringify_at (dm, row, "id"), - COL_NOME, gdaex_data_model_get_field_value_stringify_at (dm, row, "nome"), - -1); - } - - g_object_unref (dm); - } } static void organigramma_tipi_nodo_modifica (OrganigrammaTipiNodo *tipi_nodo) { GtkTreeIter iter; - gchar *id; + guint id; OrganigrammaTipiNodoPrivate *priv = ORGANIGRAMMA_TIPI_NODO_GET_PRIVATE (tipi_nodo); @@ -292,11 +305,11 @@ organigramma_tipi_nodo_modifica (OrganigrammaTipiNodo *tipi_nodo) { GtkWidget *w; - gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_tipi_nodo), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_tipi_nodo), &iter, COL_ID, &id, -1); - OrganigrammaTipoNodo *c = organigramma_tipo_nodo_new (priv->commons, strtol (id, NULL, 10)); + OrganigrammaTipoNodo *c = organigramma_tipo_nodo_new (priv->commons, id); g_signal_connect (G_OBJECT (c), "aggiornato", G_CALLBACK (organigramma_tipi_nodo_on_organigramma_tipo_nodo_aggiornato), (gpointer)tipi_nodo); @@ -317,7 +330,7 @@ organigramma_tipi_nodo_modifica (OrganigrammaTipiNodo *tipi_nodo) solipa_message_dialog (priv->selezione ? priv->widget : GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, - "Occorre prima selezionare un tipo nodo"); + "Occorre prima selezionare un tipo nodo."); } } @@ -332,7 +345,7 @@ organigramma_tipi_nodo_selezionato (OrganigrammaTipiNodo *tipi_nodo) if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) { - gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_tipi_nodo), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_tipi_nodo), &iter, COL_ID, &id, -1); @@ -346,7 +359,7 @@ organigramma_tipi_nodo_selezionato (OrganigrammaTipiNodo *tipi_nodo) solipa_message_dialog (priv->selezione ? priv->widget : GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, - "Occorre prima selezionare un tipo nodo"); + "Occorre prima selezionare un tipo nodo."); } } @@ -423,7 +436,7 @@ organigramma_tipi_nodo_on_btn_elimina_clicked (GtkButton *button, gpointer user_data) { GtkTreeIter iter; - gchar *id; + guint id; OrganigrammaTipiNodo *tipi_nodo = (OrganigrammaTipiNodo *)user_data; OrganigrammaTipiNodoPrivate *priv = ORGANIGRAMMA_TIPI_NODO_GET_PRIVATE (tipi_nodo); @@ -435,12 +448,12 @@ organigramma_tipi_nodo_on_btn_elimina_clicked (GtkButton *button, GTK_BUTTONS_YES_NO, "Sicuro di voler eliminare il tipo nodo selezionato?") == GTK_RESPONSE_YES) { - gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_tipi_nodo), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_tipi_nodo), &iter, COL_ID, &id, -1); gdaex_execute (priv->commons->gdaex, - g_strdup_printf ("UPDATE tipi_nodo SET status = 'E' WHERE id = %d", strtol (id, NULL, 10))); + g_strdup_printf ("UPDATE tipi_nodo SET status = 'E' WHERE id = %d", id)); organigramma_tipi_nodo_carica (tipi_nodo); } @@ -450,7 +463,7 @@ organigramma_tipi_nodo_on_btn_elimina_clicked (GtkButton *button, solipa_message_dialog (priv->selezione ? priv->widget : GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, - "Occorre prima selezionare un tipo nodo"); + "Occorre prima selezionare un tipo nodo."); } }