# HG changeset patch
# Node ID 9a72ae7c703e
# Parent  477bec0f3fbc
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -126,6 +126,7 @@ pidgin_request_dialog_icon(PurpleRequest
 
 		pixbuf = purple_gdk_pixbuf_from_data(icon_data, icon_size);
 		if (pixbuf) {
+			GdkTexture *texture = NULL;
 			/* scale the image if it is too large */
 			int width = gdk_pixbuf_get_width(pixbuf);
 			int height = gdk_pixbuf_get_height(pixbuf);
@@ -147,7 +148,9 @@ pidgin_request_dialog_icon(PurpleRequest
 					pixbuf = scaled;
 				}
 			}
-			img = gtk_image_new_from_pixbuf(pixbuf);
+			texture = gdk_texture_new_for_pixbuf(pixbuf);
+			img = gtk_image_new_from_paintable(GDK_PAINTABLE(texture));
+			g_object_unref(texture);
 			g_object_unref(pixbuf);
 		} else {
 			purple_debug_info("pidgin",
@@ -464,6 +467,7 @@ static GtkWidget *
 create_image_field(PurpleRequestField *field)
 {
 	PurpleRequestFieldImage *ifield = PURPLE_REQUEST_FIELD_IMAGE(field);
+	GdkTexture *texture = NULL;
 	GtkWidget *widget;
 	GdkPixbuf *buf, *scale;
 
@@ -475,9 +479,11 @@ create_image_field(PurpleRequestField *f
 			purple_request_field_image_get_scale_x(ifield) * gdk_pixbuf_get_width(buf),
 			purple_request_field_image_get_scale_y(ifield) * gdk_pixbuf_get_height(buf),
 			GDK_INTERP_BILINEAR);
-	widget = gtk_image_new_from_pixbuf(scale);
+	texture = gdk_texture_new_for_pixbuf(scale);
+	widget = gtk_image_new_from_paintable(GDK_PAINTABLE(texture));
+	g_object_unref(texture);
+	g_object_unref(scale);
 	g_object_unref(buf);
-	g_object_unref(scale);
 
 	return widget;
 }
@@ -581,10 +587,12 @@ bind_list_field_listitem_cb(G_GNUC_UNUSE
 
 	if(purple_request_field_list_has_icons(field)) {
 		GtkWidget *image = NULL;
+		GdkTexture *texture = NULL;
 
 		image = gtk_widget_get_last_child(box);
-		gtk_image_set_from_pixbuf(GTK_IMAGE(image),
-		                          g_object_get_data(wrapper, "pixbuf"));
+		texture = gdk_texture_new_for_pixbuf(g_object_get_data(wrapper, "pixbuf"));
+		gtk_image_set_from_paintable(GTK_IMAGE(image), GDK_PAINTABLE(texture));
+		g_object_unref(texture);
 	}
 }
 
diff --git a/pidgin/pidginaccounteditor.c b/pidgin/pidginaccounteditor.c
--- a/pidgin/pidginaccounteditor.c
+++ b/pidgin/pidginaccounteditor.c
@@ -49,7 +49,7 @@ struct _PidginAccountEditor {
 	GtkWidget *alias;
 
 	GtkFileDialog *avatar_dialog;
-	GdkPixbuf *avatar_pixbuf;
+	GdkTexture *avatar_texture;
 	GtkWidget *avatar_row;
 	GtkWidget *use_custom_avatar;
 	GtkWidget *avatar;
@@ -270,11 +270,23 @@ pidgin_account_editor_update_user_option
 	gtk_editable_set_text(GTK_EDITABLE(editor->alias), svalue);
 	gtk_switch_set_active(GTK_SWITCH(editor->use_custom_avatar), !use_global);
 
-	g_clear_object(&editor->avatar_pixbuf);
+	g_clear_object(&editor->avatar_texture);
 	if(PURPLE_IS_IMAGE(image)) {
-		editor->avatar_pixbuf = purple_gdk_pixbuf_from_image(image);
-		gtk_image_set_from_pixbuf(GTK_IMAGE(editor->avatar),
-		                          editor->avatar_pixbuf);
+		GBytes *contents = NULL;
+		GError *error = NULL;
+
+		contents = purple_image_get_contents(image);
+		editor->avatar_texture = gdk_texture_new_from_bytes(contents, &error);
+		if(error != NULL) {
+			g_warning("Failed to create texture from file %s: %s",
+			          purple_image_get_path(image),
+			          error->message);
+			g_clear_error(&error);
+		} else {
+			gtk_image_set_from_paintable(GTK_IMAGE(editor->avatar),
+			                             GDK_PAINTABLE(editor->avatar_texture));
+		}
+		g_bytes_unref(contents);
 	} else {
 		gtk_image_set_from_icon_name(GTK_IMAGE(editor->avatar),
 		                             "select-avatar");
@@ -963,22 +975,20 @@ pidgin_account_editor_avatar_response_cb
 	file = gtk_file_dialog_open_finish(GTK_FILE_DIALOG(obj), result, NULL);
 	if(file != NULL) {
 		GError *error = NULL;
-		char *filename = NULL;
 
-		filename = g_file_get_path(file);
-
-		g_clear_object(&editor->avatar_pixbuf);
-		editor->avatar_pixbuf = gdk_pixbuf_new_from_file(filename, &error);
+		g_clear_object(&editor->avatar_texture);
+		editor->avatar_texture = gdk_texture_new_from_file(file, &error);
 		if(error != NULL) {
-			g_warning("Failed to create pixbuf from file %s: %s", filename,
+			char *filename = g_file_get_path(file);
+			g_warning("Failed to create texture from file %s: %s", filename,
 			          error->message);
+			g_free(filename);
 			g_clear_error(&error);
 		} else {
-			gtk_image_set_from_pixbuf(GTK_IMAGE(editor->avatar),
-			                          editor->avatar_pixbuf);
+			gtk_image_set_from_paintable(GTK_IMAGE(editor->avatar),
+			                             GDK_PAINTABLE(editor->avatar_texture));
 		}
 
-		g_free(filename);
 		g_object_unref(file);
 	}
 
@@ -1008,7 +1018,7 @@ pidgin_account_editor_avatar_remove_clic
 
 	gtk_image_set_from_icon_name(GTK_IMAGE(editor->avatar), "select-avatar");
 
-	g_clear_object(&editor->avatar_pixbuf);
+	g_clear_object(&editor->avatar_texture);
 }
 
 static gchar *
@@ -1110,7 +1120,7 @@ pidgin_account_editor_dispose(GObject *o
 
 	g_clear_object(&editor->account);
 	g_clear_object(&editor->avatar_dialog);
-	g_clear_object(&editor->avatar_pixbuf);
+	g_clear_object(&editor->avatar_texture);
 
 	G_OBJECT_CLASS(pidgin_account_editor_parent_class)->dispose(obj);
 }
diff --git a/pidgin/pidginavatar.c b/pidgin/pidginavatar.c
--- a/pidgin/pidginavatar.c
+++ b/pidgin/pidginavatar.c
@@ -56,6 +56,7 @@ pidgin_avatar_update(PidginAvatar *avata
 	PurpleAvatar *purple_avatar = NULL;
 	GdkPixbufAnimation *animation = NULL;
 	GdkPixbuf *pixbuf = NULL;
+	GdkTexture *texture = NULL;
 
 	if(PURPLE_IS_CONTACT_INFO(avatar->info)) {
 		purple_avatar = purple_contact_info_get_avatar(avatar->info);
@@ -78,8 +79,11 @@ pidgin_avatar_update(PidginAvatar *avata
 		}
 	}
 
-	gtk_picture_set_pixbuf(GTK_PICTURE(avatar->icon), pixbuf);
+	texture = gdk_texture_new_for_pixbuf(pixbuf);
+	gtk_picture_set_paintable(GTK_PICTURE(avatar->icon),
+	                          GDK_PAINTABLE(texture));
 
+	g_clear_object(&texture);
 	g_clear_object(&animation);
 }
 
@@ -232,9 +236,6 @@ pidgin_avatar_init(PidginAvatar *avatar)
 
 	gtk_widget_init_template(GTK_WIDGET(avatar));
 
-	gtk_picture_set_content_fit(GTK_PICTURE(avatar->icon),
-	                            GTK_CONTENT_FIT_SCALE_DOWN);
-
 	/* Now setup our actions. */
 	group = g_simple_action_group_new();
 	g_action_map_add_action_entries(G_ACTION_MAP(group), actions,
@@ -319,17 +320,22 @@ pidgin_avatar_set_animate(PidginAvatar *
 	avatar->animate = animate;
 
 	if(GDK_IS_PIXBUF_ANIMATION(avatar->animation)) {
+		GdkTexture *texture = NULL;
+
 		if(avatar->animate &&
 		   !gdk_pixbuf_animation_is_static_image(avatar->animation)) {
-			gtk_picture_set_pixbuf(GTK_PICTURE(avatar->icon),
-			                       GDK_PIXBUF(avatar->animation));
+			texture = gdk_texture_new_for_pixbuf(GDK_PIXBUF(avatar->animation));
 		} else {
 			GdkPixbuf *frame = NULL;
 
 			frame = gdk_pixbuf_animation_get_static_image(avatar->animation);
 
-			gtk_picture_set_pixbuf(GTK_PICTURE(avatar->icon), frame);
+			texture = gdk_texture_new_for_pixbuf(frame);
 		}
+
+		gtk_picture_set_paintable(GTK_PICTURE(avatar->icon),
+		                          GDK_PAINTABLE(texture));
+		g_object_unref(texture);
 	}
 }
 
diff --git a/pidgin/resources/avatar.ui b/pidgin/resources/avatar.ui
--- a/pidgin/resources/avatar.ui
+++ b/pidgin/resources/avatar.ui
@@ -27,7 +27,7 @@ along with this program; if not, see <ht
       <object class="GtkPicture" id="icon">
         <property name="height-request">64</property>
         <property name="width-request">64</property>
-        <property name="content-fit">contain</property>
+        <property name="content-fit">scale-down</property>
       </object>
     </child>
     <child>
