[gdl] Add a deselected signal to GdlDockItem



commit 5e068d9e5ad4f4b42b27d6de0cbbb94bc050db2a
Author: James Liggett <jrliggett cox net>
Date:   Thu May 26 22:03:18 2011 -0700

    Add a deselected signal to GdlDockItem

 gdl/gdl-dock-item.c     |   30 ++++++++++++++++++++++++++++++
 gdl/gdl-dock-item.h     |    1 +
 gdl/gdl-dock-notebook.c |   18 +++++++++++++-----
 3 files changed, 44 insertions(+), 5 deletions(-)
---
diff --git a/gdl/gdl-dock-item.c b/gdl/gdl-dock-item.c
index 372f830..07df084 100644
--- a/gdl/gdl-dock-item.c
+++ b/gdl/gdl-dock-item.c
@@ -157,6 +157,7 @@ enum {
     DOCK_DRAG_MOTION,
     DOCK_DRAG_END,
     SELECTED,
+    DESELECTED,
     LAST_SIGNAL
 };
 
@@ -393,6 +394,22 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
                       G_TYPE_NONE,
                       0);
 
+    /**
+     * GdlDockItem::deselected:
+     *
+     * Signals that this dock has been deselected in a switcher.
+     */
+    gdl_dock_item_signals [DESELECTED] =
+        g_signal_new ("deselected",
+                      G_TYPE_FROM_CLASS (klass),
+                      G_SIGNAL_RUN_FIRST,
+                      0,
+                      NULL,
+                      NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+
     g_type_class_add_private (object_class, sizeof (GdlDockItemPrivate));
 
     /* set the style */
@@ -1928,6 +1945,19 @@ gdl_dock_item_notify_selected (GdlDockItem *item)
     g_signal_emit (item, gdl_dock_item_signals [SELECTED], 0);
 }
 
+/**
+ * gdl_dock_item_notify_deselected:
+ * @item: the dock item to emit a deselected signal on.
+ * 
+ * This function emits the deselected signal. It is used by #GdlSwitcher
+ * to let clients know that this item has been deselected.
+ **/
+void
+gdl_dock_item_notify_deselected (GdlDockItem *item)
+{
+    g_signal_emit (item, gdl_dock_item_signals [DESELECTED], 0);
+}
+
 /* convenient function (and to preserve source compat) */
 /**
  * gdl_dock_item_bind:
diff --git a/gdl/gdl-dock-item.h b/gdl/gdl-dock-item.h
index b96d8b6..a2f0b93 100644
--- a/gdl/gdl-dock-item.h
+++ b/gdl/gdl-dock-item.h
@@ -189,6 +189,7 @@ GtkWidget     *gdl_dock_item_get_grip          (GdlDockItem *item);
 void           gdl_dock_item_hide_grip         (GdlDockItem *item);
 void           gdl_dock_item_show_grip         (GdlDockItem *item);
 void           gdl_dock_item_notify_selected   (GdlDockItem *item);
+void           gdl_dock_item_notify_deselected (GdlDockItem *item);
 
 /* bind and unbind items to a dock */
 void           gdl_dock_item_bind              (GdlDockItem *item,
diff --git a/gdl/gdl-dock-notebook.c b/gdl/gdl-dock-notebook.c
index 81ba6f5..6f1c56b 100644
--- a/gdl/gdl-dock-notebook.c
+++ b/gdl/gdl-dock-notebook.c
@@ -263,16 +263,19 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook     *nb,
                                   gpointer         data)
 {
     GdlDockNotebook *notebook;
+    gint            current_page;
     GtkWidget       *tablabel;
-    GdlDockItem     *item;
+    GdlDockItem     *current_item;
+    GdlDockItem     *new_item;
     
     notebook = GDL_DOCK_NOTEBOOK (data);
+    current_page = gtk_notebook_get_current_page (nb);
 
     /* deactivate old tablabel */
-    if (gtk_notebook_get_current_page (nb)) {
+    if (current_page) {
         tablabel = gtk_notebook_get_tab_label (
             nb, gtk_notebook_get_nth_page (
-                nb, gtk_notebook_get_current_page (nb)));
+                nb, current_page));
         if (tablabel && GDL_IS_DOCK_TABLABEL (tablabel))
             gdl_dock_tablabel_deactivate (GDL_DOCK_TABLABEL (tablabel));
     };
@@ -288,9 +291,14 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook     *nb,
         g_signal_emit_by_name (GDL_DOCK_OBJECT (notebook)->master,
                                "layout-changed");
 
+    /* Signal that the old dock has been deselected */
+    current_item = GDL_DOCK_ITEM (gtk_notebook_get_nth_page (nb, current_page));
+
+    gdl_dock_item_notify_deselected (current_item);
+
     /* Signal that a new dock item has been selected */
-    item = GDL_DOCK_ITEM (page);
-    gdl_dock_item_notify_selected (item);
+    new_item = GDL_DOCK_ITEM (gtk_notebook_get_nth_page (nb, page_num));
+    gdl_dock_item_notify_selected (new_item);
 }
 
 static void



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