From fbf37e9102ef141f9440d5ef77e454f1d0e17e93 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Thu, 12 Aug 2010 12:36:48 +0200 Subject: [PATCH] Test gestione tipi nodo. Cambiata la gestione di GUIDIR e FORM in windows per facilitare il momento dello sviluppo (manca da modificare libautedb). --- data/organigramma/gui/organigramma.gui | 4 +- docs/organigramma/examples/Makefile.am | 3 +- docs/organigramma/examples/organigramma.conf | 6 +++ src/Makefile.am | 8 ++-- src/main.c | 50 ++++++++++++++++---- src/{tipi_nodo.c => tipinodo.c} | 14 +++--- src/{tipi_nodo.h => tipinodo.h} | 0 src/{tipo_nodo.c => tiponodo.c} | 6 +-- src/{tipo_nodo.h => tiponodo.h} | 0 9 files changed, 66 insertions(+), 25 deletions(-) create mode 100644 docs/organigramma/examples/organigramma.conf rename src/{tipi_nodo.c => tipinodo.c} (98%) rename src/{tipi_nodo.h => tipinodo.h} (100%) rename src/{tipo_nodo.c => tiponodo.c} (99%) rename src/{tipo_nodo.h => tiponodo.h} (100%) diff --git a/data/organigramma/gui/organigramma.gui b/data/organigramma/gui/organigramma.gui index b8ba3a1..e2578b6 100644 --- a/data/organigramma/gui/organigramma.gui +++ b/data/organigramma/gui/organigramma.gui @@ -7,6 +7,7 @@ center 600 400 + True @@ -67,6 +68,7 @@ True Tipi _nodo True + @@ -101,7 +103,7 @@ - + True vertical diff --git a/docs/organigramma/examples/Makefile.am b/docs/organigramma/examples/Makefile.am index bb51949..1f7a096 100644 --- a/docs/organigramma/examples/Makefile.am +++ b/docs/organigramma/examples/Makefile.am @@ -1,5 +1,6 @@ examplesdir = $(docdir)/$(PACKAGE)/examples -examples_DATA = +examples_DATA = \ + organigramma.conf EXTRA_DIST = $(examples_DATA) diff --git a/docs/organigramma/examples/organigramma.conf b/docs/organigramma/examples/organigramma.conf new file mode 100644 index 0000000..91d9111 --- /dev/null +++ b/docs/organigramma/examples/organigramma.conf @@ -0,0 +1,6 @@ +[AUTE] +plugin=/usr/local/lib/libaute/plugins/libaute-db +cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=autedb + +[DB] +cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=organigramma diff --git a/src/Makefile.am b/src/Makefile.am index 539e82a..051617b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,7 @@ bin_PROGRAMS = organigramma organigramma_SOURCES = \ commons.h \ main.c \ - tipi_nodo.c \ - tipi_nodo.h \ - tipo_nodo.c \ - tipo_nodo.h \ No newline at end of file + tipinodo.c \ + tipinodo.h \ + tiponodo.c \ + tiponodo.h \ No newline at end of file diff --git a/src/main.c b/src/main.c index 8e8c7a7..4a8b7bd 100644 --- a/src/main.c +++ b/src/main.c @@ -20,12 +20,15 @@ #include #endif +#include + #include #include #include #include "commons.h" +#include "tipinodo.h" static Commons *commons; @@ -61,6 +64,19 @@ on_mnu_view_prenotazioni_activate (GtkMenuItem *menuitem, main_set_vbx_body_child (vbx); }*/ +G_MODULE_EXPORT void +on_mnu_tabelle_tipi_nodo_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + GtkWidget *vbx; + + TipiNodo *m = tipi_nodo_new (commons, FALSE); + + vbx = tipi_nodo_get_widget (m); + + main_set_vbx_body_child (vbx); +} + G_MODULE_EXPORT void on_mnu_help_about_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -78,7 +94,7 @@ on_mnu_help_about_activate (GtkMenuItem *menuitem, } diag = GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "dlg_about")); - + gtk_window_set_transient_for (GTK_WINDOW (diag), GTK_WINDOW (w)); gtk_dialog_run (GTK_DIALOG (diag)); gtk_widget_destroy (diag); } @@ -134,7 +150,7 @@ main (int argc, char *argv[]) g_strfreev (aute_params); /* autenticazione */ - aute = aute_new (); + /*aute = aute_new (); aute_set_config (aute, sl_aute_params); while (TRUE) @@ -147,24 +163,40 @@ main (int argc, char *argv[]) } else if (g_strcmp0 (utente, "") == 0) { - return 0; + return 0; } else { break; } - } + }*/ /* inizializzazione commons */ commons = g_malloc (sizeof (Commons)); #ifdef G_OS_WIN32 -#undef GUIDIR - commons->guidir = g_build_filename (g_win32_get_package_installation_directory_of_module (NULL), "share", PACKAGE, "gui", NULL); + gchar *moddir; + gchar *p; + + moddir = g_win32_get_package_installation_directory_of_module (NULL); -#undef FORMDIR - commons->formdir = g_build_filename (g_win32_get_package_installation_directory_of_module (NULL), "share", PACKAGE, "form", NULL); + p = strrchr (moddir, G_DIR_SEPARATOR); + if (p != NULL + && g_ascii_strcasecmp (p + 1, "src") == 0) + { + /* + *p = '\0'; + commons->guidir = g_build_filename (moddir, "data", PACKAGE, "gui", NULL); + commons->formdir = g_build_filename (moddir, "data", PACKAGE, "form", NULL);*/ + commons->guidir = g_strdup (GUIDIR); + commons->formdir = g_strdup (FORMDIR); + } + else + { + commons->guidir = g_build_filename (moddir, "share", PACKAGE, "gui", NULL); + commons->formdir = g_build_filename (moddir, "share", PACKAGE, "form", NULL); + } #else @@ -173,7 +205,7 @@ main (int argc, char *argv[]) #endif - commons->guifile = g_build_filename (commons->guidir, "mezzi.gui", NULL); + commons->guifile = g_build_filename (commons->guidir, "organigramma.gui", NULL); /* leggo la stringa di connessione al db */ error = NULL; diff --git a/src/tipi_nodo.c b/src/tipinodo.c similarity index 98% rename from src/tipi_nodo.c rename to src/tipinodo.c index ded3513..8692775 100644 --- a/src/tipi_nodo.c +++ b/src/tipinodo.c @@ -17,8 +17,8 @@ * */ -#include "tipi_nodo.h" -#include "tipo_nodo.h" +#include "tipinodo.h" +#include "tiponodo.h" static void tipi_nodo_class_init (TipiNodoClass *klass); static void tipi_nodo_init (TipiNodo *tipi_nodo); @@ -258,7 +258,7 @@ tipi_nodo_carica (TipiNodo *tipi_nodo) 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_integer_at (dm, row, "id"), + 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); } @@ -271,7 +271,7 @@ static void tipi_nodo_modifica (TipiNodo *tipi_nodo) { GtkTreeIter iter; - gint id; + gchar *id; TipiNodoPrivate *priv = TIPI_NODO_GET_PRIVATE (tipi_nodo); @@ -283,7 +283,7 @@ tipi_nodo_modifica (TipiNodo *tipi_nodo) COL_ID, &id, -1); - TipoNodo *c = tipo_nodo_new (priv->commons, id); + TipoNodo *c = tipo_nodo_new (priv->commons, strtol (id, NULL, 10)); g_signal_connect (G_OBJECT (c), "aggiornato", G_CALLBACK (tipi_nodo_on_tipo_nodo_aggiornato), (gpointer)tipi_nodo); @@ -421,7 +421,7 @@ tipi_nodo_on_btn_elimina_clicked (GtkButton *button, gboolean risp; GtkTreeIter iter; - gint id; + gchar *id; TipiNodo *tipi_nodo = (TipiNodo *)user_data; TipiNodoPrivate *priv = TIPI_NODO_GET_PRIVATE (tipi_nodo); @@ -441,7 +441,7 @@ tipi_nodo_on_btn_elimina_clicked (GtkButton *button, -1); gdaex_execute (priv->commons->gdaex, - g_strdup_printf ("UPDATE tipi_nodo SET status = 'E' WHERE id = %d", id)); + g_strdup_printf ("UPDATE tipi_nodo SET status = 'E' WHERE id = %d", strtol (id, NULL, 10))); tipi_nodo_carica (tipi_nodo); } diff --git a/src/tipi_nodo.h b/src/tipinodo.h similarity index 100% rename from src/tipi_nodo.h rename to src/tipinodo.h diff --git a/src/tipo_nodo.c b/src/tiponodo.c similarity index 99% rename from src/tipo_nodo.c rename to src/tiponodo.c index fffd83f..6b30c3a 100644 --- a/src/tipo_nodo.c +++ b/src/tiponodo.c @@ -20,7 +20,7 @@ #include #include -#include "tipo_nodo.h" +#include "tiponodo.h" static void tipo_nodo_class_init (TipoNodoClass *klass); static void tipo_nodo_init (TipoNodo *tipo_nodo); @@ -144,9 +144,9 @@ TipoNodo g_signal_connect (priv->w, "delete-event", G_CALLBACK (tipo_nodo_on_w_tipo_nodo_delete_event), (gpointer *)a); - g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button27"), + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button8"), "clicked", G_CALLBACK (tipo_nodo_on_btn_annulla_clicked), (gpointer *)a); - g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button28"), + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button9"), "clicked", G_CALLBACK (tipo_nodo_on_btn_salva_clicked), (gpointer *)a); priv->id = id; diff --git a/src/tipo_nodo.h b/src/tiponodo.h similarity index 100% rename from src/tipo_nodo.h rename to src/tiponodo.h -- 2.49.0