[gdl] bgo #544988 - Iconifying should be remebered



commit e8c0107f020884c279857da2c4f151a1bac060b8
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Mon Jul 23 22:28:19 2012 +0200

    bgo #544988 - Iconifying should be remebered

 gdl/gdl-dock-bar.c  |    6 +++-
 gdl/gdl-dock-item.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++--
 gdl/gdl-dock-item.h |    2 +
 3 files changed, 56 insertions(+), 5 deletions(-)
---
diff --git a/gdl/gdl-dock-bar.c b/gdl/gdl-dock-bar.c
index bf4f364..cda5758 100644
--- a/gdl/gdl-dock-bar.c
+++ b/gdl/gdl-dock-bar.c
@@ -382,7 +382,8 @@ update_dock_items (GdlDockBar *dockbar, gboolean full_update)
                 !GDL_DOCK_ITEM_ICONIFIED (item))
                 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_ICONIFIED (item) &&
+                !gdl_dock_item_is_placeholder (item))
                 gdl_dock_bar_add_item (dockbar, item);
         }
     } else {
@@ -391,7 +392,8 @@ 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))
+            if (GDL_DOCK_ITEM_ICONIFIED (item) &&
+                !gdl_dock_item_is_placeholder (item))
                 gdl_dock_bar_add_item (dockbar, item);
         }
     }
diff --git a/gdl/gdl-dock-item.c b/gdl/gdl-dock-item.c
index 0f57516..8ae6b86 100644
--- a/gdl/gdl-dock-item.c
+++ b/gdl/gdl-dock-item.c
@@ -167,7 +167,8 @@ enum {
     PROP_BEHAVIOR,
     PROP_LOCKED,
     PROP_PREFERRED_WIDTH,
-    PROP_PREFERRED_HEIGHT
+    PROP_PREFERRED_HEIGHT,
+    PROP_ICONIFIED
 };
 
 enum {
@@ -372,8 +373,24 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
                           -1, G_MAXINT, -1,
                           G_PARAM_READWRITE));
 
-    /* signals */
-
+    /**
+     * GdlDockItem:iconified:
+     *
+     * If set, the dock item is hidden but it has a corresponding icon in the
+     * dock bar allowing to show it again.
+     *
+     * Since: 3.6
+     */
+    g_object_class_install_property (
+        object_class, PROP_ICONIFIED,
+        g_param_spec_boolean ("iconified", _("Iconified"),
+                              _("If set, the dock item is hidden but it has a "
+                                "corresponding icon in the dock bar allowing to "
+                                "show it again."),
+                              FALSE,
+                              G_PARAM_READWRITE |
+                              GDL_DOCK_PARAM_EXPORT));
+    
     /**
      * GdlDockItem::dock-drag-begin:
      * @item: The dock item which is being dragged.
@@ -689,6 +706,16 @@ gdl_dock_item_set_property  (GObject      *g_object,
         case PROP_PREFERRED_HEIGHT:
             item->priv->preferred_height = g_value_get_int (value);
             break;
+        case PROP_ICONIFIED:
+            if (g_value_get_boolean (value)) {
+                if (!GDL_DOCK_ITEM_ICONIFIED (item)) gdl_dock_item_iconify_item (item);
+            }
+            else if (GDL_DOCK_ITEM_ICONIFIED (item)) {
+                GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ICONIFIED);
+                gtk_widget_show (GTK_WIDGET (item));
+                gtk_widget_queue_resize (GTK_WIDGET (item));
+            }
+            break;            
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec);
             break;
@@ -722,6 +749,9 @@ gdl_dock_item_get_property  (GObject      *g_object,
         case PROP_PREFERRED_HEIGHT:
             g_value_set_int (value, item->priv->preferred_height);
             break;
+        case PROP_ICONIFIED:
+            g_value_set_boolean (value, GDL_DOCK_ITEM_ICONIFIED (item));
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec);
             break;
@@ -2278,6 +2308,23 @@ gdl_dock_item_or_child_has_focus (GdlDockItem *item)
     return item_or_child_has_focus;
 }
 
+/**
+ * gdl_dock_item_is_placeholder:
+ * @item: The dock item to be checked
+ *
+ * Checks whether a given #GdlDockItem is a placeholder created by the
+ * #GdlDockLayout object and does not contain a child.
+ * 
+ * Returns: %TRUE if the dock item is a placeholder
+ *
+ * Since: 3.6
+ */
+gboolean 
+gdl_dock_item_is_placeholder (GdlDockItem *item)
+{
+    return item->child == NULL;
+}
+
 
 /* ----- gtk orientation type exporter/importer ----- */
 
diff --git a/gdl/gdl-dock-item.h b/gdl/gdl-dock-item.h
index 1224452..7357bb9 100644
--- a/gdl/gdl-dock-item.h
+++ b/gdl/gdl-dock-item.h
@@ -319,6 +319,8 @@ void        gdl_dock_item_preferred_size       (GdlDockItem      *item,
 
 gboolean    gdl_dock_item_or_child_has_focus  (GdlDockItem      *item);
 
+gboolean    gdl_dock_item_is_placeholder       (GdlDockItem      *item);
+
 G_END_DECLS
 
 #endif



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