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