]> saetta.ns0.it Git - zakform/gtk/commitdiff
Migration to GValue for element value.
authorAndrea Zagli <azagli@libero.it>
Sun, 14 May 2017 10:40:06 +0000 (12:40 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 14 May 2017 10:40:06 +0000 (12:40 +0200)
src/formelementcheck.c
src/formelementcombo.c
src/formelemententry.c
src/formelementlabel.c
src/formelementradio.c
src/formelementspin.c
src/formelementtextview.c

index da2ea534e97f8a646e799c16fd58e86e704fbdcd..f1599acbb38ad6ef555e026bce70ae40c0034e64 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2017 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
        #include <config.h>
 #endif
 
+#include <libzakutils/libzakutils.h>
+
 #include "formelementcheck.h"
 
 static void zak_form_gtk_form_element_check_class_init (ZakFormGtkFormElementCheckClass *class);
 static void zak_form_gtk_form_element_check_init (ZakFormGtkFormElementCheck *zak_form_gtk_form_element_check);
 
 static void zak_form_gtk_form_element_check_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_check_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_check_dispose (GObject *gobject);
 static void zak_form_gtk_form_element_check_finalize (GObject *gobject);
 
-static gchar *zak_form_gtk_form_element_check_get_value (ZakFormGtkFormElementCheck *element);
-static gboolean zak_form_gtk_form_element_check_set_value (ZakFormGtkFormElementCheck *element, const gchar *value);
+static GValue *zak_form_gtk_form_element_check_get_value (ZakFormGtkFormElementCheck *element);
+static gboolean zak_form_gtk_form_element_check_set_value (ZakFormGtkFormElementCheck *element, GValue *value);
 
 #define ZAK_FORM_GTK_FORM_ELEMENT_CHECK_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_CHECK, ZakFormGtkFormElementCheckPrivate))
 
@@ -162,31 +164,31 @@ zak_form_gtk_form_element_check_finalize (GObject *gobject)
        parent_class->finalize (gobject);
 }
 
-static gchar
+static GValue
 *zak_form_gtk_form_element_check_get_value (ZakFormGtkFormElementCheck *element)
 {
-       gchar *ret;
+       GValue *ret;
 
        GtkWidget *w;
 
-       ret = g_strdup ("FALSE");
+       ret = zak_utils_gvalue_new_string ("FALSE");
 
        w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element));
 
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
                {
-                       ret = g_strdup ("TRUE");
+                       g_value_set_string (ret, "TRUE");
                }
        else if (gtk_toggle_button_get_inconsistent (GTK_TOGGLE_BUTTON (w)))
                {
-                       ret = g_strdup ("");
+                       g_value_set_string (ret, "");
                }
 
        return ret;
 }
 
 static gboolean
-zak_form_gtk_form_element_check_set_value (ZakFormGtkFormElementCheck *element, const gchar *value)
+zak_form_gtk_form_element_check_set_value (ZakFormGtkFormElementCheck *element, GValue *value)
 {
        GtkWidget *w;
 
@@ -195,7 +197,7 @@ zak_form_gtk_form_element_check_set_value (ZakFormGtkFormElementCheck *element,
 
        w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element));
 
-       str_value = g_strstrip (g_strdup (value));
+       str_value = g_strstrip (g_strdup (g_value_get_string (value)));
 
        if (strcmp (str_value, "0") == 0
            || strcasecmp (str_value, "f") == 0
index ca41328f6a257c5b2afe38bfc6a7cefbaf798ea0..afd4f6b5d675ade4d76dd494ef0ca61d13dacfe9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2016-2017 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
@@ -20,6 +20,8 @@
        #include <config.h>
 #endif
 
+#include <libzakutils/libzakutils.h>
+
 #include "formelementcombo.h"
 
 enum
@@ -32,19 +34,19 @@ static void zak_form_gtk_form_element_combo_class_init (ZakFormGtkFormElementCom
 static void zak_form_gtk_form_element_combo_init (ZakFormGtkFormElementCombo *zak_form_gtk_form_element_combo);
 
 static void zak_form_gtk_form_element_combo_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_combo_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_combo_dispose (GObject *gobject);
 static void zak_form_gtk_form_element_combo_finalize (GObject *gobject);
 
-static gchar *zak_form_gtk_form_element_combo_get_value (ZakFormGtkFormElementCombo *element);
-static gboolean zak_form_gtk_form_element_combo_set_value (ZakFormGtkFormElementCombo *element, const gchar *value);
+static GValue *zak_form_gtk_form_element_combo_get_value (ZakFormGtkFormElementCombo *element);
+static gboolean zak_form_gtk_form_element_combo_set_value (ZakFormGtkFormElementCombo *element, GValue *value);
 
 #define ZAK_FORM_GTK_FORM_ELEMENT_COMBO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_COMBO, ZakFormGtkFormElementComboPrivate))
 
@@ -226,10 +228,10 @@ zak_form_gtk_form_element_combo_finalize (GObject *gobject)
        parent_class->finalize (gobject);
 }
 
-static gchar
+static GValue
 *zak_form_gtk_form_element_combo_get_value (ZakFormGtkFormElementCombo *element)
 {
-       gchar *ret;
+       GValue *ret;
 
        GtkWidget *w;
        GtkTreeModel *tmodel;
@@ -243,7 +245,7 @@ static gchar
 
        w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element));
 
-       ret = g_strdup ("");
+       ret = zak_utils_gvalue_new_string ("");
 
        tmodel = gtk_combo_box_get_model (GTK_COMBO_BOX (w));
        if (tmodel != NULL)
@@ -259,7 +261,7 @@ static gchar
                                        g_value_transform (gvalue, gvstr);
 
                                        g_free (ret);
-                                       ret = g_strdup (g_value_get_string (gvstr));
+                                       g_value_set_string (ret, g_strdup (g_value_get_string (gvstr)));
 
                                        g_value_unset (gvstr);
                                        g_value_unset (gvalue);
@@ -270,7 +272,7 @@ static gchar
 }
 
 static gboolean
-zak_form_gtk_form_element_combo_set_value (ZakFormGtkFormElementCombo *element, const gchar *value)
+zak_form_gtk_form_element_combo_set_value (ZakFormGtkFormElementCombo *element, GValue *value)
 {
        GtkWidget *w;
 
@@ -300,7 +302,7 @@ zak_form_gtk_form_element_combo_set_value (ZakFormGtkFormElementCombo *element,
 
                                                        g_value_init (gvstr, G_TYPE_STRING);
                                                        g_value_transform (gvalue, gvstr);
-                                                       if (g_strcmp0 (g_value_get_string (gvstr), value) == 0)
+                                                       if (g_strcmp0 (g_value_get_string (gvstr), g_value_get_string (value)) == 0)
                                                                {
                                                                        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (w), &iter);
 
index 09d133f6cd39315f37a257527224a15c18ff62ff..e6114b9b69c220183fadb71ba9f56d9faac99d7e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2017 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
        #include <config.h>
 #endif
 
+#include <libzakutils/libzakutils.h>
+
 #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);
+                                                          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);
+                                                          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);
+static GValue *zak_form_gtk_form_element_entry_get_value (ZakFormGtkFormElementEntry *element);
+static gboolean zak_form_gtk_form_element_entry_set_value (ZakFormGtkFormElementEntry *element, GValue *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))
 
@@ -162,28 +164,28 @@ zak_form_gtk_form_element_entry_finalize (GObject *gobject)
        parent_class->finalize (gobject);
 }
 
-static gchar
+static GValue
 *zak_form_gtk_form_element_entry_get_value (ZakFormGtkFormElementEntry *element)
 {
-       gchar *ret;
+       GValue *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));
+       ret = zak_utils_gvalue_new_string ((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)
+zak_form_gtk_form_element_entry_set_value (ZakFormGtkFormElementEntry *element, GValue *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);
+       gtk_entry_set_text (GTK_ENTRY (w), g_value_get_string (value));
 
        return TRUE;
 }
index 7947fb85173290b66042dc29f67cc39548c60138..3eedb755f1b1a432a6f2cda0fb0d3cabeba91ca2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2017 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
        #include <config.h>
 #endif
 
+#include <libzakutils/libzakutils.h>
+
 #include "formelementlabel.h"
 
 static void zak_form_gtk_form_element_label_class_init (ZakFormGtkFormElementLabelClass *class);
 static void zak_form_gtk_form_element_label_init (ZakFormGtkFormElementLabel *zak_form_gtk_form_element_label);
 
 static void zak_form_gtk_form_element_label_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_label_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_label_dispose (GObject *gobject);
 static void zak_form_gtk_form_element_label_finalize (GObject *gobject);
 
-static gchar *zak_form_gtk_form_element_label_get_value (ZakFormGtkFormElementLabel *element);
-static gboolean zak_form_gtk_form_element_label_set_value (ZakFormGtkFormElementLabel *element, const gchar *value);
+static GValue *zak_form_gtk_form_element_label_get_value (ZakFormGtkFormElementLabel *element);
+static gboolean zak_form_gtk_form_element_label_set_value (ZakFormGtkFormElementLabel *element, GValue *value);
 
 #define ZAK_FORM_GTK_FORM_ELEMENT_LABEL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_LABEL, ZakFormGtkFormElementLabelPrivate))
 
@@ -162,24 +164,24 @@ zak_form_gtk_form_element_label_finalize (GObject *gobject)
        parent_class->finalize (gobject);
 }
 
-static gchar
+static GValue
 *zak_form_gtk_form_element_label_get_value (ZakFormGtkFormElementLabel *element)
 {
        GtkWidget *w;
 
        w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element));
 
-       return (gchar *)gtk_label_get_text (GTK_LABEL (w));
+       return zak_utils_gvalue_new_string ((gchar *)gtk_label_get_text (GTK_LABEL (w)));
 }
 
 static gboolean
-zak_form_gtk_form_element_label_set_value (ZakFormGtkFormElementLabel *element, const gchar *value)
+zak_form_gtk_form_element_label_set_value (ZakFormGtkFormElementLabel *element, GValue *value)
 {
        GtkWidget *w;
 
        w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element));
 
-       gtk_label_set_text (GTK_LABEL (w), value);
+       gtk_label_set_text (GTK_LABEL (w), g_value_get_string (value));
 
        return TRUE;
 }
index c0e679665a5102be59ecb5e4f71c2319ed9fcd16..e6ddbdc4fc4298e2186e9525ec85db69408e9dc9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2017 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
@@ -20,6 +20,8 @@
        #include <config.h>
 #endif
 
+#include <libzakutils/libzakutils.h>
+
 #include "formelementradio.h"
 
 enum
@@ -32,19 +34,19 @@ static void zak_form_gtk_form_element_radio_class_init (ZakFormGtkFormElementRad
 static void zak_form_gtk_form_element_radio_init (ZakFormGtkFormElementRadio *zak_form_gtk_form_element_radio);
 
 static void zak_form_gtk_form_element_radio_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_radio_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_radio_dispose (GObject *gobject);
 static void zak_form_gtk_form_element_radio_finalize (GObject *gobject);
 
-static gchar *zak_form_gtk_form_element_radio_get_value (ZakFormGtkFormElementRadio *element);
-static gboolean zak_form_gtk_form_element_radio_set_value (ZakFormGtkFormElementRadio *element, const gchar *value);
+static GValue *zak_form_gtk_form_element_radio_get_value (ZakFormGtkFormElementRadio *element);
+static gboolean zak_form_gtk_form_element_radio_set_value (ZakFormGtkFormElementRadio *element, GValue *value);
 
 #define ZAK_FORM_GTK_FORM_ELEMENT_RADIO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_RADIO, ZakFormGtkFormElementRadioPrivate))
 
@@ -234,10 +236,10 @@ zak_form_gtk_form_element_radio_finalize (GObject *gobject)
        parent_class->finalize (gobject);
 }
 
-static gchar
+static GValue
 *zak_form_gtk_form_element_radio_get_value (ZakFormGtkFormElementRadio *element)
 {
-       gchar *ret;
+       GValue *ret;
 
        GtkWidget *w;
 
@@ -245,16 +247,19 @@ static gchar
 
        w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element));
 
-       ret = g_strdup ("");
+       ret = zak_utils_gvalue_new_string ("");
        group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
        while (group != NULL)
                {
                        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (group->data)))
                                {
-                                       ret = (gchar *)g_object_get_data (G_OBJECT (group->data), "return-value");
-                                       if (ret == NULL)
+                                       if ((gchar *)g_object_get_data (G_OBJECT (group->data), "return-value") == NULL)
+                                               {
+                                                       g_value_set_string (ret, (gchar *)g_object_get_data (G_OBJECT (group->data), "return-value"));
+                                               }
+                                       else
                                                {
-                                                       ret = g_strdup ("");
+                                                       g_value_set_string (ret, "");
                                                }
                                        break;
                                }
@@ -266,7 +271,7 @@ static gchar
 }
 
 static gboolean
-zak_form_gtk_form_element_radio_set_value (ZakFormGtkFormElementRadio *element, const gchar *value)
+zak_form_gtk_form_element_radio_set_value (ZakFormGtkFormElementRadio *element, GValue *value)
 {
        GtkWidget *w;
 
@@ -277,7 +282,7 @@ zak_form_gtk_form_element_radio_set_value (ZakFormGtkFormElementRadio *element,
        group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
        while (group != NULL)
                {
-                       if (g_strcmp0 ((gchar *)g_object_get_data (G_OBJECT (group->data), "return-value"), value) == 0)
+                       if (g_strcmp0 ((gchar *)g_object_get_data (G_OBJECT (group->data), "return-value"), g_value_get_string (value)) == 0)
                                {
                                        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (group->data), TRUE);
                                        break;
index 2762eb075e2fca6952a2e469e2ce616e551a1831..5cbf3f9923b5a0fa1a826ecf0cd1313281dbe561 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2017 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
        #include <config.h>
 #endif
 
+#include <libzakutils/libzakutils.h>
+
 #include "formelementspin.h"
 
 static void zak_form_gtk_form_element_spin_class_init (ZakFormGtkFormElementSpinClass *class);
 static void zak_form_gtk_form_element_spin_init (ZakFormGtkFormElementSpin *zak_form_gtk_form_element_spin);
 
 static void zak_form_gtk_form_element_spin_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_spin_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_spin_dispose (GObject *gobject);
 static void zak_form_gtk_form_element_spin_finalize (GObject *gobject);
 
-static gchar *zak_form_gtk_form_element_spin_get_value (ZakFormGtkFormElementSpin *element);
-static gboolean zak_form_gtk_form_element_spin_set_value (ZakFormGtkFormElementSpin *element, const gchar *value);
+static GValue *zak_form_gtk_form_element_spin_get_value (ZakFormGtkFormElementSpin *element);
+static gboolean zak_form_gtk_form_element_spin_set_value (ZakFormGtkFormElementSpin *element, GValue *value);
 
 #define ZAK_FORM_GTK_FORM_ELEMENT_SPIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_SPIN, ZakFormGtkFormElementSpinPrivate))
 
@@ -162,28 +164,28 @@ zak_form_gtk_form_element_spin_finalize (GObject *gobject)
        parent_class->finalize (gobject);
 }
 
-static gchar
+static GValue
 *zak_form_gtk_form_element_spin_get_value (ZakFormGtkFormElementSpin *element)
 {
-       gchar *ret;
+       GValue *ret;
 
        GtkWidget *w;
 
        w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element));
 
-       ret = g_strdup_printf ("%f", gtk_spin_button_get_value (GTK_SPIN_BUTTON (w)));
+       ret = zak_utils_gvalue_new_string (g_strdup_printf ("%f", gtk_spin_button_get_value (GTK_SPIN_BUTTON (w))));
 
        return ret;
 }
 
 static gboolean
-zak_form_gtk_form_element_spin_set_value (ZakFormGtkFormElementSpin *element, const gchar *value)
+zak_form_gtk_form_element_spin_set_value (ZakFormGtkFormElementSpin *element, GValue *value)
 {
        GtkWidget *w;
 
        w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element));
 
-       gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), g_strtod (value, NULL));
+       gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), g_strtod (g_value_get_string (value), NULL));
 
        return TRUE;
 }
index 63b0172274d44484bf054b8c7d95a4c35a951fed..42b05af82e164d3fd8dd0771ed9f545b88bff4f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2017 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
        #include <config.h>
 #endif
 
+#include <libzakutils/libzakutils.h>
+
 #include "formelementtextview.h"
 
 static void zak_form_gtk_form_element_textview_class_init (ZakFormGtkFormElementTextviewClass *class);
 static void zak_form_gtk_form_element_textview_init (ZakFormGtkFormElementTextview *zak_form_gtk_form_element_textview);
 
 static void zak_form_gtk_form_element_textview_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_textview_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_textview_dispose (GObject *gobject);
 static void zak_form_gtk_form_element_textview_finalize (GObject *gobject);
 
-static gchar *zak_form_gtk_form_element_textview_get_value (ZakFormGtkFormElementTextview *element);
-static gboolean zak_form_gtk_form_element_textview_set_value (ZakFormGtkFormElementTextview *element, const gchar *value);
+static GValue *zak_form_gtk_form_element_textview_get_value (ZakFormGtkFormElementTextview *element);
+static gboolean zak_form_gtk_form_element_textview_set_value (ZakFormGtkFormElementTextview *element, GValue *value);
 
 #define ZAK_FORM_GTK_FORM_ELEMENT_TEXTVIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT_TEXTVIEW, ZakFormGtkFormElementTextviewPrivate))
 
@@ -106,9 +108,9 @@ zak_form_gtk_form_element_textview_xml_parsing (ZakFormElement *element, xmlNode
 /* PRIVATE */
 static void
 zak_form_gtk_form_element_textview_set_property (GObject *object,
-                   guint property_id,
-                   const GValue *value,
-                   GParamSpec *pspec)
+                                                 guint property_id,
+                                                 const GValue *value,
+                                                 GParamSpec *pspec)
 {
        ZakFormGtkFormElementTextview *zak_form_gtk_form_element_textview = (ZakFormGtkFormElementTextview *)object;
        ZakFormGtkFormElementTextviewPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_TEXTVIEW_GET_PRIVATE (zak_form_gtk_form_element_textview);
@@ -123,9 +125,9 @@ zak_form_gtk_form_element_textview_set_property (GObject *object,
 
 static void
 zak_form_gtk_form_element_textview_get_property (GObject *object,
-                   guint property_id,
-                   GValue *value,
-                   GParamSpec *pspec)
+                                                 guint property_id,
+                                                 GValue *value,
+                                                 GParamSpec *pspec)
 {
        ZakFormGtkFormElementTextview *zak_form_gtk_form_element_textview = (ZakFormGtkFormElementTextview *)object;
        ZakFormGtkFormElementTextviewPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_TEXTVIEW_GET_PRIVATE (zak_form_gtk_form_element_textview);
@@ -162,10 +164,10 @@ zak_form_gtk_form_element_textview_finalize (GObject *gobject)
        parent_class->finalize (gobject);
 }
 
-static gchar
+static GValue
 *zak_form_gtk_form_element_textview_get_value (ZakFormGtkFormElementTextview *element)
 {
-       gchar *ret;
+       GValue *ret;
 
        GtkWidget *w;
 
@@ -177,13 +179,13 @@ static gchar
 
        buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w));
        gtk_text_buffer_get_bounds (buf, &start, &end);
-       ret = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
+       ret = zak_utils_gvalue_new_string (gtk_text_buffer_get_text (buf, &start, &end, FALSE));
 
        return ret;
 }
 
 static gboolean
-zak_form_gtk_form_element_textview_set_value (ZakFormGtkFormElementTextview *element, const gchar *value)
+zak_form_gtk_form_element_textview_set_value (ZakFormGtkFormElementTextview *element, GValue *value)
 {
        GtkWidget *w;
 
@@ -192,7 +194,7 @@ zak_form_gtk_form_element_textview_set_value (ZakFormGtkFormElementTextview *ele
        w = zak_form_gtk_form_element_get_widget (ZAK_FORM_GTK_FORM_ELEMENT (element));
 
        buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w));
-       gtk_text_buffer_set_text (buf, value, -1);
+       gtk_text_buffer_set_text (buf, g_value_get_string (value), -1);
 
        return TRUE;
 }