annotate src/themes.c @ 4735:66c2388046fb

[gaim-migrate @ 5050] This patch is from Ka-Hing Cheung. It readds tooltips and the hand cursor for GtkIMHtml links. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 13 Mar 2003 06:56:40 +0000
parents 4bf9c6e8e432
children 677d3cb193a1
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"
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
25 #include "prpl.h"
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include <stdio.h>
4298
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
27 #include <string.h>
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
28 #include <ctype.h>
4341
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
29 #include <sys/stat.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) {
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
152 gboolean hidden = FALSE;
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);
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
172 smiley->hidden = hidden;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 list->smileys = g_slist_append(list->smileys, smiley);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
175 while (isspace(*i))
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 i++;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
177
4263
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 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
181
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
182 if (load) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4341
diff changeset
183 GList *cnv;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
184
4375
90eaa3486949 [gaim-migrate @ 4641]
Christian Hammond <chipx86@chipx86.com>
parents: 4359
diff changeset
185 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4341
diff changeset
186 struct gaim_conversation *conv = cnv->data;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
187
4398
a8249a5250b6 [gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents: 4375
diff changeset
188 if (GAIM_IS_GTK_CONVERSATION(conv))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4341
diff changeset
189 smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml);
4338
6c1230d15958 [gaim-migrate @ 4602]
Christian Hammond <chipx86@chipx86.com>
parents: 4323
diff changeset
190 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
191 }
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
192
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 g_free(dirname);
4323
8a932c488afc [gaim-migrate @ 4578]
Sean Egan <seanegan@gmail.com>
parents: 4321
diff changeset
194 return old ? NULL : theme;
4263
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
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 void smiley_theme_probe()
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 GDir *dir;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 const gchar *file;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 gchar *path;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 struct smiley_theme *smile;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 int l;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 char* probedirs[3];
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 probedirs[0] = g_build_filename(DATADIR, "pixmaps", "gaim", "smileys", NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 probedirs[1] = g_build_filename(gaim_user_dir(), "smileys", NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 probedirs[2] = 0;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 for (l=0; probedirs[l]; l++) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 dir = g_dir_open(probedirs[l], 0, NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 if (dir) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 while ((file = g_dir_read_name(dir))) {
4301
a23ae74677a2 [gaim-migrate @ 4555]
Sean Egan <seanegan@gmail.com>
parents: 4298
diff changeset
213 path = g_build_filename(probedirs[l], file, "theme", NULL);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 /* Here we check to see that the theme has proper syntax.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 * 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
217 * the theme yet.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 */
4298
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
219 if ((smile = load_smiley_theme(path, FALSE))) {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 smiley_themes = g_slist_append(smiley_themes, smile);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 g_free(path);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 g_dir_close(dir);
4341
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
225 } else if (l == 1) {
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
226 mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
227 }
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 g_free(probedirs[l]);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 }
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
231
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
232 GSList *get_proto_smileys(int protocol) {
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
233 struct prpl *proto = find_prpl(protocol);
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
234 struct smiley_list *list, *def;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
235
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
236 if(!current_smiley_theme)
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
237 return NULL;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
238
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
239 def = list = current_smiley_theme->list;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
240
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
241 while(list) {
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
242 if(!strcmp(list->sml, "default"))
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
243 def = list;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
244 else if(proto && !strcmp(proto->name, list->sml))
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
245 break;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
246
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
247 list = list->next;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
248 }
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
249
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
250 return list ? list->smileys : def->smileys;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
251 }