pidgin/plugins/adiumthemes/webkit.c

Mon, 10 Aug 2009 07:33:21 +0000

author
Arnold Noronha <tdrhq@soc.pidgin.im>
date
Mon, 10 Aug 2009 07:33:21 +0000
branch
soc.2009.webkitmessageview
changeset 32460
5771be5530d8
parent 32459
04857274f841
child 32461
72fe247cc953
permissions
-rw-r--r--

safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.

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>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
41 #include <notify.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
42 #include <util.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
43 #include <version.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
44
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
45 /* Pidgin headers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
46 #include <gtkconv.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
47 #include <gtkplugin.h>
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
48 #include <gtkwebview.h>
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
49 #include <smileyparser.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
50
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
51
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
52 /* 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
53 #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
54
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
55 /*
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
56 * I'm going to allow a different style for each PidginConversation.
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
57 * This way I can do two things: 1) change the theme on the fly and not
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
58 * change existing themes, and 2) Use a different theme for IMs and
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
59 * chats.
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
60 */
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
61 typedef struct _PidginMessageStyle {
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
62 int ref_counter;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
63
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
64 /* paths */
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
65 char *style_dir;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
66 char *template_path;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
67 char *css_path;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
68
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
69 /* caches */
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
70 char *template_html;
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
71 char *header_html;
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
72 char *footer_html;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
73 char *incoming_content_html;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
74 char *outgoing_content_html;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
75 char *incoming_next_content_html;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
76 char *outgoing_next_content_html;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
77 char *status_html;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
78 char *basestyle_css;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
79 } PidginMessageStyle;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
80
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
81 static GList *style_list; /**< List of PidginMessageStyles */
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
82 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
83 static void *handle = NULL;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
84
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
85 static PidginMessageStyle* pidgin_message_style_new (const char* styledir)
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
86 {
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
87 PidginMessageStyle* ret = g_new0 (PidginMessageStyle, 1);
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
88 GList *iter;
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
89
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
90 /* sanity check */
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
91 for (iter = style_list; iter; iter = g_list_next (iter))
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
92 g_assert (!g_str_equal (((PidginMessageStyle*)iter->data)->style_dir, styledir));
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
93
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
94 ret->ref_counter = 1;
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
95 ret->style_dir = g_strdup (styledir);
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
96
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
97 style_list = g_list_append (style_list, ret);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
98 return ret;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
99 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
100
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
101 static void pidgin_message_style_unref (PidginMessageStyle *style)
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
102 {
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
103 if (!style) return;
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
104 g_assert (style->ref_counter > 0);
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
105
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
106 style->ref_counter--;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
107 if (style->ref_counter) return;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
108
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
109 g_free (style->style_dir);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
110 g_free (style->template_path);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
111 g_free (style->css_path);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
112
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
113 g_free (style->template_html);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
114 g_free (style->incoming_content_html);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
115 g_free (style->outgoing_content_html);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
116 g_free (style->outgoing_next_content_html);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
117 g_free (style->status_html);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
118 g_free (style->basestyle_css);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
119
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
120 style_list = g_list_remove (style_list, style);
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
121 g_free (style);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
122 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
123
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
124 static void variant_set_default (PidginMessageStyle* style);
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
125 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
126
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
127 static PidginMessageStyle*
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
128 pidgin_message_style_load (const char* styledir)
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
129 {
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
130 /* is this style already loaded? */
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
131 GList *cur = style_list;
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
132 char *file; /* temporary variable */
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
133 PidginMessageStyle *style = 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
134
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
135 g_assert (styledir);
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
136 for (cur = style_list; cur; cur = g_list_next (cur)) {
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
137 style = (PidginMessageStyle*) cur->data;
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
138 if (g_str_equal (styledir, style->style_dir)) {
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
139 style->ref_counter++;
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
140 return style;
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
141 }
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
142 }
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
143
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
144 /* else we need to load it */
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
145 style = pidgin_message_style_new (styledir);
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
146
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
147 /* load all other files */
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
148
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
149 /* The template path can either come from the theme, or can
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
150 * be stock Template.html that comes with the plugin */
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
151 style->template_path = g_build_filename(styledir, "Contents", "Resources", "Template.html", NULL);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
152
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
153 if (!g_file_test(style->template_path, G_FILE_TEST_EXISTS)) {
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
154 g_free (style->template_path);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
155 style->template_path = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
156 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
157
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
158 if (!g_file_get_contents(style->template_path, &style->template_html, NULL, 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
159 pidgin_message_style_unref (style);
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
160 return NULL;
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
161 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
162
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
163 file = g_build_filename(styledir, "Contents", "Resources", "Status.html", NULL);
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
164 if (!g_file_get_contents(file, &style->status_html, NULL, 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
165 pidgin_message_style_unref (style);
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
166 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
167 return NULL;
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
168 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
169 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
170
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
171 file = g_build_filename(styledir, "Contents", "Resources", "main.css", 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
172 g_file_get_contents(file, &style->basestyle_css, NULL, NULL);
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
173 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
174
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
175 file = g_build_filename(styledir, "Contents", "Resources", "Header.html", NULL);
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
176 g_file_get_contents(file, &style->header_html, NULL, NULL);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
177 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
178
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
179 file = g_build_filename(styledir, "Contents", "Resources", "Footer.html", NULL);
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
180 g_file_get_contents(file, &style->footer_html, NULL, NULL);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
181 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
182
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
183 file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "Content.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
184 if (!g_file_get_contents(file, &style->incoming_content_html, NULL, 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
185 pidgin_message_style_unref (style);
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
186 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
187 return NULL;
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
188 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
189 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
190
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
191
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
192 /* according to the spec, the following are optional files */
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
193 file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "NextContent.html", NULL);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
194 if (!g_file_get_contents(file, &style->incoming_next_content_html, NULL, NULL)) {
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
195 style->incoming_next_content_html = g_strdup (style->incoming_content_html);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
196 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
197 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
198
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
199 file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "Content.html", NULL);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
200 if (!g_file_get_contents(file, &style->outgoing_content_html, NULL, NULL)) {
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
201 style->outgoing_content_html = g_strdup(style->incoming_content_html);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
202 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
203 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
204
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
205 file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
206 if (!g_file_get_contents(file, &style->outgoing_next_content_html, NULL, 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
207 style->outgoing_next_content_html = g_strdup (style->outgoing_content_html);
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
208 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
209
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
210 /* find some variant file (or load from user's settings) */
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
211 variant_set_default (style);
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
212
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
213 return style;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
214 }
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
215
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
216
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
217 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
218 {
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
219 if (handle) return handle;
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
220 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
221 }
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
222
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
223 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
224 {
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
225 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
226 g_free (handle);
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
227 }
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
228
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
229 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
230 replace_message_tokens(
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
231 char *text,
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
232 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
233 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
234 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
235 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
236 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
237 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
238 time_t mtime)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
239 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
240 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
241 char *cur = text;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
242 char *prev = cur;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
243
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
244 while ((cur = strchr(cur, '%'))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
245 const char *replace = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
246 char *fin = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
247
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
248 if (!strncmp(cur, "%message%", strlen("%message%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
249 replace = message;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
250 } 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
251 replace = flags & PURPLE_MESSAGE_SEND ? "outgoing" :
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
252 flags & PURPLE_MESSAGE_RECV ? "incoming" : "event";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
253 } 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
254 char *format = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
255 if (*(cur + strlen("%time")) == '{') {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
256 char *start = cur + strlen("%time") + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
257 char *end = strstr(start, "}%");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
258 if (!end) /* Invalid string */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
259 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
260 format = g_strndup(start, end - start);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
261 fin = end + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
262 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
263 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
264 g_free(format);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
265 } 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
266 if (flags & PURPLE_MESSAGE_SEND) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
267 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
268 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
269 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
270 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
271 replace = purple_imgstore_get_filename(img);
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 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
274 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
275 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
276 } else if (flags & PURPLE_MESSAGE_RECV) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
277 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
278 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
279 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
280 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
281 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
282 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
283
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
284 } 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
285 replace = name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
286 } 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
287 replace = alias;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
288 } 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
289 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
290 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
291 cur++;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
292 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
293 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
294
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
295 /* 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
296 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
297 g_string_append(str, replace);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
298
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
299 /* And update the pointers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
300 if (fin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
301 prev = cur = fin + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
302 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
303 prev = cur = strchr(cur + 1, '%') + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
304 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
305
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
306 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
307
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
308 /* And wrap it up */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
309 g_string_append(str, prev);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
310 return g_string_free(str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
311 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
312
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
313 static char *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
314 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
315 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
316 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
317 char *cur = text;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
318 char *prev = cur;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
319
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
320 if (text == NULL)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
321 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
322
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
323 while ((cur = strchr(cur, '%'))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
324 const char *replace = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
325 char *fin = NULL;
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 if (!strncmp(cur, "%chatName%", strlen("%chatName%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
328 replace = conv->name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
329 } 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
330 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
331 if (replace == NULL)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
332 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
333 } 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
334 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
335 if (buddy) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
336 replace = purple_buddy_get_alias(buddy);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
337 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
338 replace = conv->name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
339 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
340 } 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
341 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
342 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
343 } 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
344 } 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
345 char *format = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
346 if (*(cur + strlen("%timeOpened")) == '{') {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
347 char *start = cur + strlen("%timeOpened") + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
348 char *end = strstr(start, "}%");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
349 if (!end) /* Invalid string */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
350 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
351 format = g_strndup(start, end - start);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
352 fin = end + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
353 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
354 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
355 g_free(format);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
356 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
357 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
358 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
359
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
360 /* 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
361 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
362 g_string_append(str, replace);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
363
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
364 /* And update the pointers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
365 if (fin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
366 prev = cur = fin + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
367 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
368 prev = cur = strchr(cur + 1, '%') + 1;
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 /* And wrap it up */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
373 g_string_append(str, prev);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
374 return g_string_free(str, FALSE);
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
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
377 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
378 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
379 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
380
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
381 char **ms = g_strsplit(text, "%@", 6);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
382 char *base = NULL;
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 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
385 g_strfreev(ms);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
386 g_string_free(str, TRUE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
387 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
388 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
389
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
390 g_string_append(str, ms[0]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
391 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
392 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
393 g_string_append(str, base);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
394 g_free (base);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
395
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
396 g_string_append(str, ms[1]);
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
397 if (style->basestyle_css)
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
398 g_string_append(str, style->basestyle_css);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
399 g_string_append(str, ms[2]);
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
400 if (style->css_path) {
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
401 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
402 g_string_append(str, style->css_path);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
403 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
404
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
405 g_string_append(str, ms[3]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
406 if (header)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
407 g_string_append(str, header);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
408 g_string_append(str, ms[4]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
409 if (footer)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
410 g_string_append(str, footer);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
411 g_string_append(str, ms[5]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
412
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
413 g_strfreev(ms);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
414 return g_string_free (str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
415 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
416
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
417 static GtkWidget *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
418 get_webkit(PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
419 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
420 PidginConversation *gtkconv;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
421 gtkconv = PIDGIN_CONVERSATION(conv);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
422 if (!gtkconv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
423 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
424 else
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
425 return gtkconv->webview;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
426 }
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
427
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
428 /**
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
429 * Called when either a new PurpleConversation is created
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
430 * 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
431 * 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
432 * (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
433 * PurpleConversation gets added.
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
434 *
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
435 * 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
436 * Adium themes handle the case when the PurpleConversation
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
437 * changes.
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
438 */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
439 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
440 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
441 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
442 GtkWidget *webkit = PIDGIN_CONVERSATION(conv)->webview;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
443 char *header, *footer;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
444 char *template;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
445
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
446 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
447 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
448 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
449 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
450
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
451 if (oldStyle) return;
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
452
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
453 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
454 g_assert (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
455
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
456 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
457 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
458 header = replace_header_tokens(style->header_html, strlen(style->header_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
459 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
460 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
461
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
462 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
463
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
464 g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, 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
465
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
466 /* I need to unref this style when the webkit object destroys */
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
467 g_signal_connect (G_OBJECT(webkit), "destroy", G_CALLBACK(webkit_on_webview_destroy), style);
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
468
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
469 g_free (basedir);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
470 g_free (baseuri);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
471 g_free (header);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
472 g_free (footer);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
473 g_free (template);
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
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
477 /* 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
478 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
479 finalize_theme_for_webkit (PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
480 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
481 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
482 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
483
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
484 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
485
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
486 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
487 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
488 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
489
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
490 static void
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
491 webkit_on_webview_destroy (GtkObject *object, gpointer data)
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
492 {
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
493 pidgin_message_style_unref ((PidginMessageStyle*) data);
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
494 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
495 }
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
496
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
497 struct webkit_script {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
498 GtkWidget *webkit;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
499 char *script;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
500 };
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
501
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
502 static gboolean purple_webkit_execute_script(gpointer _script)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
503 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
504 struct webkit_script *script = (struct webkit_script*) _script;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
505 printf ("%s\n", script->script);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
506 webkit_web_view_execute_script(WEBKIT_WEB_VIEW(script->webkit), script->script);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
507 g_free(script->script);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
508 g_free(script);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
509 return FALSE;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
510 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
511
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
512
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
513 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
514 const char* name,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
515 char **pmessage,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
516 PurpleConversation *conv,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
517 PurpleMessageFlags flags,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
518 gpointer data)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
519 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
520 GtkWidget *webkit;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
521 char *message = *pmessage;
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
522 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
523 char *stripped;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
524 char *message_html;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
525 char *msg;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
526 char *escape;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
527 char *script;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
528 char *func = "appendMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
529 char *smileyed;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
530 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
531
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
532 struct webkit_script *wk_script;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
533 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
534 PidginMessageStyle *style;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
535
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
536 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
537 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
538 stripped = g_strdup(message);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
539
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
540 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
541 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
542
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
543 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
544 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
545 func = "appendNextMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
546 } 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
547 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
548 } 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
549 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
550 func = "appendNextMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
551 } 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
552 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
553 } 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
554 message_html = style->status_html;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
555 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
556 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
557
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
558 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
559 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
560 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
561 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
562
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
563 wk_script = g_new0(struct webkit_script, 1);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
564 wk_script->script = script;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
565 wk_script->webkit = webkit;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
566
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32459
diff changeset
567 g_idle_add (purple_webkit_execute_script, wk_script);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
568
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
569 g_free(smileyed);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
570 g_free(msg);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
571 g_free(stripped);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
572 g_free(escape);
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
573
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
574 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
575 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
576
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
577 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
578 const char *who,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
579 char **message,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
580 PurpleConversation *conv,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
581 PurpleMessageFlags flags,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
582 gpointer userdata)
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
583 {
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
584 /* 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
585 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
586 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
587
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
588 static void
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
589 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
590 {
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
591 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
592 }
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
593
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
594 static void
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
595 webkit_on_conversation_switched (PurpleConversation *conv, gpointer data)
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
596 {
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
597 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
598 }
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 static void
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
601 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
602 {
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
603 /*
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
604 * I'm not sure if I need to do anything here, but let's keep
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
605 * this anyway. (FIXME: have to catch a signal on the WebView
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
606 * when the WebView closes.)
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
607 */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
608 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
609
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
610 /**
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
611 * Get each of the files corresponding to each variant.
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
612 */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
613 static GList*
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
614 get_theme_files(PidginMessageStyle *style)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
615 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
616 GList *ret = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
617 GDir *variants;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
618 const char *css_file;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
619 char *css;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
620 char *variant_dir;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
621
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
622 g_assert (style->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
623 variant_dir = g_build_filename(style->style_dir, "Contents", "Resources", "Variants", NULL);
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
624
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
625 variants = g_dir_open(variant_dir, 0, NULL);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
626 if (!variants) return NULL;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
627
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
628 while ((css_file = g_dir_read_name(variants)) != NULL) {
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
629 if (!g_str_has_suffix (css_file, ".css"))
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
630 continue;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
631
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
632 css = g_build_filename(variant_dir, css_file, NULL);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
633 ret = g_list_append(ret, css);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
634 }
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
635
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
636 g_dir_close(variants);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
637 g_free(variant_dir);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
638
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
639 ret = g_list_sort (ret, (GCompareFunc)g_strcmp0);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
640 return ret;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
641 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
642
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
643 static void
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
644 variant_set_default (PidginMessageStyle* style)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
645 {
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
646 GList *all, *iter;
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
647 const char *css_path = purple_prefs_get_string ("/plugins/gtk/adiumthemes/csspath");
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
648
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
649 g_free (style->css_path);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
650 if (g_str_has_prefix (css_path, style->style_dir) &&
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
651 g_file_test (css_path, G_FILE_TEST_EXISTS)) {
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
652 style->css_path = g_strdup (css_path);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
653 return;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
654 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
655 else {
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
656 /* something about the theme has changed */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
657 css_path = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
658 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
659
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
660 all = get_theme_files (style);
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
661
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
662 if (all) {
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
663 style->css_path = g_strdup (all->data);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
664 purple_prefs_set_string ("/plugins/gtk/adiumthemes/csspath", css_path);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
665 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
666
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
667 for (iter = all; iter; iter = g_list_next (iter))
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
668 g_free (iter->data);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
669
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
670 g_list_free (all);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
671 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
672
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
673 static gboolean
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
674 plugin_load(PurplePlugin *plugin)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
675 {
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
676 PidginMessageStyle *_style; /* temp */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
677
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
678 if (g_path_is_absolute (purple_user_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
679 cur_style_dir = g_build_filename(purple_user_dir(), "style", NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
680 else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
681 char* cur = g_get_current_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
682 cur_style_dir = g_build_filename (cur, purple_user_dir(), "style", NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
683 g_free (cur);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
684 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
685
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
686
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
687 _style = pidgin_message_style_load (cur_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
688 if (!_style) {
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
689 g_free (cur_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
690 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
691 return FALSE;
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
692 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
693
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
694 pidgin_message_style_unref (_style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
695
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
696 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
697 "displaying-im-msg",
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
698 webkit_plugin_get_handle (),
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
699 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
700 NULL);
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
701
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
702 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
703 "displaying-chat-msg",
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
704 webkit_plugin_get_handle (),
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
705 PURPLE_CALLBACK(webkit_on_displaying_chat_msg),
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
706 NULL);
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
707
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
708 purple_signal_connect (pidgin_conversations_get_handle (),
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
709 "conversation-displayed",
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
710 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
711 PURPLE_CALLBACK(webkit_on_conversation_displayed),
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
712 NULL);
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
713
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
714 purple_signal_connect (pidgin_conversations_get_handle (),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
715 "conversation-switched",
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
716 webkit_plugin_get_handle (),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
717 PURPLE_CALLBACK(webkit_on_conversation_switched),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
718 NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
719
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
720 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
721 "conversation-hiding",
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
722 webkit_plugin_get_handle (),
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
723 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
724 NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
725
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
726 /* 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
727 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
728 GList* list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
729 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
730 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
731
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
732 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
733 return TRUE;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
734 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
735
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
736 static gboolean
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
737 plugin_unload(PurplePlugin *plugin)
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 GList *list;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
740
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
741 webkit_plugin_free_handle ();
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
742
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
743 list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
744 while (list) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
745 finalize_theme_for_webkit(list->data);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
746 list = g_list_next(list);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
747 }
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
748
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
749 return TRUE;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
750 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
751
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
752
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
753 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
754 variant_update_conversation (PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
755 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
756 PidginConversation *gtkconv = PIDGIN_CONVERSATION (conv);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
757 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
758 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
759 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
760
32457
834c570bfc40 more changes, but I still can't find the stupid bug. Valgrind gives me some information
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32456
diff changeset
761 g_assert (style && style->css_path);
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
762
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
763 script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
764 webkit_web_view_execute_script (webview, script);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
765 g_free (script);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
766 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
767
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
768 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
769 variant_changed (GtkWidget* combobox, gpointer null)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
770 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
771 char *name, *name_with_ext;
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
772 char *css_path;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
773 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
774 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
775
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
776 g_assert (style);
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
777
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
778 /* it is possible that the theme changed by this point, so we check
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
779 * that first */
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
780
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
781 name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox));
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
782 name_with_ext = g_strdup_printf ("%s.css", name);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
783 g_free (name);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
784
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
785 css_path = g_build_filename (style->style_dir, "Contents", "Resources", "Variants", name_with_ext, 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
786
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
787 if (!g_file_test (css_path, G_FILE_TEST_EXISTS)) {
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
788 goto cleanup;
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
789 }
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
790
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
791 g_free (style->css_path);
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
792 style->css_path = g_strdup (css_path);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
793 purple_prefs_set_string ("/plugins/gtk/adiumthemes/csspath", css_path);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
794
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
795 /* update each conversation */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
796 list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
797 while (list) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
798 variant_update_conversation (list->data);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
799 list = g_list_next(list);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
800 }
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
801
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
802 cleanup:
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
803 g_free (css_path);
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
804 g_free (name_with_ext);
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
805 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
806 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
807
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
808 static GtkWidget *
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
809 get_config_frame(PurplePlugin *plugin)
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
810 {
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
811 PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
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
812 GList *variants = get_theme_files(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
813 GList *iter = variants;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
814 char *curdir = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
815 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
816 int def = -1, index = 0;
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
817 char* css_path = g_strdup (style->css_path);
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
818
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
819 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
820
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
821 for (; iter; iter = g_list_next (iter)) {
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
822 char *basename = g_path_get_basename(iter->data);
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
823 char *dirname = g_path_get_dirname(iter->data);
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
824 if (!curdir || !g_str_equal (curdir, dirname)) {
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
825 char *plist, *plist_xml;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
826 gsize plist_len;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
827 xmlnode *node;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
828 g_free(curdir);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
829 curdir = strdup(dirname);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
830 plist = g_build_filename(curdir, "..", "..", "Info.plist", NULL);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
831 if (!g_file_get_contents(plist, &plist_xml, &plist_len, NULL)) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
832 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
833 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
834 node = xmlnode_from_str(plist_xml, plist_len);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
835 if (!node) continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
836 node = xmlnode_get_child(node, "dict");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
837 if (!node) continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
838 node = xmlnode_get_child(node, "key");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
839 while (node && strcmp(xmlnode_get_data(node), "CFBundleName")) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
840 node = xmlnode_get_next_twin(node);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
841 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
842 if (!node) continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
843 node = node->next;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
844 while (node && node->type != XMLNODE_TYPE_TAG) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
845 node = node->next;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
846 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
847
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
848 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
849
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
850 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
851 char *temp = g_strndup (basename, strlen(basename)-4);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
852 gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), temp);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
853 g_free (temp);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
854 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
855 if (g_str_has_suffix (css_path, basename))
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
856 def = index;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
857 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
858
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
859 g_free (basename);
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
860 g_free (dirname);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
861 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
862
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
863 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
864 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
865
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
866 g_free (css_path);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
867 return combobox;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
868 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
869
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
870 PidginPluginUiInfo ui_info =
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
871 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
872 get_config_frame,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
873 0, /* page_num (Reserved) */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
874
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
875 /* padding */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
876 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
877 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
878 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
879 NULL
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
880 };
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
881
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
882
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
883 static PurplePluginInfo info =
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
884 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
885 PURPLE_PLUGIN_MAGIC, /* Magic */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
886 PURPLE_MAJOR_VERSION, /* Purple Major Version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
887 PURPLE_MINOR_VERSION, /* Purple Minor Version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
888 PURPLE_PLUGIN_STANDARD, /* plugin type */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
889 PIDGIN_PLUGIN_TYPE, /* ui requirement */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
890 0, /* flags */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
891 NULL, /* dependencies */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
892 PURPLE_PRIORITY_DEFAULT, /* priority */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
893
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
894 PLUGIN_ID, /* plugin id */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
895 NULL, /* name */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
896 "0.1", /* version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
897 NULL, /* summary */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
898 NULL, /* description */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
899 PLUGIN_AUTHOR, /* author */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
900 "http://pidgin.im", /* website */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
901
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
902 plugin_load, /* load */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
903 plugin_unload, /* unload */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
904 NULL, /* destroy */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
905
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
906 &ui_info, /* ui_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
907 NULL, /* extra_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
908 NULL, /* prefs_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
909 NULL, /* actions */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
910 NULL, /* reserved 1 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
911 NULL, /* reserved 2 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
912 NULL, /* reserved 3 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
913 NULL /* reserved 4 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
914 };
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
915
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
916 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
917 init_plugin(PurplePlugin *plugin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
918 info.name = "Adium IMs";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
919 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
920 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
921
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
922 purple_prefs_add_none ("/plugins");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
923 purple_prefs_add_none ("/plugins/gtk");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
924 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
925 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
926 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
927
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
928 PURPLE_INIT_PLUGIN(webkit, init_plugin, info)

mercurial