# HG changeset patch
# Node ID df7a0fc51577
# Parent  f8cb01c54b84
diff --git a/doc/reference/pidgin/pidgin-docs.xml b/doc/reference/pidgin/pidgin-docs.xml
--- a/doc/reference/pidgin/pidgin-docs.xml
+++ b/doc/reference/pidgin/pidgin-docs.xml
@@ -68,7 +68,7 @@
       <xi:include href="xml/pidgindebug.xml" />
       <xi:include href="xml/pidgindialog.xml" />
       <xi:include href="xml/pidgingdkpixbuf.xml" />
-      <xi:include href="xml/pidginicon.xml" />
+      <xi:include href="xml/pidginiconname.xml" />
       <xi:include href="xml/pidgininfopane.xml" />
       <xi:include href="xml/pidgininvitedialog.xml" />
       <xi:include href="xml/pidginlog.xml" />
@@ -79,7 +79,6 @@
       <xi:include href="xml/pidginpluginsdialog.xml" />
       <xi:include href="xml/pidginpluginsmenu.xml" />
       <xi:include href="xml/pidginprefs.xml" />
-      <xi:include href="xml/pidginpresence.xml" />
       <xi:include href="xml/pidginpresenceicon.xml" />
       <xi:include href="xml/pidginprotocolchooser.xml" />
       <xi:include href="xml/pidginprotocolstore.xml" />
diff --git a/pidgin/meson.build b/pidgin/meson.build
--- a/pidgin/meson.build
+++ b/pidgin/meson.build
@@ -46,6 +46,7 @@
 	'pidgindebug.c',
 	'pidgindialog.c',
 	'pidgingdkpixbuf.c',
+	'pidginiconname.c',
 	'pidgininfopane.c',
 	'pidgininvitedialog.c',
 	'pidginlog.c',
@@ -55,7 +56,6 @@
 	'pidginplugininfo.c',
 	'pidginpluginsdialog.c',
 	'pidginpluginsmenu.c',
-	'pidginpresence.c',
 	'pidginpresenceicon.c',
 	'pidginprotocolchooser.c',
 	'pidginprotocolstore.c',
@@ -115,7 +115,7 @@
 	'pidgindialog.h',
 	'pidgindebug.h',
 	'pidgingdkpixbuf.h',
-	'pidginicon.h',
+	'pidginiconname.h',
 	'pidgininfopane.h',
 	'pidgininvitedialog.h',
 	'pidginlog.h',
@@ -125,7 +125,6 @@
 	'pidginplugininfo.h',
 	'pidginpluginsdialog.h',
 	'pidginpluginsmenu.h',
-	'pidginpresence.h',
 	'pidginpresenceicon.h',
 	'pidginprotocolchooser.h',
 	'pidginprotocolstore.h',
diff --git a/pidgin/pidginicon.h b/pidgin/pidginiconname.h
rename from pidgin/pidginicon.h
rename to pidgin/pidginiconname.h
--- a/pidgin/pidginicon.h
+++ b/pidgin/pidginiconname.h
@@ -1,4 +1,6 @@
-/* pidgin
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
  *
  * Pidgin is the legal property of its developers, whose names are too numerous
  * to list here.  Please refer to the COPYRIGHT file distributed with this
@@ -15,21 +17,86 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
 #if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
 # error "only <pidgin.h> may be included directly"
 #endif
 
-#ifndef PIDGIN_ICON_H
-#define PIDGIN_ICON_H
+#ifndef PIDGIN_ICON_NAME_H
+#define PIDGIN_ICON_NAME_H
+
+/**
+ * SECTION:pidginiconname
+ * @section_id: pidgin-pidginiconname
+ * @title: Icon Name Utilities
+ * @short_description: Get icon names for objects.
+ *
+ * This API makes it easy to determine which icon should be used for different
+ * objects.
+ */
+
+#include <glib.h>
+
+#include <purple.h>
+
+G_BEGIN_DECLS
+
+/**
+ * pidgin_icon_name_from_status_primitive:
+ * @primitive: The #PurpleStatusPrimitive.
+ * @fallback: The icon name to return if an icon name can not be found.
+ *
+ * Gets the icon name to use for @primitive if found, otherwise returns
+ * @fallback.
+ *
+ * Returns: The icon name to use for @primitive.
+ *
+ * Since: 3.0.0
+ */
+const gchar *pidgin_icon_name_from_status_primitive(PurpleStatusPrimitive primitive, const gchar *fallback);
 
-#define PIDGIN_ICON_CAMERA_PHOTO "camera-photo"
-#define PIDGIN_ICON_CONNECT      "pidgin-connect"
-#define PIDGIN_ICON_DIALOG_INFO  "pidgin-dialog-info"
-#define PIDGIN_ICON_MAIL_NEW     "mail-message-new"
-#define PIDGIN_ICON_MESSAGE_NEW  "pidgin-im-message-new"
+/**
+ * pidgin_icon_name_from_status_type:
+ * @type: The #PurpleStatusType.
+ * @fallback: The icon name to return if an icon name can not be found.
+ *
+ * Gets the icon name to use for @type if found, otherwise returns @fallback.
+ *
+ * Returns: The icon name to use for @type.
+ *
+ * Since: 3.0.0
+ */
+const gchar *pidgin_icon_name_from_status_type(PurpleStatusType *type, const gchar *fallback);
 
-#endif /* PIDGIN_ICON_H */
+/**
+ * pidgin_icon_name_from_status:
+ * @status: The #PurpleStatus instance.
+ * @fallback: The icon name to return if an icon name can not be found.
+ *
+ * Gets the icon name to use for @status if found, otherwise returns @fallback.
+ *
+ * Returns: The icon name to use for @status.
+ *
+ * Since: 3.0.0
+ */
+const gchar *pidgin_icon_name_from_status(PurpleStatus *status, const gchar *fallback);
+
+/**
+ * pidgin_icon_name_from_presence:
+ * @presence: The #PurplePresence instance.
+ * @fallback: The icon name to fall back to.
+ *
+ * Gets the icon name that should be used to represent @presence falling back
+ * to @fallback if @presence is invalid.
+ *
+ * Returns: The icon name to represent @presence.
+ *
+ * Since: 3.0.0
+ */
+const gchar *pidgin_icon_name_from_presence(PurplePresence *presence, const gchar *fallback);
+
+G_END_DECLS
+
+#endif /* PIDGIN_ICON_NAME_H */
diff --git a/pidgin/pidginiconname.c b/pidgin/pidginiconname.c
new file mode 100644
--- /dev/null
+++ b/pidgin/pidginiconname.c
@@ -0,0 +1,104 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "pidginiconname.h"
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+const gchar *
+pidgin_icon_name_from_status_primitive(PurpleStatusPrimitive primitive,
+                                       const gchar *fallback)
+{
+	switch(primitive) {
+		case PURPLE_STATUS_OFFLINE:
+			return "pidgin-user-offline";
+			break;
+		case PURPLE_STATUS_AVAILABLE:
+			return "pidgin-user-available";
+			break;
+		case PURPLE_STATUS_UNAVAILABLE:
+			return "pidgin-user-unavailable";
+			break;
+		case PURPLE_STATUS_AWAY:
+			return "pidgin-user-away";
+			break;
+		case PURPLE_STATUS_INVISIBLE:
+			return "pidgin-user-invisible";
+			break;
+		case PURPLE_STATUS_EXTENDED_AWAY:
+			return "pidgin-user-extended-away";
+			break;
+		case PURPLE_STATUS_MOBILE:
+		case PURPLE_STATUS_TUNE:
+		case PURPLE_STATUS_MOOD:
+		case PURPLE_STATUS_UNSET:
+		default:
+			break;
+	}
+
+	return fallback;
+}
+
+const gchar *
+pidgin_icon_name_from_status_type(PurpleStatusType *type, const gchar *fallback)
+{
+	PurpleStatusPrimitive primitive;
+
+	if(type == NULL) {
+		return fallback;
+	}
+
+	primitive = purple_status_type_get_primitive(type);
+
+	return pidgin_icon_name_from_status_primitive(primitive, fallback);
+}
+
+const gchar *
+pidgin_icon_name_from_status(PurpleStatus *status, const gchar *fallback) {
+	PurpleStatusType *type = NULL;
+
+	if(!PURPLE_IS_STATUS(status)) {
+		return fallback;
+	}
+
+	type = purple_status_get_status_type(status);
+	if(type == NULL) {
+		return fallback;
+	}
+
+	return pidgin_icon_name_from_status_type(type, fallback);
+}
+
+const gchar *
+pidgin_icon_name_from_presence(PurplePresence *presence, const gchar *fallback)
+{
+	PurpleStatus *status = NULL;
+
+	if(!PURPLE_IS_PRESENCE(presence)) {
+		return fallback;
+	}
+
+	status = purple_presence_get_active_status(presence);
+
+	return pidgin_icon_name_from_status(status, fallback);
+}
diff --git a/pidgin/pidgininfopane.c b/pidgin/pidgininfopane.c
--- a/pidgin/pidgininfopane.c
+++ b/pidgin/pidgininfopane.c
@@ -26,7 +26,6 @@
 #include "pidgin/gtkutils.h"
 #include "pidgin/pidginavatar.h"
 #include "pidgin/pidgincore.h"
-#include "pidgin/pidginpresence.h"
 #include "pidgin/pidginpresenceicon.h"
 
 struct _PidginInfoPane {
diff --git a/pidgin/pidginpresence.h b/pidgin/pidginpresence.h
deleted file mode 100644
--- a/pidgin/pidginpresence.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Pidgin - Internet Messenger
- * Copyright (C) Pidgin Developers <devel@pidgin.im>
- *
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here.  Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
-# error "only <pidgin.h> may be included directly"
-#endif
-
-#ifndef PIDGIN_PRESENCE_H
-#define PIDGIN_PRESENCE_H
-
-/**
- * SECTION:pidginpresence
- * @section_id: pidgin-presence
- * @short_description: Presence Utilities
- * @title: Presence Utility Functions
- *
- * Displaying #PurplePresence's can be tricky.  These functions make it easier.
- */
-
-#include <gtk/gtk.h>
-
-#include <purple.h>
-
-G_BEGIN_DECLS
-
-/**
- * pidgin_presence_get_icon_name:
- * @presence: The #PurplePresence instance.
- * @fallback: The icon name to fall back to.
- *
- * Gets the icon name that should be used to represent @presence falling back
- * to @fallback if @presence is invalid.
- *
- * Returns: The icon name to represent @presence.
- */
-const gchar *pidgin_presence_get_icon_name(PurplePresence *presence, const gchar *fallback);
-
-G_END_DECLS
-
-#endif /* PIDGIN_PRESENCE_H */
diff --git a/pidgin/pidginpresence.c b/pidgin/pidginpresence.c
deleted file mode 100644
--- a/pidgin/pidginpresence.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Pidgin - Internet Messenger
- * Copyright (C) Pidgin Developers <devel@pidgin.im>
- *
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here.  Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#include "pidgin/pidginpresence.h"
-
-/******************************************************************************
- * Public API
- *****************************************************************************/
-const gchar *
-pidgin_presence_get_icon_name(PurplePresence *presence, const gchar *fallback) {
-	PurpleStatus *status = NULL;
-	PurpleStatusType *type = NULL;
-
-	if(!PURPLE_IS_PRESENCE(presence)) {
-		return fallback;
-	}
-
-	status = purple_presence_get_active_status(presence);
-	if(!PURPLE_IS_STATUS(status)) {
-		return fallback;
-	}
-
-	type = purple_status_get_status_type(status);
-	if(type == NULL) {
-		return fallback;
-	}
-
-	switch(purple_status_type_get_primitive(type)) {
-		case PURPLE_STATUS_OFFLINE:
-			return "pidgin-user-offline";
-			break;
-		case PURPLE_STATUS_AVAILABLE:
-			return "pidgin-user-available";
-			break;
-		case PURPLE_STATUS_UNAVAILABLE:
-			return "pidgin-user-unavailable";
-			break;
-		case PURPLE_STATUS_AWAY:
-			return "pidgin-user-away";
-			break;
-		case PURPLE_STATUS_INVISIBLE:
-			return "pidgin-user-invisible";
-			break;
-		case PURPLE_STATUS_EXTENDED_AWAY:
-			return "pidgin-user-extended-away";
-			break;
-		case PURPLE_STATUS_MOBILE:
-		case PURPLE_STATUS_TUNE:
-		case PURPLE_STATUS_MOOD:
-		case PURPLE_STATUS_UNSET:
-		default:
-			break;
-	}
-
-	return fallback;
-}
diff --git a/pidgin/pidginpresenceicon.c b/pidgin/pidginpresenceicon.c
--- a/pidgin/pidginpresenceicon.c
+++ b/pidgin/pidginpresenceicon.c
@@ -22,7 +22,7 @@
 
 #include "pidgin/pidginpresenceicon.h"
 
-#include "pidgin/pidginpresence.h"
+#include "pidgin/pidginiconname.h"
 
 struct _PidginPresenceIcon {
 	GtkImage parent;
@@ -50,7 +50,7 @@
 pidgin_presence_icon_update(PidginPresenceIcon *icon) {
 	const gchar *icon_name = NULL;
 
-	icon_name = pidgin_presence_get_icon_name(icon->presence, icon->fallback);
+	icon_name = pidgin_icon_name_from_presence(icon->presence, icon->fallback);
 
 	gtk_image_set_from_icon_name(GTK_IMAGE(icon), icon_name, icon->icon_size);
 }
diff --git a/po/POTFILES.in b/po/POTFILES.in
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -358,6 +358,7 @@
 pidgin/pidgindebug.c
 pidgin/pidgindialog.c
 pidgin/pidgingdkpixbuf.c
+pidgin/pidginiconname.c
 pidgin/pidgininfopane.c
 pidgin/pidgininvitedialog.c
 pidgin/pidginlog.c
@@ -367,7 +368,6 @@
 pidgin/pidginplugininfo.c
 pidgin/pidginpluginsdialog.c
 pidgin/pidginpluginsmenu.c
-pidgin/pidginpresence.c
 pidgin/pidginpresenceicon.c
 pidgin/pidginprotocolchooser.c
 pidgin/pidginprotocolstore.c
