pidgin/pidgin

bd9e01f23bf4
Parents 88cf3cdfd5d9
Children 5f2110cbe878
Add item-type and n-items properties to PurpleProtocolManager

Testing Done:
Compiled

Bugs closed: PIDGIN-17856

Reviewed at https://reviews.imfreedom.org/r/3062/
--- a/libpurple/purpleprotocolmanager.c Tue Apr 09 22:49:24 2024 -0500
+++ b/libpurple/purpleprotocolmanager.c Tue Apr 09 22:52:27 2024 -0500
@@ -28,6 +28,14 @@
#include "purpleprotocolactions.h"
enum {
+ PROP_0,
+ PROP_ITEM_TYPE,
+ PROP_N_ITEMS,
+ N_PROPERTIES,
+};
+static GParamSpec *properties[N_PROPERTIES] = {NULL, };
+
+enum {
SIG_REGISTERED,
SIG_UNREGISTERED,
SIG_ACCOUNT_ACTIONS_CHANGED,
@@ -112,6 +120,27 @@
}
static void
+purple_protocol_manager_get_property(GObject *obj, guint param_id,
+ GValue *value, GParamSpec *pspec)
+{
+ PurpleProtocolManager *manager = PURPLE_PROTOCOL_MANAGER(obj);
+
+ switch(param_id) {
+ case PROP_ITEM_TYPE:
+ g_value_set_gtype(value,
+ purple_protocol_manager_get_item_type(G_LIST_MODEL(manager)));
+ break;
+ case PROP_N_ITEMS:
+ g_value_set_uint(value,
+ purple_protocol_manager_get_n_items(G_LIST_MODEL(manager)));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+ break;
+ }
+}
+
+static void
purple_protocol_manager_init(PurpleProtocolManager *manager) {
manager->protocols = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
g_object_unref);
@@ -123,6 +152,35 @@
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
obj_class->finalize = purple_protocol_manager_finalize;
+ obj_class->get_property = purple_protocol_manager_get_property;
+
+ /**
+ * PurpleProtocolManager:item-type:
+ *
+ * The type of items. See [iface@Gio.ListModel.get_item_type].
+ *
+ * Since: 3.0
+ */
+ properties[PROP_ITEM_TYPE] = g_param_spec_gtype(
+ "item-type", "item-type",
+ "The type of the contained items.",
+ G_TYPE_OBJECT,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * PurpleProtocolManager:n-items:
+ *
+ * The number of items. See [iface@Gio.ListModel.get_n_items].
+ *
+ * Since: 3.0
+ */
+ properties[PROP_N_ITEMS] = g_param_spec_uint(
+ "n-items", "n-items",
+ "The number of contained items.",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
/**
* PurpleProtocolManager::registered: