[gdl] Remove a call to the deprecated gtk_button_leave() function



commit 6e1bc49dadff504aa01c1164f71dc555afa25d2f
Author: Mirsal Ennaime <mirsal ennaime gmail com>
Date:   Thu Jun 3 15:24:05 2010 +0200

    Remove a call to the deprecated gtk_button_leave() function
    
    bgo#577469
    
    This patch replaces a call to gtk_button_leave() by manually emitting
    a "leave-notify-event" signal instead (a gdk event is synthesized for
    that purpose).

 gdl/gdl-dock-item-grip.c |   49 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/gdl/gdl-dock-item-grip.c b/gdl/gdl-dock-item-grip.c
index 68eae72..1997ae9 100644
--- a/gdl/gdl-dock-item-grip.c
+++ b/gdl/gdl-dock-item-grip.c
@@ -259,6 +259,48 @@ gdl_dock_item_grip_close_clicked (GtkWidget       *widget,
     gdl_dock_item_hide_item (grip->item);
 }
 
+#if !GTK_CHECK_VERSION (2, 20, 0)
+  #define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED(widget)
+#endif /* GTK < 2.20.0 */
+
+static void
+gdl_dock_item_grip_fix_iconify_button (GdlDockItemGrip *grip)
+{
+    GtkWidget *iconify_button = grip->_priv->iconify_button;
+    GdkWindow *window = NULL;
+    GdkEvent  *event = NULL;
+
+    GdkModifierType modifiers;
+    gint x = 0, y = 0;
+    gboolean ev_ret;
+
+    g_return_if_fail (gtk_widget_get_realized (iconify_button));
+
+    window = gtk_widget_get_parent_window (iconify_button);
+    event = gdk_event_new (GDK_LEAVE_NOTIFY);
+
+    g_assert (GDK_IS_WINDOW (window));
+    gdk_window_get_pointer (window, &x, &y, &modifiers);
+
+    event->crossing.window = g_object_ref (window);
+    event->crossing.send_event = FALSE;
+    event->crossing.subwindow = g_object_ref (window);
+    event->crossing.time = GDK_CURRENT_TIME;
+    event->crossing.x = x;
+    event->crossing.y = y;
+    event->crossing.x_root = event->crossing.y_root = 0;
+    event->crossing.mode = GDK_CROSSING_STATE_CHANGED;
+    event->crossing.detail = GDK_NOTIFY_NONLINEAR;
+    event->crossing.focus = FALSE;
+    event->crossing.state = modifiers;
+
+    GTK_BUTTON (iconify_button)->in_button = FALSE;
+    g_signal_emit_by_name (iconify_button, "leave-notify-event",
+                           event, &ev_ret, 0);
+
+    gdk_event_free (event);
+}
+
 static void
 gdl_dock_item_grip_iconify_clicked (GtkWidget       *widget,
                                     GdlDockItemGrip *grip)
@@ -267,6 +309,9 @@ gdl_dock_item_grip_iconify_clicked (GtkWidget       *widget,
     
     g_return_if_fail (grip->item != NULL);
 
+    /* Workaround to unhighlight the iconify button. */
+    gdl_dock_item_grip_fix_iconify_button (grip);
+
     parent = gtk_widget_get_parent (GTK_WIDGET (grip->item));
     if (GDL_IS_SWITCHER (parent))
     {
@@ -290,10 +335,6 @@ gdl_dock_item_grip_iconify_clicked (GtkWidget       *widget,
     {
         gdl_dock_item_iconify_item (grip->item);
     }
-    
-    /* Workaround to unhighlight the iconify button. */
-    GTK_BUTTON (grip->_priv->iconify_button)->in_button = FALSE;
-    gtk_button_leave (GTK_BUTTON (grip->_priv->iconify_button));
 }
   
 static void



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