Bug 159630

Summary: [GTK] Add webkit_context_menu_find API
Product: WebKit Reporter: Michael Catanzaro <mcatanzaro>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bugs-noreply, cgarcia, mcatanzaro
Priority: P2    
Version: Other   
Hardware: PC   
OS: Linux   

Description Michael Catanzaro 2016-07-11 10:08:32 PDT
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;
}
Comment 1 Michael Catanzaro 2016-07-11 10:16:42 PDT
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.
Comment 2 Carlos Garcia Campos 2016-07-13 00:03:43 PDT
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