pidgin/plugins/adiumthemes/webkit.c

Sat, 06 Feb 2010 22:08:41 +0000

author
Jorge Villaseñor <masca@cpw.pidgin.im>
date
Sat, 06 Feb 2010 22:08:41 +0000
branch
soc.2009.webkitmessageview
changeset 32499
91d409e20e8a
parent 32495
cfe772a1a354
child 32501
f150788023c0
permissions
-rw-r--r--

Don't crash if we don't have any theme installed.

32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1 /*
32453
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
2 * Adium Message Styles
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
3 * Copyright (C) 2009 Arnold Noronha <arnstein87@gmail.com>
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2007
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
5 *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
9 * License, or (at your option) any later version.
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
10 *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
14 * General Public License for more details.
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
15 *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
19 * 02111-1307, USA.
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
20 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
21
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
22 #define PLUGIN_ID "gtk-webview-adium-ims"
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
23 #define PLUGIN_NAME "webview-adium-ims"
32453
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
24
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
25 /*
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
26 * A lot of this was originally written by Sean Egan, but I think I've
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
27 * rewrote enough to replace the author for now.
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
28 */
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
29 #define PLUGIN_AUTHOR "Arnold Noronha <arnstein87@gmail.com>"
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
30 #define PURPLE_PLUGINS "Hell yeah"
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
31
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
32 /* System headers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
33 #include <string.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
34 #include <gdk/gdk.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
35 #include <gtk/gtk.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
36
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
37 #include <webkit/webkit.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
38
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
39 /* Purple headers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
40 #include <conversation.h>
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
41 #include <debug.h>
32499
91d409e20e8a Don't crash if we don't have any theme installed.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32495
diff changeset
42 #include <internal.h>
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
43 #include <notify.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
44 #include <util.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
45 #include <version.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
46
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
47 /* Pidgin headers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
48 #include <gtkconv.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
49 #include <gtkplugin.h>
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
50 #include <gtkwebview.h>
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
51 #include <smileyparser.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
52
32478
399d9ea27454 Parses Info.plist now!
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32477
diff changeset
53 #include <libxml/xmlreader.h>
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
54
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
55 #include "message-style.h"
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
56 /* GObject data keys */
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
57 #define MESSAGE_STYLE_KEY "message-style"
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
58
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
59 static char *cur_style_dir = NULL;
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
60 static void *handle = NULL;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
61
32472
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
62 static inline char* get_absolute_path (const char *path)
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
63 {
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
64 if (g_path_is_absolute (path)) return g_strdup (path);
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
65 else {
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
66 char* cwd = g_get_current_dir (), *ret;
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
67 ret = g_build_filename (cwd, path, NULL);
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
68 g_free (cwd);
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
69 return ret;
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
70 }
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
71 }
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
72
32478
399d9ea27454 Parses Info.plist now!
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32477
diff changeset
73 static void
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
74 glist_free_all_string (GList *list)
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
75 {
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
76 GList *first = list;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
77 for (; list; list = g_list_next (list))
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
78 g_free (list->data);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
79 g_list_free (first);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
80 }
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
81
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
82 static void webkit_on_webview_destroy (GtkObject* obj, gpointer data);
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
83
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
84 static void* webkit_plugin_get_handle ()
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
85 {
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
86 if (handle) return handle;
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
87 else return (handle = g_malloc (1));
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
88 }
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
89
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
90 static void webkit_plugin_free_handle ()
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
91 {
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
92 purple_signals_disconnect_by_handle (handle);
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
93 g_free (handle);
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
94 }
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
95
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
96 static char *
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
97 replace_message_tokens(
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
98 const char *text,
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
99 gsize len,
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
100 PurpleConversation *conv,
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
101 const char *name,
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
102 const char *alias,
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
103 const char *message,
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
104 PurpleMessageFlags flags,
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
105 time_t mtime)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
106 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
107 GString *str = g_string_new_len(NULL, len);
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
108 const char *cur = text;
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
109 const char *prev = cur;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
110
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
111 while ((cur = strchr(cur, '%'))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
112 const char *replace = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
113 char *fin = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
114
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
115 if (!strncmp(cur, "%message%", strlen("%message%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
116 replace = message;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
117 } else if (!strncmp(cur, "%messageClasses%", strlen("%messageClasses%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
118 replace = flags & PURPLE_MESSAGE_SEND ? "outgoing" :
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
119 flags & PURPLE_MESSAGE_RECV ? "incoming" : "event";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
120 } else if (!strncmp(cur, "%time", strlen("%time"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
121 char *format = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
122 if (*(cur + strlen("%time")) == '{') {
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
123 const char *start = cur + strlen("%time") + 1;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
124 char *end = strstr(start, "}%");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
125 if (!end) /* Invalid string */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
126 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
127 format = g_strndup(start, end - start);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
128 fin = end + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
129 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
130 replace = purple_utf8_strftime(format ? format : "%X", NULL);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
131 g_free(format);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
132 } else if (!strncmp(cur, "%userIconPath%", strlen("%userIconPath%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
133 if (flags & PURPLE_MESSAGE_SEND) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
134 if (purple_account_get_bool(conv->account, "use-global-buddyicon", TRUE)) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
135 replace = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
136 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
137 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(conv->account);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
138 replace = purple_imgstore_get_filename(img);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
139 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
140 if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
141 replace = g_build_filename("Outgoing", "buddy_icon.png", NULL);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
142 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
143 } else if (flags & PURPLE_MESSAGE_RECV) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
144 PurpleBuddyIcon *icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv));
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
145 replace = purple_buddy_icon_get_full_path(icon);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
146 if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
147 replace = g_build_filename("Incoming", "buddy_icon.png", NULL);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
148 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
149 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
150
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
151 } else if (!strncmp(cur, "%senderScreenName%", strlen("%senderScreenName%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
152 replace = name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
153 } else if (!strncmp(cur, "%sender%", strlen("%sender%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
154 replace = alias;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
155 } else if (!strncmp(cur, "%service%", strlen("%service%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
156 replace = purple_account_get_protocol_name(conv->account);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
157 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
158 cur++;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
159 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
160 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
161
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
162 /* Here we have a replacement to make */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
163 g_string_append_len(str, prev, cur - prev);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
164 g_string_append(str, replace);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
165
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
166 /* And update the pointers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
167 if (fin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
168 prev = cur = fin + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
169 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
170 prev = cur = strchr(cur + 1, '%') + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
171 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
172
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
173 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
174
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
175 /* And wrap it up */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
176 g_string_append(str, prev);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
177 return g_string_free(str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
178 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
179
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
180 static char *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
181 replace_header_tokens(char *text, gsize len, PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
182 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
183 GString *str = g_string_new_len(NULL, len);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
184 char *cur = text;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
185 char *prev = cur;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
186
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
187 if (text == NULL)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
188 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
189
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
190 while ((cur = strchr(cur, '%'))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
191 const char *replace = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
192 char *fin = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
193
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
194 if (!strncmp(cur, "%chatName%", strlen("%chatName%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
195 replace = conv->name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
196 } else if (!strncmp(cur, "%sourceName%", strlen("%sourceName%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
197 replace = purple_account_get_alias(conv->account);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
198 if (replace == NULL)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
199 replace = purple_account_get_username(conv->account);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
200 } else if (!strncmp(cur, "%destinationName%", strlen("%destinationName%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
201 PurpleBuddy *buddy = purple_find_buddy(conv->account, conv->name);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
202 if (buddy) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
203 replace = purple_buddy_get_alias(buddy);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
204 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
205 replace = conv->name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
206 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
207 } else if (!strncmp(cur, "%incomingIconPath%", strlen("%incomingIconPath%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
208 PurpleBuddyIcon *icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv));
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
209 replace = purple_buddy_icon_get_full_path(icon);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
210 } else if (!strncmp(cur, "%outgoingIconPath%", strlen("%outgoingIconPath%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
211 } else if (!strncmp(cur, "%timeOpened", strlen("%timeOpened"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
212 char *format = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
213 if (*(cur + strlen("%timeOpened")) == '{') {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
214 char *start = cur + strlen("%timeOpened") + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
215 char *end = strstr(start, "}%");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
216 if (!end) /* Invalid string */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
217 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
218 format = g_strndup(start, end - start);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
219 fin = end + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
220 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
221 replace = purple_utf8_strftime(format ? format : "%X", NULL);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
222 g_free(format);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
223 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
224 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
225 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
226
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
227 /* Here we have a replacement to make */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
228 g_string_append_len(str, prev, cur - prev);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
229 g_string_append(str, replace);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
230
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
231 /* And update the pointers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
232 if (fin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
233 prev = cur = fin + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
234 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
235 prev = cur = strchr(cur + 1, '%') + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
236 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
237 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
238
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
239 /* And wrap it up */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
240 g_string_append(str, prev);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
241 return g_string_free(str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
242 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
243
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
244 static char *
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
245 replace_template_tokens(PidginMessageStyle *style, char *text, int len, char *header, char *footer) {
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
246 GString *str = g_string_new_len(NULL, len);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
247
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
248 char **ms = g_strsplit(text, "%@", 6);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
249 char *base = NULL;
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
250 char *csspath = pidgin_message_style_get_css (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
251 if (ms[0] == NULL || ms[1] == NULL || ms[2] == NULL || ms[3] == NULL || ms[4] == NULL || ms[5] == NULL) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
252 g_strfreev(ms);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
253 g_string_free(str, TRUE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
254 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
255 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
256
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
257 g_string_append(str, ms[0]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
258 g_string_append(str, "file://");
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
259 base = g_build_filename (style->style_dir, "Contents", "Resources", "Template.html", NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
260 g_string_append(str, base);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
261 g_free (base);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
262
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
263 g_string_append(str, ms[1]);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
264
32486
c44fe7ecb3dd load the default variant. Bring back basestyle.css.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32485
diff changeset
265 g_string_append(str, style->basestyle_css);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
266
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
267 g_string_append(str, ms[2]);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
268
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
269 g_string_append(str, "file://");
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
270 g_string_append(str, csspath);
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
271
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
272
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
273
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
274 g_string_append(str, ms[3]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
275 if (header)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
276 g_string_append(str, header);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
277 g_string_append(str, ms[4]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
278 if (footer)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
279 g_string_append(str, footer);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
280 g_string_append(str, ms[5]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
281
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
282 g_strfreev(ms);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
283 g_free (csspath);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
284 return g_string_free (str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
285 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
286
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
287 static GtkWidget *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
288 get_webkit(PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
289 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
290 PidginConversation *gtkconv;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
291 gtkconv = PIDGIN_CONVERSATION(conv);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
292 if (!gtkconv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
293 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
294 else
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
295 return gtkconv->webview;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
296 }
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
297
32484
11ae8e769921 apparent code for webkit transparency that might not be working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32482
diff changeset
298 static void set_theme_webkit_settings (WebKitWebView *webview, PidginMessageStyle *style)
32482
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
299 {
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
300 WebKitWebSettings *settings;
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
301
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
302 g_object_get (G_OBJECT(webview), "settings", &settings, NULL);
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
303 if (style->default_font_family)
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
304 g_object_set (G_OBJECT (settings), "default-font-family", style->default_font_family, NULL);
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
305
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
306 if (style->default_font_size)
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
307 g_object_set (G_OBJECT (settings), "default-font-size", GINT_TO_POINTER (style->default_font_size), NULL);
32484
11ae8e769921 apparent code for webkit transparency that might not be working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32482
diff changeset
308
11ae8e769921 apparent code for webkit transparency that might not be working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32482
diff changeset
309 /* this does not work :( */
11ae8e769921 apparent code for webkit transparency that might not be working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32482
diff changeset
310 webkit_web_view_set_transparent (webview, style->default_background_is_transparent);
32482
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
311 }
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
312
32490
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
313 /*
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
314 * The style specification says that if the conversation is a group
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
315 * chat then the <div id="Chat"> element will be given a class
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
316 * 'groupchat'. I can't add another '%@' in Template.html because
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
317 * that breaks style-specific Template.html's. I have to either use libxml
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
318 * or conveniently play with WebKit's javascript engine. The javascript
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
319 * engine should work, but it's not an identical behavior.
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
320 */
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
321 static void
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
322 webkit_set_groupchat (GtkWebView *webview)
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
323 {
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
324 gtk_webview_safe_execute_script (webview, "document.getElementById('Chat').className = 'groupchat'");
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
325 }
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
326
32482
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
327
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
328 /**
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
329 * Called when either a new PurpleConversation is created
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
330 * or when a PidginConversation changes its active PurpleConversation
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
331 * This will not change the theme if the theme is already set.
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
332 * (This is to prevent accidental theme changes if a new
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
333 * PurpleConversation gets added.
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
334 *
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
335 * FIXME: it's not at all clear to me as to how
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
336 * Adium themes handle the case when the PurpleConversation
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
337 * changes.
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
338 */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
339 static void
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
340 init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
341 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
342 GtkWidget *webkit = PIDGIN_CONVERSATION(conv)->webview;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
343 char *header, *footer;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
344 char *template;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
345
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
346 char* basedir;
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
347 char* baseuri;
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
348 PidginMessageStyle *style, *oldStyle;
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
349 oldStyle = g_object_get_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY);
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
350
32488
17153501cae6 Fixing back variants.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32487
diff changeset
351 if (oldStyle) return;
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
352
32470
00b22ce81ec1 Debugging info to find bad themes.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32469
diff changeset
353 purple_debug_info ("webkit", "loading %s\n", style_dir);
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
354 style = pidgin_message_style_load (style_dir);
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
355 g_assert (style);
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
356 g_assert (style->template_html); /* debugging test? */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
357
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
358 basedir = g_build_filename (style->style_dir, "Contents", "Resources", "Template.html", NULL);
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
359 baseuri = g_strdup_printf ("file://%s", basedir);
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
360 header = replace_header_tokens(style->header_html, strlen(style->header_html), conv);
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
361 g_assert (style);
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
362 footer = replace_header_tokens(style->footer_html, strlen(style->footer_html), conv);
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
363 template = replace_template_tokens(style, style->template_html, strlen(style->template_html) + strlen(style->header_html), header, footer);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
364
32471
1eae26422963 small assertion code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32470
diff changeset
365 g_assert(template);
32481
3f1ea49c8c2d just some debugging info.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32480
diff changeset
366
3f1ea49c8c2d just some debugging info.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32480
diff changeset
367 purple_debug_info ("webkit", "template: %s\n", template);
32482
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
368
32484
11ae8e769921 apparent code for webkit transparency that might not be working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32482
diff changeset
369 set_theme_webkit_settings (WEBKIT_WEB_VIEW(webkit), style);
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
370 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
371
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
372 PidginMessageStyle *copy = pidgin_message_style_copy (style);
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
373 g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, copy);
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
374
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
375 pidgin_message_style_unref (style);
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
376 /* I need to unref this style when the webkit object destroys */
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
377 g_signal_connect (G_OBJECT(webkit), "destroy", G_CALLBACK(webkit_on_webview_destroy), copy);
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
378
32490
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
379 if (purple_conversation_get_type (conv) == PURPLE_CONV_TYPE_CHAT)
ece69f13d4fa Adds the 'groupchat' classname to #Chat when using groupchat.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
380 webkit_set_groupchat (GTK_WEBVIEW (webkit));
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
381 g_free (basedir);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
382 g_free (baseuri);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
383 g_free (header);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
384 g_free (footer);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
385 g_free (template);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
386 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
387
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
388
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
389 /* restore the non theme version of the conversation window */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
390 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
391 finalize_theme_for_webkit (PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
392 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
393 GtkWidget *webview = PIDGIN_CONVERSATION(conv)->webview;
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
394 PidginMessageStyle *style = g_object_get_data (G_OBJECT(webview), MESSAGE_STYLE_KEY);
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
395
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
396 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), "", "text/html", "UTF-8", "");
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
397
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
398 g_object_set_data (G_OBJECT(webview), MESSAGE_STYLE_KEY, NULL);
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
399 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
400 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
401
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
402 static void
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
403 webkit_on_webview_destroy (GtkObject *object, gpointer data)
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
404 {
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
405 pidgin_message_style_unref ((PidginMessageStyle*) data);
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
406 g_object_set_data (G_OBJECT(object), MESSAGE_STYLE_KEY, NULL);
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
407 }
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
408
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
409 static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
410 const char* name,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
411 char **pmessage,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
412 PurpleConversation *conv,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
413 PurpleMessageFlags flags,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
414 gpointer data)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
415 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
416 GtkWidget *webkit;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
417 char *message = *pmessage;
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
418 const char *alias = name; /* FIXME: signal doesn't give me alias */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
419 char *stripped;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
420 char *message_html;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
421 char *msg;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
422 char *escape;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
423 char *script;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
424 char *func = "appendMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
425 char *smileyed;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
426 time_t mtime = time (NULL); /* FIXME: this should come from the write_conv calback, but the signal doesn't pass this to me */
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
427
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
428 PurpleMessageFlags old_flags = GPOINTER_TO_INT(purple_conversation_get_data(conv, "webkit-lastflags"));
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
429 PidginMessageStyle *style;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
430
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
431 fprintf (stderr, "hmm.. here %s %s\n", name, message);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
432 webkit = get_webkit(conv);
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
433 stripped = g_strdup(message);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
434
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
435 style = g_object_get_data (G_OBJECT (webkit), MESSAGE_STYLE_KEY);
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
436 g_assert (style);
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
437
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
438 if (flags & PURPLE_MESSAGE_SEND && old_flags & PURPLE_MESSAGE_SEND) {
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
439 message_html = style->outgoing_next_content_html;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
440 func = "appendNextMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
441 } else if (flags & PURPLE_MESSAGE_SEND) {
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
442 message_html = style->outgoing_content_html;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
443 } else if (flags & PURPLE_MESSAGE_RECV && old_flags & PURPLE_MESSAGE_RECV) {
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
444 message_html = style->incoming_next_content_html;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
445 func = "appendNextMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
446 } else if (flags & PURPLE_MESSAGE_RECV) {
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
447 message_html = style->incoming_content_html;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
448 } else {
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
449 message_html = style->status_html;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
450 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
451 purple_conversation_set_data(conv, "webkit-lastflags", GINT_TO_POINTER(flags));
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
452
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
453 smileyed = smiley_parse_markup(stripped, conv->account->protocol_id);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
454 msg = replace_message_tokens(message_html, 0, conv, name, alias, smileyed, flags, mtime);
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
455 escape = gtk_webview_quote_js_string (msg);
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
456 script = g_strdup_printf("%s(%s)", func, escape);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
457
32481
3f1ea49c8c2d just some debugging info.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32480
diff changeset
458 purple_debug_info ("webkit", "JS: %s\n", script);
32461
72fe247cc953 Yep, tested, and changed some code from previous commit. This is a hard
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32460
diff changeset
459 gtk_webview_safe_execute_script (GTK_WEBVIEW (webkit), script);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
460
32461
72fe247cc953 Yep, tested, and changed some code from previous commit. This is a hard
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32460
diff changeset
461 g_free(script);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
462 g_free(smileyed);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
463 g_free(msg);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
464 g_free(stripped);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
465 g_free(escape);
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
466
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
467 return TRUE; /* GtkConv should not handle this IM */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
468 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
469
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
470 static gboolean webkit_on_displaying_chat_msg (PurpleAccount *account,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
471 const char *who,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
472 char **message,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
473 PurpleConversation *conv,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
474 PurpleMessageFlags flags,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
475 gpointer userdata)
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
476 {
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
477 /* handle exactly like an IM message for now */
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
478 return webkit_on_displaying_im_msg (account, who, message, conv, flags, NULL);
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
479 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
480
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
481 static void
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
482 webkit_on_conversation_displayed (PidginConversation *gtkconv, gpointer data)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
483 {
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
484 init_theme_for_webkit (gtkconv->active_conv, cur_style_dir);
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
485 }
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
486
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
487 static void
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
488 webkit_on_conversation_switched (PurpleConversation *conv, gpointer data)
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
489 {
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
490 init_theme_for_webkit (conv, cur_style_dir);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
491 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
492
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
493 static void
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
494 webkit_on_conversation_hiding (PidginConversation *gtkconv, gpointer data)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
495 {
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
496 /*
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
497 * I'm not sure if I need to do anything here, but let's keep
32465
6086db3c6e64 removed the fixme.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32464
diff changeset
498 * this anyway.
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
499 */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
500 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
501
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
502 static GList*
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
503 get_dir_dir_list (const char* dirname)
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
504 {
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
505 GList *ret = NULL;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
506 GDir *dir = g_dir_open (dirname, 0, NULL);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
507 const char* subdir;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
508
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
509 if (!dir) return NULL;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
510 while ((subdir = g_dir_read_name (dir))) {
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
511 ret = g_list_append (ret, g_build_filename (dirname, subdir, NULL));
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
512 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
513
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
514 g_dir_close (dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
515 return ret;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
516 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
517
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
518 /**
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
519 * Get me a list of all the available themes specified by their
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
520 * directories. I don't guarrantee that these are valid themes, just
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
521 * that they are in the directories for themes.
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
522 */
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
523 static GList*
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
524 get_style_directory_list ()
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
525 {
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
526 char *user_dir, *user_style_dir, *global_style_dir;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
527 GList *list1, *list2;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
528
32472
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
529 user_dir = get_absolute_path (purple_user_dir ());
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
530
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
531 user_style_dir = g_build_filename (user_dir, "styles", NULL);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
532 global_style_dir = g_build_filename (DATADIR, "pidgin", "styles", NULL);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
533
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
534 list1 = get_dir_dir_list (user_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
535 list2 = get_dir_dir_list (global_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
536
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
537 g_free (global_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
538 g_free (user_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
539 g_free (user_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
540
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
541 return g_list_concat (list1, list2);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
542 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
543
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
544 /**
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
545 * use heuristics or previous user options to figure out what
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
546 * theme to use as default in this Pidgin instance.
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
547 */
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
548 static void
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
549 style_set_default ()
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
550 {
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
551 GList* styles = get_style_directory_list (), *iter;
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
552 const char *stylepath = purple_prefs_get_string ("/plugins/gtk/adiumthemes/stylepath");
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
553 g_assert (cur_style_dir == NULL);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
554
32499
91d409e20e8a Don't crash if we don't have any theme installed.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32495
diff changeset
555 if (stylepath && *stylepath)
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
556 styles = g_list_prepend (styles, g_strdup (stylepath));
32499
91d409e20e8a Don't crash if we don't have any theme installed.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32495
diff changeset
557 else {
91d409e20e8a Don't crash if we don't have any theme installed.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32495
diff changeset
558 purple_notify_error(handle, _("Webkit themes"),
91d409e20e8a Don't crash if we don't have any theme installed.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32495
diff changeset
559 _("Can't find installed styles"),
91d409e20e8a Don't crash if we don't have any theme installed.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32495
diff changeset
560 _("Please install some theme and verify the installation path"));
91d409e20e8a Don't crash if we don't have any theme installed.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32495
diff changeset
561
91d409e20e8a Don't crash if we don't have any theme installed.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32495
diff changeset
562 return;
91d409e20e8a Don't crash if we don't have any theme installed.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32495
diff changeset
563 }
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
564
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
565 /* pick any one that works. Note that we have first preference
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
566 * for the one in the userdir */
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
567 for (iter = styles; iter; iter = g_list_next (iter)) {
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
568 PidginMessageStyle *style = pidgin_message_style_load (iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
569 if (style) {
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
570 cur_style_dir = (char*) g_strdup (iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
571 pidgin_message_style_unref (style);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
572 break;
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
573 }
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
574 purple_debug_info ("webkit", "Style %s is invalid\n", (char*) iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
575 }
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
576
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
577 for (iter = styles; iter; iter = g_list_next (iter))
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
578 g_free (iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
579 g_list_free (styles);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
580 }
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
581
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
582 static gboolean
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
583 plugin_load(PurplePlugin *plugin)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
584 {
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
585 style_set_default ();
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
586 if (!cur_style_dir) return FALSE; /* couldn't find a style */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
587
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
588 purple_signal_connect (pidgin_conversations_get_handle (),
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
589 "displaying-im-msg",
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
590 webkit_plugin_get_handle (),
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
591 PURPLE_CALLBACK(webkit_on_displaying_im_msg),
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
592 NULL);
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
593
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
594 purple_signal_connect (pidgin_conversations_get_handle (),
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
595 "displaying-chat-msg",
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
596 webkit_plugin_get_handle (),
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
597 PURPLE_CALLBACK(webkit_on_displaying_chat_msg),
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
598 NULL);
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
599
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
600 purple_signal_connect (pidgin_conversations_get_handle (),
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
601 "conversation-displayed",
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
602 webkit_plugin_get_handle (),
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
603 PURPLE_CALLBACK(webkit_on_conversation_displayed),
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
604 NULL);
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
605
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
606 purple_signal_connect (pidgin_conversations_get_handle (),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
607 "conversation-switched",
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
608 webkit_plugin_get_handle (),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
609 PURPLE_CALLBACK(webkit_on_conversation_switched),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
610 NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
611
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
612 purple_signal_connect (pidgin_conversations_get_handle (),
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
613 "conversation-hiding",
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
614 webkit_plugin_get_handle (),
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
615 PURPLE_CALLBACK(webkit_on_conversation_hiding),
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
616 NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
617
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
618 /* finally update each of the existing conversation windows */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
619 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
620 GList* list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
621 for (;list; list = g_list_next(list))
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
622 init_theme_for_webkit (list->data, cur_style_dir);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
623
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
624 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
625 return TRUE;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
626 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
627
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
628 static gboolean
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
629 plugin_unload(PurplePlugin *plugin)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
630 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
631 GList *list;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
632
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
633 webkit_plugin_free_handle ();
32469
ba275d3188c7 unset cur_style_dir when unloading.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32468
diff changeset
634 cur_style_dir = NULL;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
635 list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
636 while (list) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
637 finalize_theme_for_webkit(list->data);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
638 list = g_list_next(list);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
639 }
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
640
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
641 return TRUE;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
642 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
643
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
644 /*
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
645 * UI config code
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
646 */
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
647
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
648 static void
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
649 style_changed (GtkWidget* combobox, gpointer null)
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
650 {
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
651 char *name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox));
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
652 GtkWidget *dialog;
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
653 GList *styles = get_style_directory_list (), *iter;
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
654
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
655 /* find the full path for this name, I wish I could store this info in the combobox itself. :( */
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
656 for (iter = styles; iter; iter = g_list_next(iter)) {
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
657 char* basename = g_path_get_basename (iter->data);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
658 if (g_str_equal (basename, name)) {
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
659 g_free (basename);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
660 break;
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
661 }
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
662 g_free (basename);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
663 }
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
664
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
665 g_assert (iter);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
666 g_free (name);
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
667 g_free (cur_style_dir);
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
668 cur_style_dir = g_strdup (iter->data);;
32495
cfe772a1a354 save the style path across sessions.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32490
diff changeset
669 purple_prefs_set_string ("/plugins/gtk/adiumthemes/stylepath", cur_style_dir);
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
670
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
671 /* inform the user that existing conversations haven't changed */
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
672 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.");
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
673 g_assert (dialog);
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
674 gtk_widget_show (dialog);
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
675 g_signal_connect_swapped (dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
676 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
677
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
678 static GtkWidget*
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
679 get_style_config_frame ()
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
680 {
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
681 GtkWidget *combobox = gtk_combo_box_new_text ();
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
682 GList *styles = get_style_directory_list (), *iter;
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
683 int index = 0, selected = 0;
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
684
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
685 for (iter = styles; iter; iter = g_list_next (iter)) {
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
686 PidginMessageStyle *style = pidgin_message_style_load (iter->data);
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
687
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
688 if (style) {
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
689 char *text = g_path_get_basename (iter->data);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
690 gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), text);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
691 g_free (text);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
692
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
693 if (g_str_equal (iter->data, cur_style_dir))
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
694 selected = index;
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
695 index++;
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
696 pidgin_message_style_unref (style);
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
697 }
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
698 }
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
699 gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), selected);
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
700 g_signal_connect_after (G_OBJECT(combobox), "changed", G_CALLBACK(style_changed), NULL);
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
701 return combobox;
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
702 }
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
703
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
704 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
705 variant_update_conversation (PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
706 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
707 PidginConversation *gtkconv = PIDGIN_CONVERSATION (conv);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
708 WebKitWebView *webview = WEBKIT_WEB_VIEW (gtkconv->webview);
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
709 PidginMessageStyle *style = (PidginMessageStyle*) g_object_get_data (G_OBJECT(webview), MESSAGE_STYLE_KEY);
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
710 char *script;
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
711
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
712 g_assert (style);
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
713
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
714 script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", pidgin_message_style_get_css (style));
32461
72fe247cc953 Yep, tested, and changed some code from previous commit. This is a hard
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32460
diff changeset
715 gtk_webview_safe_execute_script (GTK_WEBVIEW(webview), script);
32482
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
716
32484
11ae8e769921 apparent code for webkit transparency that might not be working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32482
diff changeset
717 set_theme_webkit_settings (WEBKIT_WEB_VIEW (gtkconv->webview), style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
718 g_free (script);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
719 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
720
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
721 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
722 variant_changed (GtkWidget* combobox, gpointer null)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
723 {
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
724 char *name;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
725 GList *list;
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
726 PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
727
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
728 g_assert (style);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
729 name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combobox));
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
730 pidgin_message_style_set_variant (style, name);
32488
17153501cae6 Fixing back variants.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32487
diff changeset
731 pidgin_message_style_save_state (style);
17153501cae6 Fixing back variants.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32487
diff changeset
732
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
733 /* update conversations */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
734 list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
735 while (list) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
736 variant_update_conversation (list->data);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
737 list = g_list_next(list);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
738 }
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
739
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
740 g_free (name);
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
741 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
742 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
743
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
744 static GtkWidget *
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
745 get_variant_config_frame()
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
746 {
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
747 PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
748 GList *variants = pidgin_message_style_get_variants (style), *iter;
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
749 char *cur_variant = pidgin_message_style_get_variant (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
750 GtkWidget *combobox = gtk_combo_box_new_text();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
751 int def = -1, index = 0;
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
752
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
753 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
754
32477
f36b9ed704b1 Removed some unused code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32476
diff changeset
755 for (iter = variants; iter; iter = g_list_next (iter)) {
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
756 gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), iter->data);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
757
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
758 if (g_str_equal (cur_variant, iter->data))
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
759 def = index;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
760 index ++;
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
761
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
762 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
763
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
764 gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), def);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
765 g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(variant_changed), NULL);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
766
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
767 return combobox;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
768 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
769
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
770 static void
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
771 style_changed_reset_variants (GtkWidget* combobox, gpointer table)
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
772 {
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
773 /* I hate to do this, I swear. But I don't know how to cleanly clean an existing combobox */
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
774 GtkWidget* variants = g_object_get_data (G_OBJECT(table), "variants-cbox");
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
775 gtk_widget_destroy (variants);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
776 variants = get_variant_config_frame ();
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
777 gtk_table_attach_defaults (GTK_TABLE (table), variants, 1, 2, 1, 2);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
778 gtk_widget_show_all (GTK_WIDGET(table));
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
779
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
780 g_object_set_data (G_OBJECT(table), "variants-cbox", variants);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
781 }
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
782
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
783 static GtkWidget*
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
784 get_config_frame(PurplePlugin* plugin)
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
785 {
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
786 GtkWidget *table = gtk_table_new (2, 2, FALSE);
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
787 GtkWidget *style_config = get_style_config_frame ();
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
788 GtkWidget *variant_config = get_variant_config_frame ();
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
789
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
790 gtk_table_attach_defaults (GTK_TABLE(table), gtk_label_new ("Message Style"), 0, 1, 0, 1);
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
791 gtk_table_attach_defaults (GTK_TABLE(table), style_config, 1, 2, 0, 1);
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
792 gtk_table_attach_defaults (GTK_TABLE(table), gtk_label_new ("Style Variant"), 0, 1, 1, 2);
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
793 gtk_table_attach_defaults (GTK_TABLE(table), variant_config, 1, 2, 1, 2);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
794
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
795
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
796 g_object_set_data (G_OBJECT(table), "variants-cbox", variant_config);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
797 /* to clarify, this is a second signal connected on style config */
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
798 g_signal_connect_after (G_OBJECT(style_config), "changed", G_CALLBACK(style_changed_reset_variants), table);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
799
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
800 return table;
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
801 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
802
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
803 PidginPluginUiInfo ui_info =
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
804 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
805 get_config_frame,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
806 0, /* page_num (Reserved) */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
807
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
808 /* padding */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
809 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
810 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
811 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
812 NULL
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
813 };
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
814
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
815
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
816 static PurplePluginInfo info =
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
817 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
818 PURPLE_PLUGIN_MAGIC, /* Magic */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
819 PURPLE_MAJOR_VERSION, /* Purple Major Version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
820 PURPLE_MINOR_VERSION, /* Purple Minor Version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
821 PURPLE_PLUGIN_STANDARD, /* plugin type */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
822 PIDGIN_PLUGIN_TYPE, /* ui requirement */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
823 0, /* flags */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
824 NULL, /* dependencies */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
825 PURPLE_PRIORITY_DEFAULT, /* priority */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
826
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
827 PLUGIN_ID, /* plugin id */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
828 NULL, /* name */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
829 "0.1", /* version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
830 NULL, /* summary */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
831 NULL, /* description */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
832 PLUGIN_AUTHOR, /* author */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
833 "http://pidgin.im", /* website */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
834
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
835 plugin_load, /* load */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
836 plugin_unload, /* unload */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
837 NULL, /* destroy */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
838
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
839 &ui_info, /* ui_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
840 NULL, /* extra_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
841 NULL, /* prefs_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
842 NULL, /* actions */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
843 NULL, /* reserved 1 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
844 NULL, /* reserved 2 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
845 NULL, /* reserved 3 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
846 NULL /* reserved 4 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
847 };
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
848
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
849 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
850 init_plugin(PurplePlugin *plugin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
851 info.name = "Adium IMs";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
852 info.summary = "Adium-like IMs with Pidgin";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
853 info.description = "You can chat in Pidgin using Adium's WebKit view.";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
854
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
855 purple_prefs_add_none ("/plugins");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
856 purple_prefs_add_none ("/plugins/gtk");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
857 purple_prefs_add_none ("/plugins/gtk/adiumthemes");
32495
cfe772a1a354 save the style path across sessions.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32490
diff changeset
858 purple_prefs_add_string ("/plugins/gtk/adiumthemes/stylepath", "");
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
859 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
860
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
861 PURPLE_INIT_PLUGIN(webkit, init_plugin, info)

mercurial