# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([libzakauthedb], [0.5.0], [azagli@libero.it])
+AC_INIT([libzakauthedb], [0.5.99], [azagli@libero.it])
AC_CONFIG_SRCDIR([src/aute_db.c])
AC_CONFIG_HEADER([config.h])
AC_PROG_CC
AC_PROG_LIBTOOL
+dnl ******************************
+dnl Translations
+dnl ******************************
+GETTEXT_PACKAGE=zakformtests
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
+ [The prefix for our gettext translation domains.])
+AM_GLIB_GNU_GETTEXT
+
# Checks for libraries.
PKG_CHECK_MODULES(LIBAUTEDB, [libzakauthe >= 0.5.0
- libgtkform >= 0.5.0])
+ libzakform
+ libzakformgtk
+ libzakformgdaex])
AC_SUBST(LIBAUTEDB_CFLAGS)
AC_SUBST(LIBAUTEDB_LIBS)
<?xml version="1.0"?>
-<gtkform>
-
- <table>users</table>
-
- <widget type="entry" name="entry1" label="label6">
- <field type="text" name="code">
- <is-key>t</is-key>
- <obligatory>t</obligatory>
- </field>
- </widget>
-
- <widget type="label" name="label14">
- <field type="text" name="password">
- </field>
- </widget>
-
- <widget type="entry" name="entry2" label="label7">
- <field type="text" name="surname">
- <obligatory>t</obligatory>
- </field>
- </widget>
-
- <widget type="entry" name="entry3" label="label8">
- <field type="text" name="name" />
- </widget>
-
- <widget type="checkbox" name="checkbutton1" label="label9">
- <field type="boolean" name="enabled">
- <default>t</default>
- </field>
- </widget>
-
- <widget type="entry" name="entry4" label="label11">
- <field type="datetime" name="password_expiration">
- <datetime-type>datetime</datetime-type>
- <display-format>%d/%m/%Y %H.%M.%S</display-format>
- </field>
- </widget>
-
- <widget type="textview" name="textview1" label="label12">
- <field type="text" name="notes" />
- </widget>
-
-</gtkform>
+<zakform>
+
+ <element type="zak_form_gtk_form_element_entry">
+ <name>code</name>
+ <type>string</type>
+ <is-key>TRUE</is-key>
+ <widget>entry1</widget>
+ <label>label6</label>
+ <validator type="zak_form_element_validator_notempty"></validator>
+ </element>
+
+ <element type="zak_form_gtk_form_element_label">
+ <name>password</name>
+ <type>string</type>
+ <widget>label14</widget>
+ </element>
+
+ <element type="zak_form_gtk_form_element_entry">
+ <name>surname</name>
+ <type>string</type>
+ <widget>entry2</widget>
+ <label>label7</label>
+ <validator type="zak_form_element_validator_notempty"></validator>
+ </element>
+
+ <element type="zak_form_gtk_form_element_entry">
+ <name>name</name>
+ <type>string</type>
+ <widget>entry3</widget>
+ <label>label8</label>
+ </element>
+
+ <element type="zak_form_gtk_form_element_check">
+ <name>enabled</name>
+ <type>boolean</type>
+ <widget>checkbutton1</widget>
+ <label>label11</label>
+ </element>
+
+ <element type="zak_form_gtk_form_element_entry">
+ <name>password_expiration</name>
+ <type>datetime</type>
+ <format>%d/%m/%Y %H.%M.%S</format>
+ <widget>entry4</widget>
+ <label>label11</label>
+ <validator type="zak_form_element_validator_date">%d/%m/%Y %H.%M.%S</validator>
+ </element>
+
+ <element type="zak_form_gtk_form_element_textview">
+ <name>notes</name>
+ <type>string</type>
+ <widget>textview1</widget>
+ <label>label12</label>
+ </element>
+
+</zakform>
/*
- * Copyright (C) 2010-2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2016 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
*/
-#include <libgtkform/form.h>
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <libzakform/libzakform.h>
+#include <libzakformgtk/libzakformgtk.h>
+#include <libzakformgdaex/libzakformgdaex.h>
#include "user.h"
#include "aute_db.h"
#define USER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_USER, UserPrivate))
-enum
-{
- TXT_CODE,
- LBL_PASSWORD
-};
-
typedef struct _UserPrivate UserPrivate;
struct _UserPrivate
{
gchar *guifile;
gchar *formdir;
- GtkForm *form;
+ ZakFormGtkForm *form;
+ ZakFormGdaexProvider *provider;
GtkWidget *w;
- GObject **objects;
-
gchar *code;
};
return NULL;
}
- priv->form = gtk_form_new ();
- g_object_set (priv->form, "gdaex", priv->gdaex, NULL);
- gtk_form_load_from_file (priv->form, g_build_filename (priv->formdir, "user.form", NULL), priv->gtkbuilder);
+ priv->form = zak_form_gtk_form_new ();
+ zak_form_gtk_form_set_gtkbuilder (priv->form, priv->gtkbuilder);
+ zak_form_form_load_from_file (ZAK_FORM_FORM (priv->form), g_build_filename (priv->formdir, "user.form", NULL));
+ zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
- g_object_set (priv->form, "gdaex", priv->gdaex, NULL);
+ priv->provider = zak_form_gdaex_provider_new (gdaex, "users");
priv->w = GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "w_user"));
- priv->objects = gtk_form_get_objects_by_name (priv->form,
- "entry1",
- "label14",
- NULL);
-
g_signal_connect (priv->w,
"delete-event", G_CALLBACK (user_on_w_user_delete_event), (gpointer *)a);
}
if (priv->code == NULL || g_strcmp0 (priv->code, "") == 0)
{
- gtk_form_clear (priv->form);
+ zak_form_form_clear (ZAK_FORM_FORM (priv->form));
}
else
{
- gtk_entry_set_text (GTK_ENTRY (priv->objects[TXT_CODE]), priv->code);
- gtk_editable_set_editable (GTK_EDITABLE (priv->objects[TXT_CODE]), FALSE);
+ gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (priv->gtkbuilder, "entry1")), priv->code);
+ gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (priv->gtkbuilder, "entry1")), FALSE);
user_carica (a);
}
{
UserPrivate *priv = USER_GET_PRIVATE (user);
- if (gtk_form_fill_from_table (priv->form))
- {
- }
+ zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->provider));
}
static void
user_salva (User *user)
{
GError *error = NULL;
- gchar *sql;
+ gboolean ret;
GtkWidget *dialog;
- GDate *da;
- GDate *a;
-
UserClass *klass = USER_GET_CLASS (user);
UserPrivate *priv = USER_GET_PRIVATE (user);
- if (!gtk_form_check (priv->form, FALSE, NULL, TRUE, priv->w, TRUE))
+ if (!zak_form_gtk_form_is_valid (priv->form, priv->w))
{
return;
}
if (priv->code == NULL || g_strcmp0 (priv->code, "") == 0)
{
- gtk_label_set_text (GTK_LABEL (priv->objects[LBL_PASSWORD]),
- zak_authe_db_encrypt_password (gtk_entry_get_text (GTK_ENTRY (priv->objects[TXT_CODE]))));
- sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_INSERT);
+ gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (priv->gtkbuilder, "label14")),
+ zak_authe_db_encrypt_password (gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (priv->gtkbuilder, "entry1")))));
+ ret = zak_form_form_insert (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->provider));
}
else
{
- sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_UPDATE);
+ ret = zak_form_form_update (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->provider));
}
- if (gdaex_execute (priv->gdaex, sql) == 1)
+ if (ret)
{
g_signal_emit (user, klass->aggiornato_signal_id, 0);
- gtk_form_set_as_origin (priv->form);
+ zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
GTK_DIALOG_DESTROY_WITH_PARENT,
UserPrivate *priv = USER_GET_PRIVATE (user);
ret = TRUE;
- if (gtk_form_is_changed (priv->form))
+ if (zak_form_form_is_changed (ZAK_FORM_FORM (priv->form)))
{
dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
GTK_DIALOG_DESTROY_WITH_PARENT,