comparison 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
comparison
equal deleted inserted replaced
11524:4fd0c3a663b8 11525:b47708f46a38
2 * Themes for Gaim 2 * Themes for Gaim
3 * 3 *
4 * Gaim is the legal property of its developers, whose names are too numerous 4 * Gaim is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this 5 * to list here. Please refer to the COPYRIGHT file distributed with this
6 * source distribution. 6 * source distribution.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
29 #include "util.h" 29 #include "util.h"
30 30
31 #include "gtkconv.h" 31 #include "gtkconv.h"
32 #include "gtkdialogs.h" 32 #include "gtkdialogs.h"
33 #include "gtkimhtml.h" 33 #include "gtkimhtml.h"
34 34 #include "gtkthemes.h"
35 struct smiley_list {
36 char *sml;
37 GSList *smileys;
38 struct smiley_list *next;
39 };
40 35
41 GSList *smiley_themes = NULL; 36 GSList *smiley_themes = NULL;
42 struct smiley_theme *current_smiley_theme; 37 struct smiley_theme *current_smiley_theme;
43 38
44 void smiley_themeize(GtkWidget *imhtml) 39 gboolean gaim_gtkthemes_smileys_disabled()
40 {
41 if (!current_smiley_theme)
42 return 1;
43
44 return strcmp(current_smiley_theme->name, "none") == 0;
45 }
46
47 void gaim_gtkthemes_smiley_themeize(GtkWidget *imhtml)
45 { 48 {
46 struct smiley_list *list; 49 struct smiley_list *list;
47 if (!current_smiley_theme) 50 if (!current_smiley_theme)
48 return; 51 return;
49 52
50 gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml)); 53 gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml));
51 list = current_smiley_theme->list; 54 list = current_smiley_theme->list;
52 while (list) { 55 while (list) {
53 char *sml = !strcmp(list->sml, "default") ? NULL : list->sml; 56 char *sml = !strcmp(list->sml, "default") ? NULL : list->sml;
54 GSList *icons = list->smileys; 57 GSList *icons = list->smileys;
58 } 61 }
59 list = list->next; 62 list = list->next;
60 } 63 }
61 } 64 }
62 65
63 void load_smiley_theme(const char *file, gboolean load) 66 void gaim_gtkthemes_load_smiley_theme(const char *file, gboolean load)
64 { 67 {
65 FILE *f = g_fopen(file, "r"); 68 FILE *f = g_fopen(file, "r");
66 char buf[256]; 69 char buf[256];
67 char *i; 70 char *i;
68 struct smiley_theme *theme=NULL; 71 struct smiley_theme *theme=NULL;
194 197
195 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { 198 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
196 GaimConversation *conv = cnv->data; 199 GaimConversation *conv = cnv->data;
197 200
198 if (GAIM_IS_GTK_CONVERSATION(conv)) { 201 if (GAIM_IS_GTK_CONVERSATION(conv)) {
199 smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); 202 gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml);
200 smiley_themeize(GAIM_GTK_CONVERSATION(conv)->entry); 203 gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->entry);
201 } 204 }
202 } 205 }
203 } 206 }
204 207
205 g_free(dirname); 208 g_free(dirname);
206 fclose(f); 209 fclose(f);
207 } 210 }
208 211
209 void smiley_theme_probe() 212 void gaim_gtkthemes_smiley_theme_probe()
210 { 213 {
211 GDir *dir; 214 GDir *dir;
212 const gchar *file; 215 const gchar *file;
213 gchar *path; 216 gchar *path;
214 int l; 217 int l;
225 228
226 /* Here we check to see that the theme has proper syntax. 229 /* Here we check to see that the theme has proper syntax.
227 * We set the second argument to FALSE so that it doesn't load 230 * We set the second argument to FALSE so that it doesn't load
228 * the theme yet. 231 * the theme yet.
229 */ 232 */
230 load_smiley_theme(path, FALSE); 233 gaim_gtkthemes_load_smiley_theme(path, FALSE);
231 g_free(path); 234 g_free(path);
232 } 235 }
233 g_dir_close(dir); 236 g_dir_close(dir);
234 } else if (l == 1) { 237 } else if (l == 1) {
235 g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR); 238 g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
236 } 239 }
237 g_free(probedirs[l]); 240 g_free(probedirs[l]);
238 } 241 }
239 } 242 }
240 243
241 GSList *get_proto_smileys(const char *id) { 244 GSList *gaim_gtkthemes_get_proto_smileys(const char *id) {
242 GaimPlugin *proto; 245 GaimPlugin *proto;
243 struct smiley_list *list, *def; 246 struct smiley_list *list, *def;
244 247
245 if ((current_smiley_theme == NULL) || (current_smiley_theme->list == NULL)) 248 if ((current_smiley_theme == NULL) || (current_smiley_theme->list == NULL))
246 return NULL; 249 return NULL;
261 list = list->next; 264 list = list->next;
262 } 265 }
263 266
264 return list ? list->smileys : def->smileys; 267 return list ? list->smileys : def->smileys;
265 } 268 }
269
270 void gaim_gtkthemes_init()
271 {
272 if (current_smiley_theme == NULL) {
273 gaim_gtkthemes_smiley_theme_probe();
274 if (smiley_themes != NULL) {
275 struct smiley_theme *smile = smiley_themes->data;
276 gaim_gtkthemes_load_smiley_theme(smile->path, TRUE);
277 }
278 }
279 }