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