Hello, I would like to edit the right click context menu from a webextension. 
The problem is best described through code:

static void open_adblock_settings(GSimpleAction *action, GVariant *parameter, 
gpointer user_data)
{
g_print("Opened settings\n");
}

static gboolean context_menu_opened_callback(WebKitWebPage *web_page, 
WebKitContextMenu *context_menu, WebKitWebHitTestResult *hit_test_result, 
gpointer user_data)
{
g_print("Context menu opened\n");

webkit_context_menu_append(context_menu, 
webkit_context_menu_item_new_separator());

GSimpleAction *action = g_simple_action_new("open-settings", NULL);
g_signal_connect(action, "activate", G_CALLBACK(open_adblock_settings), NULL);

WebKitContextMenuItem *item = 
webkit_context_menu_item_new_from_gaction(G_ACTION(action), "Settings", NULL);
webkit_context_menu_append(context_menu, item);

return TRUE;
}

The context menu gets updated, but when I click on the "Settings" item nothing 
happens. However, if I activate the action manually through g_action_activate 
the "Opened settings" message gets printed just as it should. 
webkit_context_menu_item_new_from_stock_action also works, so it makes me 
wonder if it could be a bug with webkit_context_menu_item_new_from_gaction or 
if I just made a silly mistake. Here's the rest of the code for a full picture: 
https://github.com/dudik/blockit/blob/ec1f1e94b57389f53525c07f4893a7bc8fa64655/blockit.c#L75
 It's small, but if it's not clear enough I can also write a minimal working 
example if needed. Thanks in advance.
_______________________________________________
webkit-gtk mailing list
webkit-gtk@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-gtk

Reply via email to