Mercurial > pidgin
annotate src/themes.c @ 6626:7a4c4e89a1df
[gaim-migrate @ 7150]
Ambrose C. LI (acli) writes:
" fi.po with the following "safe" changes:
- went over the 0.59.8 po file and found the strings
with idential meanings with changes only in formatting
- some translations obtained by old translation strings
but which requires only some trivial editing
- added some translations from existing po files from
other projects
- converted from iso-8859-15 to utf-8
and "unsafe" changes:
- some translations obtained by old translation strings
but which requires some relatively non-trivial editing
- attempted to correct some obvious mistranslations
It is best to have a native speaker go over this"
but i figure at this point, the last update being in 0.59.8, his version
can't be any worse really
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 25 Aug 2003 23:13:52 +0000 |
parents | 338147ea6896 |
children | 662a33ce4343 |
rev | line source |
---|---|
4263 | 1 /* |
2 * Themes for Gaim | |
3 * | |
4 * Copyright (C) 2003, Sean Egan <bj91704@binghamton.edu> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
21 #include "gtkinternal.h" |
4263 | 22 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
23 #include "conversation.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
24 #include "debug.h" |
4667 | 25 #include "prpl.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
26 #include "util.h" |
4263 | 27 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
28 #include "gtkconv.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
29 #include "gtkimhtml.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
30 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
31 #include "ui.h" |
4321
1cfad48b7d93
[gaim-migrate @ 4576]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4301
diff
changeset
|
32 |
4263 | 33 struct smiley_list { |
34 char *sml; | |
35 GSList *smileys; | |
36 struct smiley_list *next; | |
37 }; | |
38 | |
4892 | 39 GSList *smiley_themes = NULL; |
4288 | 40 struct smiley_theme *current_smiley_theme; |
4263 | 41 |
42 void smiley_themeize(GtkWidget *imhtml) | |
43 { | |
44 struct smiley_list *list; | |
45 if (!current_smiley_theme) | |
46 return; | |
47 | |
48 gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml)); | |
49 list = current_smiley_theme->list; | |
50 while (list) { | |
51 char *sml = !strcmp(list->sml, "default") ? NULL : list->sml; | |
52 GSList *icons = list->smileys; | |
53 while (icons) { | |
54 gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data); | |
55 icons = icons->next; | |
56 } | |
57 list = list->next; | |
58 } | |
59 } | |
60 | |
4892 | 61 void load_smiley_theme(const char *file, gboolean load) |
4263 | 62 { |
63 FILE *f = fopen(file, "r"); | |
64 char buf[256]; | |
65 char *i; | |
66 struct smiley_theme *theme=NULL; | |
67 struct smiley_list *list = NULL; | |
68 GSList *lst = smiley_themes; | |
69 char *dirname; | |
4892 | 70 |
71 if (!f) | |
72 return; | |
4630 | 73 |
4263 | 74 while (lst) { |
75 struct smiley_theme *thm = lst->data; | |
4288 | 76 if (!strcmp(thm->path, file)) { |
4263 | 77 theme = thm; |
78 break; | |
79 } | |
80 lst = lst->next; | |
81 } | |
4630 | 82 |
4263 | 83 if (!theme) { |
84 theme = g_new0(struct smiley_theme, 1); | |
4288 | 85 theme->path = g_strdup(file); |
4892 | 86 smiley_themes = g_slist_append(smiley_themes, theme); |
4263 | 87 } |
4630 | 88 |
4263 | 89 dirname = g_path_get_dirname(file); |
90 if (load) { | |
91 if (current_smiley_theme) { | |
4288 | 92 GSList *already_freed = NULL; |
4892 | 93 struct smiley_list *wer = current_smiley_theme->list, *wer2; |
4263 | 94 while (wer) { |
4288 | 95 while (wer->smileys) { |
96 GtkIMHtmlSmiley *uio = wer->smileys->data; | |
4263 | 97 if (uio->icon) |
98 g_object_unref(uio->icon); | |
4288 | 99 if (!g_slist_find(already_freed, uio->file)) { |
100 g_free(uio->file); | |
101 already_freed = g_slist_append(already_freed, uio->file); | |
102 } | |
4263 | 103 g_free(uio->smile); |
4288 | 104 g_free(uio); |
105 wer->smileys=g_slist_remove(wer->smileys, uio); | |
4263 | 106 } |
4892 | 107 wer2 = wer->next; |
108 g_free(wer->sml); | |
109 g_free(wer); | |
110 wer = wer2; | |
4263 | 111 } |
4288 | 112 current_smiley_theme->list = NULL; |
113 g_slist_free(already_freed); | |
4263 | 114 } |
4288 | 115 current_smiley_theme = theme; |
4263 | 116 } |
4816 | 117 |
118 | |
4263 | 119 while (!feof(f)) { |
120 if (!fgets(buf, sizeof(buf), f)) { | |
4288 | 121 break; |
4263 | 122 } |
4630 | 123 |
124 if (buf[0] == '#' || buf[0] == '\0') | |
4263 | 125 continue; |
4630 | 126 |
4263 | 127 i = buf; |
128 while (isspace(*i)) | |
129 i++; | |
4630 | 130 |
4816 | 131 if (*i == '[' && strchr(i, ']') && load) { |
4263 | 132 struct smiley_list *child = g_new0(struct smiley_list, 1); |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
133 child->sml = g_strndup(i+1, strchr(i, ']') - i - 1); |
4816 | 134 if (theme->list) |
4263 | 135 list->next = child; |
136 else | |
137 theme->list = child; | |
138 list = child; | |
4816 | 139 } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) { |
4892 | 140 if(theme->name) |
141 g_free(theme->name); | |
4816 | 142 theme->name = g_strdup(i+ strlen("Name=")); |
143 theme->name[strlen(theme->name)-1] = 0; | |
144 } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) { | |
4892 | 145 if(theme->desc) |
146 g_free(theme->desc); | |
4816 | 147 theme->desc = g_strdup(i + strlen("Description=")); |
148 theme->desc[strlen(theme->desc)-1] = 0; | |
149 } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) { | |
4892 | 150 if(theme->icon) |
151 g_free(theme->icon); | |
4816 | 152 theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL); |
153 theme->icon[strlen(theme->icon)-1] = 0; | |
154 } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) { | |
4892 | 155 if(theme->author) |
156 g_free(theme->author); | |
4816 | 157 theme->author = g_strdup(i + strlen("Author=")); |
158 theme->author[strlen(theme->author)-1] = 0; | |
159 } else if (load && list) { | |
4667 | 160 gboolean hidden = FALSE; |
4288 | 161 char *sfile = NULL; |
4630 | 162 |
4266 | 163 if (*i == '!' && *(i + 1) == ' ') { |
4263 | 164 hidden = TRUE; |
165 i = i + 2; | |
166 } | |
167 while (*i) { | |
168 char l[64]; | |
169 int li = 0; | |
4630 | 170 while (!isspace(*i)) |
4263 | 171 l[li++] = *(i++); |
4288 | 172 if (!sfile) { |
4263 | 173 l[li] = 0; |
4288 | 174 sfile = g_build_filename(dirname, l, NULL); |
4263 | 175 } else { |
4632 | 176 GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1); |
4263 | 177 l[li] = 0; |
4288 | 178 smiley->file = sfile; |
4263 | 179 smiley->smile = g_strdup(l); |
4667 | 180 smiley->hidden = hidden; |
4263 | 181 list->smileys = g_slist_append(list->smileys, smiley); |
182 } | |
4630 | 183 while (isspace(*i)) |
4263 | 184 i++; |
4630 | 185 |
4263 | 186 } |
187 } | |
188 } | |
4288 | 189 |
190 if (load) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
191 GList *cnv; |
4630 | 192 |
4375
90eaa3486949
[gaim-migrate @ 4641]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
193 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
194 GaimConversation *conv = cnv->data; |
4630 | 195 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4375
diff
changeset
|
196 if (GAIM_IS_GTK_CONVERSATION(conv)) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
197 smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); |
4338
6c1230d15958
[gaim-migrate @ 4602]
Christian Hammond <chipx86@chipx86.com>
parents:
4323
diff
changeset
|
198 } |
4288 | 199 } |
200 | |
4263 | 201 g_free(dirname); |
4989 | 202 fclose(f); |
4263 | 203 } |
204 | |
205 void smiley_theme_probe() | |
206 { | |
207 GDir *dir; | |
208 const gchar *file; | |
209 gchar *path; | |
210 int l; | |
211 | |
212 char* probedirs[3]; | |
213 probedirs[0] = g_build_filename(DATADIR, "pixmaps", "gaim", "smileys", NULL); | |
214 probedirs[1] = g_build_filename(gaim_user_dir(), "smileys", NULL); | |
215 probedirs[2] = 0; | |
216 for (l=0; probedirs[l]; l++) { | |
217 dir = g_dir_open(probedirs[l], 0, NULL); | |
218 if (dir) { | |
219 while ((file = g_dir_read_name(dir))) { | |
4301 | 220 path = g_build_filename(probedirs[l], file, "theme", NULL); |
4892 | 221 |
4263 | 222 /* Here we check to see that the theme has proper syntax. |
223 * We set the second argument to FALSE so that it doesn't load | |
224 * the theme yet. | |
225 */ | |
4892 | 226 load_smiley_theme(path, FALSE); |
4263 | 227 g_free(path); |
228 } | |
229 g_dir_close(dir); | |
4341 | 230 } else if (l == 1) { |
231 mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR); | |
4892 | 232 } |
4263 | 233 g_free(probedirs[l]); |
234 } | |
235 } | |
4667 | 236 |
237 GSList *get_proto_smileys(int protocol) { | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4989
diff
changeset
|
238 GaimPlugin *proto = gaim_find_prpl(protocol); |
4667 | 239 struct smiley_list *list, *def; |
240 | |
241 if(!current_smiley_theme) | |
242 return NULL; | |
243 | |
244 def = list = current_smiley_theme->list; | |
245 | |
246 while(list) { | |
247 if(!strcmp(list->sml, "default")) | |
248 def = list; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4989
diff
changeset
|
249 else if(proto && !strcmp(proto->info->name, list->sml)) |
4667 | 250 break; |
251 | |
252 list = list->next; | |
253 } | |
254 | |
255 return list ? list->smileys : def->smileys; | |
256 } |