[glade] * gladeui/glade-widget-adaptor.[ch]: o added GladeGetInternalChildrenFunc class and base impleme
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] * gladeui/glade-widget-adaptor.[ch]: o added GladeGetInternalChildrenFunc class and base impleme
- Date: Tue, 5 Apr 2011 05:20:25 +0000 (UTC)
commit 6c0314d5f744bc19578e75617949cdb23efad877
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date: Mon Apr 4 21:31:36 2011 -0300
* gladeui/glade-widget-adaptor.[ch]:
o added GladeGetInternalChildrenFunc class and base implementation method
o removed glade_widget_adaptor_get_internal_children() function
o gwa_internal_children_update_from_node() reworked to work with simplyfied <internal-children> format
<internal-children>
<object/>
<object>
<object/>
</object>
</internal-children>
* plugins/gtk+/glade-gtk.c:
o fixed glade_gtk_container_get_children() now uses new get_internal_children
GWA method and purify the list to remove posible duplicates
* plugins/gtk+/gtk+.xml.in:
o update <internal-children> tag to new format
o make GtkTreeViewColumn:widget property parentless-widget
* src/glade-window.c: set project in inspector after finishing loading
(25% improvment in loading time)
gladeui/glade-widget-adaptor.c | 134 ++++++++++++++++++++--------------------
gladeui/glade-widget-adaptor.h | 17 +++++-
plugins/gtk+/glade-gtk.c | 14 +++-
plugins/gtk+/gtk+.xml.in | 33 ++++------
src/glade-window.c | 22 +++++--
5 files changed, 120 insertions(+), 100 deletions(-)
---
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index 7fa61d4..364b24e 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -292,54 +292,6 @@ glade_widget_adaptor_has_internal_children (GladeWidgetAdaptor *adaptor)
return adaptor->priv->internal_children != NULL;
}
-static void
-gwa_get_internal_children (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GList **children,
- GList *list)
-{
- GList *l;
-
- for (l = list; l; l = g_list_next (l))
- {
- GladeInternalChild *internal = l->data;
- GObject *child;
-
- child = glade_widget_adaptor_get_internal_child (adaptor,
- container,
- internal->name);
-
- if (child)
- {
- GtkWidget *parent;
-
- /* Only return a widget if is not packed into a wrapped object */
- if (GTK_IS_WIDGET (child) == FALSE ||
- ((parent = gtk_widget_get_parent (GTK_WIDGET (child))) &&
- glade_widget_get_from_gobject (parent) == NULL))
- *children = g_list_prepend (*children, child);
-
- if (internal->children)
- gwa_get_internal_children (adaptor, container, children, internal->children);
- }
- }
-}
-
-GList *
-glade_widget_adaptor_get_internal_children (GladeWidgetAdaptor *adaptor,
- GObject *container)
-{
- GList *children;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
-
- children = NULL;
-
- gwa_get_internal_children (adaptor, container, &children, adaptor->priv->internal_children);
-
- return children;
-}
-
static gint
gwa_signal_comp (gpointer a, gpointer b)
{
@@ -1325,6 +1277,41 @@ glade_widget_adaptor_object_create_editable (GladeWidgetAdaptor * adaptor,
return (GladeEditable *) glade_editor_table_new (adaptor, type);
}
+static void
+gwa_get_internal_children (GladeWidgetAdaptor *adaptor,
+ GObject *object,
+ GList **children,
+ GList *list)
+{
+ GList *l;
+
+ for (l = list; l; l = g_list_next (l))
+ {
+ GladeInternalChild *internal = l->data;
+ GObject *child;
+
+ child = glade_widget_adaptor_get_internal_child (adaptor,
+ object,
+ internal->name);
+ if (child)
+ *children = g_list_prepend (*children, child);
+
+ if (internal->children)
+ gwa_get_internal_children (adaptor, object, children, internal->children);
+ }
+}
+
+static GList *
+glade_widget_adaptor_object_get_internal_children (GladeWidgetAdaptor *adaptor,
+ GObject *object)
+{
+ GList *children = NULL;
+
+ gwa_get_internal_children (adaptor, object, &children, adaptor->priv->internal_children);
+
+ return children;
+}
+
/*******************************************************************************
GladeWidgetAdaptor type registration and class initializer
@@ -1353,8 +1340,7 @@ glade_widget_adaptor_class_init (GladeWidgetAdaptorClass * adaptor_class)
/* Class methods */
adaptor_class->create_widget = glade_widget_adaptor_object_create_widget;
- adaptor_class->construct_object =
- glade_widget_adaptor_object_construct_object;
+ adaptor_class->construct_object = glade_widget_adaptor_object_construct_object;
adaptor_class->deep_post_create = NULL;
adaptor_class->post_create = NULL;
adaptor_class->get_internal_child = glade_widget_adaptor_object_get_internal_child;
@@ -1369,8 +1355,7 @@ glade_widget_adaptor_class_init (GladeWidgetAdaptorClass * adaptor_class)
adaptor_class->child_set_property = NULL;
adaptor_class->child_get_property = NULL;
adaptor_class->action_activate = glade_widget_adaptor_object_action_activate;
- adaptor_class->child_action_activate =
- glade_widget_adaptor_object_child_action_activate;
+ adaptor_class->child_action_activate = glade_widget_adaptor_object_child_action_activate;
adaptor_class->action_submenu = NULL;
adaptor_class->depends = glade_widget_adaptor_object_depends;
adaptor_class->read_widget = glade_widget_adaptor_object_read_widget;
@@ -1378,9 +1363,9 @@ glade_widget_adaptor_class_init (GladeWidgetAdaptorClass * adaptor_class)
adaptor_class->read_child = glade_widget_adaptor_object_read_child;
adaptor_class->write_child = glade_widget_adaptor_object_write_child;
adaptor_class->create_eprop = glade_widget_adaptor_object_create_eprop;
- adaptor_class->string_from_value =
- glade_widget_adaptor_object_string_from_value;
+ adaptor_class->string_from_value = glade_widget_adaptor_object_string_from_value;
adaptor_class->create_editable = glade_widget_adaptor_object_create_editable;
+ adaptor_class->get_internal_children = glade_widget_adaptor_object_get_internal_children;
/* Base defaults here */
adaptor_class->toplevel = FALSE;
@@ -2322,21 +2307,36 @@ gwa_set_signals_from_node (GladeWidgetAdaptor *adaptor,
}
}
-static gint
-gwa_internal_child_cmp (gconstpointer a, gconstpointer b)
+static GladeInternalChild *
+gwa_internal_child_find (GList *list, gchar *name)
{
- const GladeInternalChild *da = a;
- return strcmp (da->name, b);
+ GList *l;
+
+ for (l = list; l; l = g_list_next (l))
+ {
+ GladeInternalChild *data = l->data;
+
+ if (strcmp (data->name, name) == 0)
+ return data;
+
+ if (data->children)
+ {
+ GladeInternalChild *child;
+ if ((child = gwa_internal_child_find (data->children, name)))
+ return child;
+ }
+ }
+
+ return NULL;
}
static GList *
gwa_internal_children_update_from_node (GList *internal_children, GladeXmlNode *node)
{
- GList *link, *retval = internal_children;
+ GList *retval = internal_children;
GladeXmlNode *child, *children;
- for (child = glade_xml_node_get_children (node);
- child; child = glade_xml_node_next (child))
+ for (child = node; child; child = glade_xml_node_next (child))
{
GladeInternalChild *data;
gchar *name;
@@ -2347,18 +2347,14 @@ gwa_internal_children_update_from_node (GList *internal_children, GladeXmlNode *
if (!(name = glade_xml_get_property_string_required (child, GLADE_TAG_NAME, NULL)))
continue;
- if ((link = g_list_find_custom (retval, name, gwa_internal_child_cmp)))
- {
- data = link->data;
- }
- else
+ if ((data = gwa_internal_child_find (retval, name)) == NULL)
{
gboolean anarchist = glade_xml_get_boolean (child, GLADE_TAG_ANARCHIST, FALSE);
data = gwa_internal_children_new (name, anarchist);
retval = g_list_prepend (retval, data);
}
- if ((children = glade_xml_search_child (child, GLADE_TAG_INTERNAL_CHILDREN)))
+ if ((children = glade_xml_search_child (child, GLADE_XML_TAG_WIDGET)))
data->children = gwa_internal_children_update_from_node (data->children, children);
g_free (name);
@@ -2405,7 +2401,9 @@ gwa_extend_with_node (GladeWidgetAdaptor * adaptor,
gwa_action_update_from_node (adaptor, TRUE, child, domain, NULL);
if ((child = glade_xml_search_child (node, GLADE_TAG_INTERNAL_CHILDREN)))
- adaptor->priv->internal_children = gwa_internal_children_update_from_node (adaptor->priv->internal_children, child);
+ adaptor->priv->internal_children =
+ gwa_internal_children_update_from_node (adaptor->priv->internal_children,
+ glade_xml_node_get_children (child));
return TRUE;
}
diff --git a/gladeui/glade-widget-adaptor.h b/gladeui/glade-widget-adaptor.h
index c609cf9..0559394 100644
--- a/gladeui/glade-widget-adaptor.h
+++ b/gladeui/glade-widget-adaptor.h
@@ -329,6 +329,18 @@ typedef GList *(* GladeGetChildrenFunc) (GladeWidgetAdaptor *adaptor,
GObject *container);
/**
+ * GladeGetInternalChildrenFunc:
+ * @adaptor: A #GladeWidgetAdaptor
+ * @object: A #GObject container
+ *
+ * A function called to get @object internal children.
+ *
+ * Returns: A #GList of #GObject internal children.
+ */
+typedef GList *(* GladeGetInternalChildrenFunc) (GladeWidgetAdaptor *adaptor,
+ GObject *container);
+
+/**
* GladeAddChildFunc:
* @adaptor: A #GladeWidgetAdaptor
* @parent: A #GObject container
@@ -660,6 +672,8 @@ struct _GladeWidgetAdaptorClass
GladeStringFromValueFunc string_from_value; /* Creates a string for a value */
GladeCreateEditableFunc create_editable; /* Creates a page for the editor */
+ GladeGetInternalChildrenFunc get_internal_children; /* Return the list of internal children */
+
void (* glade_reserved1) (void);
void (* glade_reserved2) (void);
void (* glade_reserved3) (void);
@@ -844,8 +858,7 @@ GladeSignalClass *glade_widget_adaptor_get_signal_class (GladeWidgetAdapto
GladeWidgetAdaptor *glade_widget_adaptor_get_parent_adaptor (GladeWidgetAdaptor *adaptor);
gboolean glade_widget_adaptor_has_internal_children (GladeWidgetAdaptor *adaptor);
-GList *glade_widget_adaptor_get_internal_children (GladeWidgetAdaptor *adaptor,
- GObject *container);
+
G_END_DECLS
#endif /* _GLADE_WIDGET_ADAPTOR_H_ */
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 50e21c5..876ea60 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -1226,12 +1226,20 @@ GList *
glade_gtk_container_get_children (GladeWidgetAdaptor *adaptor,
GtkContainer *container)
{
- GList *children, *internal_children;
+ GList *children;
children = glade_util_container_get_all_children (container);
- internal_children = glade_widget_adaptor_get_internal_children (adaptor, G_OBJECT (container));
- return g_list_concat (children, internal_children);
+ if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->get_internal_children)
+ {
+ GList *internal;
+
+ internal = GWA_GET_CLASS (GTK_TYPE_CONTAINER)->get_internal_children (adaptor, G_OBJECT (container));
+
+ return glade_util_purify_list (g_list_concat (children, internal));
+ }
+ else
+ return children;
}
GladeEditable *
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 86390ea..77e84d3 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1369,9 +1369,7 @@ embedded in another object</_tooltip>
<internal-children>
<object name="vbox">
- <internal-children>
- <object name="action_area"/>
- </internal-children>
+ <object name="action_area"/>
</object>
</internal-children>
@@ -1853,16 +1851,12 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkColorSelectionDialog" generic-name="colorselectiondialog" _title="Color Selection Dialog">
<internal-children>
<object name="vbox">
- <internal-children>
<object name="color_selection"/>
- <object name="action_area">
- <internal-children>
- <object name="ok_button"/>
- <object name="cancel_button"/>
- <object name="help_button"/>
- </internal-children>
- </object>
- </internal-children>
+ </object>
+ <object name="action_area">
+ <object name="ok_button"/>
+ <object name="cancel_button"/>
+ <object name="help_button"/>
</object>
</internal-children>
<properties>
@@ -1886,16 +1880,12 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkFontSelectionDialog" generic-name="fontselectiondialog" _title="Font Selection Dialog">
<internal-children>
<object name="vbox">
- <internal-children>
<object name="font_selection"/>
- <object name="action_area">
- <internal-children>
- <object name="ok_button"/>
- <object name="cancel_button"/>
- <object name="apply_button"/>
- </internal-children>
- </object>
- </internal-children>
+ </object>
+ <object name="action_area">
+ <object name="ok_button"/>
+ <object name="cancel_button"/>
+ <object name="apply_button"/>
</object>
</internal-children>
<properties>
@@ -2266,6 +2256,7 @@ embedded in another object</_tooltip>
</actions>
<properties>
+ <property id="widget" parentless-widget="True"/>
<property id="sort-column-id" since="2.18"/>
<property id="sort-order">
<displayable-values>
diff --git a/src/glade-window.c b/src/glade-window.c
index ca5219c..8b77667 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -1714,15 +1714,24 @@ notebook_switch_page_cb (GtkNotebook * notebook,
}
static void
-set_widget_sensitive_on_load (GladeProject * project, GtkWidget * widget)
+project_parse_finished_cb (GladeProject *project, GtkWidget *inspector)
+{
+ gtk_widget_set_sensitive (inspector, TRUE);
+
+ glade_inspector_set_project (GLADE_INSPECTOR (inspector), project);
+}
+
+static void
+set_widget_sensitive_on_load (GladeProject *project, GtkWidget *widget)
{
gtk_widget_set_sensitive (widget, TRUE);
}
static void
-notebook_tab_added_cb (GtkNotebook * notebook,
- GladeDesignView * view,
- guint page_num, GladeWindow * window)
+notebook_tab_added_cb (GtkNotebook *notebook,
+ GladeDesignView *view,
+ guint page_num,
+ GladeWindow *window)
{
GladeProject *project;
GtkWidget *inspector, *palette;
@@ -1754,7 +1763,6 @@ notebook_tab_added_cb (GtkNotebook * notebook,
/* create inspector */
inspector = glade_inspector_new ();
gtk_widget_show (inspector);
- glade_inspector_set_project (GLADE_INSPECTOR (inspector), project);
gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->inspectors_notebook),
inspector, NULL);
@@ -1781,10 +1789,12 @@ notebook_tab_added_cb (GtkNotebook * notebook,
gtk_widget_set_sensitive (inspector, FALSE);
gtk_widget_set_sensitive (palette, FALSE);
g_signal_connect (project, "parse-finished",
- G_CALLBACK (set_widget_sensitive_on_load), inspector);
+ G_CALLBACK (project_parse_finished_cb), inspector);
g_signal_connect (project, "parse-finished",
G_CALLBACK (set_widget_sensitive_on_load), palette);
}
+ else
+ glade_inspector_set_project (GLADE_INSPECTOR (inspector), project);
set_sensitivity_according_to_project (window, project);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]