annotate src/themes.c @ 6949:49aa5a968f04

[gaim-migrate @ 7496] 2 updated translations committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 24 Sep 2003 21:26:36 +0000
parents 338147ea6896
children 662a33ce4343
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 */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
21 #include "gtkinternal.h"
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
25 #include "prpl.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
26 #include "util.h"
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 struct smiley_list {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 char *sml;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 GSList *smileys;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 struct smiley_list *next;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 };
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
39 GSList *smiley_themes = NULL;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
40 struct smiley_theme *current_smiley_theme;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 void smiley_themeize(GtkWidget *imhtml)
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 struct smiley_list *list;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 if (!current_smiley_theme)
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 return;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml));
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 list = current_smiley_theme->list;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 while (list) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 char *sml = !strcmp(list->sml, "default") ? NULL : list->sml;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 GSList *icons = list->smileys;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 while (icons) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 icons = icons->next;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 list = list->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 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
61 void load_smiley_theme(const char *file, gboolean load)
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 FILE *f = fopen(file, "r");
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 char buf[256];
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 char *i;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 struct smiley_theme *theme=NULL;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 struct smiley_list *list = NULL;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 GSList *lst = smiley_themes;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 char *dirname;
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
70
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
71 if (!f)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
72 return;
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;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 break;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 lst = lst->next;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
82
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 if (!theme) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 theme = g_new0(struct smiley_theme, 1);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
85 theme->path = g_strdup(file);
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
86 smiley_themes = g_slist_append(smiley_themes, theme);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
88
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 dirname = g_path_get_dirname(file);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 if (load) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 if (current_smiley_theme) {
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
92 GSList *already_freed = NULL;
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
93 struct smiley_list *wer = current_smiley_theme->list, *wer2;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 while (wer) {
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
95 while (wer->smileys) {
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
96 GtkIMHtmlSmiley *uio = wer->smileys->data;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 if (uio->icon)
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 g_object_unref(uio->icon);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
99 if (!g_slist_find(already_freed, uio->file)) {
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
100 g_free(uio->file);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
101 already_freed = g_slist_append(already_freed, uio->file);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
102 }
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 g_free(uio->smile);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
104 g_free(uio);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
105 wer->smileys=g_slist_remove(wer->smileys, uio);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 }
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
107 wer2 = wer->next;
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
108 g_free(wer->sml);
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
109 g_free(wer);
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
110 wer = wer2;
4263
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 }
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
117
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
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
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
131 if (*i == '[' && strchr(i, ']') && load) {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
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;
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
139 } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) {
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
140 if(theme->name)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
141 g_free(theme->name);
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
142 theme->name = g_strdup(i+ strlen("Name="));
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
143 theme->name[strlen(theme->name)-1] = 0;
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
144 } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) {
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
145 if(theme->desc)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
146 g_free(theme->desc);
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
147 theme->desc = g_strdup(i + strlen("Description="));
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
148 theme->desc[strlen(theme->desc)-1] = 0;
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
149 } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) {
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
150 if(theme->icon)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
151 g_free(theme->icon);
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
152 theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL);
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
153 theme->icon[strlen(theme->icon)-1] = 0;
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
154 } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) {
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
155 if(theme->author)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
156 g_free(theme->author);
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
157 theme->author = g_strdup(i + strlen("Author="));
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
158 theme->author[strlen(theme->author)-1] = 0;
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
159 } else if (load && list) {
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
160 gboolean hidden = FALSE;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
161 char *sfile = NULL;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
162
4266
9ccb6c521cb2 [gaim-migrate @ 4517]
Sean Egan <seanegan@gmail.com>
parents: 4263
diff changeset
163 if (*i == '!' && *(i + 1) == ' ') {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 hidden = TRUE;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 i = i + 2;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 while (*i) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 char l[64];
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 int li = 0;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
170 while (!isspace(*i))
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 l[li++] = *(i++);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
172 if (!sfile) {
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 l[li] = 0;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
174 sfile = g_build_filename(dirname, l, NULL);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 } else {
4632
c4ca37f34130 [gaim-migrate @ 4930]
Luke Schierer <lschiere@pidgin.im>
parents: 4630
diff changeset
176 GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 l[li] = 0;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
178 smiley->file = sfile;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 smiley->smile = g_strdup(l);
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
180 smiley->hidden = hidden;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 list->smileys = g_slist_append(list->smileys, smiley);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 }
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
183 while (isspace(*i))
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 i++;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
185
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
189
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
190 if (load) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4341
diff changeset
191 GList *cnv;
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
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
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
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
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
199 }
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
200
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 g_free(dirname);
4989
0f8189301213 [gaim-migrate @ 5324]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
202 fclose(f);
4263
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
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 void smiley_theme_probe()
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 GDir *dir;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 const gchar *file;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 gchar *path;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 int l;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 char* probedirs[3];
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 probedirs[0] = g_build_filename(DATADIR, "pixmaps", "gaim", "smileys", NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 probedirs[1] = g_build_filename(gaim_user_dir(), "smileys", NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 probedirs[2] = 0;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 for (l=0; probedirs[l]; l++) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 dir = g_dir_open(probedirs[l], 0, NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 if (dir) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 while ((file = g_dir_read_name(dir))) {
4301
a23ae74677a2 [gaim-migrate @ 4555]
Sean Egan <seanegan@gmail.com>
parents: 4298
diff changeset
220 path = g_build_filename(probedirs[l], file, "theme", NULL);
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
221
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 /* Here we check to see that the theme has proper syntax.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 * 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
224 * the theme yet.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 */
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
226 load_smiley_theme(path, FALSE);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 g_free(path);
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 g_dir_close(dir);
4341
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
230 } else if (l == 1) {
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
231 mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
232 }
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 g_free(probedirs[l]);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 }
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
236
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
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
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
239 struct smiley_list *list, *def;
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 if(!current_smiley_theme)
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
242 return NULL;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
243
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
244 def = list = current_smiley_theme->list;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
245
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
246 while(list) {
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
247 if(!strcmp(list->sml, "default"))
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
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
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
250 break;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
251
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
252 list = list->next;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
253 }
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
254
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
255 return list ? list->smileys : def->smileys;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
256 }