annotate src/gtkthemes.c @ 13976:6a5aaf46bd52

[gaim-migrate @ 16534] Some more memleaks. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 20 Jul 2006 21:43:15 +0000
parents ff70d3009409
children 8bda65b88e49
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1 /*
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
2 * Themes for Gaim
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
3 *
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
6 * source distribution.
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
7 *
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 *
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 *
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21 *
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22 */
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 #include "internal.h"
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24 #include "gtkgaim.h"
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
26 #include "conversation.h"
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
27 #include "debug.h"
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
28 #include "prpl.h"
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
29 #include "util.h"
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
30
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
31 #include "gtkconv.h"
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32 #include "gtkdialogs.h"
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
33 #include "gtkimhtml.h"
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
34 #include "gtkthemes.h"
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
35
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
36 GSList *smiley_themes = NULL;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
37 struct smiley_theme *current_smiley_theme;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
38
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
39 gboolean gaim_gtkthemes_smileys_disabled()
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
40 {
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
41 if (!current_smiley_theme)
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
42 return 1;
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
43
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
44 return strcmp(current_smiley_theme->name, "none") == 0;
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
45 }
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
46
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
47 void gaim_gtkthemes_smiley_themeize(GtkWidget *imhtml)
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
48 {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
49 struct smiley_list *list;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
50 if (!current_smiley_theme)
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
51 return;
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
52
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
53 gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml));
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
54 list = current_smiley_theme->list;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
55 while (list) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
56 char *sml = !strcmp(list->sml, "default") ? NULL : list->sml;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
57 GSList *icons = list->smileys;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
58 while (icons) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
59 gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
60 icons = icons->next;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
61 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
62 list = list->next;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
63 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
64 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
65
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
66 void gaim_gtkthemes_load_smiley_theme(const char *file, gboolean load)
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
67 {
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10295
diff changeset
68 FILE *f = g_fopen(file, "r");
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
69 char buf[256];
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
70 char *i;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
71 struct smiley_theme *theme=NULL;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
72 struct smiley_list *list = NULL;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
73 GSList *lst = smiley_themes;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
74 char *dirname;
13586
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
75 gboolean new_theme = FALSE;
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
76
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
77 if (!f)
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
78 return;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
79
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
80 while (lst) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
81 struct smiley_theme *thm = lst->data;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
82 if (!strcmp(thm->path, file)) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
83 theme = thm;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
84 break;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
85 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
86 lst = lst->next;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
87 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
88
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
89 if (!theme) {
13586
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
90 new_theme = TRUE;
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
91 theme = g_new0(struct smiley_theme, 1);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
92 theme->path = g_strdup(file);
13586
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
93 } else if (theme == current_smiley_theme) {
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
94 /* Don't reload the theme if it is already loaded */
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
95 fclose(f);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
96 return;
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
97 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
98
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
99 dirname = g_path_get_dirname(file);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
100
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
101 while (!feof(f)) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
102 if (!fgets(buf, sizeof(buf), f)) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103 break;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
105
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106 if (buf[0] == '#' || buf[0] == '\0')
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 continue;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109 i = buf;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110 while (isspace(*i))
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
111 i++;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
112
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
113 if (*i == '[' && strchr(i, ']') && load) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
114 struct smiley_list *child = g_new0(struct smiley_list, 1);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
115 child->sml = g_strndup(i+1, strchr(i, ']') - i - 1);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
116 if (theme->list)
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
117 list->next = child;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118 else
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
119 theme->list = child;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
120 list = child;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
121 } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
122 if(theme->name)
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
123 g_free(theme->name);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
124 theme->name = g_strdup(i+ strlen("Name="));
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
125 theme->name[strlen(theme->name)-1] = 0;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
126 } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
127 if(theme->desc)
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
128 g_free(theme->desc);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
129 theme->desc = g_strdup(i + strlen("Description="));
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
130 theme->desc[strlen(theme->desc)-1] = 0;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
131 } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
132 if(theme->icon)
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
133 g_free(theme->icon);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
134 theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
135 theme->icon[strlen(theme->icon)-1] = 0;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
136 } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
137 if(theme->author)
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
138 g_free(theme->author);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
139 theme->author = g_strdup(i + strlen("Author="));
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
140 theme->author[strlen(theme->author)-1] = 0;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
141 } else if (load && list) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
142 gboolean hidden = FALSE;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
143 char *sfile = NULL;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
144
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
145 if (*i == '!' && *(i + 1) == ' ') {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
146 hidden = TRUE;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
147 i = i + 2;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
148 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
149 while (*i) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
150 char l[64];
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
151 int li = 0;
13133
541486fde12b [gaim-migrate @ 15495]
Richard Laager <rlaager@wiktel.com>
parents: 12915
diff changeset
152 while (!isspace(*i) && li < sizeof(l) - 1) {
541486fde12b [gaim-migrate @ 15495]
Richard Laager <rlaager@wiktel.com>
parents: 12915
diff changeset
153 if (*i == '\\' && *(i+1) != '\0' && *(i+1) != '\n' && *(i+1) != '\r')
12915
fe2cb084ab16 [gaim-migrate @ 15268]
Richard Laager <rlaager@wiktel.com>
parents: 11557
diff changeset
154 i++;
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
155 l[li++] = *(i++);
12915
fe2cb084ab16 [gaim-migrate @ 15268]
Richard Laager <rlaager@wiktel.com>
parents: 11557
diff changeset
156 }
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
157 if (!sfile) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
158 l[li] = 0;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
159 sfile = g_build_filename(dirname, l, NULL);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
160 } else {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
161 GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162 l[li] = 0;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 smiley->file = sfile;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
164 smiley->smile = g_strdup(l);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165 smiley->hidden = hidden;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166 list->smileys = g_slist_append(list->smileys, smiley);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168 while (isspace(*i))
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169 i++;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
170
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174
13586
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
175 g_free(dirname);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
176 fclose(f);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
177
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
178 if (!theme->name || !theme->desc || !theme->author) {
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
179 GSList *already_freed = NULL;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
180 struct smiley_list *wer = theme->list, *wer2;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
181
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
182 gaim_debug_error("gtkthemes", "Invalid file format, not loading smiley theme from '%s'\n", file);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
183
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
184 while (wer) {
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
185 while (wer->smileys) {
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
186 GtkIMHtmlSmiley *uio = wer->smileys->data;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
187 if (uio->icon)
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
188 g_object_unref(uio->icon);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
189 if (!g_slist_find(already_freed, uio->file)) {
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
190 g_free(uio->file);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
191 already_freed = g_slist_append(already_freed, uio->file);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
192 }
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
193 g_free(uio->smile);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
194 g_free(uio);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
195 wer->smileys = g_slist_remove(wer->smileys, uio);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
196 }
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
197 wer2 = wer->next;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
198 g_free(wer->sml);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
199 g_free(wer);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
200 wer = wer2;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
201 }
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
202 theme->list = NULL;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
203 g_slist_free(already_freed);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
204
13624
ff70d3009409 [gaim-migrate @ 16011]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13586
diff changeset
205 g_free(theme->name);
ff70d3009409 [gaim-migrate @ 16011]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13586
diff changeset
206 g_free(theme->desc);
ff70d3009409 [gaim-migrate @ 16011]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13586
diff changeset
207 g_free(theme->author);
ff70d3009409 [gaim-migrate @ 16011]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13586
diff changeset
208 g_free(theme->icon);
13586
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
209 g_free(theme->path);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
210 g_free(theme);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
211
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
212 return;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
213 }
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
214
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
215 if (new_theme) {
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
216 smiley_themes = g_slist_append(smiley_themes, theme);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
217 }
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
218
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
219 if (load) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
220 GList *cnv;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
221
13586
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
222 if (current_smiley_theme) {
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
223 GSList *already_freed = NULL;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
224 struct smiley_list *wer = current_smiley_theme->list, *wer2;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
225 while (wer) {
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
226 while (wer->smileys) {
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
227 GtkIMHtmlSmiley *uio = wer->smileys->data;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
228 if (uio->icon)
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
229 g_object_unref(uio->icon);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
230 if (!g_slist_find(already_freed, uio->file)) {
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
231 g_free(uio->file);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
232 already_freed = g_slist_append(already_freed, uio->file);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
233 }
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
234 g_free(uio->smile);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
235 g_free(uio);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
236 wer->smileys = g_slist_remove(wer->smileys, uio);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
237 }
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
238 wer2 = wer->next;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
239 g_free(wer->sml);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
240 g_free(wer);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
241 wer = wer2;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
242 }
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
243 current_smiley_theme->list = NULL;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
244 g_slist_free(already_freed);
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
245 }
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
246 current_smiley_theme = theme;
0cc7773b1d87 [gaim-migrate @ 15971]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13133
diff changeset
247
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
248 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
249 GaimConversation *conv = cnv->data;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
250
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
251 if (GAIM_IS_GTK_CONVERSATION(conv)) {
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
252 gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml);
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
253 gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->entry);
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
254 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
255 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
256 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
257 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
258
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
259 void gaim_gtkthemes_smiley_theme_probe()
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
260 {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
261 GDir *dir;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
262 const gchar *file;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
263 gchar *path;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
264 int l;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
265
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
266 char* probedirs[3];
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
267 probedirs[0] = g_build_filename(DATADIR, "pixmaps", "gaim", "smileys", NULL);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
268 probedirs[1] = g_build_filename(gaim_user_dir(), "smileys", NULL);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
269 probedirs[2] = 0;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
270 for (l=0; probedirs[l]; l++) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
271 dir = g_dir_open(probedirs[l], 0, NULL);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
272 if (dir) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
273 while ((file = g_dir_read_name(dir))) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
274 path = g_build_filename(probedirs[l], file, "theme", NULL);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
275
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
276 /* Here we check to see that the theme has proper syntax.
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
277 * We set the second argument to FALSE so that it doesn't load
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
278 * the theme yet.
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
279 */
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
280 gaim_gtkthemes_load_smiley_theme(path, FALSE);
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
281 g_free(path);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
282 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
283 g_dir_close(dir);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
284 } else if (l == 1) {
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10295
diff changeset
285 g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
286 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
287 g_free(probedirs[l]);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
288 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
289 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
290
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
291 GSList *gaim_gtkthemes_get_proto_smileys(const char *id) {
10295
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
292 GaimPlugin *proto;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
293 struct smiley_list *list, *def;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
294
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
295 if ((current_smiley_theme == NULL) || (current_smiley_theme->list == NULL))
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
296 return NULL;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
297
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
298 def = list = current_smiley_theme->list;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
299
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
300 if (id == NULL)
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
301 return def->smileys;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
302
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
303 proto = gaim_find_prpl(id);
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
304
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
305 while (list) {
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
306 if (!strcmp(list->sml, "default"))
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
307 def = list;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
308 else if (proto && !strcmp(proto->info->name, list->sml))
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
309 break;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
310
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
311 list = list->next;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
312 }
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
313
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
314 return list ? list->smileys : def->smileys;
0cf2a686266e [gaim-migrate @ 11474]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
315 }
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
316
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
317 void gaim_gtkthemes_init()
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
318 {
11557
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
319 GSList *l;
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
320 const char *current_theme =
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
321 gaim_prefs_get_string("/gaim/gtk/smileys/theme");
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
322
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
323 gaim_gtkthemes_smiley_theme_probe();
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
324
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
325 for (l = smiley_themes; l; l = l->next) {
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
326 struct smiley_theme *smile = l->data;
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
327 if (smile->name && strcmp(current_theme, smile->name) == 0) {
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
328 gaim_gtkthemes_load_smiley_theme(smile->path, TRUE);
11557
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
329 break;
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
330 }
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
331 }
11557
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
332
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
333 /* If we still don't have a smiley theme, choose the first one */
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
334 if (!current_smiley_theme && smiley_themes) {
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
335 struct smiley_theme *smile = smiley_themes->data;
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
336 gaim_gtkthemes_load_smiley_theme(smile->path, TRUE);
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
337 }
1e7c0773380f [gaim-migrate @ 13819]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11525
diff changeset
338
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 10589
diff changeset
339 }