/pidgin/main: f01e2638301f: imgstore: rip the rest of imgstore r...

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu Apr 10 18:12:05 EDT 2014


Changeset: f01e2638301f49b81c497fd67cec6aae1cd7352e
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-11 00:11 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/f01e2638301f

Description:

imgstore: rip the rest of imgstore references from Pidgin

diffstat:

 pidgin/gtkaccount.c   |  49 +++++++++++++++++++++++++++----------------------
 pidgin/gtkblist.c     |   8 +++++---
 pidgin/gtkstatusbox.c |   3 ++-
 3 files changed, 34 insertions(+), 26 deletions(-)

diffs (156 lines):

diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -45,8 +45,6 @@
 
 #include "gtk3compat.h"
 
-#include "imgstore.h" /* TODO: temp */
-
 enum
 {
 	COLUMN_ICON,
@@ -135,7 +133,7 @@ typedef struct
 	GtkWidget *icon_filesel;
 	GtkWidget *icon_preview;
 	GtkWidget *icon_text;
-	PurpleStoredImage *icon_img;
+	PurpleImage *icon_img;
 
 	/* Protocol Options */
 	GtkWidget *protocol_frame;
@@ -183,14 +181,18 @@ set_dialog_icon(AccountPrefsDialog *dial
 {
 	GdkPixbuf *pixbuf = NULL;
 
-#if 0
-	/* TODO: unref it! */
-	dialog->icon_img = purple_imgstore_unref(dialog->icon_img);
-#endif
-	if (data != NULL)
-	{
+	if (dialog->icon_img) {
+		g_object_unref(dialog->icon_img);
+		dialog->icon_img = NULL;
+	}
+
+	if (new_icon_path != NULL) {
+		dialog->icon_img = purple_image_new_from_file(new_icon_path, TRUE);
+		purple_debug_warning("gtkaccount", "data was not necessary");
+		g_free(data);
+	} else if (data != NULL) {
 		if (len > 0)
-			dialog->icon_img = purple_imgstore_new(data, len, new_icon_path);
+			dialog->icon_img = purple_image_new_from_data(data, len);
 		else
 			g_free(data);
 	}
@@ -852,8 +854,10 @@ add_user_options(AccountPrefsDialog *dia
 	gtk_widget_show(dialog->icon_entry);
 	/* TODO: Uh, isn't this next line pretty useless? */
 	pidgin_set_accessible_label(dialog->icon_entry, GTK_LABEL(label));
-	purple_imgstore_unref(dialog->icon_img);
-	dialog->icon_img = NULL;
+	if (dialog->icon_img) {
+		g_object_unref(dialog->icon_img);
+		dialog->icon_img = NULL;
+	}
 
 	vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
 	gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
@@ -880,7 +884,7 @@ add_user_options(AccountPrefsDialog *dia
 	}
 
 	if (dialog->account != NULL) {
-		PurpleStoredImage *img;
+		PurpleImage *img;
 		gpointer data = NULL;
 		size_t len = 0;
 
@@ -898,8 +902,8 @@ add_user_options(AccountPrefsDialog *dia
 		img = purple_buddy_icons_find_account_icon(dialog->account);
 		if (img)
 		{
-			len = purple_imgstore_get_size(img);
-			data = g_memdup(purple_imgstore_get_data(img), len);
+			len = purple_image_get_size(img);
+			data = g_memdup(purple_image_get_data(img), len);
 		}
 		set_dialog_icon(dialog, data, len,
 		                g_strdup(purple_account_get_buddy_icon_path(dialog->account)));
@@ -1401,7 +1405,8 @@ account_win_destroy_cb(GtkWidget *w, Gdk
 	g_free(dialog->protocol_id);
 	g_object_unref(dialog->sg);
 
-	purple_imgstore_unref(dialog->icon_img);
+	if (dialog->icon_img)
+		g_object_unref(dialog->icon_img);
 
 	if (dialog->icon_filesel)
 		gtk_widget_destroy(dialog->icon_filesel);
@@ -1530,11 +1535,11 @@ ok_account_prefs_cb(GtkWidget *w, Accoun
 		{
 			if (dialog->icon_img)
 			{
-				size_t len = purple_imgstore_get_size(dialog->icon_img);
+				size_t len = purple_image_get_size(dialog->icon_img);
 				purple_buddy_icons_set_account_icon(account,
-				                                    g_memdup(purple_imgstore_get_data(dialog->icon_img), len),
-				                                    len);
-				purple_account_set_buddy_icon_path(account, purple_imgstore_get_filename(dialog->icon_img));
+					g_memdup(purple_image_get_data(dialog->icon_img), len), len);
+				purple_account_set_buddy_icon_path(account,
+					purple_image_get_path(dialog->icon_img));
 			}
 			else
 			{
@@ -2262,7 +2267,7 @@ static void
 set_account(GtkListStore *store, GtkTreeIter *iter, PurpleAccount *account, GdkPixbuf *global_buddyicon)
 {
 	GdkPixbuf *pixbuf, *buddyicon = NULL;
-	PurpleStoredImage *img = NULL;
+	PurpleImage *img = NULL;
 	PurplePlugin *prpl;
 	PurplePluginProtocolInfo *prpl_info = NULL;
 
@@ -2282,7 +2287,7 @@ set_account(GtkListStore *store, GtkTree
 				const char *path;
 				path = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon");
 				if ((path != NULL) && (*path != '\0')) {
-					img = purple_imgstore_new_from_file(path);
+					img = purple_image_new_from_file(path, TRUE);
 				}
 			}
 		} else {
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -2735,10 +2735,12 @@ static GdkPixbuf *pidgin_blist_get_buddy
 			account ? purple_account_get_protocol_id(account) : "(no account)",
 			buddy ? purple_buddy_get_name(buddy) : "(no buddy)",
 			custom_img ? purple_image_get_size(custom_img) : 0);
+		if (custom_img)
+			g_object_unref(custom_img);
+		return NULL;
+	}
+	if (custom_img)
 		g_object_unref(custom_img);
-		return NULL;
-	}
-	g_object_unref(custom_img);
 
 	if (greyed) {
 		gboolean offline = FALSE, idle = FALSE;
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -2327,7 +2327,8 @@ pidgin_status_box_redisplay_buddy_icon(P
 void
 pidgin_status_box_set_buddy_icon(PidginStatusBox *status_box, PurpleImage *img)
 {
-	g_object_unref(status_box->buddy_icon_img);
+	if (status_box->buddy_icon_img)
+		g_object_unref(status_box->buddy_icon_img);
 	status_box->buddy_icon_img = img;
 	if (status_box->buddy_icon_img != NULL)
 		g_object_ref(status_box->buddy_icon_img);



More information about the Commits mailing list