# HG changeset patch
# Node ID fbe41227df48
# Parent  1b6374960c08
diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -14,6 +14,12 @@
 	libpurple:
 		Added:
 		* displaying-emails-clear signal (notification signal)
+		* purple_gdk_pixbuf_make_round
+		* purple_gdk_pixbuf_is_opaque
+		* purple_gdk_pixbuf_from_data
+		* purple_gdk_pixbuf_from_image
+		* purple_gdk_pixbuf_new_from_file
+		* purple_gdk_pixbuf_new_from_file_at_size
 		* PurplePluginInfoFlags (PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and
 		  PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD)
 		* purple_plugin_get_dependent_plugins
@@ -737,7 +743,6 @@
 		Added:
 		* pidgin_create_webview
 		* PidginDockletFlag
-		* pidgin_gdk_pixbuf_new_from_image
 		* PidginPluginInfo, inherits PurplePluginInfo
 		* Various WebKit-related functions in gtkwebview.h
 
@@ -879,6 +884,15 @@
 		* pidgin_dialogs_alias_contact
 		* pidgin_dialogs_log
 		* pidgin_get_dim_grey_string
+		* pidgin_gdk_pixbuf_make_round, use purple_gdk_pixbuf_make_round instead.
+		* pidgin_gdk_pixbuf_is_opaque, use purple_gdk_pixbuf_is_opaque instead.
+		* pidgin_pixbuf_from_data, use purple_gdk_pixbuf_from_data instead.
+		* pidgin_pixbuf_anim_from_data
+		* pidgin_pixbuf_from_image, use purple_gdk_pixbuf_from_image instead.
+		* pidgin_pixbuf_new_from_file, use purple_gdk_pixbuf_new_from_file instead.
+		* pidgin_pixbuf_new_from_file_at_size, use purple_gdk_pixbuf_new_from_file_at_size instead.
+		* pidgin_pixbuf_new_from_file_at_scale
+		* pidgin_pixbuf_scale_down
 		* PIDGIN_ICON_SIZE_*
 		* PIDGIN_ICON_THEME
 		* PIDGIN_ICON_THEME_CLASS
diff --git a/libpurple/meson.build b/libpurple/meson.build
--- a/libpurple/meson.build
+++ b/libpurple/meson.build
@@ -51,6 +51,7 @@
 	'purplecredentialmanager.c',
 	'purplecredentialprovider.c',
 	'purpledebugui.c',
+	'purplegdkpixbuf.c',
 	'purplehistoryadapter.c',
 	'purplehistorymanager.c',
 	'purpleidleui.c',
@@ -143,6 +144,7 @@
 	'purplecredentialmanager.h',
 	'purplecredentialprovider.h',
 	'purpledebugui.h',
+	'purplegdkpixbuf.h',
 	'purplehistoryadapter.h',
 	'purplehistorymanager.h',
 	'purpleidleui.h',
@@ -295,7 +297,7 @@
                     version : PURPLE_LIB_VERSION,
                     dependencies : # static_link_libs
                         [dnsapi, ws2_32, glib, gio, gplugin_dep, libsoup,
-                         libxml, gstreamer, gstreamer_video,
+                         libxml, gdk_pixbuf, gstreamer, gstreamer_video,
                          gstreamer_app, json, sqlite3, math])
 
 install_headers(purple_coreheaders,
@@ -313,7 +315,7 @@
 # TODO: Only use purple_filebase once everything is ported to only use purple.h
     subdirs : [purple_filebase, purple_include_base],
     # NOTE: Don't use gplugin from pkgconfig, as it might be a subproject.
-    requires : [glib, 'gplugin'],
+    requires : [glib, gdk_pixbuf, 'gplugin'],
     variables : ['plugindir=${libdir}/@0@'.format(purple_filebase)])
 
 if enable_introspection
@@ -322,7 +324,7 @@
 
 	libpurple_gir = gnome.generate_gir(libpurple,
 	    sources : introspection_sources,
-	    includes : ['GLib-2.0', 'Gio-2.0', 'GObject-2.0', 'Gst-1.0', 'GPlugin-1.0'],
+	    includes : ['GdkPixbuf-2.0', 'GLib-2.0', 'Gio-2.0', 'GObject-2.0', 'Gst-1.0', 'GPlugin-1.0'],
 	    header : 'purple.h',
 	    namespace : 'Purple',
 	    symbol_prefix : 'purple',
@@ -342,7 +344,7 @@
     sources : [purple_builtheaders] + purple_generated_sources,
     include_directories : [toplevel_inc, libpurple_inc],
     link_with : libpurple,
-    dependencies : [gstreamer, gplugin_dep, glib, gio])
+    dependencies : [gdk_pixbuf, gstreamer, gplugin_dep, glib, gio])
 
 meson.override_dependency(purple_filebase, libpurple_dep)
 
diff --git a/meson.build b/meson.build
--- a/meson.build
+++ b/meson.build
@@ -222,9 +222,9 @@
 	conf.set('HAVE_IOKIT', true)
 endif
 
-# #######################################################################
-# # Check for GLib (required)
-# #######################################################################
+#######################################################################
+# Check for GLib (required)
+#######################################################################
 glib = dependency('glib-2.0', version : '>= 2.70.0')
 gio = dependency('gio-2.0')
 gobject = dependency('gobject-2.0')
@@ -237,9 +237,13 @@
 	language : 'c',)
 
 #######################################################################
+# Check for gdk-pixbuf (required)
+#######################################################################
+gdk_pixbuf = dependency('gdk-pixbuf-2.0')
+
+#######################################################################
 # Check for GObject Introspection
 #######################################################################
-
 if get_option('introspection')
 	enable_introspection = dependency('gobject-introspection-1.0', version : '>= 1.39.0').found()
 else
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -36,7 +36,6 @@
 #include "pidgincore.h"
 #include "pidgindialog.h"
 #include "minidialog.h"
-#include "pidgingdkpixbuf.h"
 #include "pidginprotocolchooser.h"
 
 enum
@@ -195,7 +194,7 @@
 	}
 
 	if (dialog->icon_img != NULL) {
-		pixbuf = pidgin_pixbuf_from_image(dialog->icon_img);
+		pixbuf = purple_gdk_pixbuf_from_image(dialog->icon_img);
 	}
 
 	if (dialog->protocol)
@@ -2153,7 +2152,7 @@
 
 	if (img != NULL) {
 		GdkPixbuf *buddyicon_pixbuf;
-		buddyicon_pixbuf = pidgin_pixbuf_from_image(img);
+		buddyicon_pixbuf = purple_gdk_pixbuf_from_image(img);
 		g_object_unref(img);
 
 		if (buddyicon_pixbuf != NULL) {
@@ -2201,7 +2200,7 @@
 
 	path = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon");
 	if(path != NULL && *path != '\0') {
-		GdkPixbuf *pixbuf = pidgin_pixbuf_new_from_file(path);
+		GdkPixbuf *pixbuf = purple_gdk_pixbuf_new_from_file(path);
 		if(pixbuf != NULL) {
 			global_buddyicon = gdk_pixbuf_scale_simple(pixbuf, 22, 22,
 			                                           GDK_INTERP_HYPER);
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -47,7 +47,6 @@
 #include "pidgin/pidgincore.h"
 #include "pidgin/pidgindebug.h"
 #include "pidgin/pidgindnd.h"
-#include "pidgin/pidgingdkpixbuf.h"
 #include "pidgin/pidginmooddialog.h"
 #include "pidgin/pidginplugininfo.h"
 #include "pidginscrollbook.h"
@@ -2499,7 +2498,7 @@
 			return NULL;
 	}
 
-	buf = pidgin_pixbuf_from_data(data, len);
+	buf = purple_gdk_pixbuf_from_data(data, len);
 	purple_buddy_icon_unref(icon);
 	if (!buf) {
 		purple_debug_warning("gtkblist", "Couldn't load buddy icon on "
@@ -2566,8 +2565,8 @@
 		tmpbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_width, scale_height);
 		gdk_pixbuf_fill(tmpbuf, 0x00000000);
 		gdk_pixbuf_scale(buf, tmpbuf, 0, 0, scale_width, scale_height, 0, 0, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR);
-		if (pidgin_gdk_pixbuf_is_opaque(tmpbuf))
-			pidgin_gdk_pixbuf_make_round(tmpbuf);
+		if (purple_gdk_pixbuf_is_opaque(tmpbuf))
+			purple_gdk_pixbuf_make_round(tmpbuf);
 		ret = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_size, scale_size);
 		gdk_pixbuf_fill(ret, 0x00000000);
 		gdk_pixbuf_copy_area(tmpbuf, 0, 0, scale_width, scale_height, ret, (scale_size-scale_width)/2, (scale_size-scale_height)/2);
@@ -3279,7 +3278,7 @@
 		g_object_ref(pb);
 		g_free(path);
 	} else {
-		pb = pidgin_pixbuf_new_from_file(path);
+		pb = purple_gdk_pixbuf_new_from_file(path);
 		if (pb != NULL) {
 			/* We don't want to own a ref to the pixbuf, but we need to keep clean up. */
 			/* I'm not sure if it would be better to just keep our ref and not let the emblem ever be destroyed */
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -53,7 +53,6 @@
 #include "pidgincolor.h"
 #include "pidginconversationwindow.h"
 #include "pidgincore.h"
-#include "pidgingdkpixbuf.h"
 #include "pidgininfopane.h"
 #include "pidgininvitedialog.h"
 #include "pidginmessage.h"
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -33,7 +33,6 @@
 #include "pidginaccountstore.h"
 #include "pidgincore.h"
 #include "pidgindialog.h"
-#include "pidgingdkpixbuf.h"
 
 #include <gdk/gdkkeysyms.h>
 
@@ -359,7 +358,7 @@
 	if (icon_data) {
 		GdkPixbuf *pixbuf;
 
-		pixbuf = pidgin_pixbuf_from_data(icon_data, icon_size);
+		pixbuf = purple_gdk_pixbuf_from_data(icon_data, icon_size);
 		if (pixbuf) {
 			/* scale the image if it is too large */
 			int width = gdk_pixbuf_get_width(pixbuf);
@@ -1311,7 +1310,7 @@
 	GtkWidget *widget;
 	GdkPixbuf *buf, *scale;
 
-	buf = pidgin_pixbuf_from_data(
+	buf = purple_gdk_pixbuf_from_data(
 			(const guchar *)purple_request_field_image_get_buffer(field),
 			purple_request_field_image_get_size(field));
 
@@ -1452,7 +1451,7 @@
 			GdkPixbuf* pixbuf = NULL;
 
 			if (icon_path)
-				pixbuf = pidgin_pixbuf_new_from_file(icon_path);
+				pixbuf = purple_gdk_pixbuf_new_from_file(icon_path);
 
 			gtk_list_store_set(store, &iter,
 			                   0, purple_request_field_list_get_data(field, text),
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -48,7 +48,6 @@
 #include "gtkstatusbox.h"
 #include "gtkutils.h"
 #include "pidgincore.h"
-#include "pidgingdkpixbuf.h"
 #include "pidginiconname.h"
 
 /* Timeout for typing notifications in seconds */
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -47,7 +47,6 @@
 #include "gtkutils.h"
 #include "minidialog.h"
 #include "pidgincore.h"
-#include "pidgingdkpixbuf.h"
 
 /******************************************************************************
  * Enums
@@ -519,7 +518,6 @@
 	gtk_tree_path_free(path);
 }
 
-
 void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleBuddyIconScaleFlags rules, int *width, int *height)
 {
 	*width = gdk_pixbuf_get_width(buf);
@@ -937,7 +935,7 @@
 	filename = gtk_file_chooser_get_preview_filename(
 					GTK_FILE_CHOOSER(dialog->icon_filesel));
 
-	if (!filename || g_stat(filename, &st) || !(pixbuf = pidgin_pixbuf_new_from_file_at_size(filename, 128, 128)))
+	if (!filename || g_stat(filename, &st) || !(pixbuf = purple_gdk_pixbuf_new_from_file_at_size(filename, 128, 128)))
 	{
 		gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), NULL);
 		gtk_label_set_markup(GTK_LABEL(dialog->icon_text), "");
diff --git a/pidgin/gtkxfer.c b/pidgin/gtkxfer.c
--- a/pidgin/gtkxfer.c
+++ b/pidgin/gtkxfer.c
@@ -28,7 +28,6 @@
 #include "gtkxfer.h"
 #include "gtkutils.h"
 #include "pidgincore.h"
-#include "pidgingdkpixbuf.h"
 
 #ifdef _WIN32
 #  include <shellapi.h>
@@ -835,7 +834,7 @@
 
 	if (purple_xfer_get_size(xfer) <= PIDGIN_XFER_MAX_SIZE_IMAGE_THUMBNAIL) {
 		GdkPixbuf *thumbnail =
-			pidgin_pixbuf_new_from_file_at_size(
+			purple_gdk_pixbuf_new_from_file_at_size(
 					purple_xfer_get_local_filename(xfer), 128, 128);
 
 		if (thumbnail) {
diff --git a/pidgin/meson.build b/pidgin/meson.build
--- a/pidgin/meson.build
+++ b/pidgin/meson.build
@@ -39,7 +39,6 @@
 	'pidgindebug.c',
 	'pidgindialog.c',
 	'pidgindnd.c',
-	'pidgingdkpixbuf.c',
 	'pidginiconname.c',
 	'pidgininfopane.c',
 	'pidgininvitedialog.c',
@@ -101,7 +100,6 @@
 	'pidgindialog.h',
 	'pidgindebug.h',
 	'pidgindnd.h',
-	'pidgingdkpixbuf.h',
 	'pidginiconname.h',
 	'pidgininfopane.h',
 	'pidgininvitedialog.h',
diff --git a/pidgin/pidgindnd.c b/pidgin/pidgindnd.c
--- a/pidgin/pidgindnd.c
+++ b/pidgin/pidgindnd.c
@@ -27,11 +27,12 @@
 
 #include <talkatu.h>
 
+#include <purple.h>
+
 #include "pidgindnd.h"
 
 #include "gtkconv.h"
 #include "pidgincore.h"
-#include "pidgingdkpixbuf.h"
 
 enum {
 	DND_FILE_TRANSFER,
@@ -338,7 +339,7 @@
 		}
 
 		/* Are we dealing with an image? */
-		pb = pidgin_pixbuf_new_from_file(filename);
+		pb = purple_gdk_pixbuf_new_from_file(filename);
 		if (pb) {
 			pidgin_dnd_file_send_image(account, who, filename);
 
diff --git a/pidgin/pidgingdkpixbuf.h b/libpurple/purplegdkpixbuf.h
rename from pidgin/pidgingdkpixbuf.h
rename to libpurple/purplegdkpixbuf.h
--- a/pidgin/pidgingdkpixbuf.h
+++ b/libpurple/purplegdkpixbuf.h
@@ -1,6 +1,8 @@
-/* pidgin
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
  *
- * Pidgin is the legal property of its developers, whose names are too numerous
+ * Purple 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.
  *
@@ -15,46 +17,34 @@
  * 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"
+#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
+# error "only <purple.h> may be included directly"
 #endif
 
-#ifndef PIDGIN_GDK_PIXBUF_H
-#define PIDGIN_GDK_PIXBUF_H
+#ifndef PURPLE_GDK_PIXBUF_H
+#define PURPLE_GDK_PIXBUF_H
 
 #include <glib.h>
+
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
-#include <purple.h>
+#include <libpurple/image.h>
 
 G_BEGIN_DECLS
 
 /**
- * pidgin_gdk_pixbuf_new_from_image:
- * @image: A #PurpleImage instance.
- * @error: (out) (nullable): A return address for a #GError.
- *
- * Creates a new #GdkPixbuf from the #PurpleImage @image.  If provided Sets
- * @error on error.
- *
- * Returns: (transfer full) (nullable): The new #GdkPixbuf or %NULL or error.
- */
-GdkPixbuf *pidgin_gdk_pixbuf_new_from_image(PurpleImage *image, GError **error);
-
-/**
- * pidgin_gdk_pixbuf_make_round:
+ * purple_gdk_pixbuf_make_round:
  * @pixbuf:  The buddy icon to transform
  *
  * Rounds the corners of a GdkPixbuf in place.
  */
-void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf);
+void purple_gdk_pixbuf_make_round(GdkPixbuf *pixbuf);
 
 /**
- * pidgin_gdk_pixbuf_is_opaque:
+ * purple_gdk_pixbuf_is_opaque:
  * @pixbuf:  The pixbuf
  *
  * Returns TRUE if the GdkPixbuf is opaque, as determined by no
@@ -62,10 +52,10 @@
  *
  * Returns: TRUE if the pixbuf is opaque around the edges, FALSE otherwise
  */
-gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf);
+gboolean purple_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf);
 
 /**
- * pidgin_pixbuf_from_data:
+ * purple_gdk_pixbuf_from_data:
  * @buf: The raw binary image data.
  * @count: The length of buf in bytes.
  *
@@ -74,22 +64,10 @@
  * Returns: (transfer full): A GdkPixbuf created from the image data, or NULL if
  *         there was an error parsing the data.
  */
-GdkPixbuf *pidgin_pixbuf_from_data(const guchar *buf, gsize count);
+GdkPixbuf *purple_gdk_pixbuf_from_data(const guchar *buf, gsize count);
 
 /**
- * pidgin_pixbuf_anim_from_data:
- * @buf: The raw binary image data.
- * @count: The length of buf in bytes.
- *
- * Create a GdkPixbufAnimation from a chunk of image data.
- *
- * Returns: (transfer full): A GdkPixbufAnimation created from the image data, or NULL if
- *         there was an error parsing the data.
- */
-GdkPixbufAnimation *pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count);
-
-/**
- * pidgin_pixbuf_from_image:
+ * purple_gdk_pixbuf_from_image:
  * @image: a PurpleImage.
  *
  * Create a GdkPixbuf from a PurpleImage.
@@ -97,10 +75,10 @@
  * Returns: (transfer full): a GdkPixbuf created from the @image.
  */
 GdkPixbuf *
-pidgin_pixbuf_from_image(PurpleImage *image);
+purple_gdk_pixbuf_from_image(PurpleImage *image);
 
 /**
- * pidgin_pixbuf_new_from_file:
+ * purple_gdk_pixbuf_new_from_file:
  * @filename: Name of file to load, in the GLib file name encoding
  *
  * Helper function that calls gdk_pixbuf_new_from_file() and checks both
@@ -121,10 +99,10 @@
  * Returns: (transfer full): The GdkPixbuf if successful.  Otherwise NULL is returned and
  *         a warning is logged.
  */
-GdkPixbuf *pidgin_pixbuf_new_from_file(const char *filename);
+GdkPixbuf *purple_gdk_pixbuf_new_from_file(const char *filename);
 
 /**
- * pidgin_pixbuf_new_from_file_at_size:
+ * purple_gdk_pixbuf_new_from_file_at_size:
  * @filename: Name of file to load, in the GLib file name encoding
  * @width: The width the image should have or -1 to not constrain the width
  * @height: The height the image should have or -1 to not constrain the height
@@ -147,57 +125,8 @@
  * Returns: (transfer full): The GdkPixbuf if successful.  Otherwise NULL is returned and
  *         a warning is logged.
  */
-GdkPixbuf *pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height);
-
-/**
- * pidgin_pixbuf_new_from_file_at_scale:
- * @filename: Name of file to load, in the GLib file name encoding
- * @width: The width the image should have or -1 to not constrain the width
- * @height: The height the image should have or -1 to not constrain the height
- * @preserve_aspect_ratio: TRUE to preserve the image's aspect ratio
- *
- * Helper function that calls gdk_pixbuf_new_from_file_at_scale() and checks
- * both the return code and the GError and returns NULL if either one failed.
- *
- * The gdk-pixbuf documentation implies that it is sufficient to check
- * the return value of gdk_pixbuf_new_from_file_at_scale() to determine
- * whether the image was able to be loaded.  However, this is not the case
- * with gdk-pixbuf 2.23.3 and probably many earlier versions.  In some
- * cases a GdkPixbuf object is returned that will cause some operations
- * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an
- * infinite loop.
- *
- * This function shouldn't be necessary once Pidgin requires a version of
- * gdk-pixbuf where the aforementioned bug is fixed.  However, it might be
- * nice to keep this function around for the debug message that it logs.
- *
- * Returns: (transfer full): The GdkPixbuf if successful.  Otherwise NULL is returned and
- *         a warning is logged.
- */
-GdkPixbuf *pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio);
-
-/**
- * pidgin_pixbuf_scale_down:
- * @src: The source image.
- * @max_width: Maximum width in px.
- * @max_height: Maximum height in px.
- * @interp_type: Interpolation method.
- * @preserve_ratio: %TRUE to preserve image's aspect ratio.
- *
- * Scales the image to the desired dimensions. If image is smaller, it will be
- * returned without modifications.
- *
- * If new image is created, @src reference count will be decreased and new image
- * with a ref count of 1 will be returned.
- *
- * Returns: (transfer full): The image with proper sizing. %NULL in case of error.
- */
-GdkPixbuf *
-pidgin_pixbuf_scale_down(GdkPixbuf *src, guint max_width, guint max_height,
-    GdkInterpType interp_type, gboolean preserve_ratio);
-
-
+GdkPixbuf *purple_gdk_pixbuf_new_from_file_at_size(const char *filename, int width, int height);
 
 G_END_DECLS
 
-#endif /* PIDGIN_GDK_PIXBUF_H */
+#endif /* PURPLE_GDK_PIXBUF_H */
diff --git a/pidgin/pidgingdkpixbuf.c b/libpurple/purplegdkpixbuf.c
rename from pidgin/pidgingdkpixbuf.c
rename to libpurple/purplegdkpixbuf.c
--- a/pidgin/pidgingdkpixbuf.c
+++ b/libpurple/purplegdkpixbuf.c
@@ -1,6 +1,8 @@
-/* pidgin
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
  *
- * Pidgin is the legal property of its developers, whose names are too numerous
+ * Purple 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.
  *
@@ -15,46 +17,14 @@
  * 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/>.
  */
 
-#include "pidgin/pidgingdkpixbuf.h"
-
-GdkPixbuf *
-pidgin_gdk_pixbuf_new_from_image(PurpleImage *image, GError **error) {
-	GdkPixbufLoader *loader = NULL;
-	GdkPixbuf *pixbuf = NULL;
-	GBytes *data = NULL;
-	gboolean success = FALSE;
-
-	g_return_val_if_fail(PURPLE_IS_IMAGE(image), NULL);
-
-	data = purple_image_get_contents(image);
-	success = gdk_pixbuf_loader_write_bytes(loader, data, error);
-	g_bytes_unref(data);
+#include "libpurple/purplegdkpixbuf.h"
 
-	if(success) {
-		if(error != NULL && *error != NULL) {
-			g_object_unref(G_OBJECT(loader));
-
-			return NULL;
-		}
+#include "debug.h"
 
-		if(gdk_pixbuf_loader_close(loader, error)) {
-			pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
-			if(pixbuf != NULL) {
-				pixbuf = g_object_ref(pixbuf);
-			}
-		}
-
-		g_object_unref(G_OBJECT(loader));
-	}
-
-	return pixbuf;
-}
-
-void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf) {
+void purple_gdk_pixbuf_make_round(GdkPixbuf *pixbuf) {
 	gint width, height, rowstride;
 	guchar *pixels;
 
@@ -114,7 +84,7 @@
 }
 
 gboolean
-pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf) {
+purple_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf) {
 	gint height, rowstride, i;
 	guchar *pixels;
 	guchar *row;
@@ -154,7 +124,7 @@
 	return TRUE;
 }
 
-static GObject *pidgin_pixbuf_from_data_helper(const guchar *buf, gsize count, gboolean animated)
+static GObject *purple_gdk_pixbuf_from_data_helper(const guchar *buf, gsize count, gboolean animated)
 {
 	GObject *pixbuf;
 	GdkPixbufLoader *loader;
@@ -201,24 +171,19 @@
 	return pixbuf;
 }
 
-GdkPixbuf *pidgin_pixbuf_from_data(const guchar *buf, gsize count)
+GdkPixbuf *purple_gdk_pixbuf_from_data(const guchar *buf, gsize count)
 {
-	return GDK_PIXBUF(pidgin_pixbuf_from_data_helper(buf, count, FALSE));
-}
-
-GdkPixbufAnimation *pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count)
-{
-	return GDK_PIXBUF_ANIMATION(pidgin_pixbuf_from_data_helper(buf, count, TRUE));
+	return GDK_PIXBUF(purple_gdk_pixbuf_from_data_helper(buf, count, FALSE));
 }
 
 GdkPixbuf *
-pidgin_pixbuf_from_image(PurpleImage *image)
+purple_gdk_pixbuf_from_image(PurpleImage *image)
 {
-	return pidgin_pixbuf_from_data(purple_image_get_data(image),
+	return purple_gdk_pixbuf_from_data(purple_image_get_data(image),
 		purple_image_get_data_size(image));
 }
 
-GdkPixbuf *pidgin_pixbuf_new_from_file(const gchar *filename)
+GdkPixbuf *purple_gdk_pixbuf_new_from_file(const gchar *filename)
 {
 	GdkPixbuf *pixbuf;
 	GError *error = NULL;
@@ -243,7 +208,7 @@
 	return pixbuf;
 }
 
-GdkPixbuf *pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height)
+GdkPixbuf *purple_gdk_pixbuf_new_from_file_at_size(const char *filename, int width, int height)
 {
 	GdkPixbuf *pixbuf;
 	GError *error = NULL;
@@ -268,76 +233,3 @@
 
 	return pixbuf;
 }
-
-GdkPixbuf *pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio)
-{
-	GdkPixbuf *pixbuf;
-	GError *error = NULL;
-
-	g_return_val_if_fail(filename != NULL, NULL);
-	g_return_val_if_fail(filename[0] != '\0', NULL);
-
-	pixbuf = gdk_pixbuf_new_from_file_at_scale(filename,
-			width, height, preserve_aspect_ratio, &error);
-	if (!pixbuf || error) {
-		purple_debug_warning("gtkutils", "gdk_pixbuf_new_from_file_at_scale() "
-				"returned %s for file %s: %s\n",
-				pixbuf ? "something" : "nothing",
-				filename,
-				error ? error->message : "(no error message)");
-		if (error)
-			g_error_free(error);
-		if (pixbuf)
-			g_object_unref(G_OBJECT(pixbuf));
-		return NULL;
-	}
-
-	return pixbuf;
-}
-
-GdkPixbuf *
-pidgin_pixbuf_scale_down(GdkPixbuf *src, guint max_width, guint max_height,
-	GdkInterpType interp_type, gboolean preserve_ratio)
-{
-	guint cur_w, cur_h;
-	GdkPixbuf *dst;
-
-	g_return_val_if_fail(src != NULL, NULL);
-
-	if (max_width == 0 || max_height == 0) {
-		g_object_unref(src);
-		g_return_val_if_reached(NULL);
-	}
-
-	cur_w = gdk_pixbuf_get_width(src);
-	cur_h = gdk_pixbuf_get_height(src);
-
-	if (cur_w <= max_width && cur_h <= max_height)
-		return src;
-
-	/* cur_ratio = cur_w / cur_h
-	 * max_ratio = max_w / max_h
-	 */
-
-	if (!preserve_ratio) {
-		cur_w = MIN(cur_w, max_width);
-		cur_h = MIN(cur_h, max_height);
-	} else if ((guint64)cur_w * max_height > (guint64)max_width * cur_h) {
-		/* cur_w / cur_h > max_width / max_height */
-		cur_h = (guint64)max_width * cur_h / cur_w;
-		cur_w = max_width;
-	} else {
-		cur_w = (guint64)max_height * cur_w / cur_h;
-		cur_h = max_height;
-	}
-
-	if (cur_w <= 0)
-		cur_w = 1;
-	if (cur_h <= 0)
-		cur_h = 1;
-
-	dst = gdk_pixbuf_scale_simple(src, cur_w, cur_h, interp_type);
-	g_object_unref(src);
-
-	return dst;
-}
diff --git a/pidgin/prefs/pidginprefs.c b/pidgin/prefs/pidginprefs.c
--- a/pidgin/prefs/pidginprefs.c
+++ b/pidgin/prefs/pidginprefs.c
@@ -41,7 +41,6 @@
 #include "gtkutils.h"
 #include "pidgincore.h"
 #include "pidgindebug.h"
-#include "pidgingdkpixbuf.h"
 #include "pidginprefs.h"
 #include <libsoup/soup.h>
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -248,6 +248,7 @@
 libpurple/purplecredentialmanager.c
 libpurple/purplecredentialprovider.c
 libpurple/purpledebugui.c
+libpurple/purplegdkpixbuf.c
 libpurple/purple-gio.c
 libpurple/purplehistoryadapter.c
 libpurple/purplehistorymanager.c
@@ -353,7 +354,6 @@
 pidgin/pidgindebug.c
 pidgin/pidgindialog.c
 pidgin/pidgindnd.c
-pidgin/pidgingdkpixbuf.c
 pidgin/pidginiconname.c
 pidgin/pidgininfopane.c
 pidgin/pidgininvitedialog.c
