/*
- * 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))
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;
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
/*
- * 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
#include <config.h>
#endif
+#include <libzakutils/libzakutils.h>
+
#include "formelementcombo.h"
enum
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))
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;
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)
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);
}
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;
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);
/*
- * 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))
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;
}
/*
- * 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))
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;
}
/*
- * 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 "formelementradio.h"
enum
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))
parent_class->finalize (gobject);
}
-static gchar
+static GValue
*zak_form_gtk_form_element_radio_get_value (ZakFormGtkFormElementRadio *element)
{
- gchar *ret;
+ GValue *ret;
GtkWidget *w;
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;
}
}
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;
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;
/*
- * 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))
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;
}
/*
- * 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))
/* 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);
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);
parent_class->finalize (gobject);
}
-static gchar
+static GValue
*zak_form_gtk_form_element_textview_get_value (ZakFormGtkFormElementTextview *element)
{
- gchar *ret;
+ GValue *ret;
GtkWidget *w;
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;
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;
}