]> saetta.ns0.it Git - libgtkdateentry/commitdiff
Plugin for libgtkform. gtkform
authorAndrea Zagli <azagli@libero.it>
Sun, 27 Jun 2010 11:00:02 +0000 (13:00 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 27 Jun 2010 11:00:02 +0000 (13:00 +0200)
14 files changed:
.gitignore
configure.ac
docs/reference/gtkdateentry-decl-list.txt
docs/reference/gtkdateentry-decl.txt
docs/reference/gtkdateentry-undocumented.txt
docs/reference/gtkdateentry-unused.txt
src/Makefile.am
src/gtkdateentry.c
src/gtkformwidgetdateentry.c [new file with mode: 0644]
src/gtkformwidgetdateentry.h [new file with mode: 0644]
tests/Makefile.am
tests/plugin_gtkform.c [new file with mode: 0644]
tests/plugin_gtkform.form [new file with mode: 0644]
tests/plugin_gtkform.ui [new file with mode: 0644]

index 8685cb3d69c61d3ac9109b856aca096d774120af..2521cb4ccce7277807dbb9ba3c2d9802f3af51df 100644 (file)
@@ -46,3 +46,5 @@ mkinstalldirs
 stamp-it
 intltool-*
 Rules-quot
+tests/plugin_gtkform
+*.exe
index de26c58654353e0dfac9181446bab22246205cef..8be725a45198874c1d6a506e70004869d6403879 100644 (file)
@@ -32,12 +32,22 @@ GTK_DOC_CHECK(1.0)
 PKG_CHECK_MODULES(GTKDATEENTRY, [gtk+-2.0 >= 2.6.8
                                  libgtkmaskedentry >= 0.0.1])
 PKG_CHECK_EXISTS(gladeui-1.0 >= 3.2.0, [GLADEUI_FOUND=yes], [GLADEUI_FOUND=no])
+PKG_CHECK_EXISTS(libgtkform >= 0.2.0, [LIBGTKFORM_FOUND=yes], [LIBGTKFORM_FOUND=no])
 
 AM_CONDITIONAL(GLADEUI, test $GLADEUI_FOUND = yes)
+AM_CONDITIONAL(LIBGTKFORM_FOUND, test $LIBGTKFORM_FOUND = yes)
 
 AC_SUBST(GTKDATEENTRY_CFLAGS)
 AC_SUBST(GTKDATEENTRY_LIBS)
 
+if test $LIBGTKFORM_FOUND = yes; then
+PKG_CHECK_MODULES(GTKFORM, libgtkform >= 0.2.0)
+
+AC_SUBST(GTKFORM_CFLAGS)
+AC_SUBST(GTKFORM_LIBS)
+AC_SUBST(LIBGTKFORM_FOUND)
+fi
+
 # Output files
 AC_CONFIG_FILES([
   libgtkdateentry.pc
index 5ea4575bb362d3b8faebcb8be48a980386752cf0..4e60b944776d75e64579118b59cfc910cfc8ee24 100644 (file)
@@ -27,3 +27,22 @@ gtk_date_entry_get_type
 GTK_IS_DATE_CLASS
 </SECTION>
 
+<SECTION>
+<FILE>gtkformwidgetdateentry</FILE>
+<TITLE>GtkFormWidgetDateEntry</TITLE>
+GtkFormWidgetDateEntry
+GtkFormWidgetDateEntryClass
+gtk_form_widget_date_entry_new
+gtk_form_widget_date_entry_get_value_stringify
+gtk_form_widget_date_entry_set_value_stringify
+gtk_form_widget_date_entry_set_editable
+<SUBSECTION Standard>
+GTK_FORM_WIDGET_DATE_ENTRY
+GTK_FORM_IS_WIDGET_DATE_ENTRY
+GTK_FORM_TYPE_WIDGET_DATE_ENTRY
+gtk_form_widget_date_entry_get_type
+GTK_FORM_WIDGET_DATE_ENTRY_CLASS
+GTK_FORM_IS_WIDGET_DATE_ENTRY_CLASS
+GTK_FORM_WIDGET_DATE_ENTRY_GET_CLASS
+</SECTION>
+
index a5958a2fef68ba73bc4405878b5b832affb6b990..d1fea4adacf6c2b5a0fa954ee37594abb828297d 100644 (file)
@@ -117,3 +117,72 @@ GtkDateEntry *date, gboolean is_editable_with_calendar
 <RETURNS>void </RETURNS>
 GtkDateEntry *date, gboolean is_visible 
 </FUNCTION>
+<MACRO>
+<NAME>GTK_FORM_TYPE_WIDGET_DATE_ENTRY</NAME>
+#define GTK_FORM_TYPE_WIDGET_DATE_ENTRY                 (gtk_form_widget_date_entry_get_type ())
+</MACRO>
+<MACRO>
+<NAME>GTK_FORM_WIDGET_DATE_ENTRY</NAME>
+#define GTK_FORM_WIDGET_DATE_ENTRY(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_FORM_TYPE_WIDGET_DATE_ENTRY, GtkFormWidgetDateEntry))
+</MACRO>
+<MACRO>
+<NAME>GTK_FORM_WIDGET_DATE_ENTRY_CLASS</NAME>
+#define GTK_FORM_WIDGET_DATE_ENTRY_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_FORM_TYPE_WIDGET_DATE_ENTRY, GtkFormWidgetDateEntryClass))
+</MACRO>
+<MACRO>
+<NAME>GTK_FORM_IS_WIDGET_DATE_ENTRY</NAME>
+#define GTK_FORM_IS_WIDGET_DATE_ENTRY(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_FORM_TYPE_WIDGET_DATE_ENTRY))
+</MACRO>
+<MACRO>
+<NAME>GTK_FORM_IS_WIDGET_DATE_ENTRY_CLASS</NAME>
+#define GTK_FORM_IS_WIDGET_DATE_ENTRY_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_FORM_TYPE_WIDGET_DATE_ENTRY))
+</MACRO>
+<MACRO>
+<NAME>GTK_FORM_WIDGET_DATE_ENTRY_GET_CLASS</NAME>
+#define GTK_FORM_WIDGET_DATE_ENTRY_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_FORM_TYPE_WIDGET_DATE_ENTRY, GtkFormWidgetDateEntryClass))
+</MACRO>
+<STRUCT>
+<NAME>GtkFormWidgetDateEntry</NAME>
+</STRUCT>
+<STRUCT>
+<NAME>GtkFormWidgetDateEntryClass</NAME>
+</STRUCT>
+<STRUCT>
+<NAME>GtkFormWidgetDateEntry</NAME>
+struct _GtkFormWidgetDateEntry
+       {
+               GtkFormWidget parent;
+       };
+</STRUCT>
+<STRUCT>
+<NAME>GtkFormWidgetDateEntryClass</NAME>
+struct _GtkFormWidgetDateEntryClass
+       {
+               GtkFormWidgetClass parent_class;
+       };
+</STRUCT>
+<FUNCTION>
+<NAME>gtk_form_widget_date_entry_get_type</NAME>
+<RETURNS>GType </RETURNS>
+void 
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_widget_date_entry_new</NAME>
+<RETURNS>GtkFormWidget *</RETURNS>
+void 
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_widget_date_entry_get_value_stringify</NAME>
+<RETURNS>gchar *</RETURNS>
+GtkFormWidget *widget 
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_widget_date_entry_set_value_stringify</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormWidget *fwidget, const gchar *value 
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_widget_date_entry_set_editable</NAME>
+<RETURNS>void </RETURNS>
+GtkFormWidget *fwidget, gboolean editable 
+</FUNCTION>
index bc71459fad622e75f5f4afafadae928d114176c6..26999e9ac1f42e07db525feeb3d0c09baab1d3fd 100644 (file)
@@ -1,11 +1,15 @@
-83% symbol docs coverage.
+68% symbol docs coverage.
 15 symbols documented.
 0 symbols incomplete.
-3 not documented.
+7 not documented.
 
 
 gtk_date_entry_get_gdate
 gtk_date_entry_get_strf
 gtk_date_entry_get_tm
+gtk_form_widget_date_entry_get_value_stringify
+gtk_form_widget_date_entry_new
+gtk_form_widget_date_entry_set_value_stringify
+gtk_form_widget_set_editable
 
 
index 9646cae1ddec326b075c7f761b8c6518529f3890..384eb58c9701cada61370ef3c434e5525c1d35f5 100644 (file)
@@ -1,3 +1,11 @@
+GTK_FORM_IS_WIDGET_DATE_ENTRY
+GTK_FORM_IS_WIDGET_DATE_ENTRY_CLASS
+GTK_FORM_TYPE_WIDGET_DATE_ENTRY
+GTK_FORM_WIDGET_DATE_ENTRY
+GTK_FORM_WIDGET_DATE_ENTRY_CLASS
+GTK_FORM_WIDGET_DATE_ENTRY_GET_CLASS
+GtkFormWidgetDateEntry
+GtkFormWidgetDateEntryClass
 gtk_date_entry_get_gdate
 gtk_date_entry_get_tm
 gtk_date_entry_is_valid
@@ -7,3 +15,8 @@ gtk_date_entry_set_date_strf
 gtk_date_entry_set_date_tm
 gtk_date_entry_set_editable
 gtk_date_entry_set_editable_with_calendar
+gtk_form_widget_date_entry_get_type
+gtk_form_widget_date_entry_get_value_stringify
+gtk_form_widget_date_entry_new
+gtk_form_widget_date_entry_set_editable
+gtk_form_widget_date_entry_set_value_stringify
index 2093681dd7978fa579aa5549a235bb2bbbf7d398..e30cc51852c62cf3a78c8e97131fb7f5ec50a8e9 100644 (file)
@@ -1,13 +1,38 @@
 AM_CPPFLAGS = $(WARN_CFLAGS) \
               $(DISABLE_DEPRECATED_CFLAGS) \
-              $(GTKDATEENTRY_CFLAGS)
+              $(GTKDATEENTRY_CFLAGS) \
+              $(GTKFORM_CFLAGS)
 
-LIBS = $(GTKDATEENTRY_LIBS)
+LIBS = $(GTKDATEENTRY_LIBS) \
+       $(GTKFORM_LIBS)
+
+if LIBGTKFORM_FOUND
+GTKFORM_C = gtkformwidgetdateentry.c
+GTKFORM_H = gtkformwidgetdateentry.h
+libgtkformmodulesdir = `pkg-config --variable=modulesdir libgtkform`
+else
+GTKFORM_C =
+GTKFORM_H =
+libgtkformmodulesdir =
+endif
 
 lib_LTLIBRARIES = libgtkdateentry.la
 
-libgtkdateentry_la_SOURCES = gtkdateentry.c
+libgtkdateentry_la_SOURCES = gtkdateentry.c \
+                             $(GTKFORM_C)
 
 libgtkdateentry_la_LDFLAGS = -no-undefined
 
-include_HEADERS = gtkdateentry.h
+include_HEADERS = gtkdateentry.h \
+                  $(GTKFORM_H)
+
+install-exec-hook:
+       if test "x$(LIBGTKFORM_FOUND)" = "xyes"; then \
+               cd $(libgtkformmodulesdir) && \
+               ln -s -f $(libdir)/libgtkdateentry.so .; \
+       fi
+
+uninstall-hook:
+       if test "x$(LIBGTKFORM_FOUND)" = "xyes"; then \
+               rm -f $(libgtkformmodulesdir)/libgtkdateentry.so
+       fi
index 2ae57b4a563d55cf9394ef47f5cbfeba8f99aa31..eb4f9bfb60dea744e3057e9e5ec44ad9e99782b1 100644 (file)
@@ -422,21 +422,27 @@ GDate
        gint i, pos = 0, val;
        gchar *txt;
        GDate *gdate;
+       GDateDay gday;
+       GDateMonth gmon;
+       GDateYear gyear;
 
        GtkDateEntryPrivate *priv = GTK_DATE_ENTRY_GET_PRIVATE (date);
 
+       gday = G_DATE_BAD_DAY;
+       gmon = G_DATE_BAD_MONTH;
+       gyear = G_DATE_BAD_YEAR;
+
        txt = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->day));
-       gdate = g_date_new ();
 
        for (i = 0; i < 3; i++)
                {
                        switch (priv->format[i])
                                {
                                        case 'd':
-                                               val = atol (g_strndup (txt + pos, 2));
+                                               val = strtol (g_strndup (txt + pos, 2), NULL, 10);
                                                if (g_date_valid_day ((GDateDay)val))
                                                        {
-                                                               g_date_set_day (gdate, (GDateDay)val);
+                                                               gday = (GDateDay)val;
                                                                pos += 3;
                                                        }
                                                else
@@ -446,10 +452,10 @@ GDate
                                                break;
 
                                        case 'm':
-                                               val = atol (g_strndup (txt + pos, 2));
+                                               val = strtol (g_strndup (txt + pos, 2), NULL, 10);
                                                if (g_date_valid_month ((GDateMonth)val))
                                                        {
-                                                               g_date_set_month (gdate, (GDateMonth)val);
+                                                               gmon = (GDateMonth)val;
                                                                pos += 3;
                                                        }
                                                else
@@ -459,10 +465,10 @@ GDate
                                                break;
 
                                        case 'Y':
-                                               val = atol (g_strndup (txt + pos, 4));
+                                               val = strtol (g_strndup (txt + pos, 4), NULL, 10);
                                                if (g_date_valid_year ((GDateYear)val))
                                                        {
-                                                               g_date_set_year (gdate, (GDateYear)val);
+                                                               gyear = (GDateYear)val;
                                                                pos += 5;
                                                        }
                                                else
@@ -473,7 +479,16 @@ GDate
                                }
                }
 
-       return gdate;
+       if (g_date_valid_day (gday)
+               && g_date_valid_month (gmon)
+               && g_date_valid_year (gyear))
+               {
+                       return g_date_new_dmy (gday, gmon, gyear);
+               }
+       else
+               {
+                       return NULL;
+               }
 }
 
 /**
diff --git a/src/gtkformwidgetdateentry.c b/src/gtkformwidgetdateentry.c
new file mode 100644 (file)
index 0000000..7906486
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2010 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
+ * 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 <gtk/gtk.h>
+
+#include "gtkdateentry.h"
+#include "gtkformwidgetdateentry.h"
+
+enum
+{
+       PROP_0
+};
+
+static void gtk_form_widget_date_entry_class_init (GtkFormWidgetDateEntryClass *klass);
+static void gtk_form_widget_date_entry_init (GtkFormWidgetDateEntry *gtk_form_widget_date_entry);
+
+static void gtk_form_widget_date_entry_set_property (GObject *object,
+                                      guint property_id,
+                                      const GValue *value,
+                                      GParamSpec *pspec);
+static void gtk_form_widget_date_entry_get_property (GObject *object,
+                                      guint property_id,
+                                      GValue *value,
+                                      GParamSpec *pspec);
+
+#define GTK_FORM_WIDGET_DATE_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_FORM_TYPE_WIDGET_DATE_ENTRY, GtkFormWidgetDateEntryPrivate))
+
+typedef struct _GtkFormWidgetDateEntryPrivate GtkFormWidgetDateEntryPrivate;
+struct _GtkFormWidgetDateEntryPrivate
+       {
+               gpointer foo;
+       };
+
+
+G_DEFINE_TYPE (GtkFormWidgetDateEntry, gtk_form_widget_date_entry, TYPE_GTK_FORM_WIDGET)
+
+static void
+gtk_form_widget_date_entry_class_init (GtkFormWidgetDateEntryClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
+
+       object_class->set_property = gtk_form_widget_date_entry_set_property;
+       object_class->get_property = gtk_form_widget_date_entry_get_property;
+
+       widget_class->get_value_stringify = gtk_form_widget_date_entry_get_value_stringify;
+       widget_class->set_value_stringify = gtk_form_widget_date_entry_set_value_stringify;
+       widget_class->set_editable = gtk_form_widget_date_entry_set_editable;
+
+       g_type_class_add_private (object_class, sizeof (GtkFormWidgetDateEntryPrivate));
+}
+
+static void
+gtk_form_widget_date_entry_init (GtkFormWidgetDateEntry *gtk_form_widget_date_entry)
+{
+}
+
+/**
+ * gtk_form_widget_date_entry_new:
+ *
+ * Returns: the newly created #GtkFormWidgetDateEntry.
+ */
+GtkFormWidget
+*gtk_form_widget_date_entry_new ()
+{
+       return g_object_new (gtk_form_widget_date_entry_get_type (), NULL);
+}
+
+/**
+ * gtk_form_widget_date_entry_get_value_stringify:
+ * @widget:
+ *
+ */
+gchar
+*gtk_form_widget_date_entry_get_value_stringify (GtkFormWidget *fwidget)
+{
+       GtkFormWidgetDateEntryPrivate *priv = GTK_FORM_WIDGET_DATE_ENTRY_GET_PRIVATE (fwidget);
+
+       GtkWidget *w = gtk_form_widget_get_widget (fwidget);
+
+       return g_strdup (gtk_date_entry_get_strf (GTK_DATE_ENTRY (w), "Ymd", '-'));
+}
+
+/**
+ * gtk_form_widget_date_entry_set_value_stringify:
+ * @fwidget:
+ * @value:
+ *
+ */
+gboolean
+gtk_form_widget_date_entry_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_entry_set_text (GTK_ENTRY (w), value);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_set_editable:
+ * @fwidget:
+ * @editable:
+ *
+ */
+void
+gtk_form_widget_date_entry_set_editable (GtkFormWidget *fwidget, gboolean editable)
+{
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_editable_set_editable (GTK_EDITABLE (w), editable);
+}
+
+/* PRIVATE */
+static void
+gtk_form_widget_date_entry_set_property (GObject *object,
+                                guint property_id,
+                                const GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetDateEntry *widget_entry = (GtkFormWidgetDateEntry *)object;
+
+       GtkFormWidgetDateEntryPrivate *priv = GTK_FORM_WIDGET_DATE_ENTRY_GET_PRIVATE (widget_entry);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_widget_date_entry_get_property (GObject *object,
+                                guint property_id,
+                                GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetDateEntry *widget_entry = (GtkFormWidgetDateEntry *)object;
+
+       GtkFormWidgetDateEntryPrivate *priv = GTK_FORM_WIDGET_DATE_ENTRY_GET_PRIVATE (widget_entry);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
diff --git a/src/gtkformwidgetdateentry.h b/src/gtkformwidgetdateentry.h
new file mode 100644 (file)
index 0000000..d628114
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 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
+ * 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 __LIBGTK_FORM_WIDGET_ENTRY_H__
+#define __LIBGTK_FORM_WIDGET_ENTRY_H__
+
+#include <libgtkform/widget.h>
+
+
+G_BEGIN_DECLS
+
+
+#define GTK_FORM_TYPE_WIDGET_DATE_ENTRY                 (gtk_form_widget_date_entry_get_type ())
+#define GTK_FORM_WIDGET_DATE_ENTRY(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_FORM_TYPE_WIDGET_DATE_ENTRY, GtkFormWidgetDateEntry))
+#define GTK_FORM_WIDGET_DATE_ENTRY_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_FORM_TYPE_WIDGET_DATE_ENTRY, GtkFormWidgetDateEntryClass))
+#define GTK_FORM_IS_WIDGET_DATE_ENTRY(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_FORM_TYPE_WIDGET_DATE_ENTRY))
+#define GTK_FORM_IS_WIDGET_DATE_ENTRY_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_FORM_TYPE_WIDGET_DATE_ENTRY))
+#define GTK_FORM_WIDGET_DATE_ENTRY_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_FORM_TYPE_WIDGET_DATE_ENTRY, GtkFormWidgetDateEntryClass))
+
+
+typedef struct _GtkFormWidgetDateEntry GtkFormWidgetDateEntry;
+typedef struct _GtkFormWidgetDateEntryClass GtkFormWidgetDateEntryClass;
+
+struct _GtkFormWidgetDateEntry
+       {
+               GtkFormWidget parent;
+       };
+
+struct _GtkFormWidgetDateEntryClass
+       {
+               GtkFormWidgetClass parent_class;
+       };
+
+GType gtk_form_widget_date_entry_get_type (void) G_GNUC_CONST;
+
+GtkFormWidget *gtk_form_widget_date_entry_new (void);
+
+gchar *gtk_form_widget_date_entry_get_value_stringify (GtkFormWidget *widget);
+
+gboolean gtk_form_widget_date_entry_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
+
+void gtk_form_widget_date_entry_set_editable (GtkFormWidget *fwidget, gboolean editable);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_WIDGET_ENTRY_H__ */
index 71b524fbef37d684815d5b50269c39d1d691c787..664a028f2cc048ddf7773a554faa66733ab5b7a1 100644 (file)
@@ -1,10 +1,21 @@
 AM_CPPFLAGS = $(WARN_CFLAGS) \
-             $(DISABLE_DEPRECATED_CFLAGS) \
-             $(GTKDATEENTRY_CFLAGS) \
-             -I$(top_srcdir)/src
+              $(DISABLE_DEPRECATED_CFLAGS) \
+              $(GTKDATEENTRY_CFLAGS) \
+              $(GTKFORM_CFLAGS) \
+              -I$(top_srcdir)/src
 
-LIBS = $(GTKDATEENTRY_LIBS)
+LIBS = $(GTKDATEENTRY_LIBS) \
+        $(GTKFORM_LIBS)
 
 LDADD = $(top_builddir)/src/libgtkdateentry.la
 
-noinst_PROGRAMS = date_entry
+if LIBGTKFORM_FOUND
+GTKFORM_NOINST = plugin_gtkform
+else
+GTKFORM_NOINST = 
+endif
+
+noinst_PROGRAMS = date_entry \
+       $(GTKFORM_NOINST)
+
+plugin_gtkform_SOURCES = plugin_gtkform.c
diff --git a/tests/plugin_gtkform.c b/tests/plugin_gtkform.c
new file mode 100644 (file)
index 0000000..87f5bc6
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * GtkDateEntry widget test - plugin for libgtkform
+ * Copyright (C) 2010 Andrea Zagli <azagli@libero.it>
+ *
+ * This software 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 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 General Public
+ * License along with this software; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+
+#include <gtk/gtk.h>
+
+#include <libgtkform/form.h>
+
+GtkBuilder *builder;
+GtkForm *form;
+
+static void
+btn_insert_on_clicked (GtkButton *button,
+                        gpointer user_data)
+{
+       GtkTextBuffer *buf;
+
+       buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (gtk_builder_get_object (builder, "textview1")));
+       gtk_text_buffer_set_text (buf, gtk_form_get_sql (form, GTK_FORM_SQL_INSERT), -1);
+}
+
+static void
+btn_update_on_clicked (GtkButton *button,
+                      gpointer user_data)
+{
+       GtkTextBuffer *buf;
+
+       buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (gtk_builder_get_object (builder, "textview1")));
+       gtk_text_buffer_set_text (buf, gtk_form_get_sql (form, GTK_FORM_SQL_UPDATE), -1);
+}
+
+int
+main (int argc, char **argv)
+{
+       GtkWidget *w;
+       GError *error;
+
+       gtk_init (&argc, &argv);
+
+       error = NULL;
+       builder = gtk_builder_new ();
+       gtk_builder_add_from_file (builder, "plugin_gtkform.ui", &error);
+
+       gtk_builder_connect_signals (builder, NULL);
+
+       g_signal_connect (gtk_builder_get_object (builder, "button1"), "clicked", G_CALLBACK (btn_insert_on_clicked), NULL);
+       g_signal_connect (gtk_builder_get_object (builder, "button2"), "clicked", G_CALLBACK (btn_update_on_clicked), NULL);
+
+       form = gtk_form_new_from_file ("plugin_gtkform.form", builder);
+
+       w = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
+       gtk_widget_show (w);
+
+       gtk_main ();
+
+       return 0;
+}
diff --git a/tests/plugin_gtkform.form b/tests/plugin_gtkform.form
new file mode 100644 (file)
index 0000000..476f84e
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<gtkform>
+
+       <table>clients</table>
+
+       <widget type="date_entry" name="gtkdateentry1" label="label1">
+               <field type="datetime" name="data">
+                       <obligatory>TRUE</obligatory>
+                       <datetime-type>date</datetime-type>
+                       <obligatory>TRUE</obligatory>
+               </field>
+       </widget>
+
+</gtkform>
diff --git a/tests/plugin_gtkform.ui b/tests/plugin_gtkform.ui
new file mode 100644 (file)
index 0000000..ce23860
--- /dev/null
@@ -0,0 +1,88 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-requires gtkdateentry 0.0 -->
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkWindow" id="window1">
+    <property name="window_position">center</property>
+    <property name="default_width">440</property>
+    <property name="default_height">250</property>
+    <signal name="destroy" handler="gtk_main_quit"/>
+    <signal name="delete_event" handler="gtk_false"/>
+    <child>
+      <object class="GtkTable" id="table1">
+        <property name="visible">True</property>
+        <property name="n_rows">3</property>
+        <property name="n_columns">3</property>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">Date Entry</property>
+          </object>
+        </child>
+        <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="GtkTextView" id="textview1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="editable">False</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="right_attach">3</property>
+            <property name="top_attach">2</property>
+            <property name="bottom_attach">3</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="button1">
+            <property name="label" translatable="yes">SQL Insert</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+          </object>
+          <packing>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="button2">
+            <property name="label" translatable="yes">SQL Update</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="right_attach">2</property>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <object class="GtkDateEntry" id="gtkdateentry1">
+            <property name="visible">True</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="right_attach">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>