pidgin/pidgin

Fix actions in PidginPluginsMenu

18 months ago, Gary Kramlich
55aaac83f315
Parents 9d2735c0e848
Children 4f86a754ed7b
Fix actions in PidginPluginsMenu

The issue was that G_MENU_ATTRIBUTE_ACTION_NAMESPACE only works if the menu
item is a section. So we create a new menu and add the plugins menu to it in
a section that has the property set and everything works.

Testing Done:
Used the actions from idle maker.

Bugs closed: PIDGIN-17708

Reviewed at https://reviews.imfreedom.org/r/2056/
--- a/pidgin/pidginpluginsmenu.c Wed Nov 09 23:15:35 2022 -0600
+++ b/pidgin/pidginpluginsmenu.c Thu Nov 10 23:11:29 2022 -0600
@@ -166,10 +166,6 @@
g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_LABEL,
g_variant_ref_sink(value));
- value = g_variant_new_string(gplugin_plugin_info_get_id(info));
- g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_ACTION_NAMESPACE,
- g_variant_ref_sink(value));
-
g_object_unref(info);
}
@@ -194,9 +190,23 @@
info = gplugin_plugin_get_info(plugin);
purple_info = PURPLE_PLUGIN_INFO(info);
+ /* We need to use a section for the ACTION_NAMESPACE attribute to work, so
+ * create a menu, and add a new section item to it with the menu from the
+ * plugin, then set the ACTION_NAMESPACE attribute. Finally return the menu
+ * as the submenu.
+ */
actions_model = purple_plugin_info_get_action_menu(purple_info);
if(G_IS_MENU_MODEL(actions_model)) {
- g_hash_table_insert(*links, G_MENU_LINK_SUBMENU, actions_model);
+ GMenu *menu = NULL;
+ GMenuItem *section = NULL;
+
+ menu = g_menu_new();
+ section = g_menu_item_new_section(NULL, actions_model);
+ g_menu_item_set_attribute(section, G_MENU_ATTRIBUTE_ACTION_NAMESPACE,
+ "s", gplugin_plugin_info_get_id(info));
+ g_menu_append_item(menu, section);
+
+ g_hash_table_insert(*links, G_MENU_LINK_SUBMENU, menu);
}
g_object_unref(info);