pidgin/pidgin

bb7e68da6d21
Parents 114cb45a1309
Children 9da3c24cac29
Add a hash table variant of purple_menu_populate_dynamic_targets

This makes it introspectable.

Testing Done:
Compile and run `ninja test`

Reviewed at https://reviews.imfreedom.org/r/1857/
--- a/libpurple/purplemenu.c Thu Sep 29 00:56:24 2022 -0500
+++ b/libpurple/purplemenu.c Thu Sep 29 00:57:58 2022 -0500
@@ -126,6 +126,15 @@
}
void
+purple_menu_populate_dynamic_targetsv(GMenu *menu, GHashTable *properties) {
+ g_return_if_fail(G_IS_MENU(menu));
+ g_return_if_fail(properties != NULL);
+
+ purple_menu_walk(G_MENU_MODEL(menu),
+ purple_menu_populate_dynamic_targets_func, properties);
+}
+
+void
purple_menu_populate_dynamic_targets(GMenu *menu, const gchar *first_property,
...)
{
@@ -156,8 +165,7 @@
va_end(vargs);
- purple_menu_walk(G_MENU_MODEL(menu),
- purple_menu_populate_dynamic_targets_func, table);
+ purple_menu_populate_dynamic_targetsv(menu, table);
g_hash_table_unref(table);
}
--- a/libpurple/purplemenu.h Thu Sep 29 00:56:24 2022 -0500
+++ b/libpurple/purplemenu.h Thu Sep 29 00:57:58 2022 -0500
@@ -85,6 +85,27 @@
void purple_menu_populate_dynamic_targets(GMenu *menu, const gchar *first_property, ...) G_GNUC_NULL_TERMINATED;
/**
+ * purple_menu_populate_dynamic_targetsv: (rename-to purple_menu_populate_dynamic_targets):
+ * @menu: The menu instance to modify.
+ * @properties: (element-type utf8 utf8): A hash table where the keys are the
+ * names of the properties of dynamic targets to be replaced, and
+ * the values are the replacements.
+ *
+ * Updates @menu by adding a target property when an item with an attribute
+ * named "dynamic-target" is found.
+ *
+ * The value for the target is set to the matching value from @properties.
+ *
+ * For example, if you need to set the target to an account, you would set the
+ * "dynamic-target" attribute of your menu item to "account" and then call
+ * [func@Purple.menu_populate_dynamic_targetsv] with a hash table containing
+ * the key `"account"` and value from [method@Account.get_id].
+ *
+ * Since: 3.0.0
+ */
+void purple_menu_populate_dynamic_targetsv(GMenu *menu, GHashTable *properties);
+
+/**
* purple_menu_copy:
* @model: The [class@Gio.MenuModel] instance to copy.
*