*.exe
*.csv
*.gir
-*.typelib
\ No newline at end of file
+*.typelib
+tools/uifactory
\ No newline at end of file
DISTCHECK_CONFIGURE_FLAGS = --enable-introspection
-SUBDIRS = src tests
+SUBDIRS = src tests tools
ACLOCAL_AMFLAGS = -I m4
Makefile
src/Makefile
tests/Makefile
+ tools/Makefile
])
AC_OUTPUT
return ret;
}
+xmlNode
+*zak_form_gtk_form_get_ui_xml (ZakFormGtkForm *form)
+{
+ ZakFormGtkFormPrivate *priv;
+
+ xmlNode *root;
+ xmlNode *parent;
+ xmlNode *cur;
+
+ GPtrArray *elements;
+ guint i;
+
+ g_return_val_if_fail (ZAK_FORM_GTK_IS_FORM (form), NULL);
+
+ priv = ZAK_FORM_GTK_FORM_GET_PRIVATE (form);
+
+ root = xmlNewNode (NULL, (const xmlChar *)"interface");
+
+ cur = xmlNewNode (NULL, (const xmlChar *)"object");
+ xmlSetProp (cur, (const xmlChar *)"class", (const xmlChar *)"GtkWindow");
+ xmlAddChild (root, cur);
+
+ parent = cur;
+ cur = xmlNewNode (NULL, (const xmlChar *)"child");
+ xmlAddChild (parent, cur);
+
+ parent = cur;
+ cur = xmlNewNode (NULL, (const xmlChar *)"object");
+ xmlSetProp (cur, (const xmlChar *)"class", (const xmlChar *)"GtkBox");
+ xmlAddChild (parent, cur);
+
+ parent = cur;
+ cur = xmlNewNode (NULL, (const xmlChar *)"property");
+ xmlSetProp (cur, (const xmlChar *)"name", (const xmlChar *)"orientation");
+ xmlNodeSetContent (cur, (const xmlChar *)"vertical");
+ xmlAddChild (parent, cur);
+
+ cur = xmlNewNode (NULL, (const xmlChar *)"child");
+ xmlAddChild (parent, cur);
+
+ parent = cur;
+ cur = xmlNewNode (NULL, (const xmlChar *)"object");
+ xmlSetProp (cur, (const xmlChar *)"class", (const xmlChar *)"GtkGrid");
+ xmlAddChild (parent, cur);
+
+ elements = zak_form_form_get_elements (ZAK_FORM_FORM (form));
+ for (i = 0; i < elements->len; i++)
+ {
+ cur = zak_form_gtk_form_element_get_ui_xml (ZAK_FORM_GTK_FORM_ELEMENT (g_ptr_array_index (elements, i)));
+ if (cur != NULL)
+ {
+
+ }
+ }
+
+ return root;
+}
+
/* PRIVATE */
static void
zak_form_gtk_form_set_property (GObject *object,
/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 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
GObject **zak_form_gtk_form_get_gobjects_by_name (ZakFormGtkForm *form, ...);
+xmlNode *zak_form_gtk_form_get_ui_xml (ZakFormGtkForm *form);
+
G_END_DECLS
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 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
gtk_label_get_text (GTK_LABEL (priv->label)));
}
+xmlNode
+*zak_form_gtk_form_element_get_ui_xml (ZakFormGtkFormElement *element)
+{
+ if (ZAK_FORM_GTK_FORM_ELEMENT_GET_CLASS (element)->get_ui_xml != NULL)
+ {
+ return ZAK_FORM_GTK_FORM_ELEMENT_GET_CLASS (element)->get_ui_xml (ZAK_FORM_ELEMENT (element));
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
/* PRIVATE */
static void
zak_form_gtk_form_element_set_property (GObject *object,
cur = xmlnode->children;
while (cur != NULL)
{
- if (xmlStrcmp (cur->name, (const xmlChar *)"widget") == 0)
+ if (priv->builder != NULL)
{
- zak_form_gtk_form_element_set_widget_from_gtkbuilder (ZAK_FORM_GTK_FORM_ELEMENT (element), priv->builder, (gchar *)xmlNodeGetContent (cur));
+ if (xmlStrcmp (cur->name, (const xmlChar *)"widget") == 0)
+ {
+ zak_form_gtk_form_element_set_widget_from_gtkbuilder (ZAK_FORM_GTK_FORM_ELEMENT (element), priv->builder, (gchar *)xmlNodeGetContent (cur));
+ }
+ else if (xmlStrcmp (cur->name, (const xmlChar *)"label") == 0)
+ {
+ zak_form_gtk_form_element_set_label (ZAK_FORM_GTK_FORM_ELEMENT (element),
+ GTK_WIDGET (gtk_builder_get_object (priv->builder, (gchar *)xmlNodeGetContent (cur))));
+ }
}
- else if (xmlStrcmp (cur->name, (const xmlChar *)"label") == 0)
+ else
{
- zak_form_gtk_form_element_set_label (ZAK_FORM_GTK_FORM_ELEMENT (element),
- GTK_WIDGET (gtk_builder_get_object (priv->builder, (gchar *)xmlNodeGetContent (cur))));
+ if (xmlStrcmp (cur->name, (const xmlChar *)"label") == 0)
+ {
+ GtkWidget *lbl;
+
+ lbl = gtk_label_new ((gchar *)xmlNodeGetContent (cur));
+ zak_form_gtk_form_element_set_label (ZAK_FORM_GTK_FORM_ELEMENT (element), lbl);
+ }
+
}
cur = cur->next;
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 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
ZakFormElementClass parent_class;
void (*xml_parsing) (ZakFormElement *element, xmlNode *xmlnode);
+ xmlNode *(*get_ui_xml) (ZakFormElement *element);
};
GtkBuilder *zak_form_gtk_form_element_get_gtkbuilder (ZakFormGtkFormElement *element);
gboolean zak_form_gtk_form_element_set_widget_from_gtkbuilder (ZakFormGtkFormElement *element,
- GtkBuilder *gtkbuilder,
- const gchar *widget_name);
+ GtkBuilder *gtkbuilder,
+ const gchar *widget_name);
GtkWidget *zak_form_gtk_form_element_get_widget (ZakFormGtkFormElement *element);
void zak_form_gtk_form_element_set_widget (ZakFormGtkFormElement *element, GtkWidget *widget, const gchar *widget_name);
GtkWidget *zak_gtk_form_element_get_label (ZakFormGtkFormElement *element);
void zak_form_gtk_form_element_set_label (ZakFormGtkFormElement *element, GtkWidget *label);
+xmlNode *zak_form_gtk_form_element_get_ui_xml (ZakFormGtkFormElement *element);
+
G_END_DECLS
--- /dev/null
+AM_CPPFLAGS = $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED_CFLAGS) \
+ $(ZAKFORMGTK_CFLAGS) \
+ -I$(top_srcdir)/src \
+ -DGUIDIR="\"@abs_builddir@\""
+
+LIBS = $(ZAKFORMGTK_LIBS) \
+ -export-dynamic
+
+LDADD = $(top_builddir)/src/libzakformgtk.la
+
+noinst_PROGRAMS = \
+ uifactory
+
+EXTRA_DIST =
--- /dev/null
+/*
+ * Copyright (C) 2020 Andrea Zagli <azagli@libero.it>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+
+#include "form.h"
+
+int
+main (int argc, char *argv[])
+{
+ ZakFormGtkForm *form;
+
+ xmlDoc *doc;
+ xmlNode *root;
+
+ gtk_init (&argc, &argv);
+
+ form = zak_form_gtk_form_new ();
+
+ zak_form_form_load_from_file (ZAK_FORM_FORM (form), argv[1]);
+
+ doc = xmlNewDoc ("1.0");
+
+ root = zak_form_gtk_form_get_ui_xml (form);
+
+ xmlDocSetRootElement (doc, root);
+
+ xmlSaveFormatFileEnc ("did.ui", doc, "UTF-8", 2);
+
+ return 0;
+}