Add a connection parameter to the PurpleProtocolActions.get_menu virtual function
This is necessary so that protocols can dynamically add menu items for specific
accounts. This could be something like adding administrator actions after the
protocol has determined that you're an administrator for example.
Testing Done:
Connected an xmpp, ircv3, and demo account and verified all of their actions were displayed properly.
Reviewed at https://reviews.imfreedom.org/r/2172/
--- a/libpurple/protocols/demo/purpledemoprotocolactions.c Thu Jan 05 21:14:08 2023 -0600
+++ b/libpurple/protocols/demo/purpledemoprotocolactions.c Thu Jan 05 22:39:17 2023 -0600
@@ -222,7 +222,8 @@
-purple_demo_protocol_get_menu(G_GNUC_UNUSED PurpleProtocolActions *actions)
+purple_demo_protocol_get_menu(G_GNUC_UNUSED PurpleProtocolActions *actions, + G_GNUC_UNUSED PurpleConnection *connection) --- a/libpurple/protocols/gg/gg.c Thu Jan 05 21:14:08 2023 -0600
+++ b/libpurple/protocols/gg/gg.c Thu Jan 05 22:39:17 2023 -0600
@@ -1167,7 +1167,8 @@
-ggp_protocol_actions_get_menu(PurpleProtocolActions *actions) {
+ggp_protocol_actions_get_menu(G_GNUC_UNUSED PurpleProtocolActions *actions, + G_GNUC_UNUSED PurpleConnection *connection) { GMenu *menu = NULL, *submenu = NULL;
--- a/libpurple/protocols/irc/irc.c Thu Jan 05 21:14:08 2023 -0600
+++ b/libpurple/protocols/irc/irc.c Thu Jan 05 22:39:17 2023 -0600
@@ -473,7 +473,9 @@
-irc_protocol_actions_get_menu(PurpleProtocolActions *actions) {
+irc_protocol_actions_get_menu(G_GNUC_UNUSED PurpleProtocolActions *actions, + G_GNUC_UNUSED PurpleConnection *connection) --- a/libpurple/protocols/jabber/jabber.c Thu Jan 05 21:14:08 2023 -0600
+++ b/libpurple/protocols/jabber/jabber.c Thu Jan 05 22:39:17 2023 -0600
@@ -2058,7 +2058,9 @@
-xmpp_protocol_actions_get_menu(G_GNUC_UNUSED PurpleProtocolActions *actions) {
+xmpp_protocol_actions_get_menu(G_GNUC_UNUSED PurpleProtocolActions *actions, + G_GNUC_UNUSED PurpleConnection *connection) --- a/libpurple/purpleprotocolactions.c Thu Jan 05 21:14:08 2023 -0600
+++ b/libpurple/purpleprotocolactions.c Thu Jan 05 22:39:17 2023 -0600
@@ -72,7 +72,8 @@
-purple_protocol_actions_get_menu(PurpleProtocolActions *actions)
+purple_protocol_actions_get_menu(PurpleProtocolActions *actions, + PurpleConnection *connection) PurpleProtocolActionsInterface *iface = NULL;
@@ -80,7 +81,7 @@
iface = PURPLE_PROTOCOL_ACTIONS_GET_IFACE(actions);
if(iface != NULL && iface->get_menu != NULL) {
- return iface->get_menu(actions);
+ return iface->get_menu(actions, connection); --- a/libpurple/purpleprotocolactions.h Thu Jan 05 21:14:08 2023 -0600
+++ b/libpurple/purpleprotocolactions.h Thu Jan 05 22:39:17 2023 -0600
@@ -73,7 +73,7 @@
GActionGroup *(*get_action_group)(PurpleProtocolActions *actions, PurpleConnection *connection);
- GMenu *(*get_menu)(PurpleProtocolActions *actions);
+ GMenu *(*get_menu)(PurpleProtocolActions *actions, PurpleConnection *connection); @@ -109,14 +109,15 @@
* purple_protocol_actions_get_menu:
* @actions: The [iface@ProtocolActions] instance.
+ * @connection: (nullable): The [class@Connection] instance. - * Gets the menu used to display the protocol actions.
+ * Gets the menu used to display the protocol actions for @connection. * Returns: (transfer full): The menu to display or %NULL.
-GMenu *purple_protocol_actions_get_menu(PurpleProtocolActions *actions);
+GMenu *purple_protocol_actions_get_menu(PurpleProtocolActions *actions, PurpleConnection *connection); --- a/pidgin/pidginaccountsenabledmenu.c Thu Jan 05 21:14:08 2023 -0600
+++ b/pidgin/pidginaccountsenabledmenu.c Thu Jan 05 22:39:17 2023 -0600
@@ -258,7 +258,7 @@
PurpleProtocolActions *actions = PURPLE_PROTOCOL_ACTIONS(protocol);
GMenu *protocol_menu = NULL;
- protocol_menu = purple_protocol_actions_get_menu(actions);
+ protocol_menu = purple_protocol_actions_get_menu(actions, connection); if(G_IS_MENU(protocol_menu)) {
g_menu_insert_section(submenu, 1, NULL,
G_MENU_MODEL(protocol_menu));