From 9f332b4f73381c823fe14590bf90e0004c365e1e Mon Sep 17 00:00:00 2001 From: Andrea Zagli <a.zagli@comune.scandicci.fi.it> Date: Fri, 13 Aug 2010 11:26:18 +0200 Subject: [PATCH 1/1] Initial import. --- AUTHORS | 1 + Makefile.am | 22 ++ NEWS | 0 README | 0 autogen.sh | 23 ++ configure.ac | 37 ++++ data/Makefile.am | 1 + data/audit-gui/Makefile.am | 1 + data/audit-gui/gui/Makefile.am | 5 + data/audit-gui/gui/audit-gui.gui | 347 +++++++++++++++++++++++++++++++ src/Makefile.am | 15 ++ src/commons.h | 42 ++++ src/main.c | 156 ++++++++++++++ 13 files changed, 650 insertions(+) create mode 100644 AUTHORS create mode 100644 Makefile.am create mode 100644 NEWS create mode 100644 README create mode 100644 autogen.sh create mode 100644 configure.ac create mode 100644 data/Makefile.am create mode 100644 data/audit-gui/Makefile.am create mode 100644 data/audit-gui/gui/Makefile.am create mode 100644 data/audit-gui/gui/audit-gui.gui create mode 100644 src/Makefile.am create mode 100644 src/commons.h create mode 100644 src/main.c diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..ad1de0f --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Andrea Zagli <azagli@libero.it> diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..a91794b --- /dev/null +++ b/Makefile.am @@ -0,0 +1,22 @@ +SUBDIRS = src data + +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..24e8d2a --- /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="audit-gui" + +(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 audit-gui 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..39d3acf --- /dev/null +++ b/configure.ac @@ -0,0 +1,37 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.65]) +AC_INIT([audit-gui], [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(AUDITGUI, [libgda-ui-4.0 >= 4.1.0]) + +AC_SUBST(AUDITGUI_CFLAGS) +AC_SUBST(AUDITGUI_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/audit-gui/Makefile + data/audit-gui/form/Makefile + data/audit-gui/gui/Makefile +]) +AC_OUTPUT diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..f48f1a7 --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = audit-gui diff --git a/data/audit-gui/Makefile.am b/data/audit-gui/Makefile.am new file mode 100644 index 0000000..13c2b3d --- /dev/null +++ b/data/audit-gui/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = gui diff --git a/data/audit-gui/gui/Makefile.am b/data/audit-gui/gui/Makefile.am new file mode 100644 index 0000000..d1d7be1 --- /dev/null +++ b/data/audit-gui/gui/Makefile.am @@ -0,0 +1,5 @@ +guidir = $(datadir)/$(PACKAGE)/gui + +gui_DATA = audit-gui.gui + +EXTRA_DIST = $(gui_DATA) diff --git a/data/audit-gui/gui/audit-gui.gui b/data/audit-gui/gui/audit-gui.gui new file mode 100644 index 0000000..e01d61e --- /dev/null +++ b/data/audit-gui/gui/audit-gui.gui @@ -0,0 +1,347 @@ +<?xml version="1.0"?> +<interface> + <requires lib="gtk+" version="2.16"/> + <!-- interface-naming-policy project-wide --> + <object class="GtkWindow" id="w_main"> + <property name="window_position">center</property> + <signal name="destroy" handler="gtk_main_quit"/> + <child> + <object class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkMenuBar" id="menubar1"> + <property name="visible">True</property> + <child> + <object class="GtkMenuItem" id="menuitem1"> + <property name="visible">True</property> + <property name="label" translatable="yes">_File</property> + <property name="use_underline">True</property> + <child type="submenu"> + <object class="GtkMenu" id="menu1"> + <property name="visible">True</property> + <child> + <object class="GtkImageMenuItem" id="imagemenuitem2"> + <property name="label">gtk-open</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </object> + </child> + <child> + <object class="GtkSeparatorMenuItem" id="separatormenuitem1"> + <property name="visible">True</property> + </object> + </child> + <child> + <object class="GtkImageMenuItem" id="imagemenuitem5"> + <property name="label">gtk-quit</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + <signal name="activate" handler="gtk_main_quit"/> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkMenuItem" id="menuitem4"> + <property name="visible">True</property> + <property name="label" translatable="yes">A_iuto</property> + <property name="use_underline">True</property> + <child type="submenu"> + <object class="GtkMenu" id="menu3"> + <property name="visible">True</property> + <child> + <object class="GtkImageMenuItem" id="imagemenuitem10"> + <property name="label">gtk-about</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <object class="GtkStatusbar" id="statusbar1"> + <property name="visible">True</property> + <property name="spacing">2</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkAboutDialog" id="dlg_about"> + <property name="border_width">5</property> + <property name="type_hint">normal</property> + <property name="has_separator">False</property> + <property name="program_name">Audit GUI</property> + <property name="version">0.0.1</property> + <property name="copyright" translatable="yes">Andrea Zagli 2010</property> + <property name="authors">Andrea Zagli <azagli@libero.it></property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child> + <placeholder/> + </child> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">end</property> + </object> + <packing> + <property name="expand">False</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkWindow" id="w_open_audit_datasource"> + <property name="title" translatable="yes">Open Audit Datasource - Audit GUI</property> + <property name="modal">True</property> + <property name="window_position">center-on-parent</property> + <property name="destroy_with_parent">True</property> + <child> + <object class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="border_width">5</property> + <property name="orientation">vertical</property> + <property name="spacing">5</property> + <child> + <placeholder/> + </child> + <child> + <object class="GtkHButtonBox" id="hbuttonbox1"> + <property name="visible">True</property> + <property name="spacing">5</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button1"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button2"> + <property name="label">gtk-open</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkWindow" id="w_datasource"> + <property name="title" translatable="yes">Datasource - Audit GUI</property> + <property name="modal">True</property> + <property name="window_position">center-on-parent</property> + <property name="destroy_with_parent">True</property> + <child> + <object class="GtkVBox" id="vbox3"> + <property name="visible">True</property> + <property name="border_width">5</property> + <property name="orientation">vertical</property> + <property name="spacing">5</property> + <child> + <placeholder/> + </child> + <child> + <object class="GtkHButtonBox" id="hbuttonbox2"> + <property name="visible">True</property> + <property name="spacing">5</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button3"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button4"> + <property name="label">gtk-save</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkWindow" id="w_table"> + <property name="title" translatable="yes">Table - Audit GUI</property> + <property name="modal">True</property> + <property name="window_position">center-on-parent</property> + <property name="destroy_with_parent">True</property> + <child> + <object class="GtkVBox" id="vbox4"> + <property name="visible">True</property> + <property name="border_width">5</property> + <property name="orientation">vertical</property> + <property name="spacing">5</property> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">etched-in</property> + <child> + <object class="GtkTreeView" id="treeview1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">tstore_tables_fields</property> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <property name="title">Table</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext1"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn2"> + <property name="title">Field</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext2"/> + <attributes> + <attribute name="text">3</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererToggle" id="cellrenderertoggle1"/> + <attributes> + <attribute name="activatable">4</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHButtonBox" id="hbuttonbox3"> + <property name="visible">True</property> + <property name="spacing">5</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button5"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button6"> + <property name="label">gtk-save</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkTreeStore" id="tstore_tables_fields"> + <columns> + <!-- column-name id_table --> + <column type="guint"/> + <!-- column-name name_table --> + <column type="gchararray"/> + <!-- column-name id_field --> + <column type="guint"/> + <!-- column-name name_field --> + <column type="gchararray"/> + <!-- column-name choosen --> + <column type="gboolean"/> + </columns> + </object> +</interface> diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..1789045 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,15 @@ +guidir = $(datadir)/$(PACKAGE)/gui +formdir = $(datadir)/$(PACKAGE)/form + +AM_CPPFLAGS = $(AUDITGUI_CFLAGS) \ + -DGUIDIR=\""$(guidir)"\" \ + -DFORMDIR=\""$(formdir)"\" + +LIBS = $(AUDITGUI_LIBS) \ + -export-dynamic + +bin_PROGRAMS = audit-gui + +audit_gui_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..bbd47b8 --- /dev/null +++ b/src/commons.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 Andrea Zagli <a.zagli@comune.scandicci.fi.it> + * + * 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 <config.h> +#endif + +#ifndef __COMMONS_H__ +#define __COMMONS_H__ + +#include <gtk/gtk.h> + +#include <libgda/libgda.h> + +typedef struct + { + gchar *guidir; + gchar *formdir; + + GtkBuilder *gtkbuilder; + + GdaConnection *gdacon; + + const gchar *guifile; + } Commons; + +#endif /* __COMMONS_H__ */ diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..35e4d31 --- /dev/null +++ b/src/main.c @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2010 Andrea Zagli <a.zagli@comune.scandicci.fi.it> + * + * 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 <config.h> +#endif + +#include <gtk/gtk.h> + +#include <libaute.h> +#include <libgda/libgda.h> +#include <libgda-ui/libgda-ui.h> + +#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_nodi_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + GtkWidget *vbx; + + Nodi *m = nodi_new (commons, FALSE); + + vbx = nodi_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_window_set_transient_for (GTK_WINDOW (diag), GTK_WINDOW (w)); + gtk_dialog_run (GTK_DIALOG (diag)); + gtk_widget_destroy (diag); +} + +int +main (int argc, char *argv[]) +{ + GError *error; + + gtk_init (&argc, &argv); + + gda_init (); + + /* inizializzazione commons */ + commons = g_malloc (sizeof (Commons)); + +#ifdef G_OS_WIN32 + + gchar *moddir; + gchar *p; + + moddir = g_win32_get_package_installation_directory_of_module (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 + + commons->guidir = g_strdup (GUIDIR); + commons->formdir = g_strdup (FORMDIR); + +#endif + + commons->guifile = g_build_filename (commons->guidir, "audit-gui.gui", NULL); + + 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; +} -- 2.49.0