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 @@
@@ -55,7 +56,6 @@
'pidginprotocolchooser.c',
@@ -115,7 +115,7 @@
@@ -125,7 +125,6 @@
'pidginprotocolchooser.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 is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * 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"
-#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 + * 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" +/****************************************************************************** + *****************************************************************************/ +pidgin_icon_name_from_status_primitive(PurpleStatusPrimitive primitive, + case PURPLE_STATUS_OFFLINE: + return "pidgin-user-offline"; + case PURPLE_STATUS_AVAILABLE: + return "pidgin-user-available"; + case PURPLE_STATUS_UNAVAILABLE: + return "pidgin-user-unavailable"; + case PURPLE_STATUS_AWAY: + return "pidgin-user-away"; + case PURPLE_STATUS_INVISIBLE: + return "pidgin-user-invisible"; + case PURPLE_STATUS_EXTENDED_AWAY: + return "pidgin-user-extended-away"; + case PURPLE_STATUS_MOBILE: + case PURPLE_STATUS_TUNE: + case PURPLE_STATUS_MOOD: + case PURPLE_STATUS_UNSET: +pidgin_icon_name_from_status_type(PurpleStatusType *type, const gchar *fallback) + PurpleStatusPrimitive primitive; + primitive = purple_status_type_get_primitive(type); + return pidgin_icon_name_from_status_primitive(primitive, fallback); +pidgin_icon_name_from_status(PurpleStatus *status, const gchar *fallback) { + PurpleStatusType *type = NULL; + if(!PURPLE_IS_STATUS(status)) { + type = purple_status_get_status_type(status); + return pidgin_icon_name_from_status_type(type, fallback); +pidgin_icon_name_from_presence(PurplePresence *presence, const gchar *fallback) + PurpleStatus *status = NULL; + if(!PURPLE_IS_PRESENCE(presence)) { + 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 + * 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" +#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 + * 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 + * Returns: The icon name to use for @primitive. +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. +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. +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. +const gchar *pidgin_icon_name_from_presence(PurplePresence *presence, const gchar *fallback); +#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"
--- 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
- * 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"
-/******************************************************************************
- *****************************************************************************/
-pidgin_presence_get_icon_name(PurplePresence *presence, const gchar *fallback) {
- PurpleStatus *status = NULL;
- PurpleStatusType *type = NULL;
- if(!PURPLE_IS_PRESENCE(presence)) {
- status = purple_presence_get_active_status(presence);
- if(!PURPLE_IS_STATUS(status)) {
- type = purple_status_get_status_type(status);
- switch(purple_status_type_get_primitive(type)) {
- case PURPLE_STATUS_OFFLINE:
- return "pidgin-user-offline";
- case PURPLE_STATUS_AVAILABLE:
- return "pidgin-user-available";
- case PURPLE_STATUS_UNAVAILABLE:
- return "pidgin-user-unavailable";
- case PURPLE_STATUS_AWAY:
- return "pidgin-user-away";
- case PURPLE_STATUS_INVISIBLE:
- return "pidgin-user-invisible";
- case PURPLE_STATUS_EXTENDED_AWAY:
- return "pidgin-user-extended-away";
- case PURPLE_STATUS_MOBILE:
- case PURPLE_STATUS_TUNE:
- case PURPLE_STATUS_MOOD:
- case PURPLE_STATUS_UNSET:
--- 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
- * 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"
-#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.
- * 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);
-#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 {
@@ -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/pidgininvitedialog.c
@@ -367,7 +368,6 @@
pidgin/pidginplugininfo.c
pidgin/pidginpluginsdialog.c
pidgin/pidginpluginsmenu.c
pidgin/pidginpresenceicon.c
pidgin/pidginprotocolchooser.c
pidgin/pidginprotocolstore.c