changeset 16149:813258bec80c

merge of '97036f771347e3ba3136697bcb575ece5e5049a1' and 'bd8daa0b2706fa049126cbf8d7f5ece087951d66'
author Mark Doliner <mark@kingant.net>
date Sun, 15 Apr 2007 18:37:20 +0000
parents af92b284664a (current diff) 019092f88c43 (diff)
children 218818f96b93
files gaim.service.in libpurple/dbus-gaim.service pidgin/plugins/gaiminc.c
diffstat 1 files changed, 32 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkthemes.c	Sun Apr 15 18:28:56 2007 +0000
+++ b/pidgin/gtkthemes.c	Sun Apr 15 18:37:20 2007 +0000
@@ -63,6 +63,35 @@
 	}
 }
 
+static void
+pidginthemes_destroy_smiley_theme(struct smiley_theme *theme)
+{
+	GSList *already_freed = NULL;
+	struct smiley_list *wer = theme->list, *wer2;
+
+	while (wer) {
+		while (wer->smileys) {
+			GtkIMHtmlSmiley *uio = wer->smileys->data;
+			if (uio->icon)
+				g_object_unref(uio->icon);
+			if (!g_slist_find(already_freed, uio->file)) {
+				g_free(uio->file);
+				already_freed = g_slist_append(already_freed, uio->file);
+			}
+			g_free(uio->smile);
+			g_free(uio);
+			wer->smileys = g_slist_remove(wer->smileys, uio);
+		}
+		wer2 = wer->next;
+		g_free(wer->sml);
+		g_free(wer);
+		wer = wer2;
+	}
+
+	g_slist_free(already_freed);
+	theme->list = NULL;
+}
+
 void pidginthemes_load_smiley_theme(const char *file, gboolean load)
 {
 	FILE *f = g_fopen(file, "r");
@@ -180,31 +209,9 @@
 	fclose(f);
 
 	if (!theme->name || !theme->desc || !theme->author) {
-		GSList *already_freed = NULL;
-		struct smiley_list *wer = theme->list, *wer2;
-
 		purple_debug_error("gtkthemes", "Invalid file format, not loading smiley theme from '%s'\n", file);
 
-		while (wer) {
-			while (wer->smileys) {
-				GtkIMHtmlSmiley *uio = wer->smileys->data;
-				if (uio->icon)
-					g_object_unref(uio->icon);
-				if (!g_slist_find(already_freed, uio->file)) {
-					g_free(uio->file);
-					already_freed = g_slist_append(already_freed, uio->file);
-				}
-				g_free(uio->smile);
-				g_free(uio);
-				wer->smileys = g_slist_remove(wer->smileys, uio);
-			}
-			wer2 = wer->next;
-			g_free(wer->sml);
-			g_free(wer);
-			wer = wer2;
-		}
-		theme->list = NULL;
-		g_slist_free(already_freed);
+		pidginthemes_destroy_smiley_theme(theme);
 
 		g_free(theme->name);
 		g_free(theme->desc);
@@ -223,30 +230,8 @@
 	if (load) {
 		GList *cnv;
 
-		if (current_smiley_theme) {
-			GSList *already_freed = NULL;
-			struct smiley_list *wer = current_smiley_theme->list, *wer2;
-			while (wer) {
-				while (wer->smileys) {
-					GtkIMHtmlSmiley *uio = wer->smileys->data;
-					if (uio->icon)
-						g_object_unref(uio->icon);
-					if (!g_slist_find(already_freed, uio->file)) {
-						g_free(uio->file);
-						already_freed = g_slist_append(already_freed, uio->file);
-					}
-					g_free(uio->smile);
-					g_free(uio);
-					wer->smileys = g_slist_remove(wer->smileys, uio);
-				}
-				wer2 = wer->next;
-				g_free(wer->sml);
-				g_free(wer);
-				wer = wer2;
-			}
-			current_smiley_theme->list = NULL;
-			g_slist_free(already_freed);
-		}
+		if (current_smiley_theme)
+			pidginthemes_destroy_smiley_theme(current_smiley_theme);
 		current_smiley_theme = theme;
 
 		for (cnv = purple_get_conversations(); cnv != NULL; cnv = cnv->next) {