Add a pidgin_icon_name_from_presence_primitive

Sat, 04 Nov 2023 16:13:48 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sat, 04 Nov 2023 16:13:48 -0500
changeset 42476
5b5e6297cd31
parent 42475
ce06ca18db9b
child 42477
89b3308fc82f

Add a pidgin_icon_name_from_presence_primitive

Update pidgin_icon_name_from_presence to use the new function as well so we can
continue transitioning to the new presence system.

Testing Done:
Compiled and verified the ui looked okay.

Reviewed at https://reviews.imfreedom.org/r/2777/

pidgin/pidginiconname.c file | annotate | diff | comparison | revisions
pidgin/pidginiconname.h file | annotate | diff | comparison | revisions
--- a/pidgin/pidginiconname.c	Fri Nov 03 00:50:51 2023 -0500
+++ b/pidgin/pidginiconname.c	Sat Nov 04 16:13:48 2023 -0500
@@ -87,16 +87,44 @@
 	return pidgin_icon_name_from_status_type(type, fallback);
 }
 
-const gchar *
-pidgin_icon_name_from_presence(PurplePresence *presence, const gchar *fallback)
+const char *
+pidgin_icon_name_from_presence_primitive(PurplePresencePrimitive primitive,
+                                         const char *fallback)
 {
-	PurpleStatus *status = NULL;
-
-	if(!PURPLE_IS_PRESENCE(presence)) {
-		return fallback;
+	switch(primitive) {
+	case PURPLE_PRESENCE_PRIMITIVE_OFFLINE:
+		return "pidgin-user-offline";
+		break;
+	case PURPLE_PRESENCE_PRIMITIVE_AVAILABLE:
+		return "pidgin-user-available";
+		break;
+	case PURPLE_PRESENCE_PRIMITIVE_IDLE:
+		return "pidgin-user-unavailable";
+		break;
+	case PURPLE_PRESENCE_PRIMITIVE_INVISIBLE:
+		return "pidgin-user-invisible";
+		break;
+	case PURPLE_PRESENCE_PRIMITIVE_AWAY:
+		return "pidgin-user-away";
+		break;
+	case PURPLE_PRESENCE_PRIMITIVE_EXTENDED_AWAY:
+		return "pidgin-user-extended-away";
+		break;
+	case PURPLE_PRESENCE_PRIMITIVE_STREAMING:
+		/* TODO: get an icon for streaming. */
+	default:
+		break;
 	}
 
-	status = purple_presence_get_active_status(presence);
+	return fallback;
+}
 
-	return pidgin_icon_name_from_status(status, fallback);
+const char *
+pidgin_icon_name_from_presence(PurplePresence *presence, const char *fallback)
+{
+	PurplePresencePrimitive primitive;
+
+	primitive = purple_presence_get_primitive(presence);
+
+	return pidgin_icon_name_from_presence_primitive(primitive, fallback);
 }
--- a/pidgin/pidginiconname.h	Fri Nov 03 00:50:51 2023 -0500
+++ b/pidgin/pidginiconname.h	Sat Nov 04 16:13:48 2023 -0500
@@ -79,6 +79,21 @@
 const gchar *pidgin_icon_name_from_status(PurpleStatus *status, const gchar *fallback);
 
 /**
+ * pidgin_icon_name_from_presence_primitive:
+ * @primitive: The [enum@Purple.PresencePrimitive].
+ * @fallback: The icon name to fall back to.
+ *
+ * Gets the icon name that should be used to represent @primitive. If the value
+ * is unknown @fallback will be returned.
+ *
+ * Returns: (nullable): The icon name to use or @fallback.
+ *
+ * Since: 3.0.0
+ */
+PIDGIN_AVAILABLE_IN_3_0
+const char *pidgin_icon_name_from_presence_primitive(PurplePresencePrimitive primitive, const char *fallback);
+
+/**
  * pidgin_icon_name_from_presence:
  * @presence: The #PurplePresence instance.
  * @fallback: The icon name to fall back to.
@@ -91,7 +106,7 @@
  * Since: 3.0.0
  */
 PIDGIN_AVAILABLE_IN_3_0
-const gchar *pidgin_icon_name_from_presence(PurplePresence *presence, const gchar *fallback);
+const char *pidgin_icon_name_from_presence(PurplePresence *presence, const char *fallback);
 
 G_END_DECLS
 

mercurial