pidgin/plugins/adiumthemes/webkit.c

Sun, 16 Aug 2009 19:28:23 +0000

author
Arnold Noronha <tdrhq@soc.pidgin.im>
date
Sun, 16 Aug 2009 19:28:23 +0000
branch
soc.2009.webkitmessageview
changeset 32488
17153501cae6
parent 32487
13f307997f1a
child 32490
ece69f13d4fa
permissions
-rw-r--r--

Fixing back variants.

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>
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
42 #include <notify.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
43 #include <util.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
44 #include <version.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
45
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
46 /* Pidgin headers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
47 #include <gtkconv.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
48 #include <gtkplugin.h>
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
49 #include <gtkwebview.h>
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
50 #include <smileyparser.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
51
32478
399d9ea27454 Parses Info.plist now!
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32477
diff changeset
52 #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
53
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
54 #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
55 /* 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
56 #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
57
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
58 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
59 static void *handle = NULL;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
60
32472
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
61 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
62 {
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
63 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
64 else {
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
65 char* cwd = g_get_current_dir (), *ret;
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
66 ret = g_build_filename (cwd, path, NULL);
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
67 g_free (cwd);
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
68 return ret;
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
69 }
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
32478
399d9ea27454 Parses Info.plist now!
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32477
diff changeset
72 static void
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
73 glist_free_all_string (GList *list)
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
74 {
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
75 GList *first = list;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32484
diff changeset
76 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
77 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
78 g_list_free (first);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
79 }
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
80
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
81 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
82
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
83 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
84 {
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
85 if (handle) return handle;
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
86 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
87 }
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 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
90 {
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
91 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
92 g_free (handle);
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
93 }
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
94
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104 time_t mtime)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
105 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
106 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
107 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
108 const char *prev = cur;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
109
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
110 while ((cur = strchr(cur, '%'))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
111 const char *replace = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
112 char *fin = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
113
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
114 if (!strncmp(cur, "%message%", strlen("%message%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
115 replace = message;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
116 } 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
117 replace = flags & PURPLE_MESSAGE_SEND ? "outgoing" :
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
118 flags & PURPLE_MESSAGE_RECV ? "incoming" : "event";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
119 } 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
120 char *format = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
121 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
122 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
123 char *end = strstr(start, "}%");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
124 if (!end) /* Invalid string */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
125 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
126 format = g_strndup(start, end - start);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
127 fin = end + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
128 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
129 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
130 g_free(format);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
131 } 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
132 if (flags & PURPLE_MESSAGE_SEND) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
133 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
134 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
135 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
136 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
137 replace = purple_imgstore_get_filename(img);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
138 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
139 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
140 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
141 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
142 } else if (flags & PURPLE_MESSAGE_RECV) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
143 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
144 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
145 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
146 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
147 }
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 } 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
151 replace = name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
152 } 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
153 replace = alias;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
154 } 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
155 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
156 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
157 cur++;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
158 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
159 }
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 /* 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
162 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
163 g_string_append(str, replace);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
164
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
165 /* And update the pointers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
166 if (fin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
167 prev = cur = fin + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
168 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
169 prev = cur = strchr(cur + 1, '%') + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
170 }
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 /* And wrap it up */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
175 g_string_append(str, prev);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
176 return g_string_free(str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
177 }
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 static char *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
180 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
181 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
182 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
183 char *cur = text;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
184 char *prev = cur;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
185
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
186 if (text == NULL)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
187 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
188
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
189 while ((cur = strchr(cur, '%'))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
190 const char *replace = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
191 char *fin = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
192
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
193 if (!strncmp(cur, "%chatName%", strlen("%chatName%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
194 replace = conv->name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
195 } 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
196 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
197 if (replace == NULL)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
198 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
199 } 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
200 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
201 if (buddy) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
202 replace = purple_buddy_get_alias(buddy);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
203 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
204 replace = conv->name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
205 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
206 } 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
207 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
208 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
209 } 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
210 } 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
211 char *format = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
212 if (*(cur + strlen("%timeOpened")) == '{') {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
213 char *start = cur + strlen("%timeOpened") + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
214 char *end = strstr(start, "}%");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
215 if (!end) /* Invalid string */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
216 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
217 format = g_strndup(start, end - start);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
218 fin = end + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
219 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
220 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
221 g_free(format);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
222 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
223 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
224 }
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 /* 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
227 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
228 g_string_append(str, replace);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
229
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
230 /* And update the pointers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
231 if (fin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
232 prev = cur = fin + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
233 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
234 prev = cur = strchr(cur + 1, '%') + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
235 }
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 /* And wrap it up */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
239 g_string_append(str, prev);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
240 return g_string_free(str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
241 }
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 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
244 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
245 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
246
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
247 char **ms = g_strsplit(text, "%@", 6);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
248 char *base = NULL;
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
249 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
250 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
251 g_strfreev(ms);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
252 g_string_free(str, TRUE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
253 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
254 }
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 g_string_append(str, ms[0]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
257 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
258 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
259 g_string_append(str, base);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
260 g_free (base);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
261
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
262 g_string_append(str, ms[1]);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
263
32486
c44fe7ecb3dd load the default variant. Bring back basestyle.css.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32485
diff changeset
264 g_string_append(str, style->basestyle_css);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
265
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
266 g_string_append(str, ms[2]);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
267
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
268 g_string_append(str, "file://");
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
269 g_string_append(str, csspath);
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
270
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
271
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
272
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
273 g_string_append(str, ms[3]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
274 if (header)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
275 g_string_append(str, header);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
276 g_string_append(str, ms[4]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
277 if (footer)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
278 g_string_append(str, footer);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
279 g_string_append(str, ms[5]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
280
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
281 g_strfreev(ms);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
282 g_free (csspath);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
283 return g_string_free (str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
284 }
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 static GtkWidget *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
287 get_webkit(PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
288 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
289 PidginConversation *gtkconv;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
290 gtkconv = PIDGIN_CONVERSATION(conv);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
291 if (!gtkconv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
292 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
293 else
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
294 return gtkconv->webview;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
295 }
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
296
32484
11ae8e769921 apparent code for webkit transparency that might not be working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32482
diff changeset
297 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
298 {
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
299 WebKitWebSettings *settings;
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
300
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
301 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
302 if (style->default_font_family)
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
303 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
304
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
305 if (style->default_font_size)
d0f92b6cc6b4 hmm, fonts and font sizes from Info.plist.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32481
diff changeset
306 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
307
11ae8e769921 apparent code for webkit transparency that might not be working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32482
diff changeset
308 /* 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
309 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
310 }
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
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
313 /**
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
314 * Called when either a new PurpleConversation is created
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
315 * 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
316 * 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
317 * (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
318 * PurpleConversation gets added.
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
319 *
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
320 * 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
321 * Adium themes handle the case when the PurpleConversation
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
322 * changes.
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
323 */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
324 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
325 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
326 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
327 GtkWidget *webkit = PIDGIN_CONVERSATION(conv)->webview;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
328 char *header, *footer;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
329 char *template;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
330
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
331 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
332 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
333 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
334 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
335
32488
17153501cae6 Fixing back variants.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32487
diff changeset
336 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
337
32470
00b22ce81ec1 Debugging info to find bad themes.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32469
diff changeset
338 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
339 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
340 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
341 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
342
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
343 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
344 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
345 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
346 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
347 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
348 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
349
32471
1eae26422963 small assertion code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32470
diff changeset
350 g_assert(template);
32481
3f1ea49c8c2d just some debugging info.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32480
diff changeset
351
3f1ea49c8c2d just some debugging info.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32480
diff changeset
352 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
353
32484
11ae8e769921 apparent code for webkit transparency that might not be working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32482
diff changeset
354 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
355 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
356
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
357 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
358 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
359
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
360 pidgin_message_style_unref (style);
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
361 /* 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
362 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
363
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
364 g_free (basedir);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
365 g_free (baseuri);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
366 g_free (header);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
367 g_free (footer);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
368 g_free (template);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
369 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
370
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
371
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
372 /* 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
373 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
374 finalize_theme_for_webkit (PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
375 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
376 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
377 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
378
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
379 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
380
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
381 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
382 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
383 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
384
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
385 static void
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
386 webkit_on_webview_destroy (GtkObject *object, gpointer data)
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
387 {
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
388 pidgin_message_style_unref ((PidginMessageStyle*) data);
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
389 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
390 }
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
391
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
392 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
393 const char* name,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
394 char **pmessage,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
395 PurpleConversation *conv,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
396 PurpleMessageFlags flags,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
397 gpointer data)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
398 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
399 GtkWidget *webkit;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
400 char *message = *pmessage;
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
401 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
402 char *stripped;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
403 char *message_html;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
404 char *msg;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
405 char *escape;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
406 char *script;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
407 char *func = "appendMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
408 char *smileyed;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
409 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
410
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
411 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
412 PidginMessageStyle *style;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
413
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
414 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
415 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
416 stripped = g_strdup(message);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
417
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
418 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
419 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
420
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
421 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
422 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
423 func = "appendNextMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
424 } 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
425 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
426 } 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
427 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
428 func = "appendNextMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
429 } 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
430 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
431 } 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
432 message_html = style->status_html;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
433 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
434 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
435
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
436 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
437 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
438 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
439 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
440
32481
3f1ea49c8c2d just some debugging info.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32480
diff changeset
441 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
442 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
443
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
444 g_free(script);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
445 g_free(smileyed);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
446 g_free(msg);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
447 g_free(stripped);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
448 g_free(escape);
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
449
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
450 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
451 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
452
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
453 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
454 const char *who,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
455 char **message,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
456 PurpleConversation *conv,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
457 PurpleMessageFlags flags,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
458 gpointer userdata)
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
459 {
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
460 /* 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
461 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
462 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
463
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
464 static void
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
465 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
466 {
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
467 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
468 }
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
469
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
470 static void
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
471 webkit_on_conversation_switched (PurpleConversation *conv, gpointer data)
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
472 {
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
473 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
474 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
475
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
476 static void
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
477 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
478 {
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
479 /*
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
480 * 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
481 * this anyway.
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
482 */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
483 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
484
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
485 static GList*
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
486 get_dir_dir_list (const char* dirname)
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
487 {
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
488 GList *ret = NULL;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
489 GDir *dir = g_dir_open (dirname, 0, NULL);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
490 const char* subdir;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
491
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
492 if (!dir) return NULL;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
493 while ((subdir = g_dir_read_name (dir))) {
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
494 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
495 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
496
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
497 g_dir_close (dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
498 return ret;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
499 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
500
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
501 /**
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
502 * 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
503 * 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
504 * that they are in the directories for themes.
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
505 */
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
506 static GList*
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
507 get_style_directory_list ()
32464
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 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
510 GList *list1, *list2;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
511
32472
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
512 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
513
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
514 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
515 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
516
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
517 list1 = get_dir_dir_list (user_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
518 list2 = get_dir_dir_list (global_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
519
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
520 g_free (global_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
521 g_free (user_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
522 g_free (user_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
523
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
524 return g_list_concat (list1, list2);
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
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
527 /**
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
528 * use heuristics or previous user options to figure out what
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
529 * theme to use as default in this Pidgin instance.
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
530 */
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
531 static void
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
532 style_set_default ()
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
533 {
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
534 GList* styles = get_style_directory_list (), *iter;
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
535 const char *stylepath = purple_prefs_get_string ("/plugins/gtk/adiumthemes/stylepath");
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
536 g_assert (cur_style_dir == NULL);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
537
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
538 if (stylepath)
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
539 styles = g_list_prepend (styles, g_strdup (stylepath));
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
540
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
541 /* pick any one that works. Note that we have first preference
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
542 * for the one in the userdir */
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
543 for (iter = styles; iter; iter = g_list_next (iter)) {
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
544 PidginMessageStyle *style = pidgin_message_style_load (iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
545 if (style) {
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
546 cur_style_dir = (char*) g_strdup (iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
547 pidgin_message_style_unref (style);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
548 break;
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
549 }
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
550 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
551 }
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
552
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
553 for (iter = styles; iter; iter = g_list_next (iter))
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
554 g_free (iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
555 g_list_free (styles);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
556 }
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
557
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
558 static gboolean
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
559 plugin_load(PurplePlugin *plugin)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
560 {
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
561 style_set_default ();
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
562 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
563
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
564 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
565 "displaying-im-msg",
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
566 webkit_plugin_get_handle (),
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
567 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
568 NULL);
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
569
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
570 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
571 "displaying-chat-msg",
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
572 webkit_plugin_get_handle (),
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
573 PURPLE_CALLBACK(webkit_on_displaying_chat_msg),
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
574 NULL);
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
575
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
576 purple_signal_connect (pidgin_conversations_get_handle (),
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
577 "conversation-displayed",
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
578 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
579 PURPLE_CALLBACK(webkit_on_conversation_displayed),
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
580 NULL);
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
581
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
582 purple_signal_connect (pidgin_conversations_get_handle (),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
583 "conversation-switched",
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
584 webkit_plugin_get_handle (),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
585 PURPLE_CALLBACK(webkit_on_conversation_switched),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
586 NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
587
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
588 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
589 "conversation-hiding",
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
590 webkit_plugin_get_handle (),
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
591 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
592 NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
593
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
594 /* 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
595 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
596 GList* list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
597 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
598 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
599
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
600 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
601 return TRUE;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
602 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
603
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
604 static gboolean
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
605 plugin_unload(PurplePlugin *plugin)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
606 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
607 GList *list;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
608
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
609 webkit_plugin_free_handle ();
32469
ba275d3188c7 unset cur_style_dir when unloading.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32468
diff changeset
610 cur_style_dir = NULL;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
611 list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
612 while (list) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
613 finalize_theme_for_webkit(list->data);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
614 list = g_list_next(list);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
615 }
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
616
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
617 return TRUE;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
618 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
619
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
620 /*
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
621 * UI config code
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
622 */
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
623
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
624 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
625 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
626 {
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
627 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
628 GtkWidget *dialog;
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
629 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
630
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
631 /* 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
632 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
633 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
634 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
635 g_free (basename);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
636 break;
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
637 }
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
638 g_free (basename);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
639 }
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
640
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
641 g_assert (iter);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
642 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
643 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
644 cur_style_dir = g_strdup (iter->data);;
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
645
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
646 /* 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
647 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
648 g_assert (dialog);
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
649 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
650 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
651 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
652
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
653 static GtkWidget*
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
654 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
655 {
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
656 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
657 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
658 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
659
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
660 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
661 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
662
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
663 if (style) {
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
664 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
665 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
666 g_free (text);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
667
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
668 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
669 selected = index;
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
670 index++;
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
671 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
672 }
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
673 }
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
674 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
675 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
676 return combobox;
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
677 }
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
678
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
679 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
680 variant_update_conversation (PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
681 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
682 PidginConversation *gtkconv = PIDGIN_CONVERSATION (conv);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
683 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
684 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
685 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
686
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
687 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
688
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
689 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
690 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
691
32484
11ae8e769921 apparent code for webkit transparency that might not be working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32482
diff changeset
692 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
693 g_free (script);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
694 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
695
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
696 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
697 variant_changed (GtkWidget* combobox, gpointer null)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
698 {
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
699 char *name;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
700 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
701 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
702
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
703 g_assert (style);
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
704 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
705 pidgin_message_style_set_variant (style, name);
32488
17153501cae6 Fixing back variants.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32487
diff changeset
706 pidgin_message_style_save_state (style);
17153501cae6 Fixing back variants.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32487
diff changeset
707
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
708 /* update conversations */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
709 list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
710 while (list) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
711 variant_update_conversation (list->data);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
712 list = g_list_next(list);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
713 }
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
714
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
715 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
716 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
717 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
718
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
719 static GtkWidget *
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
720 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
721 {
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
722 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
723 GList *variants = pidgin_message_style_get_variants (style), *iter;
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
724 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
725 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
726 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
727
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 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
729
32477
f36b9ed704b1 Removed some unused code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32476
diff changeset
730 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
731 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
732
32480
5094cb6448af new changes seemingly working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32479
diff changeset
733 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
734 def = index;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
735 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
736
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
737 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
738
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
739 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
740 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
741
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
742 return combobox;
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
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
745 static void
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
746 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
747 {
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
748 /* 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
749 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
750 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
751 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
752 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
753 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
754
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
755 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
756 }
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
757
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
758 static GtkWidget*
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
759 get_config_frame(PurplePlugin* plugin)
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
760 {
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
761 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
762 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
763 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
764
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
765 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
766 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
767 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
768 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
769
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
770
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
771 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
772 /* 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
773 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
774
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
775 return table;
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
776 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
777
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
778 PidginPluginUiInfo ui_info =
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
779 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
780 get_config_frame,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
781 0, /* page_num (Reserved) */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
782
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
783 /* padding */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
784 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
785 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
786 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
787 NULL
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
788 };
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
789
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
790
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
791 static PurplePluginInfo info =
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
792 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
793 PURPLE_PLUGIN_MAGIC, /* Magic */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
794 PURPLE_MAJOR_VERSION, /* Purple Major Version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
795 PURPLE_MINOR_VERSION, /* Purple Minor Version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
796 PURPLE_PLUGIN_STANDARD, /* plugin type */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
797 PIDGIN_PLUGIN_TYPE, /* ui requirement */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
798 0, /* flags */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
799 NULL, /* dependencies */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
800 PURPLE_PRIORITY_DEFAULT, /* priority */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
801
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
802 PLUGIN_ID, /* plugin id */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
803 NULL, /* name */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
804 "0.1", /* version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
805 NULL, /* summary */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
806 NULL, /* description */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
807 PLUGIN_AUTHOR, /* author */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
808 "http://pidgin.im", /* website */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
809
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
810 plugin_load, /* load */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
811 plugin_unload, /* unload */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
812 NULL, /* destroy */
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 &ui_info, /* ui_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
815 NULL, /* extra_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
816 NULL, /* prefs_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
817 NULL, /* actions */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
818 NULL, /* reserved 1 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
819 NULL, /* reserved 2 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
820 NULL, /* reserved 3 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
821 NULL /* reserved 4 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
822 };
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
823
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
824 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
825 init_plugin(PurplePlugin *plugin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
826 info.name = "Adium IMs";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
827 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
828 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
829
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
830 purple_prefs_add_none ("/plugins");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
831 purple_prefs_add_none ("/plugins/gtk");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
832 purple_prefs_add_none ("/plugins/gtk/adiumthemes");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
833 purple_prefs_add_string ("/plugins/gtk/adiumthemes/csspath", "");
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
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
836 PURPLE_INIT_PLUGIN(webkit, init_plugin, info)

mercurial