From: Andrea Zagli Date: Thu, 26 Nov 2015 18:02:58 +0000 (+0100) Subject: Added ZakFormGtkFormElementEntry. X-Git-Tag: v0.1.0~16 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=cc4a14af25f652c6c7cde773ad5b20228563fde3;p=zakform%2Fgtk Added ZakFormGtkFormElementEntry. --- diff --git a/src/Makefile.am b/src/Makefile.am index 4d8a0db..ca9cbe1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,7 +9,8 @@ lib_LTLIBRARIES = libzakformgtk.la libzakformgtk_la_SOURCES = \ form.c \ formelement.c \ - formelementcheck.c + formelementcheck.c \ + formelemententry.c libzakformgtk_la_LDFLAGS = -no-undefined @@ -17,6 +18,7 @@ libzakformgtk_include_HEADERS = \ libzakformgtk.h \ form.h \ formelement.h \ - formelementcheck.h + formelementcheck.h \ + formelemententry.h libzakformgtk_includedir = $(includedir)/libzakformgtk diff --git a/src/formelementcheck.c b/src/formelementcheck.c index 91a5a4b..884ca7d 100644 --- a/src/formelementcheck.c +++ b/src/formelementcheck.c @@ -203,4 +203,6 @@ zak_form_gtk_form_element_check_set_value (ZakFormGtkFormElementCheck *element, g_free (str_value); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), active); + + return TRUE; } diff --git a/src/formelemententry.c b/src/formelemententry.c new file mode 100644 index 0000000..b89987f --- /dev/null +++ b/src/formelemententry.c @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2015 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 + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include "formelemententry.h" + +static void zak_form_gtk_form_element_entry_class_init (ZakFormGtkFormElementEntryClass *class); +static void zak_form_gtk_form_element_entry_init (ZakFormGtkFormElementEntry *zak_form_gtk_form_element_entry); + +static void zak_form_gtk_form_element_entry_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void zak_form_gtk_form_element_entry_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static void zak_form_gtk_form_element_entry_dispose (GObject *gobject); +static void zak_form_gtk_form_element_entry_finalize (GObject *gobject); + +static gchar *zak_form_gtk_form_element_entry_get_value (ZakFormGtkFormElementEntry *element); +static gboolean zak_form_gtk_form_element_entry_set_value (ZakFormGtkFormElementEntry *element, const gchar *value); + +#define ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_ENTRY, ZakFormGtkFormElementEntryPrivate)) + +typedef struct _ZakFormGtkFormElementEntryPrivate ZakFormGtkFormElementEntryPrivate; +struct _ZakFormGtkFormElementEntryPrivate + { + gpointer empty; + }; + +G_DEFINE_TYPE (ZakFormGtkFormElementEntry, zak_form_gtk_form_element_entry, ZAK_FORM_GTK_TYPE_FORM_ELEMENT) + +static void +zak_form_gtk_form_element_entry_class_init (ZakFormGtkFormElementEntryClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + ZakFormElementClass *elem_class = ZAK_FORM_ELEMENT_CLASS (klass); + + object_class->set_property = zak_form_gtk_form_element_entry_set_property; + object_class->get_property = zak_form_gtk_form_element_entry_get_property; + object_class->dispose = zak_form_gtk_form_element_entry_dispose; + object_class->finalize = zak_form_gtk_form_element_entry_finalize; + + elem_class->get_value = zak_form_gtk_form_element_entry_get_value; + elem_class->set_value = zak_form_gtk_form_element_entry_set_value; + + g_type_class_add_private (object_class, sizeof (ZakFormGtkFormElementEntryPrivate)); +} + +static void +zak_form_gtk_form_element_entry_init (ZakFormGtkFormElementEntry *zak_form_gtk_form_element_entry) +{ + ZakFormGtkFormElementEntryPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_GET_PRIVATE (zak_form_gtk_form_element_entry); + +} + +/** + * zak_form_gtk_form_element_entry_new: + * + * Returns: the newly created #ZakFormGtkFormElementEntry object. + */ +ZakFormGtkFormElement +*zak_form_gtk_form_element_entry_new () +{ + ZakFormGtkFormElementEntry *zak_form_gtk_form_element_entry; + + zak_form_gtk_form_element_entry = ZAK_FORM_GTK_FORM_ELEMENT_ENTRY (g_object_new (zak_form_gtk_form_element_entry_get_type (), NULL)); + + return ZAK_FORM_GTK_FORM_ELEMENT (zak_form_gtk_form_element_entry); +} + +/* PRIVATE */ +static void +zak_form_gtk_form_element_entry_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + ZakFormGtkFormElementEntry *zak_form_gtk_form_element_entry = (ZakFormGtkFormElementEntry *)object; + ZakFormGtkFormElementEntryPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_GET_PRIVATE (zak_form_gtk_form_element_entry); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +zak_form_gtk_form_element_entry_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + ZakFormGtkFormElementEntry *zak_form_gtk_form_element_entry = (ZakFormGtkFormElementEntry *)object; + ZakFormGtkFormElementEntryPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_GET_PRIVATE (zak_form_gtk_form_element_entry); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +zak_form_gtk_form_element_entry_dispose (GObject *gobject) +{ + ZakFormGtkFormElementEntry *zak_form_gtk_form_element_entry = (ZakFormGtkFormElementEntry *)gobject; + ZakFormGtkFormElementEntryPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_GET_PRIVATE (zak_form_gtk_form_element_entry); + + + + GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject)); + parent_class->dispose (gobject); +} + +static void +zak_form_gtk_form_element_entry_finalize (GObject *gobject) +{ + ZakFormGtkFormElementEntry *zak_form_gtk_form_element_entry = (ZakFormGtkFormElementEntry *)gobject; + ZakFormGtkFormElementEntryPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_GET_PRIVATE (zak_form_gtk_form_element_entry); + + + + GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject)); + parent_class->finalize (gobject); +} + +static gchar +*zak_form_gtk_form_element_entry_get_value (ZakFormGtkFormElementEntry *element) +{ + gchar *ret; + + GtkWidget *w; + + w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element)); + + ret = (gchar *)gtk_entry_get_text (GTK_ENTRY (w)); + + return ret; +} + +static gboolean +zak_form_gtk_form_element_entry_set_value (ZakFormGtkFormElementEntry *element, const gchar *value) +{ + GtkWidget *w; + + w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element)); + + gtk_entry_set_text (GTK_ENTRY (w), value); + + return TRUE; +} diff --git a/src/formelemententry.h b/src/formelemententry.h new file mode 100644 index 0000000..22ea0e8 --- /dev/null +++ b/src/formelemententry.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2015 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 __ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_H__ +#define __ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_H__ + + +#include + +#include "formelement.h" + + +G_BEGIN_DECLS + + +#define ZAK_FORM_GTK_TYPE_FORM_ELEMENT_ENTRY (zak_form_gtk_form_element_entry_get_type ()) +#define ZAK_FORM_GTK_FORM_ELEMENT_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_ENTRY, ZakFormGtkFormElementEntry)) +#define ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_ENTRY, ZakFormGtkFormElementEntryClass)) +#define ZAK_FORM_GTK_IS_FORM_ELEMENT_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_ENTRY)) +#define ZAK_FORM_GTK_IS_FORM_ELEMENT_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_ENTRY)) +#define ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_ENTRY, ZakFormGtkFormElementEntryClass)) + +typedef struct _ZakFormGtkFormElementEntry ZakFormGtkFormElementEntry; +typedef struct _ZakFormGtkFormElementEntryClass ZakFormGtkFormElementEntryClass; + +struct _ZakFormGtkFormElementEntry + { + ZakFormGtkFormElement parent_instance; + }; + +struct _ZakFormGtkFormElementEntryClass + { + ZakFormGtkFormElementClass parent_class; + }; + + +GType zak_form_gtk_form_element_entry_get_type (void); + +ZakFormGtkFormElement *zak_form_gtk_form_element_entry_new (void); + + +G_END_DECLS + + +#endif /* __ZAK_FORM_GTK_FORM_ELEMENT_ENTRY_H__ */ diff --git a/src/libzakformgtk.h b/src/libzakformgtk.h index 8c8b4a0..8456ab0 100644 --- a/src/libzakformgtk.h +++ b/src/libzakformgtk.h @@ -24,6 +24,7 @@ #include #include +#include #endif /* __LIBZAKFORMGTK_H__ */