annotate src/themes.c @ 5734:5cd96052bc45

[gaim-migrate @ 6158] had these prefs wrong committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Wed, 04 Jun 2003 06:05:17 +0000
parents dae79aefac8d
children 059d95c67cda
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
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);
4816
94e75b03c598 [gaim-migrate @ 5140]
Luke Schierer <lschiere@pidgin.im>
parents: 4814
diff changeset
135 child->sml = g_strndup(i+1, (int)strchr(i, ']') - (int)i - 1);
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
4398
a8249a5250b6 [gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents: 4375
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);
4338
6c1230d15958 [gaim-migrate @ 4602]
Christian Hammond <chipx86@chipx86.com>
parents: 4323
diff changeset
200 }
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
201 }
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4266
diff changeset
202
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 g_free(dirname);
4989
0f8189301213 [gaim-migrate @ 5324]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
204 fclose(f);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 }
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 void smiley_theme_probe()
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 GDir *dir;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 const gchar *file;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 gchar *path;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 int l;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 char* probedirs[3];
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 probedirs[0] = g_build_filename(DATADIR, "pixmaps", "gaim", "smileys", NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 probedirs[1] = g_build_filename(gaim_user_dir(), "smileys", NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 probedirs[2] = 0;
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 for (l=0; probedirs[l]; l++) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 dir = g_dir_open(probedirs[l], 0, NULL);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 if (dir) {
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 while ((file = g_dir_read_name(dir))) {
4301
a23ae74677a2 [gaim-migrate @ 4555]
Sean Egan <seanegan@gmail.com>
parents: 4298
diff changeset
222 path = g_build_filename(probedirs[l], file, "theme", NULL);
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
223
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 /* Here we check to see that the theme has proper syntax.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 * 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
226 * the theme yet.
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 */
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
228 load_smiley_theme(path, FALSE);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 g_free(path);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 g_dir_close(dir);
4341
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
232 } else if (l == 1) {
3ba910921aa0 [gaim-migrate @ 4605]
Sean Egan <seanegan@gmail.com>
parents: 4338
diff changeset
233 mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4816
diff changeset
234 }
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 g_free(probedirs[l]);
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 }
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 }
4667
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 GSList *get_proto_smileys(int protocol) {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4989
diff changeset
240 GaimPlugin *proto = gaim_find_prpl(protocol);
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
241 struct smiley_list *list, *def;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
242
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
243 if(!current_smiley_theme)
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
244 return NULL;
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 def = list = current_smiley_theme->list;
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 while(list) {
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
249 if(!strcmp(list->sml, "default"))
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
250 def = list;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4989
diff changeset
251 else if(proto && !strcmp(proto->info->name, list->sml))
4667
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
252 break;
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 list = list->next;
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
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
257 return list ? list->smileys : def->smileys;
4bf9c6e8e432 [gaim-migrate @ 4978]
Nathan Walp <nwalp@pidgin.im>
parents: 4632
diff changeset
258 }