Mercurial > pidgin
annotate src/themes.c @ 4359:5fb47ec9bfe4
[gaim-migrate @ 4625]
Wow, okay, where to begin with this one ;)
I rewrote the whole conversation backend. It is now core/UI split. Here's
how it works..
Every conversation is represented by a gaim_conversation structure. This
branches out into gaim_im and gaim_chat structures. Every conversation
lives in (well, normally, but it doesn't have to) a gaim_window structure.
This is a _CORE_ representation of a window. There can be multiple
gaim_window structures around.
The gaim_window and gaim_conversation structures have UI-specific operation
structures associated with them. At the moment, the only UI is GTK+, and
this will be for some time. Don't start thinking you can write a QT UI now.
It's just not going to happen.
Everything that is done on a conversation is done through the core API.
This API does core processing and then calls the UI operations for the
rendering and anything else.
Now, what does this give the user?
- Multiple windows.
- Multiple tabs per window.
- Draggable tabs.
- Send As menu is moved to the menubar.
- Menubar for chats.
- Some very cool stuff in the future, like replacing, say, IRC chat windows
with an X-Chat interface, or whatever.
- Later on, customizable window/conversation positioning.
For developers:
- Fully documented API
- Core/UI split
- Variable checking and mostly sane handling of incorrect variables.
- Logical structure to conversations, both core and UI.
- Some very cool stuff in the future, like replacing, say, IRC chat windows
with an X-Chat interface, or whatever.
- Later on, customizable window/conversation positioning.
- Oh yeah, and the beginning of a stock icon system.
Now, there are things that aren't there yet. You will see tabs even if you
have them turned off. This will be fixed in time. Also, the preferences
will change to work with the new structure. I'm starting school in 2 days,
so it may not be done immediately, but hopefully in the next week.
Enjoy!
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 20 Jan 2003 09:10:23 +0000 |
parents | 3ba910921aa0 |
children | 90eaa3486949 |
rev | line source |
---|---|
4263 | 1 /* |
2 * Themes for Gaim | |
3 * | |
4 * Copyright (C) 2003, Sean Egan <bj91704@binghamton.edu> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
4288 | 22 #include "gaim.h" |
23 #include "ui.h" | |
4263 | 24 #include "gtkimhtml.h" |
25 #include <stdio.h> | |
4298 | 26 #include <string.h> |
27 #include <ctype.h> | |
4341 | 28 #include <sys/stat.h> |
4298 | 29 #include "gaim.h" |
4263 | 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 | 35 struct smiley_list { |
36 char *sml; | |
37 GSList *smileys; | |
38 struct smiley_list *next; | |
39 }; | |
40 | |
41 GSList *smiley_themes; | |
4288 | 42 struct smiley_theme *current_smiley_theme; |
4263 | 43 |
44 void smiley_themeize(GtkWidget *imhtml) | |
45 { | |
46 struct smiley_list *list; | |
47 if (!current_smiley_theme) | |
48 return; | |
49 | |
50 gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml)); | |
51 list = current_smiley_theme->list; | |
52 while (list) { | |
53 char *sml = !strcmp(list->sml, "default") ? NULL : list->sml; | |
54 GSList *icons = list->smileys; | |
55 while (icons) { | |
56 gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data); | |
57 icons = icons->next; | |
58 } | |
59 list = list->next; | |
60 } | |
61 } | |
62 | |
4298 | 63 struct smiley_theme *load_smiley_theme(const char *file, gboolean load) |
4263 | 64 { |
65 FILE *f = fopen(file, "r"); | |
66 char buf[256]; | |
67 char *i; | |
68 struct smiley_theme *theme=NULL; | |
69 struct smiley_list *list = NULL; | |
70 GSList *lst = smiley_themes; | |
71 char *dirname; | |
4323 | 72 gboolean old=FALSE; |
4263 | 73 |
74 while (lst) { | |
75 struct smiley_theme *thm = lst->data; | |
4288 | 76 if (!strcmp(thm->path, file)) { |
4263 | 77 theme = thm; |
4323 | 78 old = TRUE; |
4263 | 79 break; |
80 } | |
81 lst = lst->next; | |
82 } | |
83 if (!theme) { | |
84 theme = g_new0(struct smiley_theme, 1); | |
4288 | 85 theme->path = g_strdup(file); |
4263 | 86 } |
87 if (!f) | |
88 return NULL; | |
89 | |
90 dirname = g_path_get_dirname(file); | |
91 if (load) { | |
92 if (current_smiley_theme) { | |
4288 | 93 GSList *already_freed = NULL; |
4263 | 94 struct smiley_list *wer = current_smiley_theme->list; |
95 while (wer) { | |
4288 | 96 GSList *already_freed = NULL; |
97 while (wer->smileys) { | |
98 GtkIMHtmlSmiley *uio = wer->smileys->data; | |
4263 | 99 if (uio->icon) |
100 g_object_unref(uio->icon); | |
4288 | 101 if (!g_slist_find(already_freed, uio->file)) { |
102 g_free(uio->file); | |
103 already_freed = g_slist_append(already_freed, uio->file); | |
104 } | |
4263 | 105 g_free(uio->smile); |
4288 | 106 g_free(uio); |
107 wer->smileys=g_slist_remove(wer->smileys, uio); | |
4263 | 108 } |
109 wer = wer->next; | |
110 } | |
4288 | 111 current_smiley_theme->list = NULL; |
112 g_slist_free(already_freed); | |
4263 | 113 } |
4288 | 114 current_smiley_theme = theme; |
4263 | 115 } |
116 | |
117 | |
118 while (!feof(f)) { | |
119 if (!fgets(buf, sizeof(buf), f)) { | |
4288 | 120 break; |
4263 | 121 } |
122 | |
123 if (buf[0] == '#' || buf[0] == '\0') | |
124 continue; | |
125 | |
126 i = buf; | |
127 while (isspace(*i)) | |
128 i++; | |
129 | |
130 if (*i == '[' && strchr(i, ']') && load) { | |
131 struct smiley_list *child = g_new0(struct smiley_list, 1); | |
132 child->sml = g_strndup(i+1, (int)strchr(i, ']') - (int)i - 1); | |
133 if (theme->list) | |
134 list->next = child; | |
135 else | |
136 theme->list = child; | |
137 list = child; | |
138 } else if (!g_strncasecmp(i, "Name=", strlen("Name="))) { | |
139 theme->name = g_strdup(i+ strlen("Name=")); | |
4288 | 140 theme->name[strlen(theme->name)-1] = 0; |
4263 | 141 } else if (!g_strncasecmp(i, "Description=", strlen("Description="))) { |
142 theme->desc = g_strdup(i + strlen("Description=")); | |
4288 | 143 theme->desc[strlen(theme->desc)-1] = 0; |
4263 | 144 } else if (!g_strncasecmp(i, "Icon=", strlen("Icon="))) { |
145 theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL); | |
4288 | 146 theme->icon[strlen(theme->icon)-1] = 0; |
147 } else if (!g_strncasecmp(i, "Author=", strlen("Author="))) { | |
148 theme->author = g_strdup(i + strlen("Author=")); | |
149 theme->author[strlen(theme->author)-1] = 0; | |
4263 | 150 } else if (load && list) { |
151 gboolean hidden; | |
4288 | 152 char *sfile = NULL; |
4263 | 153 GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1); |
154 | |
4266 | 155 if (*i == '!' && *(i + 1) == ' ') { |
4263 | 156 hidden = TRUE; |
157 i = i + 2; | |
158 } | |
159 while (*i) { | |
160 char l[64]; | |
161 int li = 0; | |
162 while (!isspace(*i)) | |
163 l[li++] = *(i++); | |
4288 | 164 if (!sfile) { |
4263 | 165 l[li] = 0; |
4288 | 166 sfile = g_build_filename(dirname, l, NULL); |
4263 | 167 } else { |
168 l[li] = 0; | |
169 smiley = g_new0(GtkIMHtmlSmiley, 1); | |
4288 | 170 smiley->file = sfile; |
4263 | 171 smiley->smile = g_strdup(l); |
172 list->smileys = g_slist_append(list->smileys, smiley); | |
173 } | |
4288 | 174 while (isspace(*i)) |
4263 | 175 i++; |
4288 | 176 |
4263 | 177 } |
178 } | |
179 } | |
4288 | 180 |
181 if (load) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
182 GList *cnv; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
183 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
184 for (cnv = conversations; cnv != NULL; cnv = cnv->next) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
185 struct gaim_conversation *conv = cnv->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
186 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
187 if (gaim_conversation_get_ops(conv) == |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
188 gaim_get_gtk_conversation_ops()) { |
4338
6c1230d15958
[gaim-migrate @ 4602]
Christian Hammond <chipx86@chipx86.com>
parents:
4323
diff
changeset
|
189 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
190 smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4341
diff
changeset
|
191 } |
4338
6c1230d15958
[gaim-migrate @ 4602]
Christian Hammond <chipx86@chipx86.com>
parents:
4323
diff
changeset
|
192 } |
4288 | 193 } |
194 | |
4263 | 195 g_free(dirname); |
4323 | 196 return old ? NULL : theme; |
4263 | 197 } |
198 | |
199 void smiley_theme_probe() | |
200 { | |
201 GDir *dir; | |
202 const gchar *file; | |
203 gchar *path; | |
204 struct smiley_theme *smile; | |
205 int l; | |
206 | |
207 char* probedirs[3]; | |
208 probedirs[0] = g_build_filename(DATADIR, "pixmaps", "gaim", "smileys", NULL); | |
209 probedirs[1] = g_build_filename(gaim_user_dir(), "smileys", NULL); | |
210 probedirs[2] = 0; | |
211 for (l=0; probedirs[l]; l++) { | |
212 dir = g_dir_open(probedirs[l], 0, NULL); | |
213 if (dir) { | |
214 while ((file = g_dir_read_name(dir))) { | |
4301 | 215 path = g_build_filename(probedirs[l], file, "theme", NULL); |
4263 | 216 |
217 /* Here we check to see that the theme has proper syntax. | |
218 * We set the second argument to FALSE so that it doesn't load | |
219 * the theme yet. | |
220 */ | |
4298 | 221 if ((smile = load_smiley_theme(path, FALSE))) { |
4263 | 222 smiley_themes = g_slist_append(smiley_themes, smile); |
223 } | |
224 g_free(path); | |
225 } | |
226 g_dir_close(dir); | |
4341 | 227 } else if (l == 1) { |
228 mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR); | |
229 } | |
4263 | 230 g_free(probedirs[l]); |
231 } | |
232 | |
233 | |
234 | |
235 } |