We have this code in ephy-window.c; it should probably be upstreamed into WebKitContextMenu. /* FIXME: Add webkit_context_menu_find() ? */ static WebKitContextMenuItem * find_item_in_context_menu (WebKitContextMenu *context_menu, WebKitContextMenuAction action) { GList *items, *iter; items = webkit_context_menu_get_items (context_menu); for (iter = items; iter; iter = g_list_next (iter)) { WebKitContextMenuItem *item = (WebKitContextMenuItem *)iter->data; if (webkit_context_menu_item_get_stock_action (item) == action) return g_object_ref (item); } return NULL; }
It's written by Carlos Garcia, so we have no copyright issues, but let's have Carlos give final review on this as a formality.
Well, this is very specific to what we need in ephy, as a general purpose API we should probably use a compare function as argument instead of searching by stock action unconditionally. And maybe a flag to indicate whether we want to search for the item in submenus or not