From: Andrea Zagli Date: Thu, 12 Aug 2010 09:35:11 +0000 (+0200) Subject: Import iniziale e prima compilazione. X-Git-Tag: 0.0.3~69 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=7ba89b4aff9f35a1f0294ecd204ec5582402dcf0;p=solipa%2Forganigramma Import iniziale e prima compilazione. --- 7ba89b4aff9f35a1f0294ecd204ec5582402dcf0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5fbe730 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +*.o +*~ +*.in +src/organigramma +COPYING +INSTALL +Makefile +Makefile.in +aclocal.m4 +autom4te.cache/ +config.guess +config.h +config.log +config.status +config.sub +configure +depcomp +install-sh +missing +src/.deps/ +stamp-h1 +.anjuta* +*exe diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..ad1de0f --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Andrea Zagli diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..db05b3f --- /dev/null +++ b/Makefile.am @@ -0,0 +1,22 @@ +SUBDIRS = src data docs + +distclean-local: + if test "$(srcdir)" = "."; then :; else \ + rm -f ChangeLog; \ + fi + +ChangeLog: + @echo Creating $@ + @if test -d "$(srcdir)/.git"; then \ + (GIT_DIR=$(top_srcdir)/.git ./missing --run git log --stat -M -C --name-status --date=short --no-color) | fmt --split-only > $@.tmp \ + && mv -f $@.tmp $@ \ + || ($(RM) $@.tmp; \ + echo Failed to generate ChangeLog, your ChangeLog may be outdated >&2; \ + (test -f $@ || echo git-log is required to generate this file >> $@)); \ + else \ + test -f $@ || \ + (echo A git checkout and git-log is required to generate ChangeLog >&2 && \ + echo A git checkout and git-log is required to generate this file >> $@); \ + fi + +.PHONY: ChangeLog diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/autogen.sh b/autogen.sh new file mode 100644 index 0000000..b4ffe6e --- /dev/null +++ b/autogen.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +PKG_NAME="organigramma" + +(test -f $srcdir/configure.ac \ + && test -d $srcdir/src \ + && test -f $srcdir/src/main.c) || { + echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" + echo " top-level organigramma directory" + exit 1 +} + +which gnome-autogen.sh || { + echo "You need to install gnome-common from GNOME and make" + echo "sure the gnome-autogen.sh script is in your \$PATH." + exit 1 +} + +USE_GNOME2_MACROS=1 . gnome-autogen.sh diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..f8d47df --- /dev/null +++ b/configure.ac @@ -0,0 +1,43 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.65]) +AC_INIT([organigramma], [0.0.1], [azagli@libero.it]) +AC_CONFIG_SRCDIR([src/main.c]) +AC_CONFIG_HEADER([config.h]) + +AM_INIT_AUTOMAKE +AM_MAINTAINER_MODE + +AC_CANONICAL_SYSTEM + +# Checks for programs. +AC_PROG_CC + +# Checks for libraries. +PKG_CHECK_MODULES(ORGANIGRAMMA, [gio-2.0 >= 2.20 + gtk+-2.0 >= 2.16 + libgtkform >= 0.1.3 + libaute >= 0.0.2]) + +AC_SUBST(ORGANIGRAMMA_CFLAGS) +AC_SUBST(ORGANIGRAMMA_LIBS) + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. + +AC_CONFIG_FILES([ + Makefile + src/Makefile + data/Makefile + data/organigramma/Makefile + data/organigramma/form/Makefile + data/organigramma/gui/Makefile + docs/Makefile + docs/organigramma/Makefile + docs/organigramma/examples/Makefile +]) +AC_OUTPUT diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..06b971e --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = organigramma diff --git a/data/organigramma/Makefile.am b/data/organigramma/Makefile.am new file mode 100644 index 0000000..93b52d7 --- /dev/null +++ b/data/organigramma/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = form gui diff --git a/data/organigramma/form/Makefile.am b/data/organigramma/form/Makefile.am new file mode 100644 index 0000000..8d770f4 --- /dev/null +++ b/data/organigramma/form/Makefile.am @@ -0,0 +1,5 @@ +formdir = $(datadir)/$(PACKAGE)/form + +form_DATA = + +EXTRA_DIST = $(form_DATA) diff --git a/data/organigramma/gui/Makefile.am b/data/organigramma/gui/Makefile.am new file mode 100644 index 0000000..c43149a --- /dev/null +++ b/data/organigramma/gui/Makefile.am @@ -0,0 +1,6 @@ +guidir = $(datadir)/$(PACKAGE)/gui + +gui_DATA = \ + organigramma.gui + +EXTRA_DIST = $(gui_DATA) diff --git a/data/organigramma/gui/organigramma.gui b/data/organigramma/gui/organigramma.gui new file mode 100644 index 0000000..0cd86db --- /dev/null +++ b/data/organigramma/gui/organigramma.gui @@ -0,0 +1,754 @@ + + + + + + Gestione organigramma + center + 600 + 400 + + + True + vertical + + + True + + + True + _File + True + + + True + + + gtk-quit + True + True + True + + + + + + + + + + True + _Visualizza + True + + + True + + + True + _Organigramma + True + + + + + + + + + True + _Tabelle + True + + + True + + + True + Tipi _nodo + True + + + + + + + + + True + A_iuto + True + + + True + + + gtk-about + True + True + True + + + + + + + + + False + 0 + + + + + True + vertical + + + + + + 1 + + + + + True + 2 + + + False + 2 + + + + + + + + + + + + + + + 5 + Informazioni su... + True + center-on-parent + True + normal + False + Organigramma + 0.0.1 + Andrea Zagli 2010 + Andrea Zagli <azagli@libero.it> + + + True + vertical + 2 + + + + + + True + end + + + False + end + 0 + + + + + + + Gestione organigramma + True + center-on-parent + True + + + True + 5 + vertical + 5 + + + True + 5 + 2 + 5 + 5 + + + True + 0 + Tipo + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + + + + 1 + + + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + 0 + Nome + + + 2 + 3 + GTK_FILL + GTK_FILL + + + + + True + True + 200 + + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + True + 0 + 0 + Descrizione + + + 3 + 4 + GTK_FILL + GTK_FILL + + + + + True + True + automatic + automatic + etched-in + + + True + True + + + + + 1 + 2 + 3 + 4 + + + + + True + 0 + Nodo superiore + + + GTK_FILL + GTK_FILL + + + + + True + 5 + + + True + True + False + + + + 0 + + + + + ... + True + True + True + + + False + 1 + + + + + lbl_id_nodi + + + False + 2 + + + + + 1 + 2 + GTK_FILL + + + + + lbl_id + + + 4 + 5 + GTK_FILL + GTK_FILL + + + + + + + + 0 + + + + + True + 5 + end + + + gtk-cancel + True + True + True + True + + + False + False + 0 + + + + + gtk-save + True + True + True + True + + + False + False + 1 + + + + + False + 1 + + + + + + + + + + + + + + + + + True + 5 + vertical + 5 + + + True + True + automatic + automatic + etched-in + + + True + True + tstore_nodi + False + 0 + + + Nome + + + + 1 + + + + + + + + + 0 + + + + + True + 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 + 1 + + + + + + + Tipo nodo - Gestione organigramma + True + center-on-parent + True + + + True + 5 + vertical + 5 + + + True + 2 + 2 + 5 + 5 + + + True + 0 + Nome + + + GTK_FILL + GTK_FILL + + + + + True + True + 200 + + + + 1 + 2 + GTK_FILL + + + + + lbl_id + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + + + + 0 + + + + + True + 5 + end + + + gtk-cancel + True + True + True + True + + + False + False + 0 + + + + + gtk-save + True + True + True + True + + + False + False + 1 + + + + + False + 1 + + + + + + + Tipi nodo - Gestione organigramma + + + True + 5 + vertical + 5 + + + True + True + automatic + automatic + etched-in + + + True + True + lstore_tipi_nodo + False + 0 + + + Nome + + + + 1 + + + + + + + + + 0 + + + + + True + 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 + 1 + + + + + + diff --git a/docs/Makefile.am b/docs/Makefile.am new file mode 100644 index 0000000..06b971e --- /dev/null +++ b/docs/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = organigramma diff --git a/docs/note.txt b/docs/note.txt new file mode 100644 index 0000000..ef1e384 --- /dev/null +++ b/docs/note.txt @@ -0,0 +1,19 @@ +ORGANIGRAMMA +----------------------------------------------------- + +CREATE TABLE nodi ( + id INTEGER, + id_tipi_nodo INTEGER, + nome VARCHAR (200) DEFAULT '', + descrizione TEXT DEFAULT '', + id_nodi INTEGER, + status VARCHAR (1) DEFAULT '', + CONSTRAINT PRIMARY KEY nodi_pkey (id) +); + +CREATE TABLE tipi_nodo ( + id INTEGER, + nome VARCHAR (200) DEFAULT '', + status VARCHAR (1) DEFAULT '', + CONSTRAINT PRIMARY KEY tipi_nodo_pkey (id) +); \ No newline at end of file diff --git a/docs/organigramma/Makefile.am b/docs/organigramma/Makefile.am new file mode 100644 index 0000000..aee2d7b --- /dev/null +++ b/docs/organigramma/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = examples diff --git a/docs/organigramma/examples/Makefile.am b/docs/organigramma/examples/Makefile.am new file mode 100644 index 0000000..bb51949 --- /dev/null +++ b/docs/organigramma/examples/Makefile.am @@ -0,0 +1,5 @@ +examplesdir = $(docdir)/$(PACKAGE)/examples + +examples_DATA = + +EXTRA_DIST = $(examples_DATA) diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..4faf9e0 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,15 @@ +guidir = $(datadir)/$(PACKAGE)/gui +formdir = $(datadir)/$(PACKAGE)/form + +AM_CPPFLAGS = $(ORGANIGRAMMA_CFLAGS) \ + -DGUIDIR=\""$(guidir)"\" \ + -DFORMDIR=\""$(formdir)"\" + +LIBS = $(ORGANIGRAMMA_LIBS) \ + -export-dynamic + +bin_PROGRAMS = organigramma + +organigramma_SOURCES = \ + commons.h \ + main.c \ No newline at end of file diff --git a/src/commons.h b/src/commons.h new file mode 100644 index 0000000..b65e42d --- /dev/null +++ b/src/commons.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 Andrea Zagli + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#ifndef __COMMONS_H__ +#define __COMMONS_H__ + +#include + +#include + +typedef struct + { + gchar *guidir; + gchar *formdir; + + GtkBuilder *gtkbuilder; + + GdaEx *gdaex; + + const gchar *guifile; + } Commons; + +#endif /* __COMMONS_H__ */ diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..8e8c7a7 --- /dev/null +++ b/src/main.c @@ -0,0 +1,223 @@ +/* + * Copyright (C) 2010 Andrea Zagli + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + +#include +#include + +#include "commons.h" + +static Commons *commons; + +static GKeyFile *config; + +static GtkWidget *w; +static GtkWidget *vbx_body; +static GtkWidget *vbx_body_child; + +static void +main_set_vbx_body_child (GtkWidget *child) +{ + if (GTK_IS_WIDGET (vbx_body_child)) + { + gtk_container_remove (GTK_CONTAINER (vbx_body), vbx_body_child); + gtk_widget_destroy (vbx_body_child); + } + + vbx_body_child = child; + gtk_box_pack_start (GTK_BOX (vbx_body), vbx_body_child, TRUE, TRUE, 0); +} + +/*G_MODULE_EXPORT void +on_mnu_view_prenotazioni_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + GtkWidget *vbx; + + Prenotazioni *m = prenotazioni_new (commons, FALSE); + + vbx = prenotazioni_get_widget (m); + + main_set_vbx_body_child (vbx); +}*/ + +G_MODULE_EXPORT void +on_mnu_help_about_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + GError *error; + GtkWidget *diag; + + error = NULL; + gtk_builder_add_objects_from_file (commons->gtkbuilder, commons->guifile, + g_strsplit_set ("dlg_about", "|", -1), + &error); + if (error != NULL) + { + g_error ("Errore: %s.", error->message); + } + + diag = GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "dlg_about")); + + gtk_dialog_run (GTK_DIALOG (diag)); + gtk_widget_destroy (diag); +} + +int +main (int argc, char *argv[]) +{ + GError *error; + + Aute *aute; + gchar **aute_params; + gsize n_aute_params; + GSList *sl_aute_params; + + gchar *utente; + + gchar *cnc_string; + + gint i; + + gtk_init (&argc, &argv); + + gda_init (); + + /* leggo la configurazione dal file */ + if (argc == 1) + { + g_error ("Occorre passare a riga di comando il file di configurazione."); + } + + error = NULL; + config = g_key_file_new (); + if (!g_key_file_load_from_file (config, argv[1], G_KEY_FILE_NONE, &error)) + { + g_error ("Impossibile caricare il file di configurazione specificato: %s.", argv[1]); + } + + /* leggo i parametri per l'autenticazione */ + error = NULL; + aute_params = g_key_file_get_keys (config, "AUTE", &n_aute_params, &error); + if (aute_params == NULL) + { + g_error ("Impossibile leggere la configurazione per il sistema di autenticazione."); + } + + sl_aute_params = NULL; + for (i = 0; i < n_aute_params; i++) + { + error = NULL; + sl_aute_params = g_slist_append (sl_aute_params, g_key_file_get_string (config, "AUTE", aute_params[i], &error)); + } + + g_strfreev (aute_params); + + /* autenticazione */ + aute = aute_new (); + aute_set_config (aute, sl_aute_params); + + while (TRUE) + { + utente = aute_autentica (aute); + + if (utente == NULL) + { + g_warning ("Nome utente o password non validi."); + } + else if (g_strcmp0 (utente, "") == 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); + +#undef FORMDIR + commons->formdir = g_build_filename (g_win32_get_package_installation_directory_of_module (NULL), "share", PACKAGE, "form", NULL); + +#else + + commons->guidir = g_strdup (GUIDIR); + commons->formdir = g_strdup (FORMDIR); + +#endif + + commons->guifile = g_build_filename (commons->guidir, "mezzi.gui", NULL); + + /* leggo la stringa di connessione al db */ + error = NULL; + cnc_string = g_key_file_get_value (config, "DB", "cnc_string", &error); + if (cnc_string == NULL) + { + if (error != NULL) + { + g_error ("Impossibile leggere la stringa di connessione dal file di configurazione: %s", error->message); + } + else + { + g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); + } + } + + commons->gdaex = gdaex_new_from_string (cnc_string); + if (commons->gdaex == NULL) + { + g_error ("Errore nella connessione al database: %s", cnc_string); + } + + commons->gtkbuilder = gtk_builder_new (); + + error = NULL; + gtk_builder_add_objects_from_file (commons->gtkbuilder, commons->guifile, + g_strsplit_set ("w_main", "|", -1), + &error); + if (error != NULL) + { + g_error ("Errore: %s", error->message); + } + + gtk_builder_connect_signals (commons->gtkbuilder, NULL); + + w = GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "w_main")); + + vbx_body = GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "vbx_body")); + + vbx_body_child = NULL; + + gtk_widget_show (w); + + gtk_main (); + + return 0; +}