]> saetta.ns0.it Git - zakform/gtk/commitdiff
Added ZakFormGtkFormElement::xml_parsing.
authorAndrea Zagli <azagli@libero.it>
Thu, 26 Nov 2015 19:16:00 +0000 (20:16 +0100)
committerAndrea Zagli <azagli@libero.it>
Thu, 26 Nov 2015 19:16:00 +0000 (20:16 +0100)
13 files changed:
src/formelement.c
src/formelement.h
src/formelementcheck.c
src/formelementcheck.h
src/formelemententry.c
src/formelemententry.h
src/formelementlabel.c
src/formelementlabel.h
src/formelementradio.c
src/formelementspin.c
src/formelementspin.h
src/formelementtextview.c
src/formelementtextview.h

index 997bc95683d8e964a23997939ea96cb57b299cd0..88a26a39cee5bf1adc5b438d8d5908019c9ba98c 100644 (file)
@@ -25,6 +25,7 @@
 enum
 {
        PROP_0,
+       PROP_GTKBUILDER,
        PROP_WIDGET,
        PROP_NAME,
        PROP_LABEL
@@ -51,11 +52,14 @@ static void zak_form_gtk_form_element_set_visible (ZakFormGtkFormElement *elemen
 static gboolean zak_form_gtk_form_element_get_editable (ZakFormGtkFormElement *element);
 static void zak_form_gtk_form_element_set_editable (ZakFormGtkFormElement *element, gboolean visible);
 
+static void zak_form_gtk_form_element_xml_parsing (ZakFormElement *element, xmlNode *xmlnode);
+
 #define ZAK_FORM_GTK_FORM_ELEMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_GTK_TYPE_FORM_ELEMENT, ZakFormGtkFormElementPrivate))
 
 typedef struct _ZakFormGtkFormElementPrivate ZakFormGtkFormElementPrivate;
 struct _ZakFormGtkFormElementPrivate
        {
+               GtkBuilder *builder;
                GtkWidget *widget;
                gchar *name;
 
@@ -75,6 +79,8 @@ zak_form_gtk_form_element_class_init (ZakFormGtkFormElementClass *class)
        object_class->dispose = zak_form_gtk_form_element_dispose;
        object_class->finalize = zak_form_gtk_form_element_finalize;
 
+       class->xml_parsing = zak_form_gtk_form_element_xml_parsing;
+
        parent_class->get_visible = zak_form_gtk_form_element_get_visible;
        parent_class->set_visible = zak_form_gtk_form_element_set_visible;
        parent_class->get_editable = zak_form_gtk_form_element_get_editable;
@@ -82,6 +88,13 @@ zak_form_gtk_form_element_class_init (ZakFormGtkFormElementClass *class)
 
        g_type_class_add_private (object_class, sizeof (ZakFormGtkFormElementPrivate));
 
+       g_object_class_install_property (object_class, PROP_GTKBUILDER,
+                                                                        g_param_spec_object ("gtkbuilder",
+                                                                                                                 "GtkBuilder",
+                                                                                                                 "GtkBuilder",
+                                                                                                                 G_TYPE_OBJECT,
+                                                                                                                 G_PARAM_READWRITE));
+
        g_object_class_install_property (object_class, PROP_WIDGET,
                                                                         g_param_spec_object ("widget",
                                                                                                                  "Widget",
@@ -109,11 +122,43 @@ zak_form_gtk_form_element_init (ZakFormGtkFormElement *zak_form_gtk_form_element
 {
        ZakFormGtkFormElementPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_GET_PRIVATE (zak_form_gtk_form_element);
 
+       priv->builder = NULL;
        priv->widget = NULL;
        priv->name = NULL;
        priv->label = NULL;
 }
 
+/**
+ * zak_form_gtk_form_element_set_gtkbuilder:
+ * @element:
+ * @gtkbuilder:
+ *
+ */
+void
+zak_form_gtk_form_element_set_gtkbuilder (ZakFormGtkFormElement *element, GtkBuilder *gtkbuilder)
+{
+       ZakFormGtkFormElementPrivate *priv;
+
+       priv = ZAK_FORM_GTK_FORM_ELEMENT_GET_PRIVATE (element);
+
+       priv->builder = gtkbuilder;
+}
+
+/**
+ * zak_form_gtk_form_element_get_gtkbuilder:
+ * @element:
+ *
+ */
+GtkBuilder
+*zak_form_gtk_form_element_get_gtkbuilder (ZakFormGtkFormElement *element)
+{
+       ZakFormGtkFormElementPrivate *priv;
+
+       priv = ZAK_FORM_GTK_FORM_ELEMENT_GET_PRIVATE (element);
+
+       return priv->builder;
+}
+
 /**
  * zak_form_gtk_form_element_widget_set_from_gtkbuilder:
  * @element:
@@ -137,12 +182,14 @@ zak_form_gtk_form_element_widget_set_from_gtkbuilder (ZakFormGtkFormElement *ele
 
        priv = ZAK_FORM_GTK_FORM_ELEMENT_GET_PRIVATE (element);
 
+       priv->builder = gtkbuilder;
+
        ret = FALSE;
        w = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, widget_name));
-       if (w != NULL)
+       if (w != NULL
+               && GTK_IS_WIDGET (w))
                {
-                       priv->widget = g_object_ref (w);
-                       priv->name = g_strdup (widget_name);
+                       zak_form_gtk_form_element_set_widget (element, w, widget_name);
                        ret = TRUE;
                }
        else
@@ -252,6 +299,10 @@ zak_form_gtk_form_element_set_property (GObject *object,
 
        switch (property_id)
                {
+               case PROP_GTKBUILDER:
+                       zak_form_gtk_form_element_set_gtkbuilder (zak_form_gtk_form_element, (GtkBuilder *)g_value_get_object (value));
+                       break;
+
                case PROP_LABEL:
                        zak_form_gtk_form_element_set_label (zak_form_gtk_form_element, (GtkWidget *)g_value_get_object (value));
                        break;
@@ -273,6 +324,10 @@ zak_form_gtk_form_element_get_property (GObject *object,
 
        switch (property_id)
                {
+               case PROP_GTKBUILDER:
+                       g_value_set_object (value, (gpointer)zak_form_gtk_form_element_get_gtkbuilder (zak_form_gtk_form_element));
+                       break;
+
                case PROP_LABEL:
                        g_value_set_object (value, (gpointer)zak_form_gtk_form_element_get_label (zak_form_gtk_form_element));
                        break;
@@ -343,3 +398,22 @@ zak_form_gtk_form_element_set_editable (ZakFormGtkFormElement *element, gboolean
 
        gtk_widget_set_sensitive (priv->widget, editable);
 }
+
+static void
+zak_form_gtk_form_element_xml_parsing (ZakFormElement *element, xmlNode *xmlnode)
+{
+       xmlNode *cur;
+
+       ZakFormGtkFormElementPrivate *priv = ZAK_FORM_GTK_FORM_ELEMENT_GET_PRIVATE ((ZakFormGtkFormElement *)element);
+
+       cur = xmlnode->children;
+       while (cur != NULL)
+               {
+                       if (xmlStrcmp (cur->name, (const xmlChar *)"widget") == 0)
+                               {
+                                       zak_form_gtk_form_element_widget_set_from_gtkbuilder (ZAK_FORM_GTK_FORM_ELEMENT (element), priv->builder, (gchar *)xmlNodeGetContent (cur));
+                               }
+
+                       cur = cur->next;
+               }
+}
index 9b59849e19ba9fccbb426897a8b477dcdb9c4c8b..a9c88c0c315be446bdc78cb007e66d6beabbd3dc 100644 (file)
@@ -39,9 +39,14 @@ G_DECLARE_DERIVABLE_TYPE (ZakFormGtkFormElement, zak_form_gtk_form_element, ZAK_
 struct _ZakFormGtkFormElementClass
        {
                ZakFormElementClass parent_class;
+
+               void (*xml_parsing) (ZakFormElement *element, xmlNode *xmlnode);
        };
 
 
+void zak_form_gtk_form_element_set_gtkbuilder (ZakFormGtkFormElement *element, GtkBuilder *gtkbuilder);
+GtkBuilder *zak_form_gtk_form_element_get_gtkbuilder (ZakFormGtkFormElement *element);
+
 gboolean zak_form_gtk_form_element_widget_set_from_gtkbuilder (ZakFormGtkFormElement *element,
                                                                                                                           GtkBuilder *gtkbuilder,
                                                                                                                           const gchar *widget_name);
index 884ca7dc44191ec40b000e26c5493c064826d7c9..b345f89f1c211767f43ec4520007b1b0903ad11a 100644 (file)
@@ -89,6 +89,20 @@ ZakFormGtkFormElement
        return ZAK_FORM_GTK_FORM_ELEMENT (zak_form_gtk_form_element_check);
 }
 
+/**
+ * zak_form_gtk_form_element_check_xml_parsing:
+ * @element:
+ * @xmlnode:
+ *
+ */
+gboolean
+zak_form_gtk_form_element_check_xml_parsing (ZakFormElement *element, xmlNodePtr xmlnode)
+{
+       ZAK_FORM_GTK_FORM_ELEMENT_CLASS (zak_form_gtk_form_element_check_parent_class)->xml_parsing (element, xmlnode);
+
+       return TRUE;
+}
+
 /* PRIVATE */
 static void
 zak_form_gtk_form_element_check_set_property (GObject *object,
index 48a80f40d17bdfea2aa04c9443f4cf5608fcf1a1..0bca3f854f88653d763ddb1dbb89c73b4fea00ba 100644 (file)
@@ -53,6 +53,8 @@ GType zak_form_gtk_form_element_check_get_type (void);
 
 ZakFormGtkFormElement *zak_form_gtk_form_element_check_new (void);
 
+gboolean zak_form_gtk_form_element_check_xml_parsing (ZakFormElement *element, xmlNodePtr xmlnode);
+
 
 G_END_DECLS
 
index b89987f70bde00798341abacb5a8c03947493624..09d133f6cd39315f37a257527224a15c18ff62ff 100644 (file)
@@ -89,6 +89,20 @@ ZakFormGtkFormElement
        return ZAK_FORM_GTK_FORM_ELEMENT (zak_form_gtk_form_element_entry);
 }
 
+/**
+ * zak_form_gtk_form_element_entry_xml_parsing:
+ * @element:
+ * @xmlnode:
+ *
+ */
+gboolean
+zak_form_gtk_form_element_entry_xml_parsing (ZakFormElement *element, xmlNodePtr xmlnode)
+{
+       ZAK_FORM_GTK_FORM_ELEMENT_CLASS (zak_form_gtk_form_element_entry_parent_class)->xml_parsing (element, xmlnode);
+
+       return TRUE;
+}
+
 /* PRIVATE */
 static void
 zak_form_gtk_form_element_entry_set_property (GObject *object,
index 22ea0e8c9c7d512ead3f67d1f539d54aac24abf2..0b3484fd3558eb2e690c6cbee5462153c271ef04 100644 (file)
@@ -53,6 +53,8 @@ GType zak_form_gtk_form_element_entry_get_type (void);
 
 ZakFormGtkFormElement *zak_form_gtk_form_element_entry_new (void);
 
+gboolean zak_form_gtk_form_element_entry_xml_parsing (ZakFormElement *element, xmlNodePtr xmlnode);
+
 
 G_END_DECLS
 
index f8ddc410231fdd6480f7487f5a973df71225ee72..7947fb85173290b66042dc29f67cc39548c60138 100644 (file)
@@ -89,6 +89,20 @@ ZakFormGtkFormElement
        return ZAK_FORM_GTK_FORM_ELEMENT (zak_form_gtk_form_element_label);
 }
 
+/**
+ * zak_form_gtk_form_element_label_xml_parsing:
+ * @element:
+ * @xmlnode:
+ *
+ */
+gboolean
+zak_form_gtk_form_element_label_xml_parsing (ZakFormElement *element, xmlNodePtr xmlnode)
+{
+       ZAK_FORM_GTK_FORM_ELEMENT_CLASS (zak_form_gtk_form_element_label_parent_class)->xml_parsing (element, xmlnode);
+
+       return TRUE;
+}
+
 /* PRIVATE */
 static void
 zak_form_gtk_form_element_label_set_property (GObject *object,
index 602c51a77d478ea4afe344f9635d3cf218d8b90b..102f87963467e5ea5a2c56be4996f13c1624d28b 100644 (file)
@@ -53,6 +53,8 @@ GType zak_form_gtk_form_element_label_get_type (void);
 
 ZakFormGtkFormElement *zak_form_gtk_form_element_label_new (void);
 
+gboolean zak_form_gtk_form_element_label_xml_parsing (ZakFormElement *element, xmlNodePtr xmlnode);
+
 
 G_END_DECLS
 
index 7204db984a6aecaa0b00d0ff210966ee5020664f..eeea2ad8cecf39025a548e50b976101df9ca5ad5 100644 (file)
@@ -113,12 +113,14 @@ zak_form_gtk_form_element_radio_xml_parsing (ZakFormElement *element, xmlNodePtr
 {
        xmlNode *cur;
 
+       ZAK_FORM_GTK_FORM_ELEMENT_CLASS (zak_form_gtk_form_element_radio_parent_class)->xml_parsing (element, xmlnode);
+
        cur = xmlnode->children;
        while (cur != NULL)
                {
                        if (xmlStrcmp (cur->name, (const xmlChar *)"return-value") == 0)
                                {
-                                       zak_form_gtk_form_element_radio_set_return_value (element, (gchar *)xmlNodeGetContent (cur));
+                                       zak_form_gtk_form_element_radio_set_return_value (ZAK_FORM_GTK_FORM_ELEMENT_RADIO (element), (gchar *)xmlNodeGetContent (cur));
                                }
 
                        cur = cur->next;
index 654e8b8ed25d817f426fec27c07d86c017750ea2..2762eb075e2fca6952a2e469e2ce616e551a1831 100644 (file)
@@ -89,6 +89,20 @@ ZakFormGtkFormElement
        return ZAK_FORM_GTK_FORM_ELEMENT (zak_form_gtk_form_element_spin);
 }
 
+/**
+ * zak_form_gtk_form_element_spin_xml_parsing:
+ * @element:
+ * @xmlnode:
+ *
+ */
+gboolean
+zak_form_gtk_form_element_spin_xml_parsing (ZakFormElement *element, xmlNodePtr xmlnode)
+{
+       ZAK_FORM_GTK_FORM_ELEMENT_CLASS (zak_form_gtk_form_element_spin_parent_class)->xml_parsing (element, xmlnode);
+
+       return TRUE;
+}
+
 /* PRIVATE */
 static void
 zak_form_gtk_form_element_spin_set_property (GObject *object,
index d258784906c51529e0ee6603770b1ec639c9a18c..13c5c7a9a053320e1c71a4a7def74e1238af8a86 100644 (file)
@@ -53,6 +53,8 @@ GType zak_form_gtk_form_element_spin_get_type (void);
 
 ZakFormGtkFormElement *zak_form_gtk_form_element_spin_new (void);
 
+gboolean zak_form_gtk_form_element_spin_xml_parsing (ZakFormElement *element, xmlNodePtr xmlnode);
+
 
 G_END_DECLS
 
index 09db12fc9d6029e9469ff31df892574a9507f458..63b0172274d44484bf054b8c7d95a4c35a951fed 100644 (file)
@@ -89,6 +89,20 @@ ZakFormGtkFormElement
        return ZAK_FORM_GTK_FORM_ELEMENT (zak_form_gtk_form_element_textview);
 }
 
+/**
+ * zak_form_gtk_form_element_textview_xml_parsing:
+ * @element:
+ * @xmlnode:
+ *
+ */
+gboolean
+zak_form_gtk_form_element_textview_xml_parsing (ZakFormElement *element, xmlNodePtr xmlnode)
+{
+       ZAK_FORM_GTK_FORM_ELEMENT_CLASS (zak_form_gtk_form_element_textview_parent_class)->xml_parsing (element, xmlnode);
+
+       return TRUE;
+}
+
 /* PRIVATE */
 static void
 zak_form_gtk_form_element_textview_set_property (GObject *object,
index dd4a16b6bbab102ae0957884a51c878270444756..816388047e427d952c2d60c8006ab2de107f1863 100644 (file)
@@ -53,6 +53,8 @@ GType zak_form_gtk_form_element_textview_get_type (void);
 
 ZakFormGtkFormElement *zak_form_gtk_form_element_textview_new (void);
 
+gboolean zak_form_gtk_form_element_textview_xml_parsing (ZakFormElement *element, xmlNodePtr xmlnode);
+
 
 G_END_DECLS