From 886fc67226294ca4e209b8df57d371672be43d77 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Tue, 1 Dec 2015 10:56:51 +0100 Subject: [PATCH] Implemented ZakFormIProvider (not methods). --- src/Makefile.am | 7 +- src/form.c | 190 ++++++++++++++++++++++++++++++++++++++++++ src/form.h | 46 ++++++++++ src/libzakformgdaex.h | 1 + 4 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 src/form.c create mode 100644 src/form.h diff --git a/src/Makefile.am b/src/Makefile.am index 638649c..b1848b5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,10 +6,13 @@ AM_CPPFLAGS = $(ZAKFORMGDAEX_CFLAGS) \ lib_LTLIBRARIES = libzakformgdaex.la -libzakformgdaex_la_SOURCES = +libzakformgdaex_la_SOURCES = \ + form.c libzakformgdaex_la_LDFLAGS = -no-undefined -libzakformgdaex_include_HEADERS = +libzakformgdaex_include_HEADERS = \ + libzakformgdaex.h \ + form.h libzakformgdaex_includedir = $(includedir)/libzakformgdaex diff --git a/src/form.c b/src/form.c new file mode 100644 index 0000000..0b7b701 --- /dev/null +++ b/src/form.c @@ -0,0 +1,190 @@ +/* + * 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 + +#include "form.h" + +static void zak_form_gdaex_provider_class_init (ZakFormGdaexProviderClass *class); +static void zak_form_gdaex_provider_init (ZakFormGdaexProvider *zak_form_gdaex_provider); +static void zak_form_iprovider_interface_init (ZakFormIProviderInterface *iface); + +static void zak_form_gdaex_provider_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void zak_form_gdaex_provider_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static void zak_form_gdaex_provider_dispose (GObject *gobject); +static void zak_form_gdaex_provider_finalize (GObject *gobject); + +static gboolean zak_form_gdaex_provider_load (ZakFormIProvider *provider, GPtrArray *elements); +static gboolean zak_form_gdaex_provider_insert (ZakFormIProvider *provider, GPtrArray *elements); +static gboolean zak_form_gdaex_provider_update (ZakFormIProvider *provider, GPtrArray *elements); +static gboolean zak_form_gdaex_provider_delete (ZakFormIProvider *provider, GPtrArray *elements); + +struct _ZakFormGdaexProvider +{ + GObject parent_instance; +}; + +#define ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_GDAEX_TYPE_PROVIDER, ZakFormGdaexProviderPrivate)) + +typedef struct _ZakFormGdaexProviderPrivate ZakFormGdaexProviderPrivate; +struct _ZakFormGdaexProviderPrivate + { + gpointer nothing; + }; + +G_DEFINE_TYPE_WITH_CODE (ZakFormGdaexProvider, zak_form_gdaex_provider, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (ZAK_FORM_TYPE_IPROVIDER, + zak_form_iprovider_interface_init)) + +static void +zak_form_gdaex_provider_class_init (ZakFormGdaexProviderClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->set_property = zak_form_gdaex_provider_set_property; + object_class->get_property = zak_form_gdaex_provider_get_property; + object_class->dispose = zak_form_gdaex_provider_dispose; + object_class->finalize = zak_form_gdaex_provider_finalize; + + g_type_class_add_private (object_class, sizeof (ZakFormGdaexProviderPrivate)); +} + +static void +zak_form_gdaex_provider_init (ZakFormGdaexProvider *zak_form_gdaex_provider) +{ + ZakFormGdaexProviderPrivate *priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (zak_form_gdaex_provider); +} + +static void +zak_form_iprovider_interface_init (ZakFormIProviderInterface *iface) +{ + iface->load = zak_form_gdaex_provider_load; + iface->insert = zak_form_gdaex_provider_insert; + iface->update = zak_form_gdaex_provider_update; + iface->delete = zak_form_gdaex_provider_delete; +} + +/** + * zak_form_gdaex_provider_new: + * + * Returns: the newly created #ZakFormGdaexProvider object. + */ +ZakFormGdaexProvider +*zak_form_gdaex_provider_new () +{ + ZakFormGdaexProvider *zak_form_gdaex_provider; + ZakFormGdaexProviderPrivate *priv; + + zak_form_gdaex_provider = ZAK_FORM_GDAEX_PROVIDER (g_object_new (zak_form_gdaex_provider_get_type (), NULL)); + + priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (zak_form_gdaex_provider); + + return zak_form_gdaex_provider; +} + +/* PRIVATE */ +static void +zak_form_gdaex_provider_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + ZakFormGdaexProvider *zak_form_gdaex_provider = (ZakFormGdaexProvider *)object; + ZakFormGdaexProviderPrivate *priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (zak_form_gdaex_provider); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +zak_form_gdaex_provider_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + ZakFormGdaexProvider *zak_form_gdaex_provider = (ZakFormGdaexProvider *)object; + ZakFormGdaexProviderPrivate *priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (zak_form_gdaex_provider); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +zak_form_gdaex_provider_dispose (GObject *gobject) +{ + ZakFormGdaexProvider *zak_form_gdaex_provider = (ZakFormGdaexProvider *)gobject; + ZakFormGdaexProviderPrivate *priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (zak_form_gdaex_provider); + + + GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject)); + parent_class->dispose (gobject); +} + +static void +zak_form_gdaex_provider_finalize (GObject *gobject) +{ + ZakFormGdaexProvider *zak_form_gdaex_provider = (ZakFormGdaexProvider *)gobject; + ZakFormGdaexProviderPrivate *priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (zak_form_gdaex_provider); + + + GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject)); + parent_class->finalize (gobject); +} + +static gboolean +zak_form_gdaex_provider_load (ZakFormIProvider *provider, GPtrArray *elements) +{ + +} + +static gboolean +zak_form_gdaex_provider_insert (ZakFormIProvider *provider, GPtrArray *elements) +{ + +} + +static gboolean +zak_form_gdaex_provider_update (ZakFormIProvider *provider, GPtrArray *elements) +{ + +} + +static gboolean +zak_form_gdaex_provider_delete (ZakFormIProvider *provider, GPtrArray *elements) +{ + +} diff --git a/src/form.h b/src/form.h new file mode 100644 index 0000000..c02a724 --- /dev/null +++ b/src/form.h @@ -0,0 +1,46 @@ +/* + * 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_GDAEX_PROVIDER_H__ +#define __ZAK_FORM_GDAEX_PROVIDER_H__ + + +#include + +#include + + +G_BEGIN_DECLS + + +#define ZAK_FORM_GDAEX_TYPE_PROVIDER zak_form_gdaex_provider_get_type () +G_DECLARE_FINAL_TYPE (ZakFormGdaexProvider, zak_form_gdaex_provider, ZAK_FORM_GDAEX, PROVIDER, GObject) + +struct _ZakFormGdaexProviderClass +{ + GObjectClass parent_class; +}; + + +ZakFormGdaexProvider *zak_form_gdaex_provider_new (void); + + +G_END_DECLS + + +#endif /* __ZAK_FORM_GDAEX_PROVIDER_H__ */ diff --git a/src/libzakformgdaex.h b/src/libzakformgdaex.h index e33a745..b1eef8b 100644 --- a/src/libzakformgdaex.h +++ b/src/libzakformgdaex.h @@ -20,6 +20,7 @@ #define __LIBZAKFORMGDAEX_H__ +#include #endif /* __LIBZAKFORMGDAEX_H__ */ -- 2.49.0