[gdl] bgo #569160 - Anjuta doesn't remember main window layout
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdl] bgo #569160 - Anjuta doesn't remember main window layout
- Date: Tue, 17 Jul 2012 20:33:24 +0000 (UTC)
commit ff8b1e3201f0abf09e231ddc650b6cbca78a05f2
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Tue Jul 17 22:31:49 2012 +0200
bgo #569160 - Anjuta doesn't remember main window layout
GdlDockLayout creates hidden GdlDockItem without a child widget for named
widget not existing yet. When adding a new widget GdlDock checks if
such hidden widget exists. If it is the case the hidden widget is replaced by the
new one, using the last saved position. If not the new widget is docked at its
default position like before. So a layout affects not only existing widgets but
widgets created afterward if they were existing before.
gdl/gdl-dock-layout.c | 28 +++++++++++++---------------
gdl/gdl-dock.c | 21 ++++++++++++++++++++-
2 files changed, 33 insertions(+), 16 deletions(-)
---
diff --git a/gdl/gdl-dock-layout.c b/gdl/gdl-dock-layout.c
index 8fb04b2..64fe096 100644
--- a/gdl/gdl-dock-layout.c
+++ b/gdl/gdl-dock-layout.c
@@ -283,11 +283,11 @@ gdl_dock_layout_setup_object (GdlDockMaster *master,
object_name = xmlGetProp (node, BAD_CAST GDL_DOCK_NAME_PROPERTY);
if (object_name && strlen ((char*)object_name) > 0) {
- /* the object must already be bound to the master */
+ /* the object can be already be bound to the master or a
+ * placeholder object is created */
object = gdl_dock_master_get_object (master, (char*)object_name);
- xmlFree (object_name);
- object_type = object ? G_TYPE_FROM_INSTANCE (object) : G_TYPE_NONE;
+ object_type = object ? G_TYPE_FROM_INSTANCE (object) : gdl_dock_object_type_from_nick ((char*)node->name);
}
else {
/* the object should be automatic, so create it by
@@ -317,11 +317,11 @@ gdl_dock_layout_setup_object (GdlDockMaster *master,
for (i = 0; i < n_props; i++) {
xmlChar *xml_prop;
- /* process all exported properties, skip
- GDL_DOCK_NAME_PROPERTY, since named items should
- already by in the master */
- if (!(props [i]->flags & GDL_DOCK_PARAM_EXPORT) ||
- !strcmp (props [i]->name, GDL_DOCK_NAME_PROPERTY))
+ /* process all exported properties */
+ /* keep GDL_DOCK_NAME_PROPERTY because we can create
+ placeholder object for object not already in the
+ master */
+ if (!(props [i]->flags & GDL_DOCK_PARAM_EXPORT))
continue;
/* get the property from xml if there is one */
@@ -360,6 +360,10 @@ gdl_dock_layout_setup_object (GdlDockMaster *master,
/* set the master, so toplevels are created correctly and
other objects are bound */
object = g_object_newv (object_type, n_params, params);
+ if (object_name) {
+ GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_AUTOMATIC);
+ gdl_dock_master_add (master, object);
+ }
}
else {
/* set the parameters to the existing object */
@@ -368,6 +372,7 @@ gdl_dock_layout_setup_object (GdlDockMaster *master,
params [i].name,
¶ms [i].value);
}
+ if (object_name) xmlFree (object_name);
/* free the parameters (names are static/const strings) */
for (i = 0; i < n_params; i++)
@@ -426,15 +431,8 @@ gdl_dock_layout_recursive_build (GdlDockMaster *master,
parent);
else if (gdl_dock_object_is_compound (parent)) {
gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (object));
- if (gtk_widget_get_visible (GTK_WIDGET (parent)))
- gtk_widget_show (GTK_WIDGET (object));
}
}
- else {
- GdlDockObject *controller = gdl_dock_master_get_controller (master);
- if (controller != object && gtk_widget_get_visible (GTK_WIDGET (controller)))
- gtk_widget_show (GTK_WIDGET (object));
- }
/* call reduce just in case any child is missing */
if (gdl_dock_object_is_compound (object))
diff --git a/gdl/gdl-dock.c b/gdl/gdl-dock.c
index 5525488..4e52141 100644
--- a/gdl/gdl-dock.c
+++ b/gdl/gdl-dock.c
@@ -1300,10 +1300,29 @@ gdl_dock_add_item (GdlDock *dock,
GdlDockItem *item,
GdlDockPlacement placement)
{
+ GdlDockObject *placeholder;
+ GdlDockObject *parent = NULL;
+ GdlDockPlacement place;
+
g_return_if_fail (dock != NULL);
g_return_if_fail (item != NULL);
- if (placement == GDL_DOCK_FLOATING)
+ /* Check if a placeholder widget already exist */
+ placeholder = gdl_dock_master_get_object (GDL_DOCK_OBJECT_GET_MASTER (dock), GDL_DOCK_OBJECT (item)->name);
+ if ((placeholder != NULL))
+ parent = gdl_dock_object_get_parent_object (placeholder);
+
+ if (parent && gdl_dock_object_child_placement (parent, placeholder, &place))
+ {
+ gdl_dock_object_freeze (GDL_DOCK_OBJECT (parent));
+ gtk_widget_destroy (GTK_WIDGET (placeholder));
+
+ gdl_dock_object_dock (GDL_DOCK_OBJECT (parent),
+ GDL_DOCK_OBJECT (item),
+ place, NULL);
+ gdl_dock_object_thaw (GDL_DOCK_OBJECT (parent));
+ }
+ else if (placement == GDL_DOCK_FLOATING)
/* Add the item to a new floating dock */
gdl_dock_add_floating_item (dock, item, 0, 0, -1, -1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]