[libgda] Got rid of LibGlade



commit 1eee2ee470baee9c758286b98a3b97a1642f44b4
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Nov 27 20:35:02 2014 +0100

    Got rid of LibGlade

 libgda-ui/data/Makefile.am            |    4 +-
 libgda-ui/data/server_operation.glade |  374 ---------------------------------
 libgda-ui/data/server_operation.xml   |  194 +++++++++++++++++
 libgda-ui/gdaui-server-operation.c    |   91 ++++-----
 libgda-ui/gdaui-server-operation.h    |    5 +-
 5 files changed, 234 insertions(+), 434 deletions(-)
---
diff --git a/libgda-ui/data/Makefile.am b/libgda-ui/data/Makefile.am
index 4fbbfda..07dd304 100644
--- a/libgda-ui/data/Makefile.am
+++ b/libgda-ui/data/Makefile.am
@@ -6,9 +6,9 @@ icons_DATA= \
 
 # other
 xmldir = $(datadir)/libgda-$(GDA_ABI_MAJOR_VERSION).$(GDA_ABI_MINOR_VERSION)
-xml_DATA = import_encodings.xml server_operation.glade
+xml_DATA = import_encodings.xml
 
 EXTRA_DIST = \
        $(icons_DATA) \
        import_encodings.xml \
-       server_operation.glade 
+       server_operation.xml
diff --git a/libgda-ui/data/server_operation.xml b/libgda-ui/data/server_operation.xml
new file mode 100644
index 0000000..dabdb59
--- /dev/null
+++ b/libgda-ui/data/server_operation.xml
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <object class="GtkNotebook" id="Root">
+    <property name="visible">True</property>
+    <property name="can_focus">True</property>
+    <child>
+      <object class="GtkNotebook" id="CREATE_TABLE">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="show_border">False</property>
+        <child>
+          <object class="GtkVBox" id="vbox1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkVBox" id="/TABLE_DEF_P">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="/TABLE_PARENTS_S">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="tab_expand">True</property>
+          </packing>
+        </child>
+        <child type="tab">
+          <object class="GtkLabel" id="label4">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">General</property>
+          </object>
+          <packing>
+            <property name="tab_fill">False</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="/FIELDS_A">
+            <property name="width_request">397</property>
+            <property name="height_request">251</property>
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="menu_label">hello</property>
+            <property name="position">1</property>
+            <property name="tab_expand">True</property>
+          </packing>
+        </child>
+        <child type="tab">
+          <object class="GtkLabel" id="label5">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Columns</property>
+          </object>
+          <packing>
+            <property name="position">1</property>
+            <property name="tab_fill">False</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="/FKEY_S">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="position">2</property>
+            <property name="tab_expand">True</property>
+          </packing>
+        </child>
+        <child type="tab">
+          <object class="GtkLabel" id="label6">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Foreign keys</property>
+          </object>
+          <packing>
+            <property name="position">2</property>
+            <property name="tab_fill">False</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="/TABLE_CONSTRAINTS_S">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="position">3</property>
+          </packing>
+        </child>
+        <child type="tab">
+          <object class="GtkLabel" id="label7">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Constraints</property>
+          </object>
+          <packing>
+            <property name="position">3</property>
+            <property name="tab_fill">False</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <child>
+              <object class="GtkViewport" id="viewport1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkVBox" id="/TABLE_OPTIONS_P">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="position">4</property>
+          </packing>
+        </child>
+        <child type="tab">
+          <object class="GtkLabel" id="label8">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Options</property>
+          </object>
+          <packing>
+            <property name="position">4</property>
+            <property name="tab_fill">False</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <child type="tab">
+      <object class="GtkLabel" id="label1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">CREATE_TABLE</property>
+      </object>
+      <packing>
+        <property name="tab_fill">False</property>
+      </packing>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child type="tab">
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child type="tab">
+      <placeholder/>
+    </child>
+  </object>
+</interface>
diff --git a/libgda-ui/gdaui-server-operation.c b/libgda-ui/gdaui-server-operation.c
index 2512f1f..f441576 100644
--- a/libgda-ui/gdaui-server-operation.c
+++ b/libgda-ui/gdaui-server-operation.c
@@ -68,9 +68,7 @@ struct _GdauiServerOperationPriv
 {
        GdaServerOperation     *op;
        GSList                 *widget_data; /* list of WidgetData structures */
-#ifdef HAVE_LIBGLADE
-       GladeXML               *glade;
-#endif
+       GtkBuilder             *builder;
        gboolean                opt_header;
 };
 
@@ -214,9 +212,7 @@ gdaui_server_operation_init (GdauiServerOperation * wid)
        wid->priv = g_new0 (GdauiServerOperationPriv, 1);
        wid->priv->op = NULL;
        wid->priv->widget_data = NULL;
-#ifdef HAVE_LIBGLADE
-       wid->priv->glade = NULL;
-#endif
+       wid->priv->builder = NULL;
        wid->priv->opt_header = FALSE;
 
        gtk_orientable_set_orientation (GTK_ORIENTABLE (wid), GTK_ORIENTATION_VERTICAL);
@@ -274,10 +270,8 @@ gdaui_server_operation_dispose (GObject *object)
                        form->priv->widget_data = NULL;
                }
 
-#ifdef HAVE_LIBGLADE
-               if (form->priv->glade)
-                       g_object_unref (form->priv->glade);
-#endif
+               if (form->priv->builder)
+                       g_object_unref (form->priv->builder);
 
                /* the private area itself */
                g_free (form->priv);
@@ -411,9 +405,9 @@ fill_create_widget (GdauiServerOperation *form, const gchar *path, gchar **secti
                *section_str = NULL;
 
        /* very custom widget rendering goes here */
-       if ((gda_server_operation_get_op_type (form->priv->op) == GDA_SERVER_OPERATION_CREATE_TABLE) &&
+       /*if ((gda_server_operation_get_op_type (form->priv->op) == GDA_SERVER_OPERATION_CREATE_TABLE) &&
            !strcmp (path, "/FIELDS_A"))
-               return create_table_fields_array_create_widget (form, path, section_str, label_widgets);
+           return create_table_fields_array_create_widget (form, path, section_str, label_widgets);*/
 
        /* generic widget rendering */
        switch (info_node->type) {
@@ -464,8 +458,9 @@ fill_create_widget (GdauiServerOperation *form, const gchar *path, gchar **secti
                model = info_node->model;
                grid = gdaui_raw_grid_new (model);
                gtk_container_add (GTK_CONTAINER (plwid), grid);
-               gtk_viewport_set_shadow_type (GTK_VIEWPORT (gtk_bin_get_child (GTK_BIN (plwid))),
-                                             GTK_SHADOW_NONE);
+               if (GTK_IS_VIEWPORT (gtk_bin_get_child (GTK_BIN (plwid))))
+                       gtk_viewport_set_shadow_type (GTK_VIEWPORT (gtk_bin_get_child (GTK_BIN (plwid))),
+                                                     GTK_SHADOW_NONE);
                gdaui_data_proxy_set_write_mode (GDAUI_DATA_PROXY (grid),
                                                 GDAUI_DATA_PROXY_WRITE_ON_ROW_CHANGE);
                gtk_widget_show (grid);
@@ -689,54 +684,47 @@ gdaui_server_operation_fill (GdauiServerOperation *form)
 {
        gint i;
        gchar **topnodes;
-#ifdef HAVE_LIBGLADE
-       gchar *glade_file;
-#endif
 
        /* parameters list management */
        if (!form->priv->op)
                /* nothing to do */
                return;
 
-       /* load Glade file for specific GUI if it exists */
-#ifdef HAVE_LIBGLADE
-       glade_file = gdaui_gbr_get_data_dir_path ("server_operation.glade");
-       form->priv->glade = glade_xml_new (glade_file,
-                                          gda_server_operation_op_type_to_string 
(gda_server_operation_get_op_type (form->priv->op)),
-                                          NULL);
-       g_free (glade_file);
-       if (form->priv->glade) {
-               GtkWidget *mainw;
-               mainw = glade_xml_get_widget (form->priv->glade,
-                                             gda_server_operation_op_type_to_string 
(gda_server_operation_get_op_type (form->priv->op)));
+       /* load specific GUI */
+       if (!form->priv->builder) {
+               form->priv->builder = gtk_builder_new ();
+               if (! gtk_builder_add_from_resource (form->priv->builder, 
"/gdaui/glade/data/server_operation.xml", NULL)) {
+                       g_message ("Could not load GdaServerOperation UI data, please report error to "
+                                  "http://bugzilla.gnome.org/ for the \"libgda\" product");
+                       g_object_unref (form->priv->builder);
+                       form->priv->builder = NULL;
+               }
+       }
+
+       GtkWidget *mainw = NULL;
+       if (form->priv->builder) {
+               mainw = (GtkWidget*) gtk_builder_get_object (form->priv->builder,
+                                                            gda_server_operation_op_type_to_string
+                                                            (gda_server_operation_get_op_type 
(form->priv->op)));
                if (mainw) {
+                       gtk_widget_unparent (mainw);
                        gtk_box_pack_start (GTK_BOX (form), mainw, TRUE, TRUE, 0);
                        gtk_widget_show (mainw);
                }
-               else {
-                       g_object_unref (form->priv->glade);
-                       form->priv->glade = NULL;
-               }
        }
-#endif
 
        /* user visible widgets */
        topnodes = gda_server_operation_get_root_nodes (form->priv->op);
-       i = 0;
-       while (topnodes[i]) {
+       for (i = 0; topnodes[i]; i++) {
                GtkWidget *plwid;
                gchar *section_str;
                GtkWidget *container = NULL;
 
-#ifdef HAVE_LIBGLADE
-               if (form->priv->glade) {
-                       container = glade_xml_get_widget (form->priv->glade, topnodes[i]);
-                       if (!container) {
-                               i++;
+               if (mainw) {
+                       container = (GtkWidget*) gtk_builder_get_object (form->priv->builder, topnodes[i]);
+                       if (!container)
                                continue;
-                       }
                }
-#endif
                if (!container)
                        container = (GtkWidget *) form;
 
@@ -806,21 +794,18 @@ gdaui_server_operation_fill (GdauiServerOperation *form)
                                break;
                        }
                }
-
-               i++;
        }
 
        /* destroying unused widgets in the Glade description */
-#ifdef HAVE_LIBGLADE
-       if (form->priv->glade) {
-               GList *widgets, *list;
+       if (mainw) {
+               GSList *widgets, *list;
 
-               widgets = glade_xml_get_widget_prefix (form->priv->glade, "/");
+               widgets = gtk_builder_get_objects (form->priv->builder);
                for (list = widgets; list; list = list->next) {
                        const gchar *name;
 
-                       name = glade_get_widget_name ((GtkWidget *) (list->data));
-                       if (!gda_server_operation_get_node_info (form->priv->op, name)) {
+                       name = gtk_buildable_get_name ((GtkBuildable *) (list->data));
+                       if ((name[0] == '/') && !gda_server_operation_get_node_info (form->priv->op, name)) {
                                GtkWidget *parent;
 
                                /* dirty hack to remove a notebook page */
@@ -837,15 +822,13 @@ gdaui_server_operation_fill (GdauiServerOperation *form)
                                        gtk_notebook_remove_page (GTK_NOTEBOOK (parent), pageno);
                                }
                                else
-                                       gtk_widget_destroy ((GtkWidget *) (list->data));
+                                       gtk_widget_hide ((GtkWidget *) (list->data));
                        }
                }
-               g_list_free (widgets);
+               g_slist_free (widgets);
        }
-#endif
 
        g_strfreev (topnodes);
-
 }
 
 /*
diff --git a/libgda-ui/gdaui-server-operation.h b/libgda-ui/gdaui-server-operation.h
index 9b753e8..c5701bf 100644
--- a/libgda-ui/gdaui-server-operation.h
+++ b/libgda-ui/gdaui-server-operation.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2009 - 2014 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
  *
  * This library is free software; you can redistribute it and/or
@@ -23,9 +23,6 @@
 
 #include <gtk/gtk.h>
 #include <libgda/libgda.h>
-#ifdef HAVE_LIBGLADE
-#include <glade/glade.h>
-#endif
 
 G_BEGIN_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]