]> spindle.queued.net Git - midori/commitdiff
Implement context menu in menu items, forward buttons from the menubar
authorChristian Dywan <christian@twotoasts.de>
Sun, 13 Dec 2009 14:44:02 +0000 (15:44 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sun, 13 Dec 2009 14:44:02 +0000 (15:44 +0100)
midori/midori-browser.c

index ae3e516b516b606a2bedfc5a50863c6d125fdfaf..87196f719acd76abb965671a2f982b204ce1b7a4 100644 (file)
@@ -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;
 }