annotate src/themes.c @ 8401:c13a4913a071

[gaim-migrate @ 9130] better error processing for jabber committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 05 Mar 2004 23:42:34 +0000
parents fa6395637e2c
children ed62fb44aa30
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 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7956
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7956
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7956
diff changeset
6 * source distribution.
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * 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
10 * the Free Software Foundation; either version 2 of the License, or
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
23 #include "gtkinternal.h"
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
25 #include "conversation.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
26 #include "debug.h"
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
27 #include "prpl.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
28 #include "util.h"
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
30 #include "gtkconv.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
31 #include "gtkimhtml.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
32
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
33 #include "ui.h"
4321
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
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
41 GSList *smiley_themes = NULL;
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
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
63 void 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;
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
72
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
73 if (!f)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
74 return;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
75
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 while (lst) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 struct smiley_theme *thm = lst->data;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
78 if (!strcmp(thm->path, file)) {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 theme = thm;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 break;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 lst = lst->next;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
84
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 if (!theme) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 theme = g_new0(struct smiley_theme, 1);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
87 theme->path = g_strdup(file);
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
88 smiley_themes = g_slist_append(smiley_themes, theme);
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;
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
95 struct smiley_list *wer = current_smiley_theme->list, *wer2;
4263
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 while (wer->smileys) {
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
98 GtkIMHtmlSmiley *uio = wer->smileys->data;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 if (uio->icon)
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 g_object_unref(uio->icon);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
101 if (!g_slist_find(already_freed, uio->file)) {
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
102 g_free(uio->file);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
103 already_freed = g_slist_append(already_freed, uio->file);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
104 }
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 g_free(uio->smile);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
106 g_free(uio);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
107 wer->smileys=g_slist_remove(wer->smileys, uio);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 }
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
109 wer2 = wer->next;
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
110 g_free(wer->sml);
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
111 g_free(wer);
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
112 wer = wer2;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
114 current_smiley_theme->list = NULL;
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
115 g_slist_free(already_freed);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
117 current_smiley_theme = theme;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 }
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
119
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
120
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 while (!feof(f)) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 if (!fgets(buf, sizeof(buf), f)) {
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
123 break;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
125
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
126 if (buf[0] == '#' || buf[0] == '\0')
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 continue;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
128
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 i = buf;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 while (isspace(*i))
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 i++;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
132
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
133 if (*i == '[' && strchr(i, ']') && load) {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 struct smiley_list *child = g_new0(struct smiley_list, 1);
6478
338147ea6896 [gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
135 child->sml = g_strndup(i+1, strchr(i, ']') - i - 1);
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
136 if (theme->list)
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 list->next = child;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 else
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 theme->list = child;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 list = child;
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
141 } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) {
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
142 if(theme->name)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
143 g_free(theme->name);
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
144 theme->name = g_strdup(i+ strlen("Name="));
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
145 theme->name[strlen(theme->name)-1] = 0;
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
146 } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) {
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
147 if(theme->desc)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
148 g_free(theme->desc);
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
149 theme->desc = g_strdup(i + strlen("Description="));
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
150 theme->desc[strlen(theme->desc)-1] = 0;
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
151 } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) {
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
152 if(theme->icon)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
153 g_free(theme->icon);
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
154 theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL);
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
155 theme->icon[strlen(theme->icon)-1] = 0;
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
156 } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) {
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
157 if(theme->author)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
158 g_free(theme->author);
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
159 theme->author = g_strdup(i + strlen("Author="));
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
160 theme->author[strlen(theme->author)-1] = 0;
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
161 } else if (load && list) {
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
162 gboolean hidden = FALSE;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
163 char *sfile = NULL;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
164
4266
9ccb6c521cb2 [gaim-migrate @ 4517]
Sean Egan <seanegan@gmail.com>
parents: 4263
diff changeset
165 if (*i == '!' && *(i + 1) == ' ') {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 hidden = TRUE;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 i = i + 2;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 while (*i) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 char l[64];
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 int li = 0;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
172 while (!isspace(*i))
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 l[li++] = *(i++);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
174 if (!sfile) {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 l[li] = 0;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
176 sfile = g_build_filename(dirname, l, NULL);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 } else {
4632
c4ca37f34130 [gaim-migrate @ 4930]
Luke Schierer <lschiere@pidgin.im>
parents: 4630
diff changeset
178 GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 l[li] = 0;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
180 smiley->file = sfile;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 smiley->smile = g_strdup(l);
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
182 smiley->hidden = hidden;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 list->smileys = g_slist_append(list->smileys, smiley);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
185 while (isspace(*i))
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 i++;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
187
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
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 if (load) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4341
diff changeset
193 GList *cnv;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
194
4375
90eaa3486949 [gaim-migrate @ 4641]
Christian Hammond <chipx86@chipx86.com>
parents: 4359
diff changeset
195 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
196 GaimConversation *conv = cnv->data;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
197
7736
662a33ce4343 [gaim-migrate @ 8381]
Sean Egan <seanegan@gmail.com>
parents: 6478
diff changeset
198 if (GAIM_IS_GTK_CONVERSATION(conv)) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4341
diff changeset
199 smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml);
7736
662a33ce4343 [gaim-migrate @ 8381]
Sean Egan <seanegan@gmail.com>
parents: 6478
diff changeset
200 smiley_themeize(GAIM_GTK_CONVERSATION(conv)->entry);
662a33ce4343 [gaim-migrate @ 8381]
Sean Egan <seanegan@gmail.com>
parents: 6478
diff changeset
201 }
4338
6c1230d15958 [gaim-migrate @ 4602]
Christian Hammond <chipx86@chipx86.com>
parents: 4323
diff changeset
202 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
203 }
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
204
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 g_free(dirname);
4989
0f8189301213 [gaim-migrate @ 5324]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
206 fclose(f);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 void smiley_theme_probe()
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 GDir *dir;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 const gchar *file;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 gchar *path;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 int l;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 char* probedirs[3];
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 probedirs[0] = g_build_filename(DATADIR, "pixmaps", "gaim", "smileys", NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 probedirs[1] = g_build_filename(gaim_user_dir(), "smileys", NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 probedirs[2] = 0;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 for (l=0; probedirs[l]; l++) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 dir = g_dir_open(probedirs[l], 0, NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 if (dir) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 while ((file = g_dir_read_name(dir))) {
4301
a23ae74677a2 [gaim-migrate @ 4555]
Sean Egan <seanegan@gmail.com>
parents: 4298
diff changeset
224 path = g_build_filename(probedirs[l], file, "theme", NULL);
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
225
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 /* Here we check to see that the theme has proper syntax.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 * 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
228 * the theme yet.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 */
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
230 load_smiley_theme(path, FALSE);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 g_free(path);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 g_dir_close(dir);
4341
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
234 } else if (l == 1) {
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
235 mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
236 }
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 g_free(probedirs[l]);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 }
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
240
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7736
diff changeset
241 GSList *get_proto_smileys(const char *id) {
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7736
diff changeset
242 GaimPlugin *proto = gaim_find_prpl(id);
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
243 struct smiley_list *list, *def;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
244
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
245 if(!current_smiley_theme)
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
246 return NULL;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
247
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
248 def = list = current_smiley_theme->list;
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 while(list) {
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
251 if(!strcmp(list->sml, "default"))
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
252 def = list;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4989
diff changeset
253 else if(proto && !strcmp(proto->info->name, list->sml))
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
254 break;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
255
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
256 list = list->next;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
257 }
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
258
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
259 return list ? list->smileys : def->smileys;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
260 }