[Xfce4-commits] <midori:master> Fix katze_widget_popup_position_menu for GTK+

Christian Dywan noreply at xfce.org
Mon Feb 20 23:04:01 CET 2012


Updating branch refs/heads/master
         to 7af5019d862d62147fdd747b0a62d3513f9f6f16 (commit)
       from 79b29a9362fad97754471f8152aaf8ae1d1880ac (commit)

commit 7af5019d862d62147fdd747b0a62d3513f9f6f16
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Feb 20 23:02:21 2012 +0100

    Fix katze_widget_popup_position_menu for GTK+
    
    The window NULL-check was wrong in any case. The
    key issue here is that GtkEntry internals changed
    in GTK+3 and we need to take that into account.

 katze/katze-utils.c |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/katze/katze-utils.c b/katze/katze-utils.c
index 25def2d..3c211aa 100644
--- a/katze/katze-utils.c
+++ b/katze/katze-utils.c
@@ -910,21 +910,29 @@ katze_widget_popup_position_menu (GtkMenu*  menu,
     GtkRequisition widget_req;
     KatzePopupInfo* info = user_data;
     GtkWidget* widget = info->widget;
+    GdkWindow* window = gtk_widget_get_window (widget);
     gint widget_height;
 
-    gtk_widget_get_allocation (widget, &allocation);
+    if (!window)
+        return;
+
+    #if !GTK_CHECK_VERSION (3, 0, 0)
+    if (GTK_IS_ENTRY (widget))
+        window = gdk_window_get_parent (window);
+    #endif
 
     /* Retrieve size and position of both widget and menu */
-    if (!gtk_widget_get_has_window (widget))
-    {
-        gdk_window_get_position (gtk_widget_get_window (widget), &wx, &wy);
-        wx += allocation.x;
-        wy += allocation.y;
-    }
-    else
-        gdk_window_get_origin (gtk_widget_get_window (widget), &wx, &wy);
+    gtk_widget_get_allocation (widget, &allocation);
+    gdk_window_get_origin (window, &wx, &wy);
+    wx += allocation.x;
+    wy += allocation.y;
+    #if GTK_CHECK_VERSION (3, 0, 0)
+    gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
+    gtk_widget_get_preferred_size (widget, &widget_req, NULL);
+    #else
     gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
     gtk_widget_size_request (widget, &widget_req);
+    #endif
     menu_width = menu_req.width;
     widget_height = widget_req.height; /* Better than allocation.height */
 


More information about the Xfce4-commits mailing list