[gdl] Save hidden widgets in layout, fix several bugs in layout
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdl] Save hidden widgets in layout, fix several bugs in layout
- Date: Sun, 29 Jul 2012 12:32:01 +0000 (UTC)
commit ff1f772201f911b8c987482ec68668633cf20214
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Sun Jul 29 14:16:41 2012 +0200
Save hidden widgets in layout, fix several bugs in layout
gdl/gdl-dock-bar.c | 4 +-
gdl/gdl-dock-item.c | 59 +++++++++++++++++++++++++++++++++++++++++++---
gdl/gdl-dock-item.h | 2 +
gdl/gdl-dock-layout.c | 20 ++++++---------
gdl/gdl-dock-notebook.c | 2 -
gdl/gdl-dock-object.c | 10 ++++++-
gdl/gdl-dock-paned.c | 1 -
7 files changed, 75 insertions(+), 23 deletions(-)
---
diff --git a/gdl/gdl-dock-bar.c b/gdl/gdl-dock-bar.c
index cda5758..7547b46 100644
--- a/gdl/gdl-dock-bar.c
+++ b/gdl/gdl-dock-bar.c
@@ -383,7 +383,7 @@ update_dock_items (GdlDockBar *dockbar, gboolean full_update)
gdl_dock_bar_remove_item (dockbar, item);
else if (g_slist_index (dockbar->priv->items, item) == -1 &&
GDL_DOCK_ITEM_ICONIFIED (item) &&
- !gdl_dock_item_is_placeholder (item))
+ !gdl_dock_item_is_closed (item))
gdl_dock_bar_add_item (dockbar, item);
}
} else {
@@ -393,7 +393,7 @@ update_dock_items (GdlDockBar *dockbar, gboolean full_update)
if (g_slist_index (dockbar->priv->items, item) != -1)
gdl_dock_bar_remove_item (dockbar, item);
if (GDL_DOCK_ITEM_ICONIFIED (item) &&
- !gdl_dock_item_is_placeholder (item))
+ !gdl_dock_item_is_closed (item))
gdl_dock_bar_add_item (dockbar, item);
}
}
diff --git a/gdl/gdl-dock-item.c b/gdl/gdl-dock-item.c
index 918d477..f60fd56 100644
--- a/gdl/gdl-dock-item.c
+++ b/gdl/gdl-dock-item.c
@@ -168,7 +168,8 @@ enum {
PROP_LOCKED,
PROP_PREFERRED_WIDTH,
PROP_PREFERRED_HEIGHT,
- PROP_ICONIFIED
+ PROP_ICONIFIED,
+ PROP_CLOSED,
};
enum {
@@ -390,6 +391,22 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
FALSE,
G_PARAM_READWRITE |
GDL_DOCK_PARAM_EXPORT));
+
+ /**
+ * GdlDockItem:closed:
+ *
+ * If set, the dock item is closed.
+ *
+ * Since: 3.6
+ */
+ g_object_class_install_property (
+ object_class, PROP_CLOSED,
+ g_param_spec_boolean ("closed", _("Closed"),
+ _("Whether the widget is closed."),
+ FALSE,
+ G_PARAM_READWRITE |
+ GDL_DOCK_PARAM_AFTER |
+ GDL_DOCK_PARAM_EXPORT));
/**
* GdlDockItem::dock-drag-begin:
@@ -715,7 +732,17 @@ gdl_dock_item_set_property (GObject *g_object,
gtk_widget_show (GTK_WIDGET (item));
gtk_widget_queue_resize (GTK_WIDGET (item));
}
- break;
+ break;
+ case PROP_CLOSED:
+ if (g_value_get_boolean (value)) {
+ GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ATTACHED);
+ gtk_widget_hide (GTK_WIDGET (item));
+ } else {
+ GDL_DOCK_OBJECT_SET_FLAGS (item, GDL_DOCK_ATTACHED);
+ if (!GDL_DOCK_ITEM_ICONIFIED (item))
+ gtk_widget_show (GTK_WIDGET (item));
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec);
break;
@@ -752,6 +779,9 @@ gdl_dock_item_get_property (GObject *g_object,
case PROP_ICONIFIED:
g_value_set_boolean (value, GDL_DOCK_ITEM_ICONIFIED (item));
break;
+ case PROP_CLOSED:
+ g_value_set_boolean (value, !GDL_DOCK_OBJECT_ATTACHED (item));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec);
break;
@@ -2188,6 +2218,7 @@ gdl_dock_item_hide_item (GdlDockItem *item)
{
g_return_if_fail (item != NULL);
+ GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ATTACHED);
gtk_widget_hide (GTK_WIDGET (item));
return;
}
@@ -2207,7 +2238,7 @@ gdl_dock_item_iconify_item (GdlDockItem *item)
g_return_if_fail (item != NULL);
GDL_DOCK_OBJECT_SET_FLAGS (item, GDL_DOCK_ICONIFIED);
- gdl_dock_item_hide_item (item);
+ gtk_widget_hide (GTK_WIDGET (item));
}
/**
@@ -2234,20 +2265,23 @@ gdl_dock_item_show_item (GdlDockItem *item)
if (item->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING) {
g_warning("Object %s has no default position and flag GDL_DOCK_ITEM_BEH_NEVER_FLOATING is set.\n",
GDL_DOCK_OBJECT(item)->name);
+ return;
} else if (toplevel) {
gdl_dock_object_dock (toplevel, GDL_DOCK_OBJECT (item),
GDL_DOCK_FLOATING, NULL);
} else
g_warning("There is no toplevel window. GdlDockItem %s cannot be shown.\n", GDL_DOCK_OBJECT(item)->name);
-
+ return;
} else
g_warning("GdlDockItem %s is not bound. It cannot be shown.\n",
GDL_DOCK_OBJECT(item)->name);
+ return;
}
GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ICONIFIED);
GDL_DOCK_OBJECT_SET_FLAGS (item, GDL_DOCK_ATTACHED);
gtk_widget_show (GTK_WIDGET (item));
+
return;
}
@@ -2348,6 +2382,23 @@ gdl_dock_item_is_placeholder (GdlDockItem *item)
return item->child == NULL;
}
+/**
+ * gdl_dock_item_is_closed:
+ * @item: The dock item to be checked
+ *
+ * Checks whether a given #GdlDockItem is closed: still in the widget hierarchy
+ * and hidden or detached.
+ *
+ * Returns: %TRUE if the dock item is closed.
+ *
+ * Since: 3.6
+ */
+gboolean
+gdl_dock_item_is_closed (GdlDockItem *item)
+{
+ return (GDL_DOCK_OBJECT_FLAGS (item) & GDL_DOCK_ATTACHED) == 0;
+}
+
/* ----- gtk orientation type exporter/importer ----- */
diff --git a/gdl/gdl-dock-item.h b/gdl/gdl-dock-item.h
index 7357bb9..6c10c76 100644
--- a/gdl/gdl-dock-item.h
+++ b/gdl/gdl-dock-item.h
@@ -321,6 +321,8 @@ gboolean gdl_dock_item_or_child_has_focus (GdlDockItem *item);
gboolean gdl_dock_item_is_placeholder (GdlDockItem *item);
+gboolean gdl_dock_item_is_closed (GdlDockItem *item);
+
G_END_DECLS
#endif
diff --git a/gdl/gdl-dock-layout.c b/gdl/gdl-dock-layout.c
index 85f983c..b949431 100644
--- a/gdl/gdl-dock-layout.c
+++ b/gdl/gdl-dock-layout.c
@@ -415,8 +415,12 @@ gdl_dock_layout_recursive_build (GdlDockMaster *master,
GINT_TO_POINTER (TRUE));
}
- /* recurse here to catch placeholders */
- gdl_dock_layout_recursive_build (master, node, object);
+ /* add the object to the parent */
+ if (parent) {
+ if (gdl_dock_object_is_compound (parent)) {
+ gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (object));
+ }
+ }
/* apply "after" parameters */
for (i = 0; i < n_after_params; i++) {
@@ -428,16 +432,8 @@ gdl_dock_layout_recursive_build (GdlDockMaster *master,
}
g_free (after_params);
- /* add the object to the parent */
- if (parent) {
- if (gdl_dock_object_is_compound (parent)) {
- gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (object));
- }
- }
-
- if (GDL_IS_DOCK_ITEM (object) &&
- !gdl_dock_item_is_placeholder (GDL_DOCK_ITEM (object)) &&
- !GDL_DOCK_ITEM_ICONIFIED (object)) gdl_dock_item_show_item(GDL_DOCK_ITEM (object));
+ /* build children */
+ gdl_dock_layout_recursive_build (master, node, object);
gdl_dock_object_thaw (object);
}
diff --git a/gdl/gdl-dock-notebook.c b/gdl/gdl-dock-notebook.c
index fe6e5e0..35568d8 100644
--- a/gdl/gdl-dock-notebook.c
+++ b/gdl/gdl-dock-notebook.c
@@ -410,8 +410,6 @@ gdl_dock_notebook_dock (GdlDockObject *object,
long_name, long_name,
stock_id, pixbuf_icon, position);
- GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED);
-
if (gtk_widget_get_visible (GTK_WIDGET (requestor))) {
/* Set current page to the newly docked widget. set current page
* really doesn't work if the page widget is not shown
diff --git a/gdl/gdl-dock-object.c b/gdl/gdl-dock-object.c
index 29f67dd..15f7a6b 100644
--- a/gdl/gdl-dock-object.c
+++ b/gdl/gdl-dock-object.c
@@ -392,10 +392,14 @@ gdl_dock_object_update_parent_visibility (GdlDockObject *object)
if (parent && GDL_DOCK_OBJECT_AUTOMATIC (parent))
{
gboolean visible = FALSE;
-
+
gtk_container_foreach (GTK_CONTAINER (parent),
(GtkCallback) gdl_dock_object_foreach_is_visible,
&visible);
+ if (visible)
+ GDL_DOCK_OBJECT_SET_FLAGS (parent, GDL_DOCK_ATTACHED);
+ else
+ GDL_DOCK_OBJECT_UNSET_FLAGS (parent, GDL_DOCK_ATTACHED);
gtk_widget_set_visible (GTK_WIDGET (parent), visible);
}
if (object->master)
@@ -428,7 +432,6 @@ gdl_dock_object_hide (GtkWidget *widget)
/* Update visibility of automatic parents */
gdl_dock_object_update_parent_visibility (GDL_DOCK_OBJECT (widget));
- GDL_DOCK_OBJECT_UNSET_FLAGS (GDL_DOCK_OBJECT (widget), GDL_DOCK_ATTACHED);
}
static void
@@ -764,6 +767,9 @@ gdl_dock_object_dock (GdlDockObject *object,
g_object_unref (requestor);
gdl_dock_object_thaw (object);
+
+ if (gtk_widget_get_visible (GTK_WIDGET (requestor)))
+ GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED);
/* Update visibility of automatic parents */
gdl_dock_object_update_parent_visibility (GDL_DOCK_OBJECT (requestor));
diff --git a/gdl/gdl-dock-paned.c b/gdl/gdl-dock-paned.c
index 29d6a4c..fb56bf4 100644
--- a/gdl/gdl-dock-paned.c
+++ b/gdl/gdl-dock-paned.c
@@ -608,7 +608,6 @@ gdl_dock_paned_dock (GdlDockObject *object,
else {
if (gtk_widget_get_visible (GTK_WIDGET (requestor)))
gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor));
- GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]