From 1a4984bceb96dbebe96af9f2559a232e01bbc670 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 3 Jun 2017 11:24:41 +0200 Subject: [PATCH] Migration to GValue. --- configure.ac | 5 +++-- src/Makefile.am | 6 +++--- src/formelementdecoder.c | 42 ++++++++++++++++++++------------------ src/libzakformgtkdecoder.h | 18 +++++----------- 4 files changed, 33 insertions(+), 38 deletions(-) diff --git a/configure.ac b/configure.ac index 7d9a720..4bacf6b 100644 --- a/configure.ac +++ b/configure.ac @@ -39,8 +39,9 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", AM_GLIB_GNU_GETTEXT # Checks for libraries. -PKG_CHECK_MODULES(ZAKFORMGTKDECODER, [libzakformgtk - libzakgtkdecoder]) +PKG_CHECK_MODULES(ZAKFORMGTKDECODER, [libzakutils + libzakformgtk + libzakgtkdecoder]) AC_SUBST(ZAKFORMGTKDECODER_CFLAGS) AC_SUBST(ZAKFORMGTKDECODER_LIBS) diff --git a/src/Makefile.am b/src/Makefile.am index fa2ff1f..46bd740 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,13 +17,13 @@ AM_CPPFLAGS = $(ZAKFORMGTKDECODER_CFLAGS) \ lib_LTLIBRARIES = libzakformgtkdecoder.la libzakformgtkdecoder_la_SOURCES = \ - formelementdecoder.c + formelementdecoder.c libzakformgtkdecoder_la_LDFLAGS = -no-undefined libzakformgtkdecoder_include_HEADERS = \ - libzakformgtkdecoder.h \ - formelementdecoder.h + libzakformgtkdecoder.h \ + formelementdecoder.h libzakformgtkdecoder_includedir = $(includedir)/libzakformgtkdecoder diff --git a/src/formelementdecoder.c b/src/formelementdecoder.c index c3c703a..7b9a2d7 100644 --- a/src/formelementdecoder.c +++ b/src/formelementdecoder.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Andrea Zagli + * Copyright (C) 2015-2017 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,6 +20,8 @@ #include #endif +#include + #include #include "formelementdecoder.h" @@ -28,19 +30,19 @@ static void zak_form_gtk_form_element_decoder_class_init (ZakFormGtkFormElementD static void zak_form_gtk_form_element_decoder_init (ZakFormGtkFormElementDecoder *zak_form_gtk_form_element_decoder); static void zak_form_gtk_form_element_decoder_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); + guint property_id, + const GValue *value, + GParamSpec *pspec); static void zak_form_gtk_form_element_decoder_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); + guint property_id, + GValue *value, + GParamSpec *pspec); static void zak_form_gtk_form_element_decoder_dispose (GObject *gobject); static void zak_form_gtk_form_element_decoder_finalize (GObject *gobject); -static gchar *zak_form_gtk_form_element_decoder_get_value (ZakFormGtkFormElementDecoder *element); -static gboolean zak_form_gtk_form_element_decoder_set_value (ZakFormGtkFormElementDecoder *element, const gchar *value); +static GValue *zak_form_gtk_form_element_decoder_get_value (ZakFormGtkFormElementDecoder *element); +static gboolean zak_form_gtk_form_element_decoder_set_value (ZakFormGtkFormElementDecoder *element, GValue *value); #define ZAK_FORM_GTK_FORM_ELEMENT_DECODER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_DECODER, ZakFormGtkFormElementDecoderPrivate)) @@ -108,9 +110,9 @@ zak_form_gtk_form_element_decoder_xml_parsing (ZakFormElement *element, xmlNodeP /* PRIVATE */ static void zak_form_gtk_form_element_decoder_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { ZakFormGtkFormElementDecoder *zak_form_gtk_form_element_decoder = (ZakFormGtkFormElementDecoder *)object; ZakFormGtkFormElementDecoderPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_DECODER_GET_PRIVATE (zak_form_gtk_form_element_decoder); @@ -125,9 +127,9 @@ zak_form_gtk_form_element_decoder_set_property (GObject *object, static void zak_form_gtk_form_element_decoder_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) + guint property_id, + GValue *value, + GParamSpec *pspec) { ZakFormGtkFormElementDecoder *zak_form_gtk_form_element_decoder = (ZakFormGtkFormElementDecoder *)object; ZakFormGtkFormElementDecoderPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_DECODER_GET_PRIVATE (zak_form_gtk_form_element_decoder); @@ -164,28 +166,28 @@ zak_form_gtk_form_element_decoder_finalize (GObject *gobject) parent_class->finalize (gobject); } -static gchar +static GValue *zak_form_gtk_form_element_decoder_get_value (ZakFormGtkFormElementDecoder *element) { - gchar *ret; + GValue *ret; GtkWidget *w; w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element)); - ret = (gchar *)zak_gtk_decoder_get_key (ZAK_GTK_DECODER (w)); + ret = zak_utils_gvalue_new_string ((gchar *)zak_gtk_decoder_get_key (ZAK_GTK_DECODER (w))); return ret; } static gboolean -zak_form_gtk_form_element_decoder_set_value (ZakFormGtkFormElementDecoder *element, const gchar *value) +zak_form_gtk_form_element_decoder_set_value (ZakFormGtkFormElementDecoder *element, GValue *value) { GtkWidget *w; w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element)); - zak_gtk_decoder_set_key (ZAK_GTK_DECODER (w), value); + zak_gtk_decoder_set_key (ZAK_GTK_DECODER (w), g_value_get_string (value)); return TRUE; } diff --git a/src/libzakformgtkdecoder.h b/src/libzakformgtkdecoder.h index 76b657b..e8ff1e6 100644 --- a/src/libzakformgtkdecoder.h +++ b/src/libzakformgtkdecoder.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Andrea Zagli + * Copyright (C) 2015-2017 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -16,19 +16,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __LIBZAKFORMGTK_H__ -#define __LIBZAKFORMGTK_H__ +#ifndef __LIBZAKFORMGTKDECODER_H__ +#define __LIBZAKFORMGTKDECODER_H__ -#include +#include -#include -#include -#include -#include -#include -#include -#include - -#endif /* __LIBZAKFORMGTK_H__ */ +#endif /* __LIBZAKFORMGTKDECODER_H__ */ -- 2.49.0