Mercurial > pidgin.yaz
annotate pidgin/plugins/adiumthemes/webkit.c @ 32561:9f6affeb2a92
new changes seemingly working.
author | tdrhq@soc.pidgin.im |
---|---|
date | Wed, 12 Aug 2009 01:12:15 +0000 |
parents | 84f75556188f |
children | a082cbc30835 |
rev | line source |
---|---|
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1 /* |
32534
0bac73a6a536
Changed the Author added copyright, etc.
tdrhq@soc.pidgin.im
parents:
32533
diff
changeset
|
2 * Adium Message Styles |
0bac73a6a536
Changed the Author added copyright, etc.
tdrhq@soc.pidgin.im
parents:
32533
diff
changeset
|
3 * Copyright (C) 2009 Arnold Noronha <arnstein87@gmail.com> |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
4 * Copyright (C) 2007 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
5 * |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
8 * published by the Free Software Foundation; either version 2 of the |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
9 * License, or (at your option) any later version. |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
10 * |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, but |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
12 * WITHOUT ANY WARRANTY; without even the implied warranty of |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
14 * General Public License for more details. |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
15 * |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
19 * 02111-1307, USA. |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
20 */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
21 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
22 #define PLUGIN_ID "gtk-webview-adium-ims" |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
23 #define PLUGIN_NAME "webview-adium-ims" |
32534
0bac73a6a536
Changed the Author added copyright, etc.
tdrhq@soc.pidgin.im
parents:
32533
diff
changeset
|
24 |
0bac73a6a536
Changed the Author added copyright, etc.
tdrhq@soc.pidgin.im
parents:
32533
diff
changeset
|
25 /* |
0bac73a6a536
Changed the Author added copyright, etc.
tdrhq@soc.pidgin.im
parents:
32533
diff
changeset
|
26 * A lot of this was originally written by Sean Egan, but I think I've |
0bac73a6a536
Changed the Author added copyright, etc.
tdrhq@soc.pidgin.im
parents:
32533
diff
changeset
|
27 * rewrote enough to replace the author for now. |
0bac73a6a536
Changed the Author added copyright, etc.
tdrhq@soc.pidgin.im
parents:
32533
diff
changeset
|
28 */ |
0bac73a6a536
Changed the Author added copyright, etc.
tdrhq@soc.pidgin.im
parents:
32533
diff
changeset
|
29 #define PLUGIN_AUTHOR "Arnold Noronha <arnstein87@gmail.com>" |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
30 #define PURPLE_PLUGINS "Hell yeah" |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
31 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
32 /* System headers */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
33 #include <string.h> |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
34 #include <gdk/gdk.h> |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
35 #include <gtk/gtk.h> |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
36 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
37 #include <webkit/webkit.h> |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
38 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
39 /* Purple headers */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
40 #include <conversation.h> |
32547 | 41 #include <debug.h> |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
42 #include <notify.h> |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
43 #include <util.h> |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
44 #include <version.h> |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
45 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
46 /* Pidgin headers */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
47 #include <gtkconv.h> |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
48 #include <gtkplugin.h> |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
49 #include <gtkwebview.h> |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
50 #include <smileyparser.h> |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
51 |
32559 | 52 #include <libxml/xmlreader.h> |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
53 /* GObject data keys */ |
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
54 #define MESSAGE_STYLE_KEY "message-style" |
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
55 |
32535 | 56 /* |
57 * I'm going to allow a different style for each PidginConversation. | |
58 * This way I can do two things: 1) change the theme on the fly and not | |
59 * change existing themes, and 2) Use a different theme for IMs and | |
60 * chats. | |
61 */ | |
62 typedef struct _PidginMessageStyle { | |
63 int ref_counter; | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
64 |
32559 | 65 /* current config options */ |
32561 | 66 char *variant; /* allowed to be NULL if there are no variants */ |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
67 char *bg_color; |
32559 | 68 |
69 /* Info.plist keys */ | |
70 int message_view_version; | |
71 char *cf_bundle_name; | |
32561 | 72 char *cf_bundle_identifier; |
32559 | 73 char *cf_bundle_get_info_string; |
74 char *default_font_family; | |
75 int default_font_size; | |
76 gboolean shows_user_icons; | |
77 gboolean disable_combine_consecutive; | |
78 gboolean default_background_is_transparent; | |
79 gboolean disable_custom_background; | |
80 char *default_background_color; | |
81 gboolean allow_text_colors; | |
82 char *image_mask; | |
83 | |
32535 | 84 /* paths */ |
85 char *style_dir; | |
86 char *template_path; | |
87 | |
88 /* caches */ | |
89 char *template_html; | |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
90 char *header_html; |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
91 char *footer_html; |
32535 | 92 char *incoming_content_html; |
93 char *outgoing_content_html; | |
94 char *incoming_next_content_html; | |
95 char *outgoing_next_content_html; | |
96 char *status_html; | |
97 char *basestyle_css; | |
98 } PidginMessageStyle; | |
99 | |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
100 static GList *style_list; /**< List of PidginMessageStyles */ |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
101 static char *cur_style_dir = NULL; |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
102 static void *handle = NULL; |
32535 | 103 |
32561 | 104 static PidginMessageStyle* pidgin_message_style_new (const char* styledir); |
105 static PidginMessageStyle* pidgin_message_style_load (const char* styledir); | |
106 static void pidgin_message_style_unref (PidginMessageStyle *style); | |
107 static void pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant); | |
108 static char* pidgin_message_style_get_variant (PidginMessageStyle *style); | |
109 static GList* pidgin_message_style_get_variants (PidginMessageStyle *style); | |
110 static void pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant); | |
111 | |
112 static void | |
113 glist_free_all_string (GList *list) | |
114 { | |
115 GList *first = list; | |
116 for (; list; list = g_list_next (list)) | |
117 g_free (list->data); | |
118 g_list_free (first); | |
119 } | |
120 | |
32553 | 121 static inline char* get_absolute_path (const char *path) |
122 { | |
123 if (g_path_is_absolute (path)) return g_strdup (path); | |
124 else { | |
125 char* cwd = g_get_current_dir (), *ret; | |
126 ret = g_build_filename (cwd, path, NULL); | |
127 g_free (cwd); | |
128 return ret; | |
129 } | |
130 } | |
131 | |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
132 static PidginMessageStyle* pidgin_message_style_new (const char* styledir) |
32535 | 133 { |
134 PidginMessageStyle* ret = g_new0 (PidginMessageStyle, 1); | |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
135 GList *iter; |
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
136 |
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
137 /* sanity check */ |
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
138 for (iter = style_list; iter; iter = g_list_next (iter)) |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
139 g_assert (!g_str_equal (((PidginMessageStyle*)iter->data)->style_dir, styledir)); |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
140 |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
141 ret->ref_counter = 1; |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
142 ret->style_dir = g_strdup (styledir); |
32535 | 143 |
144 style_list = g_list_append (style_list, ret); | |
145 return ret; | |
146 } | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
147 |
32559 | 148 /** |
149 * deallocate any memory used for info.plist options | |
150 */ | |
151 static void | |
152 pidgin_message_style_unset_info_plist (PidginMessageStyle *style) | |
153 { | |
154 style->message_view_version = 0; | |
155 g_free (style->cf_bundle_name); | |
156 style->cf_bundle_name = NULL; | |
157 | |
158 g_free (style->cf_bundle_identifier); | |
159 style->cf_bundle_identifier = NULL; | |
160 | |
161 g_free (style->cf_bundle_get_info_string); | |
162 style->cf_bundle_get_info_string = NULL; | |
163 | |
164 g_free (style->default_font_family); | |
165 style->default_font_family = NULL; | |
166 | |
167 style->default_font_size = 0; | |
168 style->shows_user_icons = TRUE; | |
169 style->disable_combine_consecutive = FALSE; | |
170 style->default_background_is_transparent = FALSE; | |
171 style->disable_custom_background = FALSE; | |
172 | |
173 g_free (style->default_background_color); | |
174 style->default_background_color = NULL; | |
175 | |
176 style->allow_text_colors = TRUE; | |
177 | |
178 g_free (style->image_mask); | |
179 style->image_mask = NULL; | |
180 } | |
181 | |
182 | |
32535 | 183 static void pidgin_message_style_unref (PidginMessageStyle *style) |
184 { | |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
185 if (!style) return; |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
186 g_assert (style->ref_counter > 0); |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
187 |
32535 | 188 style->ref_counter--; |
189 if (style->ref_counter) return; | |
190 | |
191 g_free (style->style_dir); | |
192 g_free (style->template_path); | |
193 | |
194 g_free (style->template_html); | |
195 g_free (style->incoming_content_html); | |
196 g_free (style->outgoing_content_html); | |
197 g_free (style->outgoing_next_content_html); | |
198 g_free (style->status_html); | |
199 g_free (style->basestyle_css); | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
200 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
201 style_list = g_list_remove (style_list, style); |
32535 | 202 g_free (style); |
32559 | 203 |
204 pidgin_message_style_unset_info_plist (style); | |
32535 | 205 } |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
206 |
32561 | 207 static void |
208 pidgin_message_style_save_state (PidginMessageStyle *style) | |
209 { | |
210 char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier); | |
211 char *variant = g_strdup_printf ("%s/%s", prefname, style->variant); | |
212 | |
213 purple_prefs_add_none (prefname); | |
214 purple_prefs_add_string (variant, ""); | |
215 purple_prefs_set_string (variant, style->variant); | |
216 | |
217 g_free (prefname); | |
218 g_free (variant); | |
219 } | |
220 | |
221 static void | |
222 pidgin_message_style_load_state (PidginMessageStyle *style) | |
223 { | |
224 char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier); | |
225 char *variant = g_strdup_printf ("%s/%s", prefname, style->variant); | |
226 | |
227 const char* value = purple_prefs_get_string (variant); | |
228 gboolean changed = !style->variant || !g_str_equal (style->variant, value); | |
229 | |
230 g_free (style->variant); | |
231 style->variant = g_strdup (value); | |
232 | |
233 if (changed) pidgin_message_style_read_info_plist (style, style->variant); | |
234 | |
235 g_free (prefname); | |
236 g_free(variant); | |
237 } | |
238 | |
32540
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
239 static void webkit_on_webview_destroy (GtkObject* obj, gpointer data); |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
240 |
32559 | 241 static gboolean |
242 parse_info_plist_key_value (xmlnode* key, gpointer destination, const char* expected) | |
243 { | |
244 xmlnode *val = key->next; | |
245 | |
246 for (; val && val->type != XMLNODE_TYPE_TAG; val = val->next); | |
247 if (!val) return FALSE; | |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
248 |
32559 | 249 if (expected == NULL || g_str_equal (expected, "string")) { |
250 char** dest = (char**) destination; | |
251 if (!g_str_equal (val->name, BAD_CAST "string")) return FALSE; | |
252 if (*dest) g_free (*dest); | |
253 *dest = xmlnode_get_data_unescaped (val); | |
254 } else if (g_str_equal (expected, "integer")) { | |
255 int* dest = (int*) destination; | |
256 char* value = xmlnode_get_data_unescaped (val); | |
257 | |
258 if (!g_str_equal (val->name, "integer")) return FALSE; | |
259 *dest = atoi (value); | |
260 g_free (value); | |
261 } else if (g_str_equal (expected, "boolean")) { | |
262 gboolean *dest = (gboolean*) destination; | |
263 if (g_str_equal (val->name, BAD_CAST "true")) *dest = TRUE; | |
264 else if (g_str_equal (val->name, BAD_CAST "false")) *dest = FALSE; | |
265 else return FALSE; | |
266 } else return FALSE; | |
267 | |
268 return TRUE; | |
269 } | |
270 | |
271 static | |
272 gboolean str_for_key (const char *key, const char *found, const char *variant){ | |
273 if (g_str_equal (key, found)) return TRUE; | |
274 if (!variant) return FALSE; | |
275 return (g_str_has_prefix (found, key) | |
276 && g_str_has_suffix (found, variant) | |
277 && strlen (found) == strlen (key) + strlen (variant) + 1); | |
278 } | |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
279 |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
280 /** |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
281 * Info.plist should be re-read every time the variant changes, this is because |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
282 * the keys that take precedence depend on the value of the current variant. |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
283 */ |
32559 | 284 static void |
285 pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant) | |
286 { | |
287 /* note that if a variant is used the option:VARIANTNAME takes precedence */ | |
288 char *contents = g_build_filename (style->style_dir, "Contents", NULL); | |
289 xmlnode *plist = xmlnode_from_file (contents, "Info.plist", "Info.plist", "webkit"), *iter; | |
290 xmlnode *dict = xmlnode_get_child (plist, "dict"); | |
291 | |
292 g_assert (dict); | |
293 for (iter = xmlnode_get_child (dict, "key"); iter; iter = xmlnode_get_next_twin (iter)) { | |
294 char* key = xmlnode_get_data_unescaped (iter); | |
295 gboolean pr = TRUE; | |
296 | |
297 if (g_str_equal ("MessageViewVersion", key)) | |
298 pr = parse_info_plist_key_value (iter, &style->message_view_version, "integer"); | |
299 else if (g_str_equal ("CFBundleName", key)) | |
300 pr = parse_info_plist_key_value (iter, &style->cf_bundle_name, "string"); | |
301 else if (g_str_equal ("CFBundleIdentifier", key)) | |
302 pr = parse_info_plist_key_value (iter, &style->cf_bundle_identifier, "string"); | |
303 else if (g_str_equal ("CFBundleGetInfoString", key)) | |
304 pr = parse_info_plist_key_value (iter, &style->cf_bundle_get_info_string, "string"); | |
305 else if (str_for_key ("DefaultFontFamily", key, variant)) | |
306 pr = parse_info_plist_key_value (iter, &style->default_font_family, "string"); | |
307 else if (str_for_key ("DefaultFontSize", key, variant)) | |
308 pr = parse_info_plist_key_value (iter, &style->default_font_size, "integer"); | |
309 else if (str_for_key ("ShowsUserIcons", key, variant)) | |
310 pr = parse_info_plist_key_value (iter, &style->shows_user_icons, "boolean"); | |
311 else if (str_for_key ("DisableCombineConsecutive", key, variant)) | |
312 pr = parse_info_plist_key_value (iter, &style->disable_combine_consecutive, "boolean"); | |
313 else if (str_for_key ("DefaultBackgroundIsTransparent", key, variant)) | |
314 pr = parse_info_plist_key_value (iter, &style->default_background_is_transparent, "boolean"); | |
315 else if (str_for_key ("DisableCustomBackground", key, variant)) | |
316 pr = parse_info_plist_key_value (iter, &style->disable_custom_background, "boolean"); | |
317 else if (str_for_key ("DefaultBackgroundColor", key, variant)) | |
318 pr = parse_info_plist_key_value (iter, &style->default_background_color, "string"); | |
319 else if (str_for_key ("AllowTextColors", key, variant)) | |
320 pr = parse_info_plist_key_value (iter, &style->allow_text_colors, "string"); | |
321 else if (str_for_key ("ImageMask", key, variant)) | |
322 pr = parse_info_plist_key_value (iter, &style->image_mask, "string"); | |
323 | |
324 g_free (key); | |
325 if (!pr) break; /* does not make sense */ | |
326 } | |
327 | |
328 xmlnode_free (plist); | |
329 } | |
330 | |
32535 | 331 static PidginMessageStyle* |
332 pidgin_message_style_load (const char* styledir) | |
333 { | |
32561 | 334 /* |
335 * the loading process described: | |
336 * | |
337 * First we load all the style .html files, etc. | |
338 * The we load any config options that have been stored for | |
339 * this variant. | |
340 * Then we load the Info.plist, for the currently decided variant. | |
341 * At this point, if we find that variants exist, yet | |
342 * we don't have a variant selected, we choose DefaultVariant | |
343 * and if that does not exist, we choose the first one in the | |
344 * directory. | |
345 */ | |
346 | |
32535 | 347 /* is this style already loaded? */ |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
348 GList *cur = style_list; |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
349 char *file; /* temporary variable */ |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
350 PidginMessageStyle *style = NULL; |
32551 | 351 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
352 g_assert (styledir); |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
353 for (cur = style_list; cur; cur = g_list_next (cur)) { |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
354 style = (PidginMessageStyle*) cur->data; |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
355 if (g_str_equal (styledir, style->style_dir)) { |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
356 style->ref_counter++; |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
357 return style; |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
358 } |
32535 | 359 } |
360 | |
361 /* else we need to load it */ | |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
362 style = pidgin_message_style_new (styledir); |
32535 | 363 |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
364 /* load all other files */ |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
365 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
366 /* The template path can either come from the theme, or can |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
367 * be stock Template.html that comes with the plugin */ |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
368 style->template_path = g_build_filename(styledir, "Contents", "Resources", "Template.html", NULL); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
369 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
370 if (!g_file_test(style->template_path, G_FILE_TEST_EXISTS)) { |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
371 g_free (style->template_path); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
372 style->template_path = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
373 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
374 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
375 if (!g_file_get_contents(style->template_path, &style->template_html, NULL, NULL)) { |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
376 pidgin_message_style_unref (style); |
32551 | 377 purple_debug_error ("webkit", "Could not locate a Template.html\n"); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
378 return NULL; |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
379 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
380 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
381 file = g_build_filename(styledir, "Contents", "Resources", "Status.html", NULL); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
382 if (!g_file_get_contents(file, &style->status_html, NULL, NULL)) { |
32551 | 383 purple_debug_info ("webkit", "%s could not find Resources/Status.html", styledir); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
384 pidgin_message_style_unref (style); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
385 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
386 return NULL; |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
387 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
388 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
389 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
390 file = g_build_filename(styledir, "Contents", "Resources", "main.css", NULL); |
32549
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
391 if (!g_file_get_contents(file, &style->basestyle_css, NULL, NULL)) |
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
392 style->basestyle_css = g_strdup (""); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
393 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
394 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
395 file = g_build_filename(styledir, "Contents", "Resources", "Header.html", NULL); |
32549
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
396 if (!g_file_get_contents(file, &style->header_html, NULL, NULL)) |
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
397 style->header_html = g_strdup (""); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
398 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
399 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
400 file = g_build_filename(styledir, "Contents", "Resources", "Footer.html", NULL); |
32549
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
401 if (!g_file_get_contents(file, &style->footer_html, NULL, NULL)) |
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
402 style->footer_html = g_strdup (""); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
403 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
404 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
405 file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "Content.html", NULL); |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
406 if (!g_file_get_contents(file, &style->incoming_content_html, NULL, NULL)) { |
32551 | 407 purple_debug_info ("webkit", "%s did not have a Incoming/Content.html\n", styledir); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
408 pidgin_message_style_unref (style); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
409 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
410 return NULL; |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
411 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
412 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
413 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
414 |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
415 /* according to the spec, the following are optional files */ |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
416 file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "NextContent.html", NULL); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
417 if (!g_file_get_contents(file, &style->incoming_next_content_html, NULL, NULL)) { |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
418 style->incoming_next_content_html = g_strdup (style->incoming_content_html); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
419 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
420 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
421 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
422 file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "Content.html", NULL); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
423 if (!g_file_get_contents(file, &style->outgoing_content_html, NULL, NULL)) { |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
424 style->outgoing_content_html = g_strdup(style->incoming_content_html); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
425 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
426 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
427 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
428 file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
429 if (!g_file_get_contents(file, &style->outgoing_next_content_html, NULL, NULL)) { |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
430 style->outgoing_next_content_html = g_strdup (style->outgoing_content_html); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
431 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
432 |
32561 | 433 pidgin_message_style_load_state (style); |
434 pidgin_message_style_read_info_plist (style, style->variant); | |
32559 | 435 |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
436 /* non variant dependent Info.plist checks */ |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
437 if (style->message_view_version < 3) { |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
438 pidgin_message_style_unref (style); |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
439 return NULL; |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
440 } |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
441 |
32561 | 442 if (!style->variant) |
443 { | |
444 GList *variants = pidgin_message_style_get_variants (style); | |
445 | |
446 if (variants) | |
447 pidgin_message_style_set_variant (style, variants->data); | |
448 | |
449 glist_free_all_string (variants); | |
450 pidgin_message_style_save_state (style); | |
451 } | |
452 | |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
453 return style; |
32535 | 454 } |
455 | |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
456 static void |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
457 pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant) |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
458 { |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
459 /* I'm not going to test whether this variant is valid! */ |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
460 g_free (style->variant); |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
461 style->variant = g_strdup (variant); |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
462 |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
463 pidgin_message_style_read_info_plist (style, variant); |
32561 | 464 pidgin_message_style_save_state (style); |
465 | |
466 /* todo, the style has "changed". Ideally, I would like to use signals at this point. */ | |
467 } | |
468 | |
469 char* pidgin_message_style_get_variant (PidginMessageStyle *style) | |
470 { | |
471 return g_strdup (style->variant); | |
472 } | |
473 | |
474 /** | |
475 * Get a list of variants supported by the style. | |
476 */ | |
477 static GList* | |
478 pidgin_message_style_get_variants (PidginMessageStyle *style) | |
479 { | |
480 GList *ret = NULL; | |
481 GDir *variants; | |
482 const char *css_file; | |
483 char *css; | |
484 char *variant_dir; | |
485 | |
486 g_assert (style->style_dir); | |
487 variant_dir = g_build_filename(style->style_dir, "Contents", "Resources", "Variants", NULL); | |
488 | |
489 variants = g_dir_open(variant_dir, 0, NULL); | |
490 if (!variants) return NULL; | |
491 | |
492 while ((css_file = g_dir_read_name(variants)) != NULL) { | |
493 if (!g_str_has_suffix (css_file, ".css")) | |
494 continue; | |
495 | |
496 css = g_strndup (css_file, strlen (css_file) - 4); | |
497 ret = g_list_append(ret, css); | |
498 } | |
499 | |
500 g_dir_close(variants); | |
501 g_free(variant_dir); | |
502 | |
503 ret = g_list_sort (ret, (GCompareFunc)g_strcmp0); | |
504 return ret; | |
505 } | |
506 | |
507 static char* pidgin_message_style_get_css (PidginMessageStyle *style) | |
508 { | |
509 if (!style->variant) { | |
510 return g_build_filename (style->style_dir, "Contents", "Resources", "main.css", NULL); | |
511 } else { | |
512 char *file = g_strdup_printf ("%s.css", style->variant); | |
513 char *ret = g_build_filename (style->style_dir, "Contents", "Resources", "Variants", file, NULL); | |
514 g_free (file); | |
515 return ret; | |
516 } | |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
517 } |
32535 | 518 |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
519 static void* webkit_plugin_get_handle () |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
520 { |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
521 if (handle) return handle; |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
522 else return (handle = g_malloc (1)); |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
523 } |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
524 |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
525 static void webkit_plugin_free_handle () |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
526 { |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
527 purple_signals_disconnect_by_handle (handle); |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
528 g_free (handle); |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
529 } |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
530 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
531 static char * |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
532 replace_message_tokens( |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
533 char *text, |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
534 gsize len, |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
535 PurpleConversation *conv, |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
536 const char *name, |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
537 const char *alias, |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
538 const char *message, |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
539 PurpleMessageFlags flags, |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
540 time_t mtime) |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
541 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
542 GString *str = g_string_new_len(NULL, len); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
543 char *cur = text; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
544 char *prev = cur; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
545 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
546 while ((cur = strchr(cur, '%'))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
547 const char *replace = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
548 char *fin = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
549 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
550 if (!strncmp(cur, "%message%", strlen("%message%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
551 replace = message; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
552 } else if (!strncmp(cur, "%messageClasses%", strlen("%messageClasses%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
553 replace = flags & PURPLE_MESSAGE_SEND ? "outgoing" : |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
554 flags & PURPLE_MESSAGE_RECV ? "incoming" : "event"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
555 } else if (!strncmp(cur, "%time", strlen("%time"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
556 char *format = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
557 if (*(cur + strlen("%time")) == '{') { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
558 char *start = cur + strlen("%time") + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
559 char *end = strstr(start, "}%"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
560 if (!end) /* Invalid string */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
561 continue; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
562 format = g_strndup(start, end - start); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
563 fin = end + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
564 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
565 replace = purple_utf8_strftime(format ? format : "%X", NULL); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
566 g_free(format); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
567 } else if (!strncmp(cur, "%userIconPath%", strlen("%userIconPath%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
568 if (flags & PURPLE_MESSAGE_SEND) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
569 if (purple_account_get_bool(conv->account, "use-global-buddyicon", TRUE)) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
570 replace = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
571 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
572 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(conv->account); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
573 replace = purple_imgstore_get_filename(img); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
574 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
575 if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
576 replace = g_build_filename("Outgoing", "buddy_icon.png", NULL); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
577 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
578 } else if (flags & PURPLE_MESSAGE_RECV) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
579 PurpleBuddyIcon *icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv)); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
580 replace = purple_buddy_icon_get_full_path(icon); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
581 if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
582 replace = g_build_filename("Incoming", "buddy_icon.png", NULL); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
583 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
584 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
585 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
586 } else if (!strncmp(cur, "%senderScreenName%", strlen("%senderScreenName%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
587 replace = name; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
588 } else if (!strncmp(cur, "%sender%", strlen("%sender%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
589 replace = alias; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
590 } else if (!strncmp(cur, "%service%", strlen("%service%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
591 replace = purple_account_get_protocol_name(conv->account); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
592 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
593 cur++; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
594 continue; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
595 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
596 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
597 /* Here we have a replacement to make */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
598 g_string_append_len(str, prev, cur - prev); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
599 g_string_append(str, replace); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
600 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
601 /* And update the pointers */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
602 if (fin) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
603 prev = cur = fin + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
604 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
605 prev = cur = strchr(cur + 1, '%') + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
606 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
607 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
608 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
609 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
610 /* And wrap it up */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
611 g_string_append(str, prev); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
612 return g_string_free(str, FALSE); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
613 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
614 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
615 static char * |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
616 replace_header_tokens(char *text, gsize len, PurpleConversation *conv) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
617 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
618 GString *str = g_string_new_len(NULL, len); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
619 char *cur = text; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
620 char *prev = cur; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
621 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
622 if (text == NULL) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
623 return NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
624 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
625 while ((cur = strchr(cur, '%'))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
626 const char *replace = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
627 char *fin = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
628 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
629 if (!strncmp(cur, "%chatName%", strlen("%chatName%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
630 replace = conv->name; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
631 } else if (!strncmp(cur, "%sourceName%", strlen("%sourceName%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
632 replace = purple_account_get_alias(conv->account); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
633 if (replace == NULL) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
634 replace = purple_account_get_username(conv->account); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
635 } else if (!strncmp(cur, "%destinationName%", strlen("%destinationName%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
636 PurpleBuddy *buddy = purple_find_buddy(conv->account, conv->name); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
637 if (buddy) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
638 replace = purple_buddy_get_alias(buddy); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
639 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
640 replace = conv->name; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
641 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
642 } else if (!strncmp(cur, "%incomingIconPath%", strlen("%incomingIconPath%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
643 PurpleBuddyIcon *icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv)); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
644 replace = purple_buddy_icon_get_full_path(icon); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
645 } else if (!strncmp(cur, "%outgoingIconPath%", strlen("%outgoingIconPath%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
646 } else if (!strncmp(cur, "%timeOpened", strlen("%timeOpened"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
647 char *format = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
648 if (*(cur + strlen("%timeOpened")) == '{') { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
649 char *start = cur + strlen("%timeOpened") + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
650 char *end = strstr(start, "}%"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
651 if (!end) /* Invalid string */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
652 continue; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
653 format = g_strndup(start, end - start); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
654 fin = end + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
655 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
656 replace = purple_utf8_strftime(format ? format : "%X", NULL); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
657 g_free(format); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
658 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
659 continue; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
660 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
661 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
662 /* Here we have a replacement to make */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
663 g_string_append_len(str, prev, cur - prev); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
664 g_string_append(str, replace); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
665 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
666 /* And update the pointers */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
667 if (fin) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
668 prev = cur = fin + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
669 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
670 prev = cur = strchr(cur + 1, '%') + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
671 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
672 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
673 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
674 /* And wrap it up */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
675 g_string_append(str, prev); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
676 return g_string_free(str, FALSE); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
677 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
678 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
679 static char * |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
680 replace_template_tokens(PidginMessageStyle *style, char *text, int len, char *header, char *footer) { |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
681 GString *str = g_string_new_len(NULL, len); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
682 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
683 char **ms = g_strsplit(text, "%@", 6); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
684 char *base = NULL; |
32561 | 685 char *csspath = pidgin_message_style_get_css (style); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
686 if (ms[0] == NULL || ms[1] == NULL || ms[2] == NULL || ms[3] == NULL || ms[4] == NULL || ms[5] == NULL) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
687 g_strfreev(ms); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
688 g_string_free(str, TRUE); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
689 return NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
690 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
691 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
692 g_string_append(str, ms[0]); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
693 g_string_append(str, "file://"); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
694 base = g_build_filename (style->style_dir, "Contents", "Resources", "Template.html", NULL); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
695 g_string_append(str, base); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
696 g_free (base); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
697 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
698 g_string_append(str, ms[1]); |
32561 | 699 |
700 /* I'm just going to skip main.css at this point */ | |
701 | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
702 g_string_append(str, ms[2]); |
32561 | 703 |
704 g_string_append(str, "file://"); | |
705 g_string_append(str, csspath); | |
706 | |
707 | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
708 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
709 g_string_append(str, ms[3]); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
710 if (header) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
711 g_string_append(str, header); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
712 g_string_append(str, ms[4]); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
713 if (footer) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
714 g_string_append(str, footer); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
715 g_string_append(str, ms[5]); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
716 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
717 g_strfreev(ms); |
32561 | 718 g_free (csspath); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
719 return g_string_free (str, FALSE); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
720 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
721 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
722 static GtkWidget * |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
723 get_webkit(PurpleConversation *conv) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
724 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
725 PidginConversation *gtkconv; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
726 gtkconv = PIDGIN_CONVERSATION(conv); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
727 if (!gtkconv) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
728 return NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
729 else |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
730 return gtkconv->webview; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
731 } |
32531 | 732 |
733 /** | |
734 * Called when either a new PurpleConversation is created | |
735 * or when a PidginConversation changes its active PurpleConversation | |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
736 * This will not change the theme if the theme is already set. |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
737 * (This is to prevent accidental theme changes if a new |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
738 * PurpleConversation gets added. |
32531 | 739 * |
740 * FIXME: it's not at all clear to me as to how | |
741 * Adium themes handle the case when the PurpleConversation | |
742 * changes. | |
743 */ | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
744 static void |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
745 init_theme_for_webkit (PurpleConversation *conv, char *style_dir) |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
746 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
747 GtkWidget *webkit = PIDGIN_CONVERSATION(conv)->webview; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
748 char *header, *footer; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
749 char *template; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
750 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
751 char* basedir; |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
752 char* baseuri; |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
753 PidginMessageStyle *style, *oldStyle; |
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
754 oldStyle = g_object_get_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY); |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
755 |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
756 if (oldStyle) return; |
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
757 |
32551 | 758 purple_debug_info ("webkit", "loading %s\n", style_dir); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
759 style = pidgin_message_style_load (style_dir); |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
760 g_assert (style); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
761 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
762 basedir = g_build_filename (style->style_dir, "Contents", "Resources", "Template.html", NULL); |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
763 baseuri = g_strdup_printf ("file://%s", basedir); |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
764 header = replace_header_tokens(style->header_html, strlen(style->header_html), conv); |
32549
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
765 g_assert (style); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
766 footer = replace_header_tokens(style->footer_html, strlen(style->footer_html), conv); |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
767 template = replace_template_tokens(style, style->template_html, strlen(style->template_html) + strlen(style->header_html), header, footer); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
768 |
32552 | 769 g_assert(template); |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
770 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri); |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
771 |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
772 g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style); |
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
773 |
32540
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
774 /* I need to unref this style when the webkit object destroys */ |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
775 g_signal_connect (G_OBJECT(webkit), "destroy", G_CALLBACK(webkit_on_webview_destroy), style); |
32531 | 776 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
777 g_free (basedir); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
778 g_free (baseuri); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
779 g_free (header); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
780 g_free (footer); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
781 g_free (template); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
782 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
783 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
784 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
785 /* restore the non theme version of the conversation window */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
786 static void |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
787 finalize_theme_for_webkit (PurpleConversation *conv) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
788 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
789 GtkWidget *webview = PIDGIN_CONVERSATION(conv)->webview; |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
790 PidginMessageStyle *style = g_object_get_data (G_OBJECT(webview), MESSAGE_STYLE_KEY); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
791 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
792 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), "", "text/html", "UTF-8", ""); |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
793 |
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
794 g_object_set_data (G_OBJECT(webview), MESSAGE_STYLE_KEY, NULL); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
795 pidgin_message_style_unref (style); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
796 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
797 |
32540
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
798 static void |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
799 webkit_on_webview_destroy (GtkObject *object, gpointer data) |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
800 { |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
801 pidgin_message_style_unref ((PidginMessageStyle*) data); |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
802 g_object_set_data (G_OBJECT(object), MESSAGE_STYLE_KEY, NULL); |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
803 } |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
804 |
32533 | 805 static gboolean webkit_on_displaying_im_msg (PurpleAccount *account, |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
806 const char* name, |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
807 char **pmessage, |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
808 PurpleConversation *conv, |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
809 PurpleMessageFlags flags, |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
810 gpointer data) |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
811 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
812 GtkWidget *webkit; |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
813 char *message = *pmessage; |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
814 const char *alias = name; /* FIXME: signal doesn't give me alias */ |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
815 char *stripped; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
816 char *message_html; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
817 char *msg; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
818 char *escape; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
819 char *script; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
820 char *func = "appendMessage"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
821 char *smileyed; |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
822 time_t mtime = time (NULL); /* FIXME: this should come from the write_conv calback, but the signal doesn't pass this to me */ |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
823 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
824 PurpleMessageFlags old_flags = GPOINTER_TO_INT(purple_conversation_get_data(conv, "webkit-lastflags")); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
825 PidginMessageStyle *style; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
826 |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
827 fprintf (stderr, "hmm.. here %s %s\n", name, message); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
828 webkit = get_webkit(conv); |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
829 stripped = g_strdup(message); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
830 |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
831 style = g_object_get_data (G_OBJECT (webkit), MESSAGE_STYLE_KEY); |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
832 g_assert (style); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
833 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
834 if (flags & PURPLE_MESSAGE_SEND && old_flags & PURPLE_MESSAGE_SEND) { |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
835 message_html = style->outgoing_next_content_html; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
836 func = "appendNextMessage"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
837 } else if (flags & PURPLE_MESSAGE_SEND) { |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
838 message_html = style->outgoing_content_html; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
839 } else if (flags & PURPLE_MESSAGE_RECV && old_flags & PURPLE_MESSAGE_RECV) { |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
840 message_html = style->incoming_next_content_html; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
841 func = "appendNextMessage"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
842 } else if (flags & PURPLE_MESSAGE_RECV) { |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
843 message_html = style->incoming_content_html; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
844 } else { |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
845 message_html = style->status_html; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
846 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
847 purple_conversation_set_data(conv, "webkit-lastflags", GINT_TO_POINTER(flags)); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
848 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
849 smileyed = smiley_parse_markup(stripped, conv->account->protocol_id); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
850 msg = replace_message_tokens(message_html, 0, conv, name, alias, smileyed, flags, mtime); |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
851 escape = gtk_webview_quote_js_string (msg); |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
852 script = g_strdup_printf("%s(%s)", func, escape); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
853 |
32542
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
854 gtk_webview_safe_execute_script (GTK_WEBVIEW (webkit), script); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
855 |
32542
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
856 g_free(script); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
857 g_free(smileyed); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
858 g_free(msg); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
859 g_free(stripped); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
860 g_free(escape); |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
861 |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
862 return TRUE; /* GtkConv should not handle this IM */ |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
863 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
864 |
32533 | 865 static gboolean webkit_on_displaying_chat_msg (PurpleAccount *account, |
866 const char *who, | |
867 char **message, | |
868 PurpleConversation *conv, | |
869 PurpleMessageFlags flags, | |
870 gpointer userdata) | |
871 { | |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
872 /* handle exactly like an IM message for now */ |
32533 | 873 return webkit_on_displaying_im_msg (account, who, message, conv, flags, NULL); |
874 } | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
875 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
876 static void |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
877 webkit_on_conversation_displayed (PidginConversation *gtkconv, gpointer data) |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
878 { |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
879 init_theme_for_webkit (gtkconv->active_conv, cur_style_dir); |
32531 | 880 } |
881 | |
882 static void | |
883 webkit_on_conversation_switched (PurpleConversation *conv, gpointer data) | |
884 { | |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
885 init_theme_for_webkit (conv, cur_style_dir); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
886 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
887 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
888 static void |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
889 webkit_on_conversation_hiding (PidginConversation *gtkconv, gpointer data) |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
890 { |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
891 /* |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
892 * I'm not sure if I need to do anything here, but let's keep |
32546 | 893 * this anyway. |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
894 */ |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
895 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
896 |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
897 static GList* |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
898 get_dir_dir_list (const char* dirname) |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
899 { |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
900 GList *ret = NULL; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
901 GDir *dir = g_dir_open (dirname, 0, NULL); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
902 const char* subdir; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
903 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
904 if (!dir) return NULL; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
905 while ((subdir = g_dir_read_name (dir))) { |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
906 ret = g_list_append (ret, g_build_filename (dirname, subdir, NULL)); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
907 } |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
908 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
909 g_dir_close (dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
910 return ret; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
911 } |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
912 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
913 /** |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
914 * Get me a list of all the available themes specified by their |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
915 * directories. I don't guarrantee that these are valid themes, just |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
916 * that they are in the directories for themes. |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
917 */ |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
918 static GList* |
32547 | 919 get_style_directory_list () |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
920 { |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
921 char *user_dir, *user_style_dir, *global_style_dir; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
922 GList *list1, *list2; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
923 |
32553 | 924 user_dir = get_absolute_path (purple_user_dir ()); |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
925 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
926 user_style_dir = g_build_filename (user_dir, "styles", NULL); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
927 global_style_dir = g_build_filename (DATADIR, "pidgin", "styles", NULL); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
928 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
929 list1 = get_dir_dir_list (user_style_dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
930 list2 = get_dir_dir_list (global_style_dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
931 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
932 g_free (global_style_dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
933 g_free (user_style_dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
934 g_free (user_dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
935 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
936 return g_list_concat (list1, list2); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
937 } |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
938 |
32547 | 939 /** |
940 * use heuristics or previous user options to figure out what | |
941 * theme to use as default in this Pidgin instance. | |
942 */ | |
943 static void | |
944 style_set_default () | |
945 { | |
946 GList* styles = get_style_directory_list (), *iter; | |
947 const char *stylepath = purple_prefs_get_string ("/plugins/gtk/adiumthemes/stylepath"); | |
948 g_assert (cur_style_dir == NULL); | |
949 | |
950 if (stylepath) | |
951 styles = g_list_prepend (styles, g_strdup (stylepath)); | |
952 | |
953 /* pick any one that works. Note that we have first preference | |
954 * for the one in the userdir */ | |
955 for (iter = styles; iter; iter = g_list_next (iter)) { | |
956 PidginMessageStyle *style = pidgin_message_style_load (iter->data); | |
957 if (style) { | |
958 cur_style_dir = (char*) g_strdup (iter->data); | |
959 pidgin_message_style_unref (style); | |
960 break; | |
961 } | |
962 purple_debug_info ("webkit", "Style %s is invalid\n", (char*) iter->data); | |
963 } | |
964 | |
965 for (iter = styles; iter; iter = g_list_next (iter)) | |
966 g_free (iter->data); | |
967 g_list_free (styles); | |
968 } | |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
969 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
970 static gboolean |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
971 plugin_load(PurplePlugin *plugin) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
972 { |
32547 | 973 style_set_default (); |
974 if (!cur_style_dir) return FALSE; /* couldn't find a style */ | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
975 |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
976 purple_signal_connect (pidgin_conversations_get_handle (), |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
977 "displaying-im-msg", |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
978 webkit_plugin_get_handle (), |
32533 | 979 PURPLE_CALLBACK(webkit_on_displaying_im_msg), |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
980 NULL); |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
981 |
32531 | 982 purple_signal_connect (pidgin_conversations_get_handle (), |
32533 | 983 "displaying-chat-msg", |
984 webkit_plugin_get_handle (), | |
985 PURPLE_CALLBACK(webkit_on_displaying_chat_msg), | |
986 NULL); | |
987 | |
988 purple_signal_connect (pidgin_conversations_get_handle (), | |
32531 | 989 "conversation-displayed", |
990 webkit_plugin_get_handle (), | |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
991 PURPLE_CALLBACK(webkit_on_conversation_displayed), |
32531 | 992 NULL); |
993 | |
994 purple_signal_connect (pidgin_conversations_get_handle (), | |
995 "conversation-switched", | |
996 webkit_plugin_get_handle (), | |
997 PURPLE_CALLBACK(webkit_on_conversation_switched), | |
998 NULL); | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
999 |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
1000 purple_signal_connect (pidgin_conversations_get_handle (), |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
1001 "conversation-hiding", |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
1002 webkit_plugin_get_handle (), |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
1003 PURPLE_CALLBACK(webkit_on_conversation_hiding), |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
1004 NULL); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1005 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1006 /* finally update each of the existing conversation windows */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1007 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1008 GList* list = purple_get_conversations (); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1009 for (;list; list = g_list_next(list)) |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1010 init_theme_for_webkit (list->data, cur_style_dir); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1011 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1012 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1013 return TRUE; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1014 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1015 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1016 static gboolean |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1017 plugin_unload(PurplePlugin *plugin) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1018 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1019 GList *list; |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
1020 |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
1021 webkit_plugin_free_handle (); |
32550 | 1022 cur_style_dir = NULL; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1023 list = purple_get_conversations (); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1024 while (list) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1025 finalize_theme_for_webkit(list->data); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1026 list = g_list_next(list); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1027 } |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
1028 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1029 return TRUE; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1030 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1031 |
32561 | 1032 /* |
1033 * UI config code | |
1034 */ | |
1035 | |
32549
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
1036 static void |
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
1037 style_changed (GtkWidget* combobox, gpointer null) |
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
1038 { |
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
1039 char *name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox)); |
32554
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1040 GtkWidget *dialog; |
32557
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1041 GList *styles = get_style_directory_list (), *iter; |
32549
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
1042 |
32557
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1043 /* find the full path for this name, I wish I could store this info in the combobox itself. :( */ |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1044 for (iter = styles; iter; iter = g_list_next(iter)) { |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1045 char* basename = g_path_get_basename (iter->data); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1046 if (g_str_equal (basename, name)) { |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1047 g_free (basename); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1048 break; |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1049 } |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1050 g_free (basename); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1051 } |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1052 |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1053 g_assert (iter); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1054 g_free (name); |
32549
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
1055 g_free (cur_style_dir); |
32557
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1056 cur_style_dir = g_strdup (iter->data);; |
32554
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1057 |
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1058 /* inform the user that existing conversations haven't changed */ |
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1059 dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "The style for existing conversations have not been changed. Please close and re-open the conversation for the changes to take effect."); |
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1060 g_assert (dialog); |
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1061 gtk_widget_show (dialog); |
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1062 g_signal_connect_swapped (dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog); |
32549
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
1063 } |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1064 |
32548
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1065 static GtkWidget* |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1066 get_style_config_frame () |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1067 { |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1068 GtkWidget *combobox = gtk_combo_box_new_text (); |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1069 GList *styles = get_style_directory_list (), *iter; |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1070 int index = 0, selected = 0; |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1071 |
32554
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1072 for (iter = styles; iter; iter = g_list_next (iter)) { |
32548
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1073 PidginMessageStyle *style = pidgin_message_style_load (iter->data); |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1074 |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1075 if (style) { |
32557
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1076 char *text = g_path_get_basename (iter->data); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1077 gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), text); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1078 g_free (text); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1079 |
32548
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1080 if (g_str_equal (iter->data, cur_style_dir)) |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1081 selected = index; |
32554
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1082 index++; |
32548
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1083 pidgin_message_style_unref (style); |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1084 } |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1085 } |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1086 gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), selected); |
32556
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1087 g_signal_connect_after (G_OBJECT(combobox), "changed", G_CALLBACK(style_changed), NULL); |
32548
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1088 return combobox; |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1089 } |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1090 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1091 static void |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1092 variant_update_conversation (PurpleConversation *conv) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1093 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1094 PidginConversation *gtkconv = PIDGIN_CONVERSATION (conv); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1095 WebKitWebView *webview = WEBKIT_WEB_VIEW (gtkconv->webview); |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
1096 PidginMessageStyle *style = (PidginMessageStyle*) g_object_get_data (G_OBJECT(webview), MESSAGE_STYLE_KEY); |
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
1097 char *script; |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1098 |
32561 | 1099 g_assert (style); |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
1100 |
32561 | 1101 script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", pidgin_message_style_get_css (style)); |
32542
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
1102 gtk_webview_safe_execute_script (GTK_WEBVIEW(webview), script); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1103 g_free (script); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1104 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1105 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1106 static void |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1107 variant_changed (GtkWidget* combobox, gpointer null) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1108 { |
32561 | 1109 char *name; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1110 GList *list; |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1111 PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1112 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1113 g_assert (style); |
32561 | 1114 name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combobox)); |
1115 pidgin_message_style_set_variant (style, name); | |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1116 |
32561 | 1117 /* update conversations */ |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1118 list = purple_get_conversations (); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1119 while (list) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1120 variant_update_conversation (list->data); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1121 list = g_list_next(list); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1122 } |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1123 |
32561 | 1124 g_free (name); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1125 pidgin_message_style_unref (style); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1126 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1127 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1128 static GtkWidget * |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1129 get_variant_config_frame() |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1130 { |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1131 PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir); |
32561 | 1132 GList *variants = pidgin_message_style_get_variants (style), *iter; |
1133 char *cur_variant = pidgin_message_style_get_variant (style); | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1134 GtkWidget *combobox = gtk_combo_box_new_text(); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1135 int def = -1, index = 0; |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1136 |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1137 pidgin_message_style_unref (style); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1138 |
32558 | 1139 for (iter = variants; iter; iter = g_list_next (iter)) { |
32561 | 1140 gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), iter->data); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1141 |
32561 | 1142 if (g_str_equal (cur_variant, iter->data)) |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1143 def = index; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1144 index ++; |
32538
3b1a130f7e88
more changes, but I still can't find the stupid bug. Valgrind gives me some information
tdrhq@soc.pidgin.im
parents:
32537
diff
changeset
|
1145 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1146 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1147 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1148 gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), def); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1149 g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(variant_changed), NULL); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1150 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1151 return combobox; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1152 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1153 |
32556
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1154 static void |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1155 style_changed_reset_variants (GtkWidget* combobox, gpointer table) |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1156 { |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1157 /* I hate to do this, I swear. But I don't know how to cleanly clean an existing combobox */ |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1158 GtkWidget* variants = g_object_get_data (G_OBJECT(table), "variants-cbox"); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1159 gtk_widget_destroy (variants); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1160 variants = get_variant_config_frame (); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1161 gtk_table_attach_defaults (GTK_TABLE (table), variants, 1, 2, 1, 2); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1162 gtk_widget_show_all (GTK_WIDGET(table)); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1163 |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1164 g_object_set_data (G_OBJECT(table), "variants-cbox", variants); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1165 } |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1166 |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1167 static GtkWidget* |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1168 get_config_frame(PurplePlugin* plugin) |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1169 { |
32555
d1ed820fa416
use a table to display the options neatly.
tdrhq@soc.pidgin.im
parents:
32554
diff
changeset
|
1170 GtkWidget *table = gtk_table_new (2, 2, FALSE); |
32556
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1171 GtkWidget *style_config = get_style_config_frame (); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1172 GtkWidget *variant_config = get_variant_config_frame (); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1173 |
32555
d1ed820fa416
use a table to display the options neatly.
tdrhq@soc.pidgin.im
parents:
32554
diff
changeset
|
1174 gtk_table_attach_defaults (GTK_TABLE(table), gtk_label_new ("Message Style"), 0, 1, 0, 1); |
32556
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1175 gtk_table_attach_defaults (GTK_TABLE(table), style_config, 1, 2, 0, 1); |
32555
d1ed820fa416
use a table to display the options neatly.
tdrhq@soc.pidgin.im
parents:
32554
diff
changeset
|
1176 gtk_table_attach_defaults (GTK_TABLE(table), gtk_label_new ("Style Variant"), 0, 1, 1, 2); |
32556
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1177 gtk_table_attach_defaults (GTK_TABLE(table), variant_config, 1, 2, 1, 2); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1178 |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1179 |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1180 g_object_set_data (G_OBJECT(table), "variants-cbox", variant_config); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1181 /* to clarify, this is a second signal connected on style config */ |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1182 g_signal_connect_after (G_OBJECT(style_config), "changed", G_CALLBACK(style_changed_reset_variants), table); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1183 |
32555
d1ed820fa416
use a table to display the options neatly.
tdrhq@soc.pidgin.im
parents:
32554
diff
changeset
|
1184 return table; |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1185 } |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1186 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1187 PidginPluginUiInfo ui_info = |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1188 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1189 get_config_frame, |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1190 0, /* page_num (Reserved) */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1191 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1192 /* padding */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1193 NULL, |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1194 NULL, |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1195 NULL, |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1196 NULL |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1197 }; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1198 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1199 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1200 static PurplePluginInfo info = |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1201 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1202 PURPLE_PLUGIN_MAGIC, /* Magic */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1203 PURPLE_MAJOR_VERSION, /* Purple Major Version */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1204 PURPLE_MINOR_VERSION, /* Purple Minor Version */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1205 PURPLE_PLUGIN_STANDARD, /* plugin type */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1206 PIDGIN_PLUGIN_TYPE, /* ui requirement */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1207 0, /* flags */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1208 NULL, /* dependencies */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1209 PURPLE_PRIORITY_DEFAULT, /* priority */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1210 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1211 PLUGIN_ID, /* plugin id */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1212 NULL, /* name */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1213 "0.1", /* version */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1214 NULL, /* summary */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1215 NULL, /* description */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1216 PLUGIN_AUTHOR, /* author */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1217 "http://pidgin.im", /* website */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1218 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1219 plugin_load, /* load */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1220 plugin_unload, /* unload */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1221 NULL, /* destroy */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1222 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1223 &ui_info, /* ui_info */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1224 NULL, /* extra_info */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1225 NULL, /* prefs_info */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1226 NULL, /* actions */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1227 NULL, /* reserved 1 */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1228 NULL, /* reserved 2 */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1229 NULL, /* reserved 3 */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1230 NULL /* reserved 4 */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1231 }; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1232 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1233 static void |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1234 init_plugin(PurplePlugin *plugin) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1235 info.name = "Adium IMs"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1236 info.summary = "Adium-like IMs with Pidgin"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1237 info.description = "You can chat in Pidgin using Adium's WebKit view."; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1238 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1239 purple_prefs_add_none ("/plugins"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1240 purple_prefs_add_none ("/plugins/gtk"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1241 purple_prefs_add_none ("/plugins/gtk/adiumthemes"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1242 purple_prefs_add_string ("/plugins/gtk/adiumthemes/csspath", ""); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1243 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1244 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1245 PURPLE_INIT_PLUGIN(webkit, init_plugin, info) |