diff src/gtkthemes.c @ 11525:b47708f46a38

[gaim-migrate @ 13773] Here's the rest of that custom smiley receiving patch, with some changes from me. I'm still not all that happy with it, but that's probably not the author's fault, and I don't have time to take it further right now. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Mon, 12 Sep 2005 13:25:41 +0000
parents 0f7452b1f777
children 1e7c0773380f
line wrap: on
line diff
--- a/src/gtkthemes.c	Mon Sep 12 06:50:29 2005 +0000
+++ b/src/gtkthemes.c	Mon Sep 12 13:25:41 2005 +0000
@@ -4,7 +4,7 @@
  * Gaim 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.
- * 
+ *
  * 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
@@ -31,22 +31,25 @@
 #include "gtkconv.h"
 #include "gtkdialogs.h"
 #include "gtkimhtml.h"
-
-struct smiley_list {
-	char *sml;
-	GSList *smileys;
-	struct smiley_list *next;
-};
+#include "gtkthemes.h"
 
 GSList *smiley_themes = NULL;
 struct smiley_theme *current_smiley_theme;
 
-void smiley_themeize(GtkWidget *imhtml)
+gboolean gaim_gtkthemes_smileys_disabled()
+{
+	if (!current_smiley_theme)
+		return 1;
+
+	return strcmp(current_smiley_theme->name, "none") == 0;
+}
+
+void gaim_gtkthemes_smiley_themeize(GtkWidget *imhtml)
 {
 	struct smiley_list *list;
 	if (!current_smiley_theme)
 		return;
-	
+
 	gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml));
 	list = current_smiley_theme->list;
 	while (list) {
@@ -60,7 +63,7 @@
 	}
 }
 
-void load_smiley_theme(const char *file, gboolean load)
+void gaim_gtkthemes_load_smiley_theme(const char *file, gboolean load)
 {
 	FILE *f = g_fopen(file, "r");
 	char buf[256];
@@ -196,8 +199,8 @@
 			GaimConversation *conv = cnv->data;
 
 			if (GAIM_IS_GTK_CONVERSATION(conv)) {
-				smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml);
-				smiley_themeize(GAIM_GTK_CONVERSATION(conv)->entry);
+				gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml);
+				gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->entry);
 			}
 		}
 	}
@@ -206,7 +209,7 @@
 	fclose(f);
 }
 
-void smiley_theme_probe()
+void gaim_gtkthemes_smiley_theme_probe()
 {
 	GDir *dir;
 	const gchar *file;
@@ -227,7 +230,7 @@
 				 * We set the second argument to FALSE so that it doesn't load
 				 * the theme yet.
 				 */
-				load_smiley_theme(path, FALSE);
+				gaim_gtkthemes_load_smiley_theme(path, FALSE);
 				g_free(path);
 			}
 			g_dir_close(dir);
@@ -238,7 +241,7 @@
 	}
 }
 
-GSList *get_proto_smileys(const char *id) {
+GSList *gaim_gtkthemes_get_proto_smileys(const char *id) {
 	GaimPlugin *proto;
 	struct smiley_list *list, *def;
 
@@ -263,3 +266,14 @@
 
 	return list ? list->smileys : def->smileys;
 }
+
+void gaim_gtkthemes_init()
+{
+	if (current_smiley_theme == NULL) {
+		gaim_gtkthemes_smiley_theme_probe();
+		if (smiley_themes != NULL) {
+			struct smiley_theme *smile = smiley_themes->data;
+			gaim_gtkthemes_load_smiley_theme(smile->path, TRUE);
+		}
+	}
+}