pidgin/pidgin

aa0e688f2f46
Parents 961691c45150
Children 943b2cb45314
Add a bunch of icon name utility functions

Testing Done:
Verified that `PidginPresenceIcon` still worked as expected.

Reviewed at https://reviews.imfreedom.org/r/891/
--- a/doc/reference/pidgin/pidgin-docs.xml Sat Aug 14 04:14:59 2021 -0500
+++ b/doc/reference/pidgin/pidgin-docs.xml Sat Aug 14 04:15:36 2021 -0500
@@ -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" />
--- a/pidgin/meson.build Sat Aug 14 04:14:59 2021 -0500
+++ b/pidgin/meson.build Sat Aug 14 04:15:36 2021 -0500
@@ -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',
--- a/pidgin/pidginicon.h Sat Aug 14 04:14:59 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/* pidgin
- *
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#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
-
-#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"
-
-#endif /* PIDGIN_ICON_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginiconname.c Sat Aug 14 04:15:36 2021 -0500
@@ -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);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginiconname.h Sat Aug 14 04:15:36 2021 -0500
@@ -0,0 +1,102 @@
+/*
+ * 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_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);
+
+/**
+ * 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);
+
+/**
+ * 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 */
--- a/pidgin/pidgininfopane.c Sat Aug 14 04:14:59 2021 -0500
+++ b/pidgin/pidgininfopane.c Sat Aug 14 04:15:36 2021 -0500
@@ -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 {
--- a/pidgin/pidginpresence.c Sat Aug 14 04:14:59 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
-}
--- a/pidgin/pidginpresence.h Sat Aug 14 04:14:59 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 */
--- a/pidgin/pidginpresenceicon.c Sat Aug 14 04:14:59 2021 -0500
+++ b/pidgin/pidginpresenceicon.c Sat Aug 14 04:15:36 2021 -0500
@@ -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);
}
--- a/po/POTFILES.in Sat Aug 14 04:14:59 2021 -0500
+++ b/po/POTFILES.in Sat Aug 14 04:15:36 2021 -0500
@@ -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