From d2d5bf33b642a23e3e711f7a85bbcf7f16dd5b5c Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 13 Dec 2009 15:44:02 +0100 Subject: [PATCH] Implement context menu in menu items, forward buttons from the menubar --- midori/midori-browser.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index ae3e516b..87196f71 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; }