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

This commit is contained in:
Christian Dywan 2009-12-13 15:44:02 +01:00
parent 2733ae4f2e
commit d2d5bf33b6

View 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 static gboolean
_action_menus_activate_item_alt (GtkAction* action, _action_menus_activate_item_alt (GtkAction* action,
KatzeItem* item, KatzeItem* item,
@ -2974,6 +2980,13 @@ _action_menus_activate_item_alt (GtkAction* action,
return TRUE; 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; return FALSE;
} }
@ -3992,15 +4005,25 @@ midori_browser_menu_button_press_event_cb (GtkWidget* toolitem,
GdkEventButton* event, GdkEventButton* event,
MidoriBrowser* browser) 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 ( midori_browser_toolbar_popup_context_menu_cb (
GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ? GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ?
gtk_widget_get_parent (toolitem) : toolitem, gtk_widget_get_parent (toolitem) : toolitem,
event->x, event->y, event->button, browser); event->x, event->y, event->button, browser);
return TRUE; 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; return FALSE;
} }