Mercurial > pidgin.yaz
annotate pidgin/plugins/adiumthemes/webkit.c @ 32560:84f75556188f
some work... temporary towards the bigger picture.
author | tdrhq@soc.pidgin.im |
---|---|
date | Tue, 11 Aug 2009 23:54:39 +0000 |
parents | 64a3d266e6ff |
children | 9f6affeb2a92 |
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 */ |
66 char *variant; | |
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; | |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
72 char *cf_bundle_identifier; /* we're not using this */ |
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 char *css_path; | |
88 | |
89 /* caches */ | |
90 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
|
91 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
|
92 char *footer_html; |
32535 | 93 char *incoming_content_html; |
94 char *outgoing_content_html; | |
95 char *incoming_next_content_html; | |
96 char *outgoing_next_content_html; | |
97 char *status_html; | |
98 char *basestyle_css; | |
99 } PidginMessageStyle; | |
100 | |
32537
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 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
|
102 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
|
103 static void *handle = NULL; |
32535 | 104 |
32553 | 105 static inline char* get_absolute_path (const char *path) |
106 { | |
107 if (g_path_is_absolute (path)) return g_strdup (path); | |
108 else { | |
109 char* cwd = g_get_current_dir (), *ret; | |
110 ret = g_build_filename (cwd, path, NULL); | |
111 g_free (cwd); | |
112 return ret; | |
113 } | |
114 } | |
115 | |
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
|
116 static PidginMessageStyle* pidgin_message_style_new (const char* styledir) |
32535 | 117 { |
118 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
|
119 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
|
120 |
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
|
121 /* 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
|
122 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
|
123 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
|
124 |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
125 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
|
126 ret->style_dir = g_strdup (styledir); |
32535 | 127 |
128 style_list = g_list_append (style_list, ret); | |
129 return ret; | |
130 } | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
131 |
32559 | 132 /** |
133 * deallocate any memory used for info.plist options | |
134 */ | |
135 static void | |
136 pidgin_message_style_unset_info_plist (PidginMessageStyle *style) | |
137 { | |
138 style->message_view_version = 0; | |
139 g_free (style->cf_bundle_name); | |
140 style->cf_bundle_name = NULL; | |
141 | |
142 g_free (style->cf_bundle_identifier); | |
143 style->cf_bundle_identifier = NULL; | |
144 | |
145 g_free (style->cf_bundle_get_info_string); | |
146 style->cf_bundle_get_info_string = NULL; | |
147 | |
148 g_free (style->default_font_family); | |
149 style->default_font_family = NULL; | |
150 | |
151 style->default_font_size = 0; | |
152 style->shows_user_icons = TRUE; | |
153 style->disable_combine_consecutive = FALSE; | |
154 style->default_background_is_transparent = FALSE; | |
155 style->disable_custom_background = FALSE; | |
156 | |
157 g_free (style->default_background_color); | |
158 style->default_background_color = NULL; | |
159 | |
160 style->allow_text_colors = TRUE; | |
161 | |
162 g_free (style->image_mask); | |
163 style->image_mask = NULL; | |
164 } | |
165 | |
166 | |
32535 | 167 static void pidgin_message_style_unref (PidginMessageStyle *style) |
168 { | |
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
|
169 if (!style) return; |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
170 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
|
171 |
32535 | 172 style->ref_counter--; |
173 if (style->ref_counter) return; | |
174 | |
175 g_free (style->style_dir); | |
176 g_free (style->template_path); | |
177 g_free (style->css_path); | |
178 | |
179 g_free (style->template_html); | |
180 g_free (style->incoming_content_html); | |
181 g_free (style->outgoing_content_html); | |
182 g_free (style->outgoing_next_content_html); | |
183 g_free (style->status_html); | |
184 g_free (style->basestyle_css); | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
185 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
186 style_list = g_list_remove (style_list, style); |
32535 | 187 g_free (style); |
32559 | 188 |
189 pidgin_message_style_unset_info_plist (style); | |
32535 | 190 } |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
191 |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
192 static void variant_set_default (PidginMessageStyle* style); |
32540
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
193 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
|
194 |
32559 | 195 static gboolean |
196 parse_info_plist_key_value (xmlnode* key, gpointer destination, const char* expected) | |
197 { | |
198 xmlnode *val = key->next; | |
199 | |
200 for (; val && val->type != XMLNODE_TYPE_TAG; val = val->next); | |
201 if (!val) return FALSE; | |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
202 |
32559 | 203 if (expected == NULL || g_str_equal (expected, "string")) { |
204 char** dest = (char**) destination; | |
205 if (!g_str_equal (val->name, BAD_CAST "string")) return FALSE; | |
206 if (*dest) g_free (*dest); | |
207 *dest = xmlnode_get_data_unescaped (val); | |
208 } else if (g_str_equal (expected, "integer")) { | |
209 int* dest = (int*) destination; | |
210 char* value = xmlnode_get_data_unescaped (val); | |
211 | |
212 if (!g_str_equal (val->name, "integer")) return FALSE; | |
213 *dest = atoi (value); | |
214 g_free (value); | |
215 } else if (g_str_equal (expected, "boolean")) { | |
216 gboolean *dest = (gboolean*) destination; | |
217 if (g_str_equal (val->name, BAD_CAST "true")) *dest = TRUE; | |
218 else if (g_str_equal (val->name, BAD_CAST "false")) *dest = FALSE; | |
219 else return FALSE; | |
220 } else return FALSE; | |
221 | |
222 return TRUE; | |
223 } | |
224 | |
225 static | |
226 gboolean str_for_key (const char *key, const char *found, const char *variant){ | |
227 if (g_str_equal (key, found)) return TRUE; | |
228 if (!variant) return FALSE; | |
229 return (g_str_has_prefix (found, key) | |
230 && g_str_has_suffix (found, variant) | |
231 && strlen (found) == strlen (key) + strlen (variant) + 1); | |
232 } | |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
233 |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
234 /** |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
235 * 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
|
236 * 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
|
237 */ |
32559 | 238 static void |
239 pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant) | |
240 { | |
241 /* note that if a variant is used the option:VARIANTNAME takes precedence */ | |
242 char *contents = g_build_filename (style->style_dir, "Contents", NULL); | |
243 xmlnode *plist = xmlnode_from_file (contents, "Info.plist", "Info.plist", "webkit"), *iter; | |
244 xmlnode *dict = xmlnode_get_child (plist, "dict"); | |
245 | |
246 g_assert (dict); | |
247 for (iter = xmlnode_get_child (dict, "key"); iter; iter = xmlnode_get_next_twin (iter)) { | |
248 char* key = xmlnode_get_data_unescaped (iter); | |
249 gboolean pr = TRUE; | |
250 | |
251 if (g_str_equal ("MessageViewVersion", key)) | |
252 pr = parse_info_plist_key_value (iter, &style->message_view_version, "integer"); | |
253 else if (g_str_equal ("CFBundleName", key)) | |
254 pr = parse_info_plist_key_value (iter, &style->cf_bundle_name, "string"); | |
255 else if (g_str_equal ("CFBundleIdentifier", key)) | |
256 pr = parse_info_plist_key_value (iter, &style->cf_bundle_identifier, "string"); | |
257 else if (g_str_equal ("CFBundleGetInfoString", key)) | |
258 pr = parse_info_plist_key_value (iter, &style->cf_bundle_get_info_string, "string"); | |
259 else if (str_for_key ("DefaultFontFamily", key, variant)) | |
260 pr = parse_info_plist_key_value (iter, &style->default_font_family, "string"); | |
261 else if (str_for_key ("DefaultFontSize", key, variant)) | |
262 pr = parse_info_plist_key_value (iter, &style->default_font_size, "integer"); | |
263 else if (str_for_key ("ShowsUserIcons", key, variant)) | |
264 pr = parse_info_plist_key_value (iter, &style->shows_user_icons, "boolean"); | |
265 else if (str_for_key ("DisableCombineConsecutive", key, variant)) | |
266 pr = parse_info_plist_key_value (iter, &style->disable_combine_consecutive, "boolean"); | |
267 else if (str_for_key ("DefaultBackgroundIsTransparent", key, variant)) | |
268 pr = parse_info_plist_key_value (iter, &style->default_background_is_transparent, "boolean"); | |
269 else if (str_for_key ("DisableCustomBackground", key, variant)) | |
270 pr = parse_info_plist_key_value (iter, &style->disable_custom_background, "boolean"); | |
271 else if (str_for_key ("DefaultBackgroundColor", key, variant)) | |
272 pr = parse_info_plist_key_value (iter, &style->default_background_color, "string"); | |
273 else if (str_for_key ("AllowTextColors", key, variant)) | |
274 pr = parse_info_plist_key_value (iter, &style->allow_text_colors, "string"); | |
275 else if (str_for_key ("ImageMask", key, variant)) | |
276 pr = parse_info_plist_key_value (iter, &style->image_mask, "string"); | |
277 | |
278 g_free (key); | |
279 if (!pr) break; /* does not make sense */ | |
280 } | |
281 | |
282 xmlnode_free (plist); | |
283 } | |
284 | |
32535 | 285 static PidginMessageStyle* |
286 pidgin_message_style_load (const char* styledir) | |
287 { | |
288 /* is this style already loaded? */ | |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
289 GList *cur = style_list; |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
290 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
|
291 PidginMessageStyle *style = NULL; |
32551 | 292 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
293 g_assert (styledir); |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
294 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
|
295 style = (PidginMessageStyle*) cur->data; |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
296 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
|
297 style->ref_counter++; |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
298 return style; |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
299 } |
32535 | 300 } |
301 | |
302 /* 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
|
303 style = pidgin_message_style_new (styledir); |
32535 | 304 |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
305 /* load all other files */ |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
306 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
307 /* 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
|
308 * 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
|
309 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
|
310 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
311 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
|
312 g_free (style->template_path); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
313 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
|
314 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
315 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
316 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
|
317 pidgin_message_style_unref (style); |
32551 | 318 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
|
319 return NULL; |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
320 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
321 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
322 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
|
323 if (!g_file_get_contents(file, &style->status_html, NULL, NULL)) { |
32551 | 324 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
|
325 pidgin_message_style_unref (style); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
326 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
327 return NULL; |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
328 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
329 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
330 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
331 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
|
332 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
|
333 style->basestyle_css = g_strdup (""); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
334 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
335 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
336 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
|
337 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
|
338 style->header_html = g_strdup (""); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
339 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
340 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
341 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
|
342 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
|
343 style->footer_html = g_strdup (""); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
344 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
345 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
346 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
|
347 if (!g_file_get_contents(file, &style->incoming_content_html, NULL, NULL)) { |
32551 | 348 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
|
349 pidgin_message_style_unref (style); |
32536
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
350 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
351 return NULL; |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
352 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
353 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
354 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
355 |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
356 /* 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
|
357 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
|
358 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
|
359 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
|
360 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
361 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
362 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
363 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
|
364 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
|
365 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
|
366 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
367 g_free (file); |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
368 |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
369 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
|
370 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
|
371 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
|
372 } |
fc2c2f20370f
Another temporary commit that will not compile.
tdrhq@soc.pidgin.im
parents:
32535
diff
changeset
|
373 |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
374 /* find some variant file (or load from user's settings) */ |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
375 variant_set_default (style); |
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
376 |
32559 | 377 pidgin_message_style_read_info_plist (style, NULL); |
378 | |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
379 /* non variant dependent Info.plist checks */ |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
380 if (style->message_view_version < 3) { |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
381 pidgin_message_style_unref (style); |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
382 return NULL; |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
383 } |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
384 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
385 return style; |
32535 | 386 } |
387 | |
32560
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
388 static void |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
389 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
|
390 { |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
391 /* 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
|
392 g_free (style->variant); |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
393 style->variant = g_strdup (variant); |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
394 |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
395 pidgin_message_style_read_info_plist (style, variant); |
84f75556188f
some work... temporary towards the bigger picture.
tdrhq@soc.pidgin.im
parents:
32559
diff
changeset
|
396 } |
32535 | 397 |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
398 static void* webkit_plugin_get_handle () |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
399 { |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
400 if (handle) return handle; |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
401 else return (handle = g_malloc (1)); |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
402 } |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
403 |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
404 static void webkit_plugin_free_handle () |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
405 { |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
406 purple_signals_disconnect_by_handle (handle); |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
407 g_free (handle); |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
408 } |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
409 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
410 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
|
411 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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 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
|
417 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
|
418 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
|
419 time_t mtime) |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
420 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
421 GString *str = g_string_new_len(NULL, len); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
422 char *cur = text; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
423 char *prev = cur; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
424 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
425 while ((cur = strchr(cur, '%'))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
426 const char *replace = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
427 char *fin = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
428 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
429 if (!strncmp(cur, "%message%", strlen("%message%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
430 replace = message; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
431 } else if (!strncmp(cur, "%messageClasses%", strlen("%messageClasses%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
432 replace = flags & PURPLE_MESSAGE_SEND ? "outgoing" : |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
433 flags & PURPLE_MESSAGE_RECV ? "incoming" : "event"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
434 } else if (!strncmp(cur, "%time", strlen("%time"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
435 char *format = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
436 if (*(cur + strlen("%time")) == '{') { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
437 char *start = cur + strlen("%time") + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
438 char *end = strstr(start, "}%"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
439 if (!end) /* Invalid string */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
440 continue; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
441 format = g_strndup(start, end - start); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
442 fin = end + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
443 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
444 replace = purple_utf8_strftime(format ? format : "%X", NULL); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
445 g_free(format); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
446 } else if (!strncmp(cur, "%userIconPath%", strlen("%userIconPath%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
447 if (flags & PURPLE_MESSAGE_SEND) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
448 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
|
449 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
|
450 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
451 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
|
452 replace = purple_imgstore_get_filename(img); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
453 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
454 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
|
455 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
|
456 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
457 } else if (flags & PURPLE_MESSAGE_RECV) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
458 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
|
459 replace = purple_buddy_icon_get_full_path(icon); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
460 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
|
461 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
|
462 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
463 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
464 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
465 } else if (!strncmp(cur, "%senderScreenName%", strlen("%senderScreenName%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
466 replace = name; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
467 } else if (!strncmp(cur, "%sender%", strlen("%sender%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
468 replace = alias; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
469 } else if (!strncmp(cur, "%service%", strlen("%service%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
470 replace = purple_account_get_protocol_name(conv->account); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
471 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
472 cur++; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
473 continue; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
474 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
475 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
476 /* Here we have a replacement to make */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
477 g_string_append_len(str, prev, cur - prev); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
478 g_string_append(str, replace); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
479 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
480 /* And update the pointers */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
481 if (fin) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
482 prev = cur = fin + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
483 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
484 prev = cur = strchr(cur + 1, '%') + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
485 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
486 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
487 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
488 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
489 /* And wrap it up */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
490 g_string_append(str, prev); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
491 return g_string_free(str, FALSE); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
492 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
493 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
494 static char * |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
495 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
|
496 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
497 GString *str = g_string_new_len(NULL, len); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
498 char *cur = text; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
499 char *prev = cur; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
500 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
501 if (text == NULL) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
502 return NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
503 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
504 while ((cur = strchr(cur, '%'))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
505 const char *replace = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
506 char *fin = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
507 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
508 if (!strncmp(cur, "%chatName%", strlen("%chatName%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
509 replace = conv->name; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
510 } else if (!strncmp(cur, "%sourceName%", strlen("%sourceName%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
511 replace = purple_account_get_alias(conv->account); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
512 if (replace == NULL) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
513 replace = purple_account_get_username(conv->account); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
514 } else if (!strncmp(cur, "%destinationName%", strlen("%destinationName%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
515 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
|
516 if (buddy) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
517 replace = purple_buddy_get_alias(buddy); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
518 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
519 replace = conv->name; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
520 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
521 } else if (!strncmp(cur, "%incomingIconPath%", strlen("%incomingIconPath%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
522 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
|
523 replace = purple_buddy_icon_get_full_path(icon); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
524 } else if (!strncmp(cur, "%outgoingIconPath%", strlen("%outgoingIconPath%"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
525 } else if (!strncmp(cur, "%timeOpened", strlen("%timeOpened"))) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
526 char *format = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
527 if (*(cur + strlen("%timeOpened")) == '{') { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
528 char *start = cur + strlen("%timeOpened") + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
529 char *end = strstr(start, "}%"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
530 if (!end) /* Invalid string */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
531 continue; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
532 format = g_strndup(start, end - start); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
533 fin = end + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
534 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
535 replace = purple_utf8_strftime(format ? format : "%X", NULL); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
536 g_free(format); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
537 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
538 continue; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
539 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
540 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
541 /* Here we have a replacement to make */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
542 g_string_append_len(str, prev, cur - prev); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
543 g_string_append(str, replace); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
544 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
545 /* And update the pointers */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
546 if (fin) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
547 prev = cur = fin + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
548 } else { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
549 prev = cur = strchr(cur + 1, '%') + 1; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
550 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
551 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
552 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
553 /* And wrap it up */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
554 g_string_append(str, prev); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
555 return g_string_free(str, FALSE); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
556 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
557 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
558 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
|
559 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
|
560 GString *str = g_string_new_len(NULL, len); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
561 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
562 char **ms = g_strsplit(text, "%@", 6); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
563 char *base = NULL; |
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 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
|
566 g_strfreev(ms); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
567 g_string_free(str, TRUE); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
568 return NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
569 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
570 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
571 g_string_append(str, ms[0]); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
572 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
|
573 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
|
574 g_string_append(str, base); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
575 g_free (base); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
576 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
577 g_string_append(str, ms[1]); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
578 if (style->basestyle_css) |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
579 g_string_append(str, style->basestyle_css); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
580 g_string_append(str, ms[2]); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
581 if (style->css_path) { |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
582 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
|
583 g_string_append(str, style->css_path); |
32525
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 g_string_append(str, ms[3]); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
587 if (header) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
588 g_string_append(str, header); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
589 g_string_append(str, ms[4]); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
590 if (footer) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
591 g_string_append(str, footer); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
592 g_string_append(str, ms[5]); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
593 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
594 g_strfreev(ms); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
595 return g_string_free (str, FALSE); |
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 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
598 static GtkWidget * |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
599 get_webkit(PurpleConversation *conv) |
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 PidginConversation *gtkconv; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
602 gtkconv = PIDGIN_CONVERSATION(conv); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
603 if (!gtkconv) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
604 return NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
605 else |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
606 return gtkconv->webview; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
607 } |
32531 | 608 |
609 /** | |
610 * Called when either a new PurpleConversation is created | |
611 * 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
|
612 * 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
|
613 * (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
|
614 * PurpleConversation gets added. |
32531 | 615 * |
616 * FIXME: it's not at all clear to me as to how | |
617 * Adium themes handle the case when the PurpleConversation | |
618 * changes. | |
619 */ | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
620 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
|
621 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
|
622 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
623 GtkWidget *webkit = PIDGIN_CONVERSATION(conv)->webview; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
624 char *header, *footer; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
625 char *template; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
626 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
627 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
|
628 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
|
629 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
|
630 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
|
631 |
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
|
632 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
|
633 |
32551 | 634 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
|
635 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
|
636 g_assert (style); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
637 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
638 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
|
639 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
|
640 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
|
641 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
|
642 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
|
643 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
|
644 |
32552 | 645 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
|
646 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
|
647 |
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
|
648 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
|
649 |
32540
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
650 /* 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
|
651 g_signal_connect (G_OBJECT(webkit), "destroy", G_CALLBACK(webkit_on_webview_destroy), style); |
32531 | 652 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
653 g_free (basedir); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
654 g_free (baseuri); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
655 g_free (header); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
656 g_free (footer); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
657 g_free (template); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
658 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
659 |
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 /* 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
|
662 static void |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
663 finalize_theme_for_webkit (PurpleConversation *conv) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
664 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
665 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
|
666 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
|
667 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
668 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
|
669 |
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
|
670 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
|
671 pidgin_message_style_unref (style); |
32525
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 |
32540
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
674 static void |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
675 webkit_on_webview_destroy (GtkObject *object, gpointer data) |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
676 { |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
677 pidgin_message_style_unref ((PidginMessageStyle*) data); |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
678 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
|
679 } |
7b92a2b852db
Cleanly handle webkit destroy events.
tdrhq@soc.pidgin.im
parents:
32539
diff
changeset
|
680 |
32533 | 681 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
|
682 const char* name, |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
683 char **pmessage, |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
684 PurpleConversation *conv, |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
685 PurpleMessageFlags flags, |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
686 gpointer data) |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
687 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
688 GtkWidget *webkit; |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
689 char *message = *pmessage; |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
690 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
|
691 char *stripped; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
692 char *message_html; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
693 char *msg; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
694 char *escape; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
695 char *script; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
696 char *func = "appendMessage"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
697 char *smileyed; |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
698 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
|
699 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
700 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
|
701 PidginMessageStyle *style; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
702 |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
703 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
|
704 webkit = get_webkit(conv); |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
705 stripped = g_strdup(message); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
706 |
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
|
707 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
|
708 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
|
709 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
710 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
|
711 message_html = style->outgoing_next_content_html; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
712 func = "appendNextMessage"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
713 } 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
|
714 message_html = style->outgoing_content_html; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
715 } 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
|
716 message_html = style->incoming_next_content_html; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
717 func = "appendNextMessage"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
718 } 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
|
719 message_html = style->incoming_content_html; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
720 } 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
|
721 message_html = style->status_html; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
722 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
723 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
|
724 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
725 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
|
726 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
|
727 escape = gtk_webview_quote_js_string (msg); |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
728 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
|
729 |
32542
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
730 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
|
731 |
32542
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
732 g_free(script); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
733 g_free(smileyed); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
734 g_free(msg); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
735 g_free(stripped); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
736 g_free(escape); |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
737 |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
738 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
|
739 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
740 |
32533 | 741 static gboolean webkit_on_displaying_chat_msg (PurpleAccount *account, |
742 const char *who, | |
743 char **message, | |
744 PurpleConversation *conv, | |
745 PurpleMessageFlags flags, | |
746 gpointer userdata) | |
747 { | |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
748 /* handle exactly like an IM message for now */ |
32533 | 749 return webkit_on_displaying_im_msg (account, who, message, conv, flags, NULL); |
750 } | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
751 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
752 static void |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
753 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
|
754 { |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
755 init_theme_for_webkit (gtkconv->active_conv, cur_style_dir); |
32531 | 756 } |
757 | |
758 static void | |
759 webkit_on_conversation_switched (PurpleConversation *conv, gpointer data) | |
760 { | |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
761 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
|
762 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
763 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
764 static void |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
765 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
|
766 { |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
767 /* |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
768 * I'm not sure if I need to do anything here, but let's keep |
32546 | 769 * this anyway. |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
770 */ |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
771 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
772 |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
773 static GList* |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
774 get_dir_dir_list (const char* dirname) |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
775 { |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
776 GList *ret = NULL; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
777 GDir *dir = g_dir_open (dirname, 0, NULL); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
778 const char* subdir; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
779 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
780 if (!dir) return NULL; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
781 while ((subdir = g_dir_read_name (dir))) { |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
782 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
|
783 } |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
784 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
785 g_dir_close (dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
786 return ret; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
787 } |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
788 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
789 /** |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
790 * 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
|
791 * 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
|
792 * that they are in the directories for themes. |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
793 */ |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
794 static GList* |
32547 | 795 get_style_directory_list () |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
796 { |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
797 char *user_dir, *user_style_dir, *global_style_dir; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
798 GList *list1, *list2; |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
799 |
32553 | 800 user_dir = get_absolute_path (purple_user_dir ()); |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
801 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
802 user_style_dir = g_build_filename (user_dir, "styles", NULL); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
803 global_style_dir = g_build_filename (DATADIR, "pidgin", "styles", NULL); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
804 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
805 list1 = get_dir_dir_list (user_style_dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
806 list2 = get_dir_dir_list (global_style_dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
807 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
808 g_free (global_style_dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
809 g_free (user_style_dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
810 g_free (user_dir); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
811 |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
812 return g_list_concat (list1, list2); |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
813 } |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
814 |
32547 | 815 /** |
816 * use heuristics or previous user options to figure out what | |
817 * theme to use as default in this Pidgin instance. | |
818 */ | |
819 static void | |
820 style_set_default () | |
821 { | |
822 GList* styles = get_style_directory_list (), *iter; | |
823 const char *stylepath = purple_prefs_get_string ("/plugins/gtk/adiumthemes/stylepath"); | |
824 g_assert (cur_style_dir == NULL); | |
825 | |
826 if (stylepath) | |
827 styles = g_list_prepend (styles, g_strdup (stylepath)); | |
828 | |
829 /* pick any one that works. Note that we have first preference | |
830 * for the one in the userdir */ | |
831 for (iter = styles; iter; iter = g_list_next (iter)) { | |
832 PidginMessageStyle *style = pidgin_message_style_load (iter->data); | |
833 if (style) { | |
834 cur_style_dir = (char*) g_strdup (iter->data); | |
835 pidgin_message_style_unref (style); | |
836 break; | |
837 } | |
838 purple_debug_info ("webkit", "Style %s is invalid\n", (char*) iter->data); | |
839 } | |
840 | |
841 for (iter = styles; iter; iter = g_list_next (iter)) | |
842 g_free (iter->data); | |
843 g_list_free (styles); | |
844 } | |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
845 |
32535 | 846 /** |
847 * Get each of the files corresponding to each variant. | |
848 */ | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
849 static GList* |
32544
ef8d9e44cc73
get_theme_files --> get_variant_files.
tdrhq@soc.pidgin.im
parents:
32542
diff
changeset
|
850 get_variant_files(PidginMessageStyle *style) |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
851 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
852 GList *ret = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
853 GDir *variants; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
854 const char *css_file; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
855 char *css; |
32535 | 856 char *variant_dir; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
857 |
32535 | 858 g_assert (style->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
|
859 variant_dir = g_build_filename(style->style_dir, "Contents", "Resources", "Variants", NULL); |
32535 | 860 |
861 variants = g_dir_open(variant_dir, 0, NULL); | |
862 if (!variants) return NULL; | |
863 | |
864 while ((css_file = g_dir_read_name(variants)) != NULL) { | |
865 if (!g_str_has_suffix (css_file, ".css")) | |
866 continue; | |
867 | |
868 css = g_build_filename(variant_dir, css_file, NULL); | |
869 ret = g_list_append(ret, css); | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
870 } |
32535 | 871 |
872 g_dir_close(variants); | |
873 g_free(variant_dir); | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
874 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
875 ret = g_list_sort (ret, (GCompareFunc)g_strcmp0); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
876 return ret; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
877 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
878 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
879 static void |
32535 | 880 variant_set_default (PidginMessageStyle* style) |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
881 { |
32535 | 882 GList *all, *iter; |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
883 const char *css_path = purple_prefs_get_string ("/plugins/gtk/adiumthemes/csspath"); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
884 |
32535 | 885 g_free (style->css_path); |
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
|
886 if (css_path && g_str_has_prefix (css_path, style->style_dir) && |
32535 | 887 g_file_test (css_path, G_FILE_TEST_EXISTS)) { |
888 style->css_path = g_strdup (css_path); | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
889 return; |
32535 | 890 } |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
891 else { |
32535 | 892 /* something about the theme has changed */ |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
893 css_path = NULL; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
894 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
895 |
32544
ef8d9e44cc73
get_theme_files --> get_variant_files.
tdrhq@soc.pidgin.im
parents:
32542
diff
changeset
|
896 all = get_variant_files (style); |
32535 | 897 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
898 if (all) { |
32535 | 899 style->css_path = g_strdup (all->data); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
900 purple_prefs_set_string ("/plugins/gtk/adiumthemes/csspath", css_path); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
901 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
902 |
32535 | 903 for (iter = all; iter; iter = g_list_next (iter)) |
904 g_free (iter->data); | |
905 | |
906 g_list_free (all); | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
907 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
908 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
909 static gboolean |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
910 plugin_load(PurplePlugin *plugin) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
911 { |
32547 | 912 style_set_default (); |
913 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
|
914 |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
915 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
|
916 "displaying-im-msg", |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
917 webkit_plugin_get_handle (), |
32533 | 918 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
|
919 NULL); |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
920 |
32531 | 921 purple_signal_connect (pidgin_conversations_get_handle (), |
32533 | 922 "displaying-chat-msg", |
923 webkit_plugin_get_handle (), | |
924 PURPLE_CALLBACK(webkit_on_displaying_chat_msg), | |
925 NULL); | |
926 | |
927 purple_signal_connect (pidgin_conversations_get_handle (), | |
32531 | 928 "conversation-displayed", |
929 webkit_plugin_get_handle (), | |
32539
7194ddfc8158
woo, fixed the bug. Now things are looking wonderfully stable.
tdrhq@soc.pidgin.im
parents:
32538
diff
changeset
|
930 PURPLE_CALLBACK(webkit_on_conversation_displayed), |
32531 | 931 NULL); |
932 | |
933 purple_signal_connect (pidgin_conversations_get_handle (), | |
934 "conversation-switched", | |
935 webkit_plugin_get_handle (), | |
936 PURPLE_CALLBACK(webkit_on_conversation_switched), | |
937 NULL); | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
938 |
32532
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
939 purple_signal_connect (pidgin_conversations_get_handle (), |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
940 "conversation-hiding", |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
941 webkit_plugin_get_handle (), |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
942 PURPLE_CALLBACK(webkit_on_conversation_hiding), |
32d7d3c4163c
* removed delete_conversation uiops and instead used signals.
tdrhq@soc.pidgin.im
parents:
32531
diff
changeset
|
943 NULL); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
944 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
945 /* finally update each of the existing conversation windows */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
946 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
947 GList* list = purple_get_conversations (); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
948 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
|
949 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
|
950 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
951 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
952 return TRUE; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
953 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
954 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
955 static gboolean |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
956 plugin_unload(PurplePlugin *plugin) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
957 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
958 GList *list; |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
959 |
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
960 webkit_plugin_free_handle (); |
32550 | 961 cur_style_dir = NULL; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
962 list = purple_get_conversations (); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
963 while (list) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
964 finalize_theme_for_webkit(list->data); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
965 list = g_list_next(list); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
966 } |
32529
50a38bbca397
use displaying-im-msg instead of write_conv uiops.
tdrhq@soc.pidgin.im
parents:
32525
diff
changeset
|
967 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
968 return TRUE; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
969 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
970 |
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
|
971 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
|
972 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
|
973 { |
7d8f8c6ebae2
some code for style_changed and also default any empty file to "" rather than NULL.
tdrhq@soc.pidgin.im
parents:
32548
diff
changeset
|
974 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
|
975 GtkWidget *dialog; |
32557
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
976 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
|
977 |
32557
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
978 /* 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
|
979 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
|
980 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
|
981 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
|
982 g_free (basename); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
983 break; |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
984 } |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
985 g_free (basename); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
986 } |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
987 |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
988 g_assert (iter); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
989 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
|
990 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
|
991 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
|
992 |
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
993 /* 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
|
994 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
|
995 g_assert (dialog); |
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
996 gtk_widget_show (dialog); |
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
997 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
|
998 } |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
999 |
32548
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1000 static GtkWidget* |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1001 get_style_config_frame () |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1002 { |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1003 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
|
1004 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
|
1005 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
|
1006 |
32554
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1007 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
|
1008 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
|
1009 |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1010 if (style) { |
32557
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1011 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
|
1012 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
|
1013 g_free (text); |
d5b2b5021851
Show only the MessageStyle name and not the entire path.
tdrhq@soc.pidgin.im
parents:
32556
diff
changeset
|
1014 |
32548
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1015 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
|
1016 selected = index; |
32554
a6d6b0867cd3
Inform the user about how the theme change takes effect.
tdrhq@soc.pidgin.im
parents:
32553
diff
changeset
|
1017 index++; |
32548
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1018 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
|
1019 } |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1020 } |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1021 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
|
1022 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
|
1023 return combobox; |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1024 } |
1c84e102c8ee
some code to get a list of styles and blah blah.
tdrhq@soc.pidgin.im
parents:
32547
diff
changeset
|
1025 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1026 static void |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1027 variant_update_conversation (PurpleConversation *conv) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1028 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1029 PidginConversation *gtkconv = PIDGIN_CONVERSATION (conv); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1030 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
|
1031 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
|
1032 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
|
1033 |
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
|
1034 g_assert (style && style->css_path); |
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
|
1035 |
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
|
1036 script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path); |
32542
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
1037 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
|
1038 g_free (script); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1039 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1040 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1041 static void |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1042 variant_changed (GtkWidget* combobox, gpointer null) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1043 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1044 char *name, *name_with_ext; |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1045 char *css_path; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1046 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
|
1047 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
|
1048 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1049 g_assert (style); |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1050 |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1051 /* it is possible that the theme changed by this point, so we check |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1052 * that first */ |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1053 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1054 name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox)); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1055 name_with_ext = g_strdup_printf ("%s.css", name); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1056 g_free (name); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1057 |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1058 css_path = g_build_filename (style->style_dir, "Contents", "Resources", "Variants", name_with_ext, NULL); |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1059 |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1060 if (!g_file_test (css_path, G_FILE_TEST_EXISTS)) { |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1061 goto cleanup; |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1062 } |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1063 |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1064 g_free (style->css_path); |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1065 style->css_path = g_strdup (css_path); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1066 purple_prefs_set_string ("/plugins/gtk/adiumthemes/csspath", css_path); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1067 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1068 /* update each conversation */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1069 list = purple_get_conversations (); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1070 while (list) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1071 variant_update_conversation (list->data); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1072 list = g_list_next(list); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1073 } |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1074 |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1075 cleanup: |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1076 g_free (css_path); |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1077 g_free (name_with_ext); |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1078 pidgin_message_style_unref (style); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1079 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1080 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1081 static GtkWidget * |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1082 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
|
1083 { |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1084 PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir); |
32558 | 1085 GList *variants = get_variant_files(style), *iter; |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1086 GtkWidget *combobox = gtk_combo_box_new_text(); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1087 int def = -1, index = 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
|
1088 char* css_path = g_strdup (style->css_path); |
32537
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1089 |
9ad4257f5e8f
Ok, good part of this work of moving global variables to defined styles is
tdrhq@soc.pidgin.im
parents:
32536
diff
changeset
|
1090 pidgin_message_style_unref (style); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1091 |
32558 | 1092 for (iter = variants; iter; iter = g_list_next (iter)) { |
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
|
1093 char *basename = g_path_get_basename(iter->data); |
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
|
1094 char *dirname = g_path_get_dirname(iter->data); |
32558 | 1095 char *temp = g_strndup (basename, strlen(basename)-4); |
1096 gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), temp); | |
1097 g_free (temp); | |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1098 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1099 if (g_str_has_suffix (css_path, basename)) |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1100 def = index; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1101 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
|
1102 |
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
|
1103 g_free (basename); |
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
|
1104 g_free (dirname); |
32525
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 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1107 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
|
1108 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
|
1109 |
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
|
1110 g_free (css_path); |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1111 return combobox; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1112 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1113 |
32556
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1114 static void |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1115 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
|
1116 { |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1117 /* 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
|
1118 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
|
1119 gtk_widget_destroy (variants); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1120 variants = get_variant_config_frame (); |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1121 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
|
1122 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
|
1123 |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1124 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
|
1125 } |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1126 |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1127 static GtkWidget* |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1128 get_config_frame(PurplePlugin* plugin) |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1129 { |
32555
d1ed820fa416
use a table to display the options neatly.
tdrhq@soc.pidgin.im
parents:
32554
diff
changeset
|
1130 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
|
1131 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
|
1132 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
|
1133 |
32555
d1ed820fa416
use a table to display the options neatly.
tdrhq@soc.pidgin.im
parents:
32554
diff
changeset
|
1134 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
|
1135 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
|
1136 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
|
1137 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
|
1138 |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1139 |
d25e6f4a239a
Reset the list of variants when the MessageStyle is changed.
tdrhq@soc.pidgin.im
parents:
32555
diff
changeset
|
1140 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
|
1141 /* 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
|
1142 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
|
1143 |
32555
d1ed820fa416
use a table to display the options neatly.
tdrhq@soc.pidgin.im
parents:
32554
diff
changeset
|
1144 return table; |
32545
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1145 } |
d60517f63f99
partial work towards theme selection.
tdrhq@soc.pidgin.im
parents:
32544
diff
changeset
|
1146 |
32525
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1147 PidginPluginUiInfo ui_info = |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1148 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1149 get_config_frame, |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1150 0, /* page_num (Reserved) */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1151 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1152 /* padding */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1153 NULL, |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1154 NULL, |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1155 NULL, |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1156 NULL |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1157 }; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1158 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1159 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1160 static PurplePluginInfo info = |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1161 { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1162 PURPLE_PLUGIN_MAGIC, /* Magic */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1163 PURPLE_MAJOR_VERSION, /* Purple Major Version */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1164 PURPLE_MINOR_VERSION, /* Purple Minor Version */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1165 PURPLE_PLUGIN_STANDARD, /* plugin type */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1166 PIDGIN_PLUGIN_TYPE, /* ui requirement */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1167 0, /* flags */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1168 NULL, /* dependencies */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1169 PURPLE_PRIORITY_DEFAULT, /* priority */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1170 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1171 PLUGIN_ID, /* plugin id */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1172 NULL, /* name */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1173 "0.1", /* version */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1174 NULL, /* summary */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1175 NULL, /* description */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1176 PLUGIN_AUTHOR, /* author */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1177 "http://pidgin.im", /* website */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1178 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1179 plugin_load, /* load */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1180 plugin_unload, /* unload */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1181 NULL, /* destroy */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1182 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1183 &ui_info, /* ui_info */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1184 NULL, /* extra_info */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1185 NULL, /* prefs_info */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1186 NULL, /* actions */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1187 NULL, /* reserved 1 */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1188 NULL, /* reserved 2 */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1189 NULL, /* reserved 3 */ |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1190 NULL /* reserved 4 */ |
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 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1193 static void |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1194 init_plugin(PurplePlugin *plugin) { |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1195 info.name = "Adium IMs"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1196 info.summary = "Adium-like IMs with Pidgin"; |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1197 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
|
1198 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1199 purple_prefs_add_none ("/plugins"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1200 purple_prefs_add_none ("/plugins/gtk"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1201 purple_prefs_add_none ("/plugins/gtk/adiumthemes"); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1202 purple_prefs_add_string ("/plugins/gtk/adiumthemes/csspath", ""); |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1203 } |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1204 |
d0be198c4694
other files that missed my main major commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
1205 PURPLE_INIT_PLUGIN(webkit, init_plugin, info) |