[gdl] Deprecate GdlDockPlaceholder



commit 2f0382e33d49931a4a607eae488f54243521c5df
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Sun Jul 22 18:01:53 2012 +0200

    Deprecate GdlDockPlaceholder

 docs/reference/gdl-docs.sgml       |    2 +-
 gdl/deprecated/gdl-dock-tablabel.c |    2 +-
 gdl/gdl-deprecated.c               |   37 ++++++++++++++++
 gdl/gdl-dock-item.c                |   45 --------------------
 gdl/gdl-dock-layout.c              |   80 ++++--------------------------------
 gdl/gdl-dock-object.c              |    6 +++
 gdl/gdl-dock-placeholder.c         |   15 +++++++
 gdl/gdl-dock-placeholder.h         |    4 +-
 gdl/gdl-dock.c                     |   26 ------------
 9 files changed, 71 insertions(+), 146 deletions(-)
---
diff --git a/docs/reference/gdl-docs.sgml b/docs/reference/gdl-docs.sgml
index 9be5c3f..422962d 100644
--- a/docs/reference/gdl-docs.sgml
+++ b/docs/reference/gdl-docs.sgml
@@ -34,12 +34,12 @@
       <title>Private Classes</title>
       <xi:include href="xml/gdl-dock-item-grip.xml" />
       <xi:include href="xml/gdl-dock-item-button-image.xml" />
-      <xi:include href="xml/gdl-dock-placeholder.xml" />
       <xi:include href="xml/gdl-preview-window.xml" />
       <xi:include href="xml/gdl-switcher.xml" />
     </chapter>
     <chapter id="deprecated">
       <title>Deprecated Classes</title>
+      <xi:include href="xml/gdl-dock-placeholder.xml" />
       <xi:include href="xml/gdl-dock-tablabel.xml" />
     </chapter>
   </part>
diff --git a/gdl/deprecated/gdl-dock-tablabel.c b/gdl/deprecated/gdl-dock-tablabel.c
index cb1474e..71892a9 100644
--- a/gdl/deprecated/gdl-dock-tablabel.c
+++ b/gdl/deprecated/gdl-dock-tablabel.c
@@ -41,7 +41,7 @@
  * @short_description: A custom label widget.
  * @stability: Unstable
  *
- * This is a deprecated label widget.
+ * This is a deprecated label widget in GDL 3.6.
  */
 
 
diff --git a/gdl/gdl-deprecated.c b/gdl/gdl-deprecated.c
index 17e1fc9..653d593 100644
--- a/gdl/gdl-deprecated.c
+++ b/gdl/gdl-deprecated.c
@@ -87,4 +87,41 @@ gdl_dock_xor_rect_hide (GdlDock      *dock)
     gdl_dock_hide_preview (dock);
 }
 
+/**
+ * gdl_dock_get_placeholder_by_name:
+ * @dock: A #GdlDock widget
+ * @name: An item name
+ *
+ * Looks for an #GdlDockPlaceholder object bound to the master of the dock item.
+ * It does not search only in the children of this particular dock widget.
+ *
+ * Returns: (transfer none): A #GdlDockPlaceholder object or %NULL
+ *
+ * Deprecated: 3.6: This function is always returning %NULL.
+ */
+GdlDockPlaceholder *
+gdl_dock_get_placeholder_by_name (GdlDock     *dock,
+                                  const gchar *name)
+{
+    return NULL;
+}
+
+/**
+ * gdl_dock_item_set_default_position:
+ * @item: The dock item
+ * @reference: The GdlDockObject which is the default dock for @item
+ *
+ * This method has only an effect when you add you dock_item with
+ * GDL_DOCK_ITEM_BEH_NEVER_FLOATING. In this case you have to assign
+ * it a default position.*
+ *
+ * Deprecated 3.6: This function is doing nothing now.
+ **/
+void
+gdl_dock_item_set_default_position (GdlDockItem   *item,
+                                    GdlDockObject *reference)
+{
+    g_return_if_fail (item != NULL);
+}
+
 #endif
diff --git a/gdl/gdl-dock-item.c b/gdl/gdl-dock-item.c
index a1bbbe1..0f57516 100644
--- a/gdl/gdl-dock-item.c
+++ b/gdl/gdl-dock-item.c
@@ -42,7 +42,6 @@
 #include "gdl-dock-item-grip.h"
 #include "gdl-dock-notebook.h"
 #include "gdl-dock-paned.h"
-#include "gdl-dock-placeholder.h"
 #include "gdl-dock-master.h"
 #include "libgdltypebuiltins.h"
 #include "libgdlmarshal.h"
@@ -201,8 +200,6 @@ struct _GdlDockItemPrivate {
     gint       preferred_width;
     gint       preferred_height;
 
-    GdlDockPlaceholder *ph;
-
     gint       start_x, start_y;
 };
 
@@ -540,8 +537,6 @@ gdl_dock_item_init (GdlDockItem *item)
     item->priv->preferred_width = item->priv->preferred_height = -1;
     item->priv->tab_label = NULL;
     item->priv->intern_tab_label = FALSE;
-
-    item->priv->ph = NULL;
 }
 
 static gboolean
@@ -753,11 +748,6 @@ gdl_dock_item_dispose (GObject *object)
         priv->grip = NULL;
     }
 
-    if (priv->ph) {
-        g_object_unref (priv->ph);
-        priv->ph = NULL;
-    }
-
     G_OBJECT_CLASS (gdl_dock_item_parent_class)->dispose (object);
 }
 
@@ -2235,41 +2225,6 @@ gdl_dock_item_unlock (GdlDockItem *item)
 }
 
 /**
- * gdl_dock_item_set_default_position:
- * @item: The dock item
- * @reference: The GdlDockObject which is the default dock for @item
- *
- * This method has only an effect when you add you dock_item with
- * GDL_DOCK_ITEM_BEH_NEVER_FLOATING. In this case you have to assign
- * it a default position.
- **/
-void
-gdl_dock_item_set_default_position (GdlDockItem   *item,
-                                    GdlDockObject *reference)
-{
-    g_return_if_fail (item != NULL);
-
-    if (item->priv->ph) {
-        g_object_unref (item->priv->ph);
-        item->priv->ph = NULL;
-    }
-
-    if (reference && GDL_DOCK_OBJECT_ATTACHED (reference)) {
-        if (GDL_IS_DOCK_PLACEHOLDER (reference)) {
-            g_object_ref_sink (reference);
-            item->priv->ph = GDL_DOCK_PLACEHOLDER (reference);
-        } else {
-            item->priv->ph = GDL_DOCK_PLACEHOLDER (
-                g_object_new (GDL_TYPE_DOCK_PLACEHOLDER,
-                              "sticky", TRUE,
-                              "host", reference,
-                              NULL));
-            g_object_ref_sink (item->priv->ph);
-        }
-    }
-}
-
-/**
  * gdl_dock_item_preferred_size:
  * @item: The dock item to get the preferred size of.
  * @req: A pointer to a #GtkRequisition into which the preferred size
diff --git a/gdl/gdl-dock-layout.c b/gdl/gdl-dock-layout.c
index 64fe096..d6f329d 100644
--- a/gdl/gdl-dock-layout.c
+++ b/gdl/gdl-dock-layout.c
@@ -30,7 +30,7 @@
 #include <gtk/gtk.h>
 
 #include "gdl-dock-layout.h"
-#include "gdl-dock-placeholder.h"
+
 
 /**
  * SECTION:gdl-dock-layout
@@ -410,10 +410,6 @@ gdl_dock_layout_recursive_build (GdlDockMaster *master,
             /* recurse here to catch placeholders */
             gdl_dock_layout_recursive_build (master, node, object);
 
-            if (GDL_IS_DOCK_PLACEHOLDER (object))
-                /* placeholders are later attached to the parent */
-                gdl_dock_object_detach (object, FALSE);
-
             /* apply "after" parameters */
             for (i = 0; i < n_after_params; i++) {
                 g_object_set_property (G_OBJECT (object),
@@ -426,10 +422,7 @@ gdl_dock_layout_recursive_build (GdlDockMaster *master,
 
             /* add the object to the parent */
             if (parent) {
-                if (GDL_IS_DOCK_PLACEHOLDER (object))
-                    gdl_dock_placeholder_attach (GDL_DOCK_PLACEHOLDER (object),
-                                                 parent);
-                else if (gdl_dock_object_is_compound (parent)) {
+                if (gdl_dock_object_is_compound (parent)) {
                     gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (object));
                 }
             }
@@ -474,20 +467,16 @@ static void
 gdl_dock_layout_foreach_object_save (GdlDockObject *object,
                                      gpointer       user_data)
 {
-    struct {
-        xmlNodePtr  where;
-        GHashTable *placeholders;
-    } *info = user_data, info_child;
-
+    xmlNodePtr where = (xmlNodePtr)user_data;
     xmlNodePtr   node;
     guint        n_props, i;
     GParamSpec **props;
     GValue       attr = { 0, };
 
     g_return_if_fail (object != NULL && GDL_IS_DOCK_OBJECT (object));
-    g_return_if_fail (info->where != NULL);
+    g_return_if_fail (where != NULL);
 
-    node = xmlNewChild (info->where,
+    node = xmlNewChild (where,
                         NULL,               /* ns */
                         BAD_CAST gdl_dock_object_nick_from_type (G_TYPE_FROM_INSTANCE (object)),
                         BAD_CAST NULL);     /* contents */
@@ -524,45 +513,11 @@ gdl_dock_layout_foreach_object_save (GdlDockObject *object,
     g_value_unset (&attr);
     g_free (props);
 
-    info_child = *info;
-    info_child.where = node;
-
-    /* save placeholders for the object */
-    if (info->placeholders && !GDL_IS_DOCK_PLACEHOLDER (object)) {
-        GList *lph = g_hash_table_lookup (info->placeholders, object);
-        for (; lph; lph = lph->next)
-            gdl_dock_layout_foreach_object_save (GDL_DOCK_OBJECT (lph->data),
-                                                 (gpointer) &info_child);
-    }
-
     /* recurse the object if appropiate */
     if (gdl_dock_object_is_compound (object)) {
         gtk_container_foreach (GTK_CONTAINER (object),
                                (GtkCallback) gdl_dock_layout_foreach_object_save,
-                               (gpointer) &info_child);
-    }
-}
-
-static void
-add_placeholder (GdlDockObject *object,
-                 GHashTable    *placeholders)
-{
-    if (GDL_IS_DOCK_PLACEHOLDER (object)) {
-        GdlDockObject *host;
-        GList *l;
-
-        g_object_get (object, "host", &host, NULL);
-        if (host) {
-            l = g_hash_table_lookup (placeholders, host);
-            /* add the current placeholder to the list of placeholders
-               for that host */
-            if (l)
-                g_hash_table_steal (placeholders, host);
-
-            l = g_list_prepend (l, object);
-            g_hash_table_insert (placeholders, host, l);
-            g_object_unref (host);
-        }
+                               (gpointer) node);
     }
 }
 
@@ -570,32 +525,13 @@ static void
 gdl_dock_layout_save (GdlDockMaster *master,
                       xmlNodePtr     where)
 {
-    struct {
-        xmlNodePtr  where;
-        GHashTable *placeholders;
-    } info;
 
-    GHashTable *placeholders;
-
-    g_return_if_fail (master != NULL && where != NULL);
-
-    /* build the placeholder's hash: the hash keeps lists of
-     * placeholders associated to each object, so that we can save the
-     * placeholders when we are saving the object (since placeholders
-     * don't show up in the normal widget hierarchy) */
-    placeholders = g_hash_table_new_full (g_direct_hash, g_direct_equal,
-                                          NULL, (GDestroyNotify) g_list_free);
-    gdl_dock_master_foreach (master, (GFunc) add_placeholder, placeholders);
+	g_return_if_fail (master != NULL && where != NULL);
 
     /* save the layout recursively */
-    info.where = where;
-    info.placeholders = placeholders;
-
     gdl_dock_master_foreach_toplevel (master, TRUE,
                                       (GFunc) gdl_dock_layout_foreach_object_save,
-                                      (gpointer) &info);
-
-    g_hash_table_destroy (placeholders);
+                                      (gpointer) where);
 }
 
 
diff --git a/gdl/gdl-dock-object.c b/gdl/gdl-dock-object.c
index dcc319a..29f67dd 100644
--- a/gdl/gdl-dock-object.c
+++ b/gdl/gdl-dock-object.c
@@ -1070,7 +1070,11 @@ gdl_dock_param_get_type (void)
 static void
 gdl_dock_object_register_init (void)
 {
+#ifdef GDL_DISABLE_DEPRECATED
+    const size_t n_default = 4;
+#else    
     const size_t n_default = 5;
+#endif    
     guint i = 0;
     struct DockRegisterItem default_items[n_default];
 
@@ -1089,8 +1093,10 @@ gdl_dock_object_register_init (void)
     default_items[2].type = (gpointer) GDL_TYPE_DOCK_PANED;
     default_items[3].nick = "notebook";
     default_items[3].type = (gpointer) GDL_TYPE_DOCK_NOTEBOOK;
+#ifndef GDL_DISABLE_DEPRECATED    
     default_items[4].nick = "placeholder";
     default_items[4].type = (gpointer) GDL_TYPE_DOCK_PLACEHOLDER;
+#endif    
 
     for (i = 0; i < n_default; i++)
         g_array_append_val (dock_register, default_items[i]);
diff --git a/gdl/gdl-dock-placeholder.c b/gdl/gdl-dock-placeholder.c
index 24b9d4c..15124ab 100644
--- a/gdl/gdl-dock-placeholder.c
+++ b/gdl/gdl-dock-placeholder.c
@@ -25,6 +25,9 @@
 #include <config.h>
 #endif
 
+#ifndef GDL_DISABLE_DEPRECATED
+#define GDL_DISABLE_DEPRECATION_WARNINGS
+
 #include "gdl-i18n.h"
 
 #include "gdl-dock-placeholder.h"
@@ -43,6 +46,10 @@
  * A dock placeholder is a widget allowing to keep track of a docking place.
  * Unfortunately, all the details of the initial goal have been forgotten and
  * the code has still some issues.
+ * 
+ * In GDL 3.6, this part has been deprecated. Placeholder widgets are not
+ * used anymore. Instead, closed widgets are hidden but kept in the widget
+ * hierarchy.
  */
 
 #undef PLACEHOLDER_DEBUG
@@ -562,6 +569,8 @@ gdl_dock_placeholder_present (GdlDockObject *object,
  * working though.
  * 
  * Returns: The newly created placeholder.
+ * 
+ * Deprecated: 3.6:
  */
 GtkWidget * 
 gdl_dock_placeholder_new (const gchar     *name,
@@ -698,6 +707,8 @@ detach_cb (GdlDockObject *object,
  * children and see if any of them matches the placement which is at
  * the top of the stack.  If this is the case, it tries again with the
  * new host.
+ * 
+ * Deprecated: 3.6:
  **/
 static void
 do_excursion (GdlDockPlaceholder *ph)
@@ -826,6 +837,8 @@ connect_host (GdlDockPlaceholder *ph,
  * @object: A new #GdlDockObject
  * 
  * Move the placeholder to the position of @object.
+ * 
+ * Deprecated: 3.6:
  */
 void
 gdl_dock_placeholder_attach (GdlDockPlaceholder *ph,
@@ -853,3 +866,5 @@ gdl_dock_placeholder_attach (GdlDockPlaceholder *ph,
     
     gdl_dock_object_thaw (GDL_DOCK_OBJECT (ph));
 }
+
+#endif
diff --git a/gdl/gdl-dock-placeholder.h b/gdl/gdl-dock-placeholder.h
index dcaa230..54ae7b9 100644
--- a/gdl/gdl-dock-placeholder.h
+++ b/gdl/gdl-dock-placeholder.h
@@ -28,6 +28,8 @@
 
 G_BEGIN_DECLS
 
+#ifndef GDL_DISABLE_DEPRECATED
+
 /* standard macros */
 #define GDL_TYPE_DOCK_PLACEHOLDER             (gdl_dock_placeholder_get_type ())
 #define GDL_DOCK_PLACEHOLDER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholder))
@@ -62,7 +64,7 @@ GtkWidget  *gdl_dock_placeholder_new      (const gchar       *name,
 
 void        gdl_dock_placeholder_attach   (GdlDockPlaceholder *ph,
                                            GdlDockObject      *object);
-
+#endif
 
 G_END_DECLS
 
diff --git a/gdl/gdl-dock.c b/gdl/gdl-dock.c
index 4e52141..57b6c7d 100644
--- a/gdl/gdl-dock.c
+++ b/gdl/gdl-dock.c
@@ -32,7 +32,6 @@
 #include "gdl-dock-master.h"
 #include "gdl-dock-paned.h"
 #include "gdl-dock-notebook.h"
-#include "gdl-dock-placeholder.h"
 #include "gdl-preview-window.h"
 
 #include "libgdlmarshal.h"
@@ -1421,31 +1420,6 @@ gdl_dock_get_item_by_name (GdlDock     *dock,
 }
 
 /**
- * gdl_dock_get_placeholder_by_name:
- * @dock: A #GdlDock widget
- * @name: An item name
- *
- * Looks for an #GdlDockPlaceholder object bound to the master of the dock item.
- * It does not search only in the children of this particular dock widget.
- *
- * Returns: (transfer none): A #GdlDockPlaceholder object or %NULL
- */
-GdlDockPlaceholder *
-gdl_dock_get_placeholder_by_name (GdlDock     *dock,
-                                  const gchar *name)
-{
-    GdlDockObject *found;
-
-    g_return_val_if_fail (dock != NULL && name != NULL, NULL);
-
-    /* proxy the call to our master */
-    found = gdl_dock_master_get_object (GDL_DOCK_OBJECT_GET_MASTER (dock), name);
-
-    return (found && GDL_IS_DOCK_PLACEHOLDER (found)) ?
-        GDL_DOCK_PLACEHOLDER (found) : NULL;
-}
-
-/**
  * gdl_dock_get_named_items:
  * @dock: A #GdlDock widget
  *



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