From: Andrea Zagli Date: Wed, 8 Jun 2011 14:36:07 +0000 (+0200) Subject: Initial import. X-Git-Tag: v0.0.1~16 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=b40f9d650359cfb4ab6400f627a1b1554ee7bfbf;p=zakautho%2Fgui Initial import. --- b40f9d650359cfb4ab6400f627a1b1554ee7bfbf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aee532a --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +*.o +*~ +*.in +src/autoz-gui +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..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 100755 index 0000000..81a7991 --- /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="autoz-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 autoz-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..e0acc21 --- /dev/null +++ b/configure.ac @@ -0,0 +1,39 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.65]) +AC_INIT([autoz-gui], [0.0.1], [azagli@libero.it]) +AC_CONFIG_SRCDIR([src/main.c]) +AC_CONFIG_HEADER([config.h]) + +AM_INIT_AUTOMAKE(-Wall) + +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) + +AM_MAINTAINER_MODE + +AC_CANONICAL_SYSTEM + +# Checks for programs. +AC_PROG_CC + +# Checks for libraries. +PKG_CHECK_MODULES(AUTOZGUI, [libgda-ui-4.0 >= 4.1.0]) + +AC_SUBST(AUTOZGUI_CFLAGS) +AC_SUBST(AUTOZGUI_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/autoz-gui/Makefile + data/autoz-gui/gui/Makefile +]) +AC_OUTPUT diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..4cd2946 --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = autoz-gui diff --git a/data/autoz-gui/Makefile.am b/data/autoz-gui/Makefile.am new file mode 100644 index 0000000..13c2b3d --- /dev/null +++ b/data/autoz-gui/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = gui diff --git a/data/autoz-gui/gui/Makefile.am b/data/autoz-gui/gui/Makefile.am new file mode 100644 index 0000000..a73fe1d --- /dev/null +++ b/data/autoz-gui/gui/Makefile.am @@ -0,0 +1,5 @@ +guidir = $(datadir)/$(PACKAGE)/gui + +gui_DATA = autoz-gui.gui + +EXTRA_DIST = $(gui_DATA) diff --git a/data/autoz-gui/gui/autoz-gui.ui b/data/autoz-gui/gui/autoz-gui.ui new file mode 100644 index 0000000..5d8a3d2 --- /dev/null +++ b/data/autoz-gui/gui/autoz-gui.ui @@ -0,0 +1,792 @@ + + + + + + Autoz GUI + center + 600 + 400 + + + + True + vertical + + + True + + + True + _File + True + + + True + + + gtk-open + True + True + True + + + + + + gtk-close + True + True + True + + + + + + True + + + + + gtk-quit + True + True + True + + + + + + + + + + True + _View + True + + + True + + + True + _Roles + True + + + + + True + Re_sources + True + + + + + True + _Authorizations + 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 + w_main + True + Autoz GUI + 0.0.1 + Andrea Zagli 2011 + Andrea Zagli <azagli@libero.it> + True + + + True + vertical + 2 + + + + + + True + end + + + False + end + 0 + + + + + + + Open Autoz Datasource - Autoz GUI + True + center-on-parent + True + + + True + 5 + vertical + 5 + + + + + + True + 5 + end + + + gtk-cancel + True + True + True + True + + + False + False + 0 + + + + + gtk-open + True + True + True + True + + + False + False + 1 + + + + + False + 1 + + + + + + + Role - Autoz GUI + True + center-on-parent + True + + + True + 5 + vertical + 5 + + + True + 3 + 2 + 5 + 5 + + + True + 0 + ID + + + GTK_FILL + GTK_FILL + + + + + True + 0 + lbl_id + + + 1 + 2 + GTK_FILL + + + + + True + 0 + Name + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + True + 30 + + + + 1 + 2 + 1 + 2 + 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 + + + + + + + + + + + + + + + + + + + + + + + Roles - Autoz GUI + True + center-on-parent + True + + + True + 5 + vertical + 5 + + + True + True + automatic + automatic + etched-in + + + True + True + lstore_roles + False + True + 1 + + + Roles + + + + 1 + + + + + + + + + 0 + + + + + True + 5 + end + + + gtk-new + True + 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 + + + + + + + Audit GUI + True + center-on-parent + 550 + True + False + + + True + 5 + vertical + 5 + + + True + label + + + False + 0 + + + + + True + + + False + 1 + + + + + + + Resource - Autoz GUI + True + center-on-parent + True + + + True + 5 + vertical + 5 + + + True + 3 + 2 + 5 + 5 + + + True + 0 + ID + + + GTK_FILL + GTK_FILL + + + + + True + 0 + lbl_id + + + 1 + 2 + GTK_FILL + + + + + True + 0 + Name + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + True + 30 + + + + 1 + 2 + 1 + 2 + 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 + + + + + + + Resources - Autoz GUI + True + center-on-parent + True + + + True + 5 + vertical + 5 + + + True + True + automatic + automatic + etched-in + + + True + True + lstore_resources + False + True + 1 + + + Resources + + + + 1 + + + + + + + + + 0 + + + + + True + 5 + end + + + gtk-new + True + 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/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..5c053d6 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,15 @@ +guidir = $(datadir)/$(PACKAGE)/gui + +AM_CPPFLAGS = $(AUDITGUI_CFLAGS) \ + -DGUIDIR=\""$(guidir)"\" + +LIBS = $(AUDITGUI_LIBS) \ + -export-dynamic + +bin_PROGRAMS = autoz-gui + +autoz_gui_SOURCES = \ + commons.h \ + main.c \ + openauditds.c \ + openauditds.h diff --git a/src/commons.h b/src/commons.h new file mode 100644 index 0000000..0fc225b --- /dev/null +++ b/src/commons.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2011 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 + { + const gchar *guidir; + const gchar *guifile; + + GtkBuilder *gtkbuilder; + + GdaConnection *gdacon; + GdaSqlParser *gdaparser; + } Commons; + +#endif /* __COMMONS_H__ */ diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..0e8b23d --- /dev/null +++ b/src/main.c @@ -0,0 +1,230 @@ +/* + * Copyright (C) 2011 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 + +#include "commons.h" +#include "openauditds.h" + +G_MODULE_EXPORT void on_mnu_file_close_activate (GtkMenuItem *menuitem, + gpointer user_data); + +static Commons *commons; + +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); +} + +static void +main_on_ds_opened (gpointer instance, const gchar *arg1, gpointer user_data) +{ + GtkWidget *vbx; + GError *error; + + gchar *cnc; + gchar *pos; + + if (arg1 == NULL) + { + return; + } + + cnc = g_strstrip (g_strdup (arg1)); + if (g_strcmp0 (cnc, "") == 0) + { + return; + } + + error = NULL; + commons->gdacon = gda_connection_open_from_string (NULL, cnc, NULL, + GDA_CONNECTION_OPTIONS_NONE, + &error); + if (!commons->gdacon || error != NULL) + { + GtkWidget *dialog; + dialog = gtk_message_dialog_new (GTK_WINDOW (w), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Unable to connect to the choosen autoz db.\n\n%s\n\n%s", + arg1, + (error != NULL && error->message != NULL ? error->message : "No details.")); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + return; + } + + commons->gdaparser = gda_connection_create_parser (commons->gdacon); + if (!commons->gdaparser) + { + /* @cnc doe snot provide its own parser => use default one */ + commons->gdaparser = gda_sql_parser_new (); + } + + gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "menuitem2")), TRUE); + + g_free (cnc); +} + +G_MODULE_EXPORT void +on_mnu_file_open_audit_ds_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + GtkWidget *vbx; + + if (vbx_body_child != NULL) + { + on_mnu_file_close_activate (NULL, user_data); + } + + OpenAuditDS *m = open_audit_ds_new (commons); + + vbx = open_audit_ds_get_widget (m); + + g_signal_connect (G_OBJECT (m), "opened", + G_CALLBACK (main_on_ds_opened), NULL); + + gtk_window_set_transient_for (GTK_WINDOW (vbx), GTK_WINDOW (w)); + gtk_widget_show_all (vbx); +} + +G_MODULE_EXPORT void +on_mnu_file_close_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + gtk_widget_destroy (vbx_body_child); + vbx_body_child = NULL; + + gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "menuitem2")), FALSE); +} + +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_malloc0 (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) + { + commons->guidir = g_strdup (GUIDIR); + } + else + { + commons->guidir = g_build_filename (moddir, "share", PACKAGE, "gui", NULL); + } + +#else + + commons->guidir = g_strdup (GUIDIR); + +#endif + + commons->guifile = g_build_filename (commons->guidir, "autoz-gui.ui", 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_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "menuitem2")), FALSE); + + if (argc > 0) + { + /* try to use the first argument of command line as a cnc_string */ + main_on_ds_opened (NULL, argv[1], NULL); + } + + gtk_main (); + + return 0; +} diff --git a/src/openauditds.c b/src/openauditds.c new file mode 100644 index 0000000..e7aa48f --- /dev/null +++ b/src/openauditds.c @@ -0,0 +1,240 @@ +/* + * Copyright (C) 2011 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include + +#include "openauditds.h" + +static void open_audit_ds_class_init (OpenAuditDSClass *klass); +static void open_audit_ds_init (OpenAuditDS *open_audit_ds); + +static void open_audit_ds_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void open_audit_ds_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static void open_audit_ds_on_wlogin_changed (GdauiLogin *gdauilogin, + gboolean arg1, + gpointer user_data); + +static void open_audit_ds_on_btn_cancel_clicked (GtkButton *button, + gpointer user_data); +static void open_audit_ds_on_btn_open_clicked (GtkButton *button, + gpointer user_data); + +#define OPEN_AUDIT_DS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_OPEN_AUDIT_DS, OpenAuditDSPrivate)) + +typedef struct _OpenAuditDSPrivate OpenAuditDSPrivate; +struct _OpenAuditDSPrivate + { + Commons *commons; + + GtkWidget *w; + GtkWidget *wlogin; + }; + +G_DEFINE_TYPE (OpenAuditDS, open_audit_ds, G_TYPE_OBJECT) + +static void +open_audit_ds_class_init (OpenAuditDSClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (OpenAuditDSPrivate)); + + object_class->set_property = open_audit_ds_set_property; + object_class->get_property = open_audit_ds_get_property; + + /** + * OpenAuditDS::opened: + * @open_audit_ds: + * + */ + klass->opened_signal_id = g_signal_new ("opened", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, G_TYPE_STRING); +} + +static void +open_audit_ds_init (OpenAuditDS *open_audit_ds) +{ + OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); +} + +/** + * open_audit_ds_new: + * @commons: + * @id: + * + * Returns: the newly created #OpenAuditDS object. + */ +OpenAuditDS +*open_audit_ds_new (Commons *commons) +{ + GError *error; + + GdauiLoginMode mode; + + OpenAuditDS *a = OPEN_AUDIT_DS (g_object_new (open_audit_ds_get_type (), NULL)); + + OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (a); + + priv->commons = commons; + + error = NULL; + gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile, + g_strsplit ("w_open_audit_datasource", "|", -1), + &error); + if (error != NULL) + { + g_warning ("Errore: %s.", error->message); + return NULL; + } + + priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_open_audit_datasource")); + + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button1"), + "clicked", G_CALLBACK (open_audit_ds_on_btn_cancel_clicked), (gpointer *)a); + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button2"), + "clicked", G_CALLBACK (open_audit_ds_on_btn_open_clicked), (gpointer *)a); + + /* creating login widget */ + priv->wlogin = gdaui_login_new (NULL); + + g_object_get (G_OBJECT (priv->wlogin), "mode", &mode, NULL); + mode |= GDA_UI_LOGIN_HIDE_DSN_SELECTION_MODE; + gdaui_login_set_mode (GDAUI_LOGIN (priv->wlogin), mode); + + g_signal_connect (G_OBJECT (priv->wlogin), "changed", + G_CALLBACK (open_audit_ds_on_wlogin_changed), (gpointer *)a); + + gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (priv->commons->gtkbuilder, "vbox2")), + priv->wlogin, TRUE, TRUE, 0); + gtk_box_reorder_child (GTK_BOX (gtk_builder_get_object (priv->commons->gtkbuilder, "vbox2")), + priv->wlogin, 0); + + gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button2")), FALSE); + + return a; +} + +/** + * open_audit_ds_get_widget: + * @open_audit_ds: + * + */ +GtkWidget +*open_audit_ds_get_widget (OpenAuditDS *open_audit_ds) +{ + OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + + return priv->w; +} + +/* PRIVATE */ +static void +open_audit_ds_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + OpenAuditDS *open_audit_ds = OPEN_AUDIT_DS (object); + + OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +open_audit_ds_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + OpenAuditDS *open_audit_ds = OPEN_AUDIT_DS (object); + + OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +/* CALLBACK */ +static void +open_audit_ds_on_wlogin_changed (GdauiLogin *gdauilogin, + gboolean arg1, + gpointer user_data) +{ + OpenAuditDS *open_audit_ds = (OpenAuditDS *)user_data; + + OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + + gboolean is_valid; + + g_object_get (G_OBJECT (priv->wlogin), "valid", &is_valid, NULL); + gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button2")), + is_valid); +} + +static void +open_audit_ds_on_btn_cancel_clicked (GtkButton *button, + gpointer user_data) +{ + OpenAuditDS *open_audit_ds = (OpenAuditDS *)user_data; + + OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + + gtk_widget_destroy (priv->w); +} + +static void +open_audit_ds_on_btn_open_clicked (GtkButton *button, + gpointer user_data) +{ + OpenAuditDS *open_audit_ds = (OpenAuditDS *)user_data; + OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + OpenAuditDSClass *klass = OPEN_AUDIT_DS_GET_CLASS (open_audit_ds); + + gchar *cncstring; + + const GdaDsnInfo *info; + info = gdaui_login_get_connection_information (GDAUI_LOGIN (priv->wlogin)); + + cncstring = g_strconcat (info->provider, "://", + (info->auth_string != NULL ? g_strdup_printf ("%s;", info->auth_string) : ""), + info->cnc_string, + NULL); + + g_signal_emit (open_audit_ds, klass->opened_signal_id, 0, cncstring); + + gtk_widget_destroy (priv->w); +} diff --git a/src/openauditds.h b/src/openauditds.h new file mode 100644 index 0000000..dced370 --- /dev/null +++ b/src/openauditds.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2010-2011 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __OPEN_AUDIT_DS_H__ +#define __OPEN_AUDIT_DS_H__ + +#include +#include + +#include + +#include "commons.h" + +G_BEGIN_DECLS + + +#define TYPE_OPEN_AUDIT_DS (open_audit_ds_get_type ()) +#define OPEN_AUDIT_DS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_OPEN_AUDIT_DS, OpenAuditDS)) +#define OPEN_AUDIT_DS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_OPEN_AUDIT_DS, OpenAuditDSClass)) +#define IS_OPEN_AUDIT_DS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_OPEN_AUDIT_DS)) +#define IS_OPEN_AUDIT_DS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_OPEN_AUDIT_DS)) +#define OPEN_AUDIT_DS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_OPEN_AUDIT_DS, OpenAuditDSClass)) + + +typedef struct _OpenAuditDS OpenAuditDS; +typedef struct _OpenAuditDSClass OpenAuditDSClass; + +struct _OpenAuditDS + { + GObject parent; + }; + +struct _OpenAuditDSClass + { + GObjectClass parent_class; + + guint opened_signal_id; + }; + +GType open_audit_ds_get_type (void) G_GNUC_CONST; + +OpenAuditDS *open_audit_ds_new (Commons *commons); + +GtkWidget *open_audit_ds_get_widget (OpenAuditDS *open_audit_ds); + + +G_END_DECLS + +#endif /* __OPEN_AUDIT_DS_H__ */