[Xfce4-commits] <midori:master> Implement context menu in menu items, forward buttons from the menubar

Christian Dywan noreply at xfce.org
Sun Dec 13 16:02:02 CET 2009


Updating branch refs/heads/master
         to d2d5bf33b642a23e3e711f7a85bbcf7f16dd5b5c (commit)
       from 2733ae4f2eecd475bcb0ea8325705525524cf304 (commit)

commit d2d5bf33b642a23e3e711f7a85bbcf7f16dd5b5c
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Dec 13 15:44:02 2009 +0100

    Implement context menu in menu items, forward buttons from the menubar

 midori/midori-browser.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index ae3e516..87196f7 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -2961,6 +2961,12 @@ _action_tools_populate_popup (GtkAction*     action,
     }
 }
 
+static void
+midori_browser_bookmark_popup (GtkWidget*      widget,
+                               GdkEventButton* event,
+                               KatzeItem*      item,
+                               MidoriBrowser*  browser);
+
 static gboolean
 _action_menus_activate_item_alt (GtkAction*     action,
                                  KatzeItem*     item,
@@ -2974,6 +2980,13 @@ _action_menus_activate_item_alt (GtkAction*     action,
 
         return TRUE;
     }
+    else if (button == 3)
+    {
+        GdkEvent* event = gtk_get_current_event ();
+        midori_browser_bookmark_popup (gtk_get_event_widget (event),
+            (GdkEventButton*)event, item, browser);
+        return TRUE;
+    }
 
     return FALSE;
 }
@@ -3992,15 +4005,25 @@ midori_browser_menu_button_press_event_cb (GtkWidget*      toolitem,
                                            GdkEventButton* event,
                                            MidoriBrowser*  browser)
 {
-    if (event->button == 3)
+    /* GtkMenuBar catches button events on children with submenus,
+       so we need to see if the actual widget is the menubar, and if
+       it is an item, we forward it to the actual widget. */
+    toolitem = gtk_get_event_widget ((GdkEvent*)event);
+
+    if (GTK_IS_MENU_BAR (toolitem) && event->button == 3)
     {
         midori_browser_toolbar_popup_context_menu_cb (
             GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ?
                 gtk_widget_get_parent (toolitem) : toolitem,
             event->x, event->y, event->button, browser);
-
         return TRUE;
     }
+    else if (GTK_IS_MENU_ITEM (toolitem) && event->button == 3)
+    {
+        gboolean handled;
+        g_signal_emit_by_name (toolitem, "button-press-event", event, &handled);
+        return handled;
+    }
     return FALSE;
 }
 



More information about the Xfce4-commits mailing list