[gdl] Fix the preview window disappearing from time to time



commit 39434b4c8c41780151fe4a42a81a1faa806c2113
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Sun May 13 11:28:01 2012 +0200

    Fix the preview window disappearing from time to time
    
    It was because the preview window was hidden in each motion event.
    Now the window is hidden only at the end of a drag event or when another preview window is shown.

 gdl/gdl-dock-master.c |  202 ++++++++++++++++++++++++------------------------
 gdl/gdl-dock.c        |  198 ++++++++++++++++++++++++------------------------
 gdl/gdl-dock.h        |    6 +-
 3 files changed, 203 insertions(+), 203 deletions(-)
---
diff --git a/gdl/gdl-dock-master.c b/gdl/gdl-dock-master.c
index 616c65b..039d210 100644
--- a/gdl/gdl-dock-master.c
+++ b/gdl/gdl-dock-master.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  *
  * gdl-dock-master.c - Object which manages a dock ring
  *
@@ -54,13 +54,13 @@ static void     gdl_dock_master_get_property  (GObject            *object,
 static void     _gdl_dock_master_remove       (GdlDockObject      *object,
                                                GdlDockMaster      *master);
 
-static void     gdl_dock_master_drag_begin    (GdlDockItem        *item, 
+static void     gdl_dock_master_drag_begin    (GdlDockItem        *item,
                                                gpointer            data);
 static void     gdl_dock_master_drag_end      (GdlDockItem        *item,
                                                gboolean            cancelled,
                                                gpointer            data);
-static void     gdl_dock_master_drag_motion   (GdlDockItem        *item, 
-                                               gint                x, 
+static void     gdl_dock_master_drag_motion   (GdlDockItem        *item,
+                                               gint                x,
                                                gint                y,
                                                gpointer            data);
 
@@ -68,7 +68,9 @@ static void     _gdl_dock_master_foreach      (gpointer            key,
                                                gpointer            value,
                                                gpointer            user_data);
 
-static void     gdl_dock_master_xor_rect      (GdlDockMaster      *master);
+static void     gdl_dock_master_show_preview   (GdlDockMaster      *master);
+
+static void     gdl_dock_master_hide_preview   (GdlDockMaster      *master);
 
 static void     gdl_dock_master_layout_changed (GdlDockMaster     *master);
 
@@ -92,10 +94,9 @@ enum {
 struct _GdlDockMasterPrivate {
     gint            number;             /* for naming nameless manual objects */
     gchar          *default_title;
-    
-    gboolean        rect_drawn;
+
     GdlDock        *rect_owner;
-    
+
     GdlDockRequest *drag_request;
 
     /* source id for the idle handler to emit a layout_changed signal */
@@ -108,7 +109,7 @@ struct _GdlDockMasterPrivate {
      */
     GHashTable     *locked_items;
     GHashTable     *unlocked_items;
-    
+
     GdlSwitcherStyle switcher_style;
 
     /* Window for preview rect */
@@ -146,7 +147,7 @@ gdl_dock_master_class_init (GdlDockMasterClass *klass)
                              _("Default title for newly created floating docks"),
                              NULL,
                              G_PARAM_READWRITE));
-    
+
     g_object_class_install_property (
         object_class, PROP_LOCKED,
         g_param_spec_int ("locked", _("Locked"),
@@ -164,8 +165,8 @@ gdl_dock_master_class_init (GdlDockMasterClass *klass)
                            GDL_SWITCHER_STYLE_BOTH,
                            G_PARAM_READWRITE));
 
-    master_signals [LAYOUT_CHANGED] = 
-        g_signal_new ("layout-changed", 
+    master_signals [LAYOUT_CHANGED] =
+        g_signal_new ("layout-changed",
                       G_TYPE_FROM_CLASS (klass),
                       G_SIGNAL_RUN_LAST,
                       G_STRUCT_OFFSET (GdlDockMasterClass, layout_changed),
@@ -213,7 +214,7 @@ _gdl_dock_master_remove (GdlDockObject *object,
         if (object == master->controller) {
             GList *last;
             GdlDockObject *new_controller = NULL;
-            
+
             /* now find some other non-automatic toplevel to use as a
                new controller.  start from the last dock, since it's
                probably a non-floating and manual */
@@ -237,7 +238,7 @@ _gdl_dock_master_remove (GdlDockObject *object,
         }
     }
     /* disconnect dock object signals */
-    g_signal_handlers_disconnect_matched (object, G_SIGNAL_MATCH_DATA, 
+    g_signal_handlers_disconnect_matched (object, G_SIGNAL_MATCH_DATA,
                                           0, 0, NULL, NULL, master);
 
     /* unref the object from the hash if it's there */
@@ -325,13 +326,13 @@ gdl_dock_master_finalize (GObject *object)
     G_OBJECT_CLASS (gdl_dock_master_parent_class)->finalize (object);
 }
 
-static void 
+static void
 foreach_lock_unlock (GdlDockItem *item,
                      gboolean     locked)
 {
     if (!GDL_IS_DOCK_ITEM (item))
         return;
-    
+
     g_object_set (item, "locked", locked, NULL);
     if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (item)))
         gtk_container_foreach (GTK_CONTAINER (item),
@@ -344,7 +345,7 @@ gdl_dock_master_lock_unlock (GdlDockMaster *master,
                              gboolean       locked)
 {
     GList *l;
-    
+
     for (l = master->toplevel_docks; l; l = l->next) {
         GdlDock *dock = GDL_DOCK (l->data);
         if (dock->root)
@@ -413,7 +414,7 @@ gdl_dock_master_drag_begin (GdlDockItem *item,
 {
     GdlDockMaster  *master;
     GdlDockRequest *request;
-    
+
     g_return_if_fail (data != NULL);
     g_return_if_fail (item != NULL);
 
@@ -423,7 +424,7 @@ gdl_dock_master_drag_begin (GdlDockItem *item,
         master->priv->drag_request = g_new0 (GdlDockRequest, 1);
 
     request = master->priv->drag_request;
-    
+
     /* Set the target to itself so it won't go floating with just a click. */
     request->applicant = GDL_DOCK_OBJECT (item);
     request->target = GDL_DOCK_OBJECT (item);
@@ -431,46 +432,44 @@ gdl_dock_master_drag_begin (GdlDockItem *item,
     if (G_IS_VALUE (&request->extra))
         g_value_unset (&request->extra);
 
-    master->priv->rect_drawn = FALSE;
     master->priv->rect_owner = NULL;
 }
 
 static void
-gdl_dock_master_drag_end (GdlDockItem *item, 
+gdl_dock_master_drag_end (GdlDockItem *item,
                           gboolean     cancelled,
                           gpointer     data)
 {
     GdlDockMaster  *master;
     GdlDockRequest *request;
-    
+
     g_return_if_fail (data != NULL);
     g_return_if_fail (item != NULL);
 
     master = GDL_DOCK_MASTER (data);
     request = master->priv->drag_request;
-    
+
     g_return_if_fail (GDL_DOCK_OBJECT (item) == request->applicant);
-    
-    /* Erase previously drawn rectangle */
-    if (master->priv->rect_drawn)
-        gdl_dock_master_xor_rect (master);    
+
+    /* Hide the preview window */
+    gdl_dock_master_hide_preview (master);
 
     /* cancel conditions */
     if (cancelled || request->applicant == request->target)
         return;
-    
+
     /* dock object to the requested position */
     gdl_dock_object_dock (request->target,
                           request->applicant,
                           request->position,
                           &request->extra);
-    
+
     g_signal_emit (master, master_signals [LAYOUT_CHANGED], 0);
 }
 
 static void
-gdl_dock_master_drag_motion (GdlDockItem *item, 
-                             gint         root_x, 
+gdl_dock_master_drag_motion (GdlDockItem *item,
+                             gint         root_x,
                              gint         root_y,
                              gpointer     data)
 {
@@ -482,14 +481,14 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
     gint            x, y;
     GdlDock        *dock = NULL;
     gboolean        may_dock = FALSE;
-    
+
     g_return_if_fail (item != NULL && data != NULL);
 
     master = GDL_DOCK_MASTER (data);
     request = master->priv->drag_request;
 
     g_return_if_fail (GDL_DOCK_OBJECT (item) == request->applicant);
-    
+
     my_request = *request;
 
     /* first look under the pointer */
@@ -500,12 +499,12 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
            get to a GdlDock by walking up the hierarchy */
         gdk_window_get_user_data (window, (gpointer) &widget);
         if (GTK_IS_WIDGET (widget)) {
-            while (widget && (!GDL_IS_DOCK (widget) || 
+            while (widget && (!GDL_IS_DOCK (widget) ||
 	           GDL_DOCK_OBJECT_GET_MASTER (widget) != master))
                 widget = gtk_widget_get_parent (widget);
             if (widget) {
                 gint win_w, win_h;
-                
+
                 widget_window = gtk_widget_get_window (widget);
 
                 /* verify that the pointer is still in that dock
@@ -551,7 +550,7 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
         }
     }
 
-  
+
     if (!may_dock) {
         GtkRequisition req;
 	/* Special case for GdlDockItems : they must respect the flags */
@@ -587,24 +586,20 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
 	&& dock != GDL_DOCK(master->controller))
 	    return;
 
-    if (!(my_request.rect.x == request->rect.x &&
-          my_request.rect.y == request->rect.y &&
-          my_request.rect.width == request->rect.width &&
-          my_request.rect.height == request->rect.height &&
-          dock == master->priv->rect_owner)) {
-
-        /* erase the previous rectangle */
-        if (master->priv->rect_drawn)
-            gdl_dock_master_xor_rect (master);
+    /* the previous windows is drawn by the dock master object if the preview
+     * is floating or by the corresponding dock object. It is not necessary
+     * the dock master could handle all cases but then it would be more
+     * difficult to implement different preview window in both cases */
+    /* erase previous preview window if necessary */
+    if (master->priv->rect_owner != dock)
+    {
+        gdl_dock_master_hide_preview (master);
+        master->priv->rect_owner = dock;
     }
 
-    /* set the new values */
+    /* draw the preview window */
     *request = my_request;
-    master->priv->rect_owner = dock;
-    
-    /* draw the previous rectangle */
-    if (~master->priv->rect_drawn)
-        gdl_dock_master_xor_rect (master);
+    gdl_dock_master_show_preview (master);
 }
 
 static void
@@ -621,40 +616,45 @@ _gdl_dock_master_foreach (gpointer key,
 }
 
 static void
-gdl_dock_master_xor_rect (GdlDockMaster *master)
+gdl_dock_master_show_preview (GdlDockMaster *master)
 {
-    cairo_rectangle_int_t *rect;
-    
     if (!master->priv || !master->priv->drag_request)
         return;
-    
-    master->priv->rect_drawn = ~master->priv->rect_drawn;
-    
-    if (master->priv->rect_owner) 
+
+    if (master->priv->rect_owner)
     {
-        if (master->priv->rect_drawn)
-        {
-            gdl_dock_xor_rect (master->priv->rect_owner,
+        gdl_dock_show_preview (master->priv->rect_owner,
                                &master->priv->drag_request->rect);
-        }
-        else
+    }
+    else
+    {
+        cairo_rectangle_int_t *rect;
+
+        rect = &master->priv->drag_request->rect;
+
+        if (!master->priv->area_window)
         {
-            gdl_dock_xor_rect_hide(master->priv->rect_owner);
-            master->priv->rect_owner = NULL;
+            master->priv->area_window = gdl_preview_window_new ();
         }
-    }        
-    if (master->priv->rect_drawn && !master->priv->rect_owner)
-    {
-            rect = &master->priv->drag_request->rect;
 
-            if (!master->priv->area_window)
-            {
-                master->priv->area_window = gdl_preview_window_new ();
-            }
+        gdl_preview_window_update (GDL_PREVIEW_WINDOW (master->priv->area_window), rect);
+    }
+}
+
+static void
+gdl_dock_master_hide_preview (GdlDockMaster *master)
+{
+    cairo_rectangle_int_t *rect;
 
-            gdl_preview_window_update (GDL_PREVIEW_WINDOW (master->priv->area_window), rect);
+    if (!master->priv)
+        return;
+
+    if (master->priv->rect_owner)
+    {
+        gdl_dock_hide_preview (master->priv->rect_owner);
+        master->priv->rect_owner = NULL;
     }
-    else if (master->priv->area_window)
+    if (master->priv->area_window)
     {
         gtk_widget_hide (master->priv->area_window);
     }
@@ -686,11 +686,11 @@ idle_emit_layout_changed (gpointer user_data)
 
     master->priv->idle_layout_changed_id = 0;
     g_signal_emit (master, master_signals [LAYOUT_CHANGED], 0);
-    
+
     return FALSE;
 }
 
-static void 
+static void
 item_dock_cb (GdlDockObject    *object,
               GdlDockObject    *requestor,
               GdlDockPlacement  position,
@@ -698,7 +698,7 @@ item_dock_cb (GdlDockObject    *object,
               gpointer          user_data)
 {
     GdlDockMaster *master = user_data;
-    
+
     g_return_if_fail (requestor && GDL_IS_DOCK_OBJECT (requestor));
     g_return_if_fail (master && GDL_IS_DOCK_MASTER (master));
 
@@ -713,13 +713,13 @@ item_dock_cb (GdlDockObject    *object,
     }
 }
 
-static void 
+static void
 item_detach_cb (GdlDockObject *object,
                 gboolean       recursive,
                 gpointer       user_data)
 {
     GdlDockMaster *master = user_data;
-    
+
     g_return_if_fail (object && GDL_IS_DOCK_OBJECT (object));
     g_return_if_fail (master && GDL_IS_DOCK_MASTER (master));
 
@@ -739,7 +739,7 @@ item_notify_cb (GdlDockObject *object,
     GdlDockMaster *master = user_data;
     gint locked = COMPUTE_LOCKED (master);
     gboolean item_locked;
-    
+
     g_object_get (object, "locked", &item_locked, NULL);
 
     if (item_locked) {
@@ -749,7 +749,7 @@ item_notify_cb (GdlDockObject *object,
         g_hash_table_remove (master->priv->locked_items, object);
         g_hash_table_insert (master->priv->unlocked_items, object, NULL);
     }
-    
+
     if (COMPUTE_LOCKED (master) != locked)
         g_object_notify (G_OBJECT (master), "locked");
 }
@@ -764,13 +764,13 @@ gdl_dock_master_add (GdlDockMaster *master,
 
     if (!GDL_DOCK_OBJECT_AUTOMATIC (object)) {
         GdlDockObject *found_object;
-        
+
         /* create a name for the object if it doesn't have one */
         if (!object->name)
             /* directly set the name, since it's a construction only
                property */
             object->name = g_strdup_printf ("__dock_%u", master->priv->number++);
-        
+
         /* add the object to our hash list */
         if ((found_object = g_hash_table_lookup (master->dock_objects, object->name))) {
             g_warning (_("master %p: unable to add object %p[%s] to the hash.  "
@@ -782,15 +782,15 @@ gdl_dock_master_add (GdlDockMaster *master,
             g_hash_table_insert (master->dock_objects, g_strdup (object->name), object);
         }
     }
-    
+
     if (GDL_IS_DOCK (object)) {
         gboolean floating;
-        
+
         /* if this is the first toplevel we are adding, name it controller */
         if (!master->toplevel_docks)
             /* the dock should already have the ref */
             master->controller = object;
-        
+
         /* add dock to the toplevel list */
         g_object_get (object, "floating", &floating, NULL);
         if (floating)
@@ -824,7 +824,7 @@ gdl_dock_master_add (GdlDockMaster *master,
                               G_CALLBACK (item_notify_cb), master);
             item_notify_cb (object, NULL, master);
         }
-        
+
         /* If the item is notebook, set the switcher style */
         if (GDL_IS_DOCK_NOTEBOOK (object) &&
             GDL_IS_SWITCHER (GDL_DOCK_ITEM (object)->child))
@@ -832,7 +832,7 @@ gdl_dock_master_add (GdlDockMaster *master,
             g_object_set (GDL_DOCK_ITEM (object)->child, "switcher-style",
                           master->priv->switcher_style, NULL);
         }
-        
+
         /* post a layout_changed emission if the item is not automatic
          * (since it should be added to the items model) */
         if (!GDL_DOCK_OBJECT_AUTOMATIC (object)) {
@@ -859,10 +859,10 @@ gdl_dock_master_remove (GdlDockMaster *master,
                 g_object_notify (G_OBJECT (master), "locked");
         }
     }
-        
+
     /* ref the master, since removing the controller could cause master disposal */
     g_object_ref (master);
-    
+
     /* all the interesting stuff happens in _gdl_dock_master_remove */
     _gdl_dock_master_remove (object, master);
 
@@ -873,7 +873,7 @@ gdl_dock_master_remove (GdlDockMaster *master,
             master->priv->idle_layout_changed_id =
                 g_idle_add (idle_emit_layout_changed, master);
     }
-    
+
     /* balance ref count */
     g_object_unref (master);
 }
@@ -902,7 +902,7 @@ gdl_dock_master_foreach_toplevel (GdlDockMaster *master,
                                   gpointer       user_data)
 {
     GList *l;
-    
+
     g_return_if_fail (master != NULL && function != NULL);
 
     for (l = master->toplevel_docks; l; ) {
@@ -918,7 +918,7 @@ gdl_dock_master_get_object (GdlDockMaster *master,
                             const gchar   *nick_name)
 {
     gpointer *found;
-    
+
     g_return_val_if_fail (master != NULL, NULL);
 
     if (!nick_name)
@@ -947,7 +947,7 @@ gdl_dock_master_set_controller (GdlDockMaster *master,
         if (GDL_DOCK_OBJECT_AUTOMATIC (new_controller))
             g_warning (_("The new dock controller %p is automatic.  Only manual "
                          "dock objects should be named controller."), new_controller);
-        
+
         /* check that the controller is in the toplevel list */
         if (!g_list_find (master->toplevel_docks, new_controller))
             gdl_dock_master_add (master, new_controller);
@@ -964,19 +964,19 @@ static void
 set_switcher_style_foreach (GtkWidget *obj, gpointer user_data)
 {
     GdlSwitcherStyle style = GPOINTER_TO_INT (user_data);
-    
+
     if (!GDL_IS_DOCK_ITEM (obj))
         return;
-    
+
     if (GDL_IS_DOCK_NOTEBOOK (obj)) {
-        
+
         GtkWidget *child = GDL_DOCK_ITEM (obj)->child;
         if (GDL_IS_SWITCHER (child)) {
-            
+
             g_object_set (child, "switcher-style", style, NULL);
         }
     } else if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (obj))) {
-        
+
         gtk_container_foreach (GTK_CONTAINER (obj),
                                set_switcher_style_foreach,
                                user_data);
@@ -989,7 +989,7 @@ gdl_dock_master_set_switcher_style (GdlDockMaster *master,
 {
     GList *l;
     g_return_if_fail (GDL_IS_DOCK_MASTER (master));
-    
+
     master->priv->switcher_style = switcher_style;
     for (l = master->toplevel_docks; l; l = l->next) {
         GdlDock *dock = GDL_DOCK (l->data);
diff --git a/gdl/gdl-dock.c b/gdl/gdl-dock.c
index 5fa1ffd..7a47697 100644
--- a/gdl/gdl-dock.c
+++ b/gdl/gdl-dock.c
@@ -1,10 +1,10 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  *
  * This file is part of the GNOME Devtools Libraries.
  *
  * Copyright (C) 2002 Gustavo GirÃldez <gustavo giraldez gmx net>
  *               2007 Naba Kumar  <naba gnome org>
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
@@ -122,7 +122,7 @@ struct _GdlDockPrivate
     gboolean            floating;
     GtkWidget          *window;
     gboolean            auto_title;
-    
+
     gint                float_x;
     gint                float_y;
     gint                width;
@@ -162,17 +162,17 @@ gdl_dock_class_init (GdlDockClass *klass)
     GtkWidgetClass     *widget_class;
     GtkContainerClass  *container_class;
     GdlDockObjectClass *object_class;
-    
+
     g_object_class = G_OBJECT_CLASS (klass);
     widget_class = GTK_WIDGET_CLASS (klass);
     container_class = GTK_CONTAINER_CLASS (klass);
     object_class = GDL_DOCK_OBJECT_CLASS (klass);
-    
+
     g_object_class->constructor = gdl_dock_constructor;
     g_object_class->set_property = gdl_dock_set_property;
     g_object_class->get_property = gdl_dock_get_property;
     g_object_class->dispose = gdl_dock_dispose;
-    
+
     /* properties */
 
     g_object_class_install_property (
@@ -182,14 +182,14 @@ gdl_dock_class_init (GdlDockClass *klass)
                               FALSE,
                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
                               GDL_DOCK_PARAM_EXPORT));
-    
+
     g_object_class_install_property (
         g_object_class, PROP_DEFAULT_TITLE,
         g_param_spec_string ("default-title", _("Default title"),
                              _("Default title for the newly created floating docks"),
                              NULL,
                              G_PARAM_READWRITE));
-    
+
     g_object_class_install_property (
         g_object_class, PROP_WIDTH,
         g_param_spec_int ("width", _("Width"),
@@ -197,7 +197,7 @@ gdl_dock_class_init (GdlDockClass *klass)
                           -1, G_MAXINT, -1,
                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
                           GDL_DOCK_PARAM_EXPORT));
-    
+
     g_object_class_install_property (
         g_object_class, PROP_HEIGHT,
         g_param_spec_int ("height", _("Height"),
@@ -205,7 +205,7 @@ gdl_dock_class_init (GdlDockClass *klass)
                           -1, G_MAXINT, -1,
                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
                           GDL_DOCK_PARAM_EXPORT));
-    
+
     g_object_class_install_property (
         g_object_class, PROP_FLOAT_X,
         g_param_spec_int ("floatx", _("Float X"),
@@ -213,7 +213,7 @@ gdl_dock_class_init (GdlDockClass *klass)
                           G_MININT, G_MAXINT, 0,
                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
                           GDL_DOCK_PARAM_EXPORT));
-    
+
     g_object_class_install_property (
         g_object_class, PROP_FLOAT_Y,
         g_param_spec_int ("floaty", _("Float Y"),
@@ -229,7 +229,7 @@ gdl_dock_class_init (GdlDockClass *klass)
     widget_class->unmap = gdl_dock_unmap;
     widget_class->show = gdl_dock_show;
     widget_class->hide = gdl_dock_hide;
-    
+
     container_class->add = gdl_dock_add;
     container_class->remove = gdl_dock_remove;
     container_class->forall = gdl_dock_forall;
@@ -237,19 +237,19 @@ gdl_dock_class_init (GdlDockClass *klass)
     gtk_container_class_handle_border_width (container_class);
 
     object_class->is_compound = TRUE;
-    
+
     object_class->detach = gdl_dock_detach;
     object_class->reduce = gdl_dock_reduce;
     object_class->dock_request = gdl_dock_dock_request;
     object_class->dock = gdl_dock_dock;
-    object_class->reorder = gdl_dock_reorder;    
+    object_class->reorder = gdl_dock_reorder;
     object_class->child_placement = gdl_dock_child_placement;
     object_class->present = gdl_dock_present;
-    
+
     /* signals */
 
-    dock_signals [LAYOUT_CHANGED] = 
-        g_signal_new ("layout-changed", 
+    dock_signals [LAYOUT_CHANGED] =
+        g_signal_new ("layout-changed",
                       G_TYPE_FROM_CLASS (klass),
                       G_SIGNAL_RUN_LAST,
                       G_STRUCT_OFFSET (GdlDockClass, layout_changed),
@@ -278,13 +278,13 @@ gdl_dock_init (GdlDock *dock)
     dock->priv->height = -1;
 }
 
-static gboolean 
+static gboolean
 gdl_dock_floating_configure_event_cb (GtkWidget         *widget,
                                       GdkEventConfigure *event,
                                       gpointer           user_data)
 {
     GdlDock *dock;
-    
+
     g_return_val_if_fail (user_data != NULL && GDL_IS_DOCK (user_data), TRUE);
 
     dock = GDL_DOCK (user_data);
@@ -354,7 +354,7 @@ gdl_dock_constructor (GType                  type,
             gtk_container_add (GTK_CONTAINER (dock->priv->window), GTK_WIDGET (dock));
 
             g_signal_connect (dock->priv->window, "delete_event",
-                              G_CALLBACK (gdl_dock_floating_window_delete_event_cb), 
+                              G_CALLBACK (gdl_dock_floating_window_delete_event_cb),
                               NULL);
         }
         GDL_DOCK_OBJECT_SET_FLAGS (dock, GDL_DOCK_ATTACHED);
@@ -370,7 +370,7 @@ gdl_dock_set_property  (GObject      *object,
                         GParamSpec   *pspec)
 {
     GdlDock *dock = GDL_DOCK (object);
-    
+
     switch (prop_id) {
         case PROP_FLOATING:
             dock->priv->floating = g_value_get_boolean (value);
@@ -459,10 +459,10 @@ gdl_dock_set_title (GdlDock *dock)
 {
     GdlDockObject *object = GDL_DOCK_OBJECT (dock);
     gchar         *title = NULL;
-    
+
     if (!dock->priv->window)
         return;
-    
+
     if (!dock->priv->auto_title && object->long_name) {
         title = object->long_name;
     }
@@ -473,7 +473,7 @@ gdl_dock_set_title (GdlDock *dock)
     if (!title && dock->root) {
         g_object_get (dock->root, "long-name", &title, NULL);
     }
-    
+
     if (!title) {
         /* set a default title in the long_name */
         dock->priv->auto_title = TRUE;
@@ -493,7 +493,7 @@ gdl_dock_notify_cb (GObject    *object,
 {
     GdlDock *dock;
     gchar* long_name;
-    
+
     g_return_if_fail (object != NULL || GDL_IS_DOCK (object));
 
     g_object_get (object, "long-name", &long_name, NULL);
@@ -615,7 +615,7 @@ gdl_dock_unmap (GtkWidget *widget)
 {
     GtkWidget *child;
     GdlDock   *dock;
-    
+
     g_return_if_fail (widget != NULL);
     g_return_if_fail (GDL_IS_DOCK (widget));
 
@@ -628,7 +628,7 @@ gdl_dock_unmap (GtkWidget *widget)
         if (gtk_widget_get_visible (child) && gtk_widget_get_mapped (child))
             gtk_widget_unmap (child);
     }
-    
+
     if (dock->priv->window)
         gtk_widget_unmap (dock->priv->window);
 }
@@ -647,12 +647,12 @@ static void
 gdl_dock_show (GtkWidget *widget)
 {
     GdlDock *dock;
-    
+
     g_return_if_fail (widget != NULL);
     g_return_if_fail (GDL_IS_DOCK (widget));
-    
+
     GTK_WIDGET_CLASS (gdl_dock_parent_class)->show (widget);
-    
+
     dock = GDL_DOCK (widget);
     if (dock->priv->floating && dock->priv->window)
         gtk_widget_show (dock->priv->window);
@@ -668,12 +668,12 @@ static void
 gdl_dock_hide (GtkWidget *widget)
 {
     GdlDock *dock;
-    
+
     g_return_if_fail (widget != NULL);
     g_return_if_fail (GDL_IS_DOCK (widget));
-    
+
     GTK_WIDGET_CLASS (gdl_dock_parent_class)->hide (widget);
-    
+
     dock = GDL_DOCK (widget);
     if (dock->priv->floating && dock->priv->window)
         gtk_widget_hide (dock->priv->window);
@@ -693,8 +693,8 @@ gdl_dock_add (GtkContainer *container,
     g_return_if_fail (GDL_IS_DOCK (container));
     g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
 
-    gdl_dock_add_item (GDL_DOCK (container), 
-                       GDL_DOCK_ITEM (widget), 
+    gdl_dock_add_item (GDL_DOCK (container),
+                       GDL_DOCK_ITEM (widget),
                        GDL_DOCK_TOP);  /* default position */
 }
 
@@ -750,7 +750,7 @@ gdl_dock_detach (GdlDockObject *object,
                  gboolean       recursive)
 {
     GdlDock *dock = GDL_DOCK (object);
-    
+
     /* detach children */
     if (recursive && dock->root) {
         gdl_dock_object_detach (dock->root, recursive);
@@ -763,10 +763,10 @@ gdl_dock_reduce (GdlDockObject *object)
 {
     GdlDock *dock = GDL_DOCK (object);
     GtkWidget *parent;
-    
+
     if (dock->root)
         return;
-    
+
     if (GDL_DOCK_OBJECT_AUTOMATIC (dock)) {
         gtk_widget_destroy (GTK_WIDGET (dock));
 
@@ -799,9 +799,9 @@ gdl_dock_dock_request (GdlDockObject  *object,
     g_return_val_if_fail (GDL_IS_DOCK (object), FALSE);
 
     /* we get (x,y) in our allocation coordinates system */
-    
+
     dock = GDL_DOCK (object);
-    
+
     /* Get dock size. */
     gtk_widget_get_allocation (GTK_WIDGET (dock), &alloc);
     bw = gtk_container_get_border_width (GTK_CONTAINER (dock));
@@ -812,7 +812,7 @@ gdl_dock_dock_request (GdlDockObject  *object,
 
     if (request)
         my_request = *request;
-        
+
     /* Check if coordinates are in GdlDock widget. */
     if (rel_x > 0 && rel_x < alloc.width &&
         rel_y > 0 && rel_y < alloc.height) {
@@ -826,7 +826,7 @@ gdl_dock_dock_request (GdlDockObject  *object,
         my_request.rect.width = alloc.width - 2*bw;
         my_request.rect.height = alloc.height - 2*bw;
 
-	/* If GdlDock has no root item yet, set the dock itself as 
+	/* If GdlDock has no root item yet, set the dock itself as
 	   possible target. */
         if (!dock->root) {
             my_request.position = GDL_DOCK_TOP;
@@ -853,7 +853,7 @@ gdl_dock_dock_request (GdlDockObject  *object,
                 /* Otherwise try our children. */
                 /* give them allocation coordinates (we are a
                    GTK_NO_WINDOW) widget */
-                may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock->root), 
+                may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock->root),
                                                          x, y, &my_request);
             }
         }
@@ -861,7 +861,7 @@ gdl_dock_dock_request (GdlDockObject  *object,
 
     if (may_dock && request)
         *request = my_request;
-    
+
     return may_dock;
 }
 
@@ -872,13 +872,13 @@ gdl_dock_dock (GdlDockObject    *object,
                GValue           *user_data)
 {
     GdlDock *dock;
-    
+
     g_return_if_fail (GDL_IS_DOCK (object));
     /* only dock items allowed at this time */
     g_return_if_fail (GDL_IS_DOCK_ITEM (requestor));
 
     dock = GDL_DOCK (object);
-    
+
     if (position == GDL_DOCK_FLOATING) {
         GdlDockItem *item = GDL_DOCK_ITEM (requestor);
         gint x, y, width, height;
@@ -896,7 +896,7 @@ gdl_dock_dock (GdlDockObject    *object,
             x = y = 0;
             width = height = -1;
         }
-        
+
         gdl_dock_add_floating_item (dock, item,
                                     x, y, width, height);
     }
@@ -905,44 +905,44 @@ gdl_dock_dock (GdlDockObject    *object,
            pass the request on because we only have on child */
         gdl_dock_object_dock (dock->root, requestor, position, NULL);
         gdl_dock_set_title (dock);
-        
+
     }
     else { /* Item about to be added is root item. */
         GtkWidget *widget = GTK_WIDGET (requestor);
-        
+
         dock->root = requestor;
         GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED);
         gtk_widget_set_parent (widget, GTK_WIDGET (dock));
-        
+
         gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor));
 
-        /* Realize the item (create its corresponding GdkWindow) when 
+        /* Realize the item (create its corresponding GdkWindow) when
            GdlDock has been realized. */
         if (gtk_widget_get_realized (GTK_WIDGET (dock)))
             gtk_widget_realize (widget);
-        
-        /* Map the widget if it's visible and the parent is visible and has 
-           been mapped. This is done to make sure that the GdkWindow is 
+
+        /* Map the widget if it's visible and the parent is visible and has
+           been mapped. This is done to make sure that the GdkWindow is
            visible. */
-        if (gtk_widget_get_visible (GTK_WIDGET (dock)) && 
+        if (gtk_widget_get_visible (GTK_WIDGET (dock)) &&
             gtk_widget_get_visible (widget)) {
             if (gtk_widget_get_mapped (GTK_WIDGET (dock)))
                 gtk_widget_map (widget);
-            
+
             /* Make the widget resize. */
             gtk_widget_queue_resize (widget);
         }
         gdl_dock_set_title (dock);
     }
 }
-    
+
 static gboolean
 gdl_dock_floating_window_delete_event_cb (GtkWidget *widget)
 {
     GdlDock *dock;
-    
+
     g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE);
-    
+
     dock = GDL_DOCK (g_object_get_data (G_OBJECT (widget), "dock"));
     if (dock->root) {
         /* this will call reduce on ourselves, hiding the window if appropiate */
@@ -970,11 +970,11 @@ gdl_dock_reorder (GdlDockObject    *object,
 {
     GdlDock *dock = GDL_DOCK (object);
     gboolean handled = FALSE;
-    
+
     if (dock->priv->floating &&
         new_position == GDL_DOCK_FLOATING &&
         dock->root == requestor) {
-        
+
         if (other_data && G_VALUE_HOLDS (other_data, GDK_TYPE_RECTANGLE)) {
             GdkRectangle *rect;
 
@@ -985,30 +985,30 @@ gdl_dock_reorder (GdlDockObject    *object,
             handled = TRUE;
         }
     }
-    
+
     return handled;
 }
 
-static gboolean 
+static gboolean
 gdl_dock_child_placement (GdlDockObject    *object,
                           GdlDockObject    *child,
                           GdlDockPlacement *placement)
 {
     GdlDock *dock = GDL_DOCK (object);
     gboolean retval = TRUE;
-    
+
     if (dock->root == child) {
         if (placement) {
             if (*placement == GDL_DOCK_NONE || *placement == GDL_DOCK_FLOATING)
                 *placement = GDL_DOCK_TOP;
         }
-    } else 
+    } else
         retval = FALSE;
 
     return retval;
 }
 
-static void 
+static void
 gdl_dock_present (GdlDockObject *object,
                   GdlDockObject *child)
 {
@@ -1028,7 +1028,7 @@ gdl_dock_new (void)
 
     dock = g_object_new (GDL_TYPE_DOCK, NULL);
     GDL_DOCK_OBJECT_UNSET_FLAGS (dock, GDL_DOCK_AUTOMATIC);
-    
+
     return GTK_WIDGET (dock);
 }
 
@@ -1037,15 +1037,15 @@ gdl_dock_new_from (GdlDock  *original,
                    gboolean  floating)
 {
     GObject *new_dock;
-    
+
     g_return_val_if_fail (original != NULL, NULL);
-    
-    new_dock = g_object_new (GDL_TYPE_DOCK, 
-                             "master", GDL_DOCK_OBJECT_GET_MASTER (original), 
+
+    new_dock = g_object_new (GDL_TYPE_DOCK,
+                             "master", GDL_DOCK_OBJECT_GET_MASTER (original),
                              "floating", floating,
                              NULL);
     GDL_DOCK_OBJECT_UNSET_FLAGS (new_dock, GDL_DOCK_AUTOMATIC);
-    
+
     return GTK_WIDGET (new_dock);
 }
 
@@ -1060,7 +1060,7 @@ gdl_dock_refine_placement (GdlDock *dock, GdlDockItem *dock_item,
 {
     GtkAllocation allocation;
     GtkRequisition object_size;
-    
+
     gdl_dock_item_preferred_size (dock_item, &object_size);
     gtk_widget_get_allocation (GTK_WIDGET (dock), &allocation);
 
@@ -1095,18 +1095,18 @@ gdl_dock_select_larger_item (GdlDockItem *dock_item_1,
                              gint level /* for debugging */)
 {
     GtkRequisition size_1, size_2;
-    
+
     g_return_val_if_fail (dock_item_1 != NULL, dock_item_2);
     g_return_val_if_fail (dock_item_2 != NULL, dock_item_1);
-    
+
     gdl_dock_item_preferred_size (dock_item_1, &size_1);
     gdl_dock_item_preferred_size (dock_item_2, &size_2);
-    
+
     g_return_val_if_fail (size_1.width > 0, dock_item_2);
     g_return_val_if_fail (size_1.height > 0, dock_item_2);
     g_return_val_if_fail (size_2.width > 0, dock_item_1);
     g_return_val_if_fail (size_2.height > 0, dock_item_1);
-    
+
     if (placement == GDL_DOCK_LEFT || placement == GDL_DOCK_RIGHT)
     {
         /* For left/right placement, height is what matters */
@@ -1143,17 +1143,17 @@ gdl_dock_find_best_placement_item (GdlDockItem *dock_item,
                                    gint level /* for debugging */)
 {
     GdlDockItem *ret_item = NULL;
-    
+
     if (GDL_IS_DOCK_PANED (dock_item))
     {
         GtkOrientation orientation;
         GdlDockItem *dock_item_1, *dock_item_2;
         GList* children;
-        
+
         children = gtk_container_get_children (GTK_CONTAINER (dock_item));
-        
+
         g_assert (g_list_length (children) == 2);
-        
+
         g_object_get (dock_item, "orientation", &orientation, NULL);
         if ((orientation == GTK_ORIENTATION_HORIZONTAL &&
              placement == GDL_DOCK_LEFT) ||
@@ -1219,7 +1219,7 @@ gdl_dock_add_item (GdlDock          *dock,
         if (dock->root) {
             GdlDockPlacement local_placement;
             GtkRequisition preferred_size;
-            
+
             best_dock_item =
                 gdl_dock_find_best_placement_item (GDL_DOCK_ITEM (dock->root),
                                                    placement, 0);
@@ -1245,24 +1245,24 @@ gdl_dock_add_floating_item (GdlDock        *dock,
                             gint            height)
 {
     GdlDock *new_dock;
-    
+
     g_return_if_fail (dock != NULL);
     g_return_if_fail (item != NULL);
-    
-    new_dock = GDL_DOCK (g_object_new (GDL_TYPE_DOCK, 
-                                       "master", GDL_DOCK_OBJECT_GET_MASTER (dock), 
+
+    new_dock = GDL_DOCK (g_object_new (GDL_TYPE_DOCK,
+                                       "master", GDL_DOCK_OBJECT_GET_MASTER (dock),
                                        "floating", TRUE,
                                        "width", width,
                                        "height", height,
                                        "floatx", x,
                                        "floaty", y,
                                        NULL));
-    
+
     if (gtk_widget_get_visible (GTK_WIDGET (dock))) {
         gtk_widget_show (GTK_WIDGET (new_dock));
         if (gtk_widget_get_mapped (GTK_WIDGET (dock)))
             gtk_widget_map (GTK_WIDGET (new_dock));
-        
+
         /* Make the widget resize. */
         gtk_widget_queue_resize (GTK_WIDGET (new_dock));
     }
@@ -1275,9 +1275,9 @@ gdl_dock_get_item_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);
 
@@ -1289,9 +1289,9 @@ 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);
 
@@ -1303,7 +1303,7 @@ GList *
 gdl_dock_get_named_items (GdlDock *dock)
 {
     GList *list = NULL;
-    
+
     g_return_val_if_fail (dock != NULL, NULL);
 
     gdl_dock_master_foreach (GDL_DOCK_OBJECT_GET_MASTER (dock),
@@ -1316,7 +1316,7 @@ GdlDock *
 gdl_dock_object_get_toplevel (GdlDockObject *object)
 {
     GdlDockObject *parent = object;
-    
+
     g_return_val_if_fail (object != NULL, NULL);
 
     while (parent && !GDL_IS_DOCK (parent))
@@ -1326,25 +1326,25 @@ gdl_dock_object_get_toplevel (GdlDockObject *object)
 }
 
 void
-gdl_dock_xor_rect (GdlDock      *dock,
-                   cairo_rectangle_int_t *rect)
+gdl_dock_show_preview (GdlDock      *dock,
+                       cairo_rectangle_int_t *rect)
 {
     gint x, y;
     GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (dock));
     gdk_window_get_origin (window, &x, &y);
-    
+
     if (!dock->priv->area_window) {
         dock->priv->area_window = gdl_preview_window_new ();
     }
 
     rect->x += x;
     rect->y += y;
-    
+
     gdl_preview_window_update (GDL_PREVIEW_WINDOW (dock->priv->area_window), rect);
 }
 
 void
-gdl_dock_xor_rect_hide (GdlDock      *dock)
+gdl_dock_hide_preview (GdlDock      *dock)
 {
     if (dock->priv->area_window)
         gtk_widget_hide (dock->priv->area_window);
diff --git a/gdl/gdl-dock.h b/gdl/gdl-dock.h
index 4eb01f8..348fea7 100644
--- a/gdl/gdl-dock.h
+++ b/gdl/gdl-dock.h
@@ -62,7 +62,7 @@ struct _GdlDockClass {
      GDL_DOCK_OBJECT (dock))
 
 /* public interface */
- 
+
 GtkWidget     *gdl_dock_new               (void);
 
 GtkWidget     *gdl_dock_new_from          (GdlDock          *original,
@@ -91,9 +91,9 @@ GList         *gdl_dock_get_named_items   (GdlDock    *dock);
 
 GdlDock       *gdl_dock_object_get_toplevel (GdlDockObject *object);
 
-void           gdl_dock_xor_rect            (GdlDock       *dock,
+void           gdl_dock_show_preview        (GdlDock       *dock,
                                              GdkRectangle  *rect);
-void           gdl_dock_xor_rect_hide       (GdlDock       *dock);
+void           gdl_dock_hide_preview        (GdlDock       *dock);
 
 G_END_DECLS
 



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