annotate src/themes.c @ 4659:260678c4aeb3

[gaim-migrate @ 4970] That's to Ari Pollak for pointing out that when we set the directory for the file send dialog, we need to have a trailing slash in the name. And thanks for suggesting a fix, also. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 07 Mar 2003 05:32:44 +0000
parents c4ca37f34130
children 4bf9c6e8e432
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * Themes for Gaim
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2003, Sean Egan <bj91704@binghamton.edu>
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * (at your option) any later version.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * GNU General Public License for more details.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 */
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
22 #include "gaim.h"
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
23 #include "ui.h"
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "gtkimhtml.h"
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include <stdio.h>
4298
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
26 #include <string.h>
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
27 #include <ctype.h>
4341
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
28 #include <sys/stat.h>
4298
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
29 #include "gaim.h"
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
4321
1cfad48b7d93 [gaim-migrate @ 4576]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4301
diff changeset
31 #ifdef _WIN32
1cfad48b7d93 [gaim-migrate @ 4576]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4301
diff changeset
32 #include "win32dep.h"
1cfad48b7d93 [gaim-migrate @ 4576]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4301
diff changeset
33 #endif
1cfad48b7d93 [gaim-migrate @ 4576]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4301
diff changeset
34
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 struct smiley_list {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 char *sml;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 GSList *smileys;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 struct smiley_list *next;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 };
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 GSList *smiley_themes;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
42 struct smiley_theme *current_smiley_theme;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 void smiley_themeize(GtkWidget *imhtml)
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 struct smiley_list *list;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 if (!current_smiley_theme)
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 return;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml));
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 list = current_smiley_theme->list;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 while (list) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 char *sml = !strcmp(list->sml, "default") ? NULL : list->sml;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 GSList *icons = list->smileys;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 while (icons) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 icons = icons->next;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 list = list->next;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
4298
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
63 struct smiley_theme *load_smiley_theme(const char *file, gboolean load)
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 FILE *f = fopen(file, "r");
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 char buf[256];
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 char *i;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 struct smiley_theme *theme=NULL;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 struct smiley_list *list = NULL;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 GSList *lst = smiley_themes;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 char *dirname;
4323
8a932c488afc [gaim-migrate @ 4578]
Sean Egan <seanegan@gmail.com>
parents: 4321
diff changeset
72 gboolean old=FALSE;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
73
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 while (lst) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 struct smiley_theme *thm = lst->data;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
76 if (!strcmp(thm->path, file)) {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 theme = thm;
4323
8a932c488afc [gaim-migrate @ 4578]
Sean Egan <seanegan@gmail.com>
parents: 4321
diff changeset
78 old = TRUE;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 break;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 lst = lst->next;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
83
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
84 if (!f)
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
85 return NULL;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 if (!theme) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 theme = g_new0(struct smiley_theme, 1);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
88 theme->path = g_strdup(file);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
90
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 dirname = g_path_get_dirname(file);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 if (load) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 if (current_smiley_theme) {
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
94 GSList *already_freed = NULL;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 struct smiley_list *wer = current_smiley_theme->list;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 while (wer) {
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
97 GSList *already_freed = NULL;
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
98 while (wer->smileys) {
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
99 GtkIMHtmlSmiley *uio = wer->smileys->data;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 if (uio->icon)
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 g_object_unref(uio->icon);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
102 if (!g_slist_find(already_freed, uio->file)) {
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
103 g_free(uio->file);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
104 already_freed = g_slist_append(already_freed, uio->file);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
105 }
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 g_free(uio->smile);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
107 g_free(uio);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
108 wer->smileys=g_slist_remove(wer->smileys, uio);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 wer = wer->next;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
112 current_smiley_theme->list = NULL;
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
113 g_slist_free(already_freed);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
115 current_smiley_theme = theme;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
117
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
118
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 while (!feof(f)) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 if (!fgets(buf, sizeof(buf), f)) {
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
121 break;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
123
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
124 if (buf[0] == '#' || buf[0] == '\0')
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 continue;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
126
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 i = buf;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 while (isspace(*i))
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 i++;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
130
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 if (*i == '[' && strchr(i, ']') && load) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 struct smiley_list *child = g_new0(struct smiley_list, 1);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 child->sml = g_strndup(i+1, (int)strchr(i, ']') - (int)i - 1);
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
134 if (theme->list)
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 list->next = child;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 else
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 theme->list = child;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 list = child;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 } else if (!g_strncasecmp(i, "Name=", strlen("Name="))) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 theme->name = g_strdup(i+ strlen("Name="));
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
141 theme->name[strlen(theme->name)-1] = 0;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 } else if (!g_strncasecmp(i, "Description=", strlen("Description="))) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 theme->desc = g_strdup(i + strlen("Description="));
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
144 theme->desc[strlen(theme->desc)-1] = 0;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 } else if (!g_strncasecmp(i, "Icon=", strlen("Icon="))) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
147 theme->icon[strlen(theme->icon)-1] = 0;
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
148 } else if (!g_strncasecmp(i, "Author=", strlen("Author="))) {
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
149 theme->author = g_strdup(i + strlen("Author="));
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
150 theme->author[strlen(theme->author)-1] = 0;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 } else if (load && list) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 gboolean hidden;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
153 char *sfile = NULL;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
154
4266
9ccb6c521cb2 [gaim-migrate @ 4517]
Sean Egan <seanegan@gmail.com>
parents: 4263
diff changeset
155 if (*i == '!' && *(i + 1) == ' ') {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 hidden = TRUE;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 i = i + 2;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 while (*i) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 char l[64];
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 int li = 0;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
162 while (!isspace(*i))
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 l[li++] = *(i++);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
164 if (!sfile) {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 l[li] = 0;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
166 sfile = g_build_filename(dirname, l, NULL);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 } else {
4632
c4ca37f34130 [gaim-migrate @ 4930]
Luke Schierer <lschiere@pidgin.im>
parents: 4630
diff changeset
168 GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 l[li] = 0;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
170 smiley->file = sfile;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 smiley->smile = g_strdup(l);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 list->smileys = g_slist_append(list->smileys, smiley);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
174 while (isspace(*i))
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 i++;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
176
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
180
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
181 if (load) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4341
diff changeset
182 GList *cnv;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
183
4375
90eaa3486949 [gaim-migrate @ 4641]
Christian Hammond <chipx86@chipx86.com>
parents: 4359
diff changeset
184 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4341
diff changeset
185 struct gaim_conversation *conv = cnv->data;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
186
4398
a8249a5250b6 [gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents: 4375
diff changeset
187 if (GAIM_IS_GTK_CONVERSATION(conv))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4341
diff changeset
188 smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml);
4338
6c1230d15958 [gaim-migrate @ 4602]
Christian Hammond <chipx86@chipx86.com>
parents: 4323
diff changeset
189 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
190 }
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
191
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 g_free(dirname);
4323
8a932c488afc [gaim-migrate @ 4578]
Sean Egan <seanegan@gmail.com>
parents: 4321
diff changeset
193 return old ? NULL : theme;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 void smiley_theme_probe()
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 GDir *dir;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 const gchar *file;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 gchar *path;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 struct smiley_theme *smile;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 int l;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 char* probedirs[3];
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 probedirs[0] = g_build_filename(DATADIR, "pixmaps", "gaim", "smileys", NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 probedirs[1] = g_build_filename(gaim_user_dir(), "smileys", NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 probedirs[2] = 0;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 for (l=0; probedirs[l]; l++) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 dir = g_dir_open(probedirs[l], 0, NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 if (dir) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 while ((file = g_dir_read_name(dir))) {
4301
a23ae74677a2 [gaim-migrate @ 4555]
Sean Egan <seanegan@gmail.com>
parents: 4298
diff changeset
212 path = g_build_filename(probedirs[l], file, "theme", NULL);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 /* Here we check to see that the theme has proper syntax.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 * We set the second argument to FALSE so that it doesn't load
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 * the theme yet.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 */
4298
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
218 if ((smile = load_smiley_theme(path, FALSE))) {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 smiley_themes = g_slist_append(smiley_themes, smile);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 g_free(path);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 g_dir_close(dir);
4341
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
224 } else if (l == 1) {
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
225 mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
226 }
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 g_free(probedirs[l]);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 }