From 329da1fbb60a5ad5b6e4916d8af285f3754c9790 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 26 Jun 2010 18:23:12 +0200 Subject: [PATCH] Plugin for libgtkform. --- configure.ac | 10 + docs/reference/gtkmaskedentry-undeclared.txt | 0 .../reference/gtkmaskedentry-undocumented.txt | 15 -- docs/reference/gtkmaskedentry-unused.txt | 2 - docs/reference/gtkmaskedentry.args | 30 --- docs/reference/gtkmaskedentry.hierarchy | 28 --- docs/reference/gtkmaskedentry.interfaces | 6 - docs/reference/gtkmaskedentry.prerequisites | 2 - docs/reference/gtkmaskedentry.signals | 0 src/Makefile.am | 29 ++- src/gtkformwidgetmaskedentry.c | 198 ++++++++++++++++++ src/gtkformwidgetmaskedentry.h | 63 ++++++ 12 files changed, 296 insertions(+), 87 deletions(-) delete mode 100644 docs/reference/gtkmaskedentry-undeclared.txt delete mode 100644 docs/reference/gtkmaskedentry-undocumented.txt delete mode 100644 docs/reference/gtkmaskedentry-unused.txt delete mode 100644 docs/reference/gtkmaskedentry.args delete mode 100644 docs/reference/gtkmaskedentry.hierarchy delete mode 100644 docs/reference/gtkmaskedentry.interfaces delete mode 100644 docs/reference/gtkmaskedentry.prerequisites delete mode 100644 docs/reference/gtkmaskedentry.signals create mode 100644 src/gtkformwidgetmaskedentry.c create mode 100644 src/gtkformwidgetmaskedentry.h diff --git a/configure.ac b/configure.ac index 3195684..e96e92c 100644 --- a/configure.ac +++ b/configure.ac @@ -30,10 +30,20 @@ GTK_DOC_CHECK(1.0) PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6.0) 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]) AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) +AM_CONDITIONAL(LIBGTKFORM_FOUND, test $LIBGTKFORM_FOUND = yes) + +if test $LIBGTKFORM_FOUND = yes; then +PKG_CHECK_MODULES(GTKFORM, libgtkform >= 0.2.0) + +AC_SUBST(GTKFORM_CFLAGS) +AC_SUBST(GTKFORM_LIBS) +fi + # Output files AC_CONFIG_FILES([ libgtkmaskedentry.pc diff --git a/docs/reference/gtkmaskedentry-undeclared.txt b/docs/reference/gtkmaskedentry-undeclared.txt deleted file mode 100644 index e69de29..0000000 diff --git a/docs/reference/gtkmaskedentry-undocumented.txt b/docs/reference/gtkmaskedentry-undocumented.txt deleted file mode 100644 index 825630c..0000000 --- a/docs/reference/gtkmaskedentry-undocumented.txt +++ /dev/null @@ -1,15 +0,0 @@ -59% symbol docs coverage. -10 symbols documented. -0 symbols incomplete. -7 not documented. - - -GtkCellRendererMasked -GtkMaskedEntry -gtk_masked_entry_get_mask -gtk_masked_entry_get_text - - -gtkcellrenderermasked:Short_Description -gtkmaskedentry:Long_Description -gtkmaskedentry:Short_Description diff --git a/docs/reference/gtkmaskedentry-unused.txt b/docs/reference/gtkmaskedentry-unused.txt deleted file mode 100644 index 4fcebfe..0000000 --- a/docs/reference/gtkmaskedentry-unused.txt +++ /dev/null @@ -1,2 +0,0 @@ -GtkCellRendererMaskedClass -GtkMaskedEntryClass diff --git a/docs/reference/gtkmaskedentry.args b/docs/reference/gtkmaskedentry.args deleted file mode 100644 index 3f5fd46..0000000 --- a/docs/reference/gtkmaskedentry.args +++ /dev/null @@ -1,30 +0,0 @@ - -GtkMaskedEntry::mask -gchar* - -rw -The mask -The mask. -"" - - - -GtkMaskedEntry::tab-inside -gboolean - -rw -Tabulation inside the widget -Whether pressing tab moves between mask's parts or outside the widget. -FALSE - - - -GtkCellRendererMasked::mask -gchar* - -rw -Mask -Mask. -NULL - - diff --git a/docs/reference/gtkmaskedentry.hierarchy b/docs/reference/gtkmaskedentry.hierarchy deleted file mode 100644 index 1c316eb..0000000 --- a/docs/reference/gtkmaskedentry.hierarchy +++ /dev/null @@ -1,28 +0,0 @@ -GObject - GInitiallyUnowned - GtkObject - GtkWidget - GtkEntry - GtkMaskedEntry - GtkContainer - GtkMenuShell - GtkMenu - GtkCellRenderer - GtkCellRendererText - GtkCellRendererMasked - GtkStyle - GdkDrawable - GdkWindow - GdkDragContext - GtkTooltip - GdkScreen - GtkEntryBuffer - GdkPixbuf - GtkSettings -GInterface - GTypePlugin - AtkImplementorIface - GtkBuildable - GtkEditable - GtkCellEditable - GIcon diff --git a/docs/reference/gtkmaskedentry.interfaces b/docs/reference/gtkmaskedentry.interfaces deleted file mode 100644 index 2cfe9a3..0000000 --- a/docs/reference/gtkmaskedentry.interfaces +++ /dev/null @@ -1,6 +0,0 @@ -GtkWidget AtkImplementorIface GtkBuildable -GtkEntry GtkCellEditable AtkImplementorIface GtkBuildable GtkEditable -GtkMaskedEntry GtkCellEditable AtkImplementorIface GtkBuildable GtkEditable -GtkContainer AtkImplementorIface GtkBuildable -GtkMenuShell AtkImplementorIface GtkBuildable -GtkMenu AtkImplementorIface GtkBuildable diff --git a/docs/reference/gtkmaskedentry.prerequisites b/docs/reference/gtkmaskedentry.prerequisites deleted file mode 100644 index 5c1f531..0000000 --- a/docs/reference/gtkmaskedentry.prerequisites +++ /dev/null @@ -1,2 +0,0 @@ -GtkCellEditable GtkWidget -GIcon GObject diff --git a/docs/reference/gtkmaskedentry.signals b/docs/reference/gtkmaskedentry.signals deleted file mode 100644 index e69de29..0000000 diff --git a/src/Makefile.am b/src/Makefile.am index 3a98c04..b4b8e76 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,15 +1,36 @@ INCLUDES = $(WARN_CFLAGS) \ $(DISABLE_DEPRECATED_CFLAGS) \ - $(GTK_CFLAGS) + $(GTK_CFLAGS) \ + $(GTKFORM_CFLAGS) -LIBS = $(GTK_LIBS) +LIBS = $(GTK_LIBS) \ + $(GTKFORM_LIBS) lib_LTLIBRARIES = libgtkmaskedentry.la +if LIBGTKFORM_FOUND +GTKFORM_C = gtkformwidgetmaskedentry.c +GTKFORM_H = gtkformwidgetmaskedentry.h +libgtkformmodulesdir = `pkg-config --variable=modulesdir libgtkform` +else +GTKFORM_C = +GTKFORM_H = +libgtkformmodulesdir = +endif + libgtkmaskedentry_la_SOURCES = gtkmaskedentry.c \ - gtkcellrenderermasked.c + gtkcellrenderermasked.c \ + $(GTKFORM_C) libgtkmaskedentry_la_LDFLAGS = -no-undefined include_HEADERS = gtkmaskedentry.h \ - gtkcellrenderermasked.h + gtkcellrenderermasked.h \ + $(GTKFORM_H) + +install-exec-hook: + cd $(libgtkformmodulesdir) && \ + ln -s $(libdir)/libgtkmaskedentry.so . + +uninstall-hook: + rm -f $(libgtkformmodulesdir)/libgtkmaskedentry.so diff --git a/src/gtkformwidgetmaskedentry.c b/src/gtkformwidgetmaskedentry.c new file mode 100644 index 0000000..985b7a3 --- /dev/null +++ b/src/gtkformwidgetmaskedentry.c @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2010 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 "gtkmaskedentry.h" +#include "gtkformwidgetmaskedentry.h" + +enum +{ + PROP_0, + PROP_STRINGIFY_WITH_MASK +}; + +static void gtk_form_widget_masked_entry_class_init (GtkFormWidgetMaskedEntryClass *klass); +static void gtk_form_widget_masked_entry_init (GtkFormWidgetMaskedEntry *gtk_form_widget_masked_entry); + +static void gtk_form_widget_masked_entry_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_form_widget_masked_entry_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +#define GTK_FORM_WIDGET_MASKED_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_FORM_TYPE_WIDGET_MASKED_ENTRY, GtkFormWidgetMaskedEntryPrivate)) + +typedef struct _GtkFormWidgetMaskedEntryPrivate GtkFormWidgetMaskedEntryPrivate; +struct _GtkFormWidgetMaskedEntryPrivate + { + gboolean stringify_with_mask; + }; + + +G_DEFINE_TYPE (GtkFormWidgetMaskedEntry, gtk_form_widget_masked_entry, TYPE_GTK_FORM_WIDGET) + +static void +gtk_form_widget_masked_entry_class_init (GtkFormWidgetMaskedEntryClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass); + + object_class->set_property = gtk_form_widget_masked_entry_set_property; + object_class->get_property = gtk_form_widget_masked_entry_get_property; + + widget_class->get_value_stringify = gtk_form_widget_masked_entry_get_value_stringify; + widget_class->set_value_stringify = gtk_form_widget_masked_entry_set_value_stringify; + widget_class->set_editable = gtk_form_widget_masked_entry_set_editable; + + g_object_class_install_property (object_class, PROP_STRINGIFY_WITH_MASK, + g_param_spec_boolean ("stringify-with-mask", + "GtkFormWidgetMaskedEntry::get_value_stringify returns with mask", + "GtkFormWidgetMaskedEntry::get_value_stringify returns with mask", + TRUE, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + + g_type_class_add_private (object_class, sizeof (GtkFormWidgetMaskedEntryPrivate)); +} + +static void +gtk_form_widget_masked_entry_init (GtkFormWidgetMaskedEntry *gtk_form_widget_masked_entry) +{ +} + +/** + * gtk_form_widget_masked_entry_new: + * + * Returns: the newly created #GtkFormWidgetMaskedEntry. + */ +GtkFormWidget +*gtk_form_widget_masked_entry_new () +{ + return g_object_new (gtk_form_widget_masked_entry_get_type (), NULL); +} + +/** + * gtk_form_widget_masked_entry_get_value_stringify: + * @widget: + * + */ +gchar +*gtk_form_widget_masked_entry_get_value_stringify (GtkFormWidget *fwidget) +{ + GtkFormWidgetMaskedEntryPrivate *priv = GTK_FORM_WIDGET_MASKED_ENTRY_GET_PRIVATE (fwidget); + + GtkWidget *w = gtk_form_widget_get_widget (fwidget); + + if (priv->stringify_with_mask) + { + return g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + } + else + { + return g_strdup (gtk_masked_entry_get_text (GTK_MASKED_ENTRY (w))); + } +} + +/** + * gtk_form_widget_masked_entry_set_value_stringify: + * @fwidget: + * @value: + * + */ +gboolean +gtk_form_widget_masked_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_masked_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_masked_entry_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkFormWidgetMaskedEntry *widget_entry = (GtkFormWidgetMaskedEntry *)object; + + GtkFormWidgetMaskedEntryPrivate *priv = GTK_FORM_WIDGET_MASKED_ENTRY_GET_PRIVATE (widget_entry); + + switch (property_id) + { + case PROP_STRINGIFY_WITH_MASK: + priv->stringify_with_mask = g_value_get_boolean (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gtk_form_widget_masked_entry_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GtkFormWidgetMaskedEntry *widget_entry = (GtkFormWidgetMaskedEntry *)object; + + GtkFormWidgetMaskedEntryPrivate *priv = GTK_FORM_WIDGET_MASKED_ENTRY_GET_PRIVATE (widget_entry); + + switch (property_id) + { + case PROP_STRINGIFY_WITH_MASK: + g_value_set_boolean (value, priv->stringify_with_mask); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} diff --git a/src/gtkformwidgetmaskedentry.h b/src/gtkformwidgetmaskedentry.h new file mode 100644 index 0000000..1ce4c3a --- /dev/null +++ b/src/gtkformwidgetmaskedentry.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2010 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 __LIBGTK_FORM_WIDGET_ENTRY_H__ +#define __LIBGTK_FORM_WIDGET_ENTRY_H__ + +#include + + +G_BEGIN_DECLS + + +#define GTK_FORM_TYPE_WIDGET_MASKED_ENTRY (gtk_form_widget_masked_entry_get_type ()) +#define GTK_FORM_WIDGET_MASKED_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_FORM_TYPE_WIDGET_MASKED_ENTRY, GtkFormWidgetMaskedEntry)) +#define GTK_FORM_WIDGET_MASKED_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_FORM_TYPE_WIDGET_MASKED_ENTRY, GtkFormWidgetMaskedEntryClass)) +#define GTK_FORM_IS_WIDGET_MASKED_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_FORM_TYPE_WIDGET_MASKED_ENTRY)) +#define GTK_FORM_IS_WIDGET_MASKED_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_FORM_TYPE_WIDGET_MASKED_ENTRY)) +#define GTK_FORM_WIDGET_MASKED_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_FORM_TYPE_WIDGET_MASKED_ENTRY, GtkFormWidgetMaskedEntryClass)) + + +typedef struct _GtkFormWidgetMaskedEntry GtkFormWidgetMaskedEntry; +typedef struct _GtkFormWidgetMaskedEntryClass GtkFormWidgetMaskedEntryClass; + +struct _GtkFormWidgetMaskedEntry + { + GtkFormWidget parent; + }; + +struct _GtkFormWidgetMaskedEntryClass + { + GtkFormWidgetClass parent_class; + }; + +GType gtk_form_widget_masked_entry_get_type (void) G_GNUC_CONST; + +GtkFormWidget *gtk_form_widget_masked_entry_new (void); + +gchar *gtk_form_widget_masked_entry_get_value_stringify (GtkFormWidget *widget); + +gboolean gtk_form_widget_masked_entry_set_value_stringify (GtkFormWidget *fwidget, const gchar *value); + +void gtk_form_widget_masked_entry_set_editable (GtkFormWidget *fwidget, gboolean editable); + + +G_END_DECLS + + +#endif /* __LIBGTK_FORM_WIDGET_ENTRY_H__ */ -- 2.49.0