pidgin/plugins/adiumthemes/webkit.c

Tue, 11 Aug 2009 00:09:01 +0000

author
Arnold Noronha <tdrhq@soc.pidgin.im>
date
Tue, 11 Aug 2009 00:09:01 +0000
branch
soc.2009.webkitmessageview
changeset 32477
f36b9ed704b1
parent 32476
03712ece5275
child 32478
399d9ea27454
permissions
-rw-r--r--

Removed some unused code.

32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1 /*
32453
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
2 * Adium Message Styles
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
3 * Copyright (C) 2009 Arnold Noronha <arnstein87@gmail.com>
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2007
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
5 *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
9 * License, or (at your option) any later version.
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
10 *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
14 * General Public License for more details.
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
15 *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
19 * 02111-1307, USA.
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
20 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
21
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
22 #define PLUGIN_ID "gtk-webview-adium-ims"
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
23 #define PLUGIN_NAME "webview-adium-ims"
32453
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
24
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
25 /*
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
26 * A lot of this was originally written by Sean Egan, but I think I've
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
27 * rewrote enough to replace the author for now.
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
28 */
12b7ca7ec8fa Changed the Author added copyright, etc.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32452
diff changeset
29 #define PLUGIN_AUTHOR "Arnold Noronha <arnstein87@gmail.com>"
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
30 #define PURPLE_PLUGINS "Hell yeah"
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
31
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
32 /* System headers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
33 #include <string.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
34 #include <gdk/gdk.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
35 #include <gtk/gtk.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
36
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
37 #include <webkit/webkit.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
38
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
39 /* Purple headers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
40 #include <conversation.h>
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
41 #include <debug.h>
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
42 #include <notify.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
43 #include <util.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
44 #include <version.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
45
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
46 /* Pidgin headers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
47 #include <gtkconv.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
48 #include <gtkplugin.h>
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
49 #include <gtkwebview.h>
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
50 #include <smileyparser.h>
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
51
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
52
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 /* 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
54 #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
55
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
56 /*
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
57 * I'm going to allow a different style for each PidginConversation.
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
58 * 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
59 * 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
60 * chats.
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
61 */
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
62 typedef struct _PidginMessageStyle {
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
63 int ref_counter;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
64
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
65 /* paths */
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
66 char *style_dir;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
67 char *template_path;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
68 char *css_path;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
69
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
70 /* caches */
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
71 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
72 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
73 char *footer_html;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
74 char *incoming_content_html;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
75 char *outgoing_content_html;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
76 char *incoming_next_content_html;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
77 char *outgoing_next_content_html;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
78 char *status_html;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
79 char *basestyle_css;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
80 } PidginMessageStyle;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
81
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
82 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
83 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
84 static void *handle = NULL;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
85
32472
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
86 static inline char* get_absolute_path (const char *path)
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
87 {
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
88 if (g_path_is_absolute (path)) return g_strdup (path);
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
89 else {
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
90 char* cwd = g_get_current_dir (), *ret;
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
91 ret = g_build_filename (cwd, path, NULL);
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
92 g_free (cwd);
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
93 return ret;
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
94 }
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
95 }
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
96
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
97 static PidginMessageStyle* pidgin_message_style_new (const char* styledir)
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
98 {
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
99 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
100 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
101
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
102 /* 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
103 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
104 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
105
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
106 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
107 ret->style_dir = g_strdup (styledir);
32454
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 style_list = g_list_append (style_list, ret);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
110 return ret;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
111 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
112
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
113 static void pidgin_message_style_unref (PidginMessageStyle *style)
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
114 {
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
115 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
116 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
117
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
118 style->ref_counter--;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
119 if (style->ref_counter) return;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
120
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
121 g_free (style->style_dir);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
122 g_free (style->template_path);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
123 g_free (style->css_path);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
124
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
125 g_free (style->template_html);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
126 g_free (style->incoming_content_html);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
127 g_free (style->outgoing_content_html);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
128 g_free (style->outgoing_next_content_html);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
129 g_free (style->status_html);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
130 g_free (style->basestyle_css);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
131
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
132 style_list = g_list_remove (style_list, style);
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
133 g_free (style);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
134 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
135
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
136 static void variant_set_default (PidginMessageStyle* style);
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
137 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
138
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
139 static PidginMessageStyle*
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
140 pidgin_message_style_load (const char* styledir)
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
141 {
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
142 /* is this style already loaded? */
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
143 GList *cur = style_list;
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
144 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
145 PidginMessageStyle *style = NULL;
32470
00b22ce81ec1 Debugging info to find bad themes.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32469
diff changeset
146
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
147 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
148 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
149 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
150 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
151 style->ref_counter++;
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
152 return style;
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
153 }
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
154 }
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
155
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
156 /* 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
157 style = pidgin_message_style_new (styledir);
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
158
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
159 /* load all other files */
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
160
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
161 /* 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
162 * 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
163 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
164
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
165 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
166 g_free (style->template_path);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
167 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
168 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
169
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
170 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
171 pidgin_message_style_unref (style);
32470
00b22ce81ec1 Debugging info to find bad themes.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32469
diff changeset
172 purple_debug_error ("webkit", "Could not locate a Template.html\n");
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
173 return NULL;
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
174 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
175
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
176 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
177 if (!g_file_get_contents(file, &style->status_html, NULL, NULL)) {
32470
00b22ce81ec1 Debugging info to find bad themes.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32469
diff changeset
178 purple_debug_info ("webkit", "%s could not find Resources/Status.html", styledir);
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 pidgin_message_style_unref (style);
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
180 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
181 return NULL;
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
182 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
183 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
184
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
185 file = g_build_filename(styledir, "Contents", "Resources", "main.css", NULL);
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
186 if (!g_file_get_contents(file, &style->basestyle_css, NULL, NULL))
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
187 style->basestyle_css = g_strdup ("");
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
188 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
189
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
190 file = g_build_filename(styledir, "Contents", "Resources", "Header.html", NULL);
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
191 if (!g_file_get_contents(file, &style->header_html, NULL, NULL))
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
192 style->header_html = g_strdup ("");
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
193 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
194
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
195 file = g_build_filename(styledir, "Contents", "Resources", "Footer.html", NULL);
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
196 if (!g_file_get_contents(file, &style->footer_html, NULL, NULL))
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
197 style->footer_html = g_strdup ("");
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
198 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
199
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
200 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
201 if (!g_file_get_contents(file, &style->incoming_content_html, NULL, NULL)) {
32470
00b22ce81ec1 Debugging info to find bad themes.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32469
diff changeset
202 purple_debug_info ("webkit", "%s did not have a Incoming/Content.html\n", styledir);
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
203 pidgin_message_style_unref (style);
32455
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
204 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
205 return NULL;
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
206 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
207 g_free (file);
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 /* 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
211 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
212 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
213 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
214 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
215 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
216
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
217 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
218 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
219 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
220 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
221 g_free (file);
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
222
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
223 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
224 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
225 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
226 }
f90986bb3388 Another temporary commit that will not compile.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32454
diff changeset
227
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
228 /* 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
229 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
230
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
231 return style;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
232 }
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
233
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
234
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
235 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
236 {
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
237 if (handle) return handle;
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
238 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
239 }
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
240
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
241 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
242 {
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
243 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
244 g_free (handle);
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
245 }
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
246
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 time_t mtime)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
257 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
258 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
259 char *cur = text;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
260 char *prev = cur;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
261
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
262 while ((cur = strchr(cur, '%'))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
263 const char *replace = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
264 char *fin = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
265
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
266 if (!strncmp(cur, "%message%", strlen("%message%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
267 replace = message;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
268 } 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
269 replace = flags & PURPLE_MESSAGE_SEND ? "outgoing" :
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
270 flags & PURPLE_MESSAGE_RECV ? "incoming" : "event";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
271 } 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
272 char *format = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
273 if (*(cur + strlen("%time")) == '{') {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
274 char *start = cur + strlen("%time") + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
275 char *end = strstr(start, "}%");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
276 if (!end) /* Invalid string */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
277 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
278 format = g_strndup(start, end - start);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
279 fin = end + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
280 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
281 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
282 g_free(format);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
283 } 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
284 if (flags & PURPLE_MESSAGE_SEND) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
285 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
286 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
287 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
288 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
289 replace = purple_imgstore_get_filename(img);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
290 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
291 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
292 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
293 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
294 } else if (flags & PURPLE_MESSAGE_RECV) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
295 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
296 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
297 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
298 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
299 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
300 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
301
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
302 } 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
303 replace = name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
304 } 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
305 replace = alias;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
306 } 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
307 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
308 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
309 cur++;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
310 continue;
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 /* 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
314 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
315 g_string_append(str, replace);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
316
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
317 /* And update the pointers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
318 if (fin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
319 prev = cur = fin + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
320 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
321 prev = cur = strchr(cur + 1, '%') + 1;
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
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
324 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
325
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
326 /* And wrap it up */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
327 g_string_append(str, prev);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
328 return g_string_free(str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
329 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
330
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
331 static char *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
332 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
333 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
334 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
335 char *cur = text;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
336 char *prev = cur;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
337
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
338 if (text == NULL)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
339 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
340
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
341 while ((cur = strchr(cur, '%'))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
342 const char *replace = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
343 char *fin = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
344
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
345 if (!strncmp(cur, "%chatName%", strlen("%chatName%"))) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
346 replace = conv->name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
347 } 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
348 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
349 if (replace == NULL)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
350 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
351 } 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
352 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
353 if (buddy) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
354 replace = purple_buddy_get_alias(buddy);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
355 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
356 replace = conv->name;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
357 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
358 } 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
359 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
360 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
361 } 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
362 } 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
363 char *format = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
364 if (*(cur + strlen("%timeOpened")) == '{') {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
365 char *start = cur + strlen("%timeOpened") + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
366 char *end = strstr(start, "}%");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
367 if (!end) /* Invalid string */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
368 continue;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
369 format = g_strndup(start, end - start);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
370 fin = end + 1;
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 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
373 g_free(format);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
374 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
375 continue;
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
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
378 /* 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
379 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
380 g_string_append(str, replace);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
381
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
382 /* And update the pointers */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
383 if (fin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
384 prev = cur = fin + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
385 } else {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
386 prev = cur = strchr(cur + 1, '%') + 1;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
387 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
388 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
389
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
390 /* And wrap it up */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
391 g_string_append(str, prev);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
392 return g_string_free(str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
393 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
394
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
395 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
396 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
397 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
398
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
399 char **ms = g_strsplit(text, "%@", 6);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
400 char *base = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
401
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
402 if (ms[0] == NULL || ms[1] == NULL || ms[2] == NULL || ms[3] == NULL || ms[4] == NULL || ms[5] == NULL) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
403 g_strfreev(ms);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
404 g_string_free(str, TRUE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
405 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
406 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
407
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
408 g_string_append(str, ms[0]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
409 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
410 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
411 g_string_append(str, base);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
412 g_free (base);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
413
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
414 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
415 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
416 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
417 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
418 if (style->css_path) {
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
419 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
420 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
421 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
422
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
423 g_string_append(str, ms[3]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
424 if (header)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
425 g_string_append(str, header);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
426 g_string_append(str, ms[4]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
427 if (footer)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
428 g_string_append(str, footer);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
429 g_string_append(str, ms[5]);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
430
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
431 g_strfreev(ms);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
432 return g_string_free (str, FALSE);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
433 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
434
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
435 static GtkWidget *
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
436 get_webkit(PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
437 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
438 PidginConversation *gtkconv;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
439 gtkconv = PIDGIN_CONVERSATION(conv);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
440 if (!gtkconv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
441 return NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
442 else
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
443 return gtkconv->webview;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
444 }
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
445
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
446 /**
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
447 * Called when either a new PurpleConversation is created
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
448 * 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
449 * 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
450 * (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
451 * PurpleConversation gets added.
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
452 *
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
453 * 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
454 * Adium themes handle the case when the PurpleConversation
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
455 * changes.
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
456 */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
457 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
458 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
459 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
460 GtkWidget *webkit = PIDGIN_CONVERSATION(conv)->webview;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
461 char *header, *footer;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
462 char *template;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
463
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
464 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
465 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
466 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
467 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
468
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
469 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
470
32470
00b22ce81ec1 Debugging info to find bad themes.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32469
diff changeset
471 purple_debug_info ("webkit", "loading %s\n", style_dir);
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
472 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
473 g_assert (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
474
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
475 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
476 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
477 header = replace_header_tokens(style->header_html, strlen(style->header_html), conv);
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
478 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
479 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
480 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
481
32471
1eae26422963 small assertion code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32470
diff changeset
482 g_assert(template);
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
483 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
484
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 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
486
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
487 /* 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
488 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
489
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
490 g_free (basedir);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
491 g_free (baseuri);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
492 g_free (header);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
493 g_free (footer);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
494 g_free (template);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
495 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
496
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
497
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
498 /* 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
499 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
500 finalize_theme_for_webkit (PurpleConversation *conv)
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 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
503 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
504
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
505 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
506
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
507 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
508 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
509 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
510
32459
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
511 static void
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
512 webkit_on_webview_destroy (GtkObject *object, gpointer data)
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
513 {
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
514 pidgin_message_style_unref ((PidginMessageStyle*) data);
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
515 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
516 }
04857274f841 Cleanly handle webkit destroy events.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32458
diff changeset
517
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
518 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
519 const char* name,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
520 char **pmessage,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
521 PurpleConversation *conv,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
522 PurpleMessageFlags flags,
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
523 gpointer data)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
524 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
525 GtkWidget *webkit;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
526 char *message = *pmessage;
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
527 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
528 char *stripped;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
529 char *message_html;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
530 char *msg;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
531 char *escape;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
532 char *script;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
533 char *func = "appendMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
534 char *smileyed;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
535 time_t mtime = time (NULL); /* FIXME: this should come from the write_conv calback, but the signal doesn't pass this to me */
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
536
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
537 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
538 PidginMessageStyle *style;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
539
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
540 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
541 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
542 stripped = g_strdup(message);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
543
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
544 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
545 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
546
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
547 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
548 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
549 func = "appendNextMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
550 } 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
551 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
552 } 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
553 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
554 func = "appendNextMessage";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
555 } 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
556 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
557 } 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
558 message_html = style->status_html;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
559 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
560 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
561
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
562 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
563 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
564 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
565 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
566
32461
72fe247cc953 Yep, tested, and changed some code from previous commit. This is a hard
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32460
diff changeset
567 gtk_webview_safe_execute_script (GTK_WEBVIEW (webkit), script);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
568
32461
72fe247cc953 Yep, tested, and changed some code from previous commit. This is a hard
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32460
diff changeset
569 g_free(script);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
570 g_free(smileyed);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
571 g_free(msg);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
572 g_free(stripped);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
573 g_free(escape);
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
574
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
575 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
576 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
577
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
578 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
579 const char *who,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
580 char **message,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
581 PurpleConversation *conv,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
582 PurpleMessageFlags flags,
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
583 gpointer userdata)
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
584 {
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
585 /* 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
586 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
587 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
588
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
589 static void
32458
184f94216441 woo, fixed the bug. Now things are looking wonderfully stable.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32457
diff changeset
590 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
591 {
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
592 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
593 }
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
594
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
595 static void
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
596 webkit_on_conversation_switched (PurpleConversation *conv, gpointer data)
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
597 {
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
598 init_theme_for_webkit (conv, cur_style_dir);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
599 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
600
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
601 static void
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
602 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
603 {
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
604 /*
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
605 * I'm not sure if I need to do anything here, but let's keep
32465
6086db3c6e64 removed the fixme.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32464
diff changeset
606 * this anyway.
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
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
610 static GList*
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
611 get_dir_dir_list (const char* dirname)
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
612 {
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
613 GList *ret = NULL;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
614 GDir *dir = g_dir_open (dirname, 0, NULL);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
615 const char* subdir;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
616
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
617 if (!dir) return NULL;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
618 while ((subdir = g_dir_read_name (dir))) {
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
619 ret = g_list_append (ret, g_build_filename (dirname, subdir, NULL));
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
620 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
621
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
622 g_dir_close (dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
623 return ret;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
624 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
625
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
626 /**
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
627 * Get me a list of all the available themes specified by their
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
628 * directories. I don't guarrantee that these are valid themes, just
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
629 * that they are in the directories for themes.
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
630 */
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
631 static GList*
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
632 get_style_directory_list ()
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
633 {
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
634 char *user_dir, *user_style_dir, *global_style_dir;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
635 GList *list1, *list2;
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
636
32472
a8b826d5aa0b make a get_absolute_path function.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32471
diff changeset
637 user_dir = get_absolute_path (purple_user_dir ());
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
638
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
639 user_style_dir = g_build_filename (user_dir, "styles", NULL);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
640 global_style_dir = g_build_filename (DATADIR, "pidgin", "styles", NULL);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
641
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
642 list1 = get_dir_dir_list (user_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
643 list2 = get_dir_dir_list (global_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
644
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
645 g_free (global_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
646 g_free (user_style_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
647 g_free (user_dir);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
648
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
649 return g_list_concat (list1, list2);
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
650 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
651
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
652 /**
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
653 * use heuristics or previous user options to figure out what
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
654 * theme to use as default in this Pidgin instance.
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
655 */
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
656 static void
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
657 style_set_default ()
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
658 {
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
659 GList* styles = get_style_directory_list (), *iter;
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
660 const char *stylepath = purple_prefs_get_string ("/plugins/gtk/adiumthemes/stylepath");
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
661 g_assert (cur_style_dir == NULL);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
662
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
663 if (stylepath)
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
664 styles = g_list_prepend (styles, g_strdup (stylepath));
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
665
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
666 /* pick any one that works. Note that we have first preference
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
667 * for the one in the userdir */
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
668 for (iter = styles; iter; iter = g_list_next (iter)) {
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
669 PidginMessageStyle *style = pidgin_message_style_load (iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
670 if (style) {
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
671 cur_style_dir = (char*) g_strdup (iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
672 pidgin_message_style_unref (style);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
673 break;
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
674 }
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
675 purple_debug_info ("webkit", "Style %s is invalid\n", (char*) iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
676 }
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
677
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
678 for (iter = styles; iter; iter = g_list_next (iter))
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
679 g_free (iter->data);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
680 g_list_free (styles);
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
681 }
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
682
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
683 /**
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
684 * Get each of the files corresponding to each variant.
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
685 */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
686 static GList*
32463
235fc4971d5e get_theme_files --> get_variant_files.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32461
diff changeset
687 get_variant_files(PidginMessageStyle *style)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
688 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
689 GList *ret = NULL;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
690 GDir *variants;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
691 const char *css_file;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
692 char *css;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
693 char *variant_dir;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
694
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
695 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
696 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
697
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
698 variants = g_dir_open(variant_dir, 0, NULL);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
699 if (!variants) return NULL;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
700
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
701 while ((css_file = g_dir_read_name(variants)) != NULL) {
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
702 if (!g_str_has_suffix (css_file, ".css"))
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
703 continue;
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
704
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
705 css = g_build_filename(variant_dir, css_file, NULL);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
706 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
707 }
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
708
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
709 g_dir_close(variants);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
710 g_free(variant_dir);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
711
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
712 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
713 return ret;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
714 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
715
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
716 static void
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
717 variant_set_default (PidginMessageStyle* style)
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
718 {
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
719 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
720 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
721
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
722 g_free (style->css_path);
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
723 if (css_path && g_str_has_prefix (css_path, style->style_dir) &&
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
724 g_file_test (css_path, G_FILE_TEST_EXISTS)) {
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
725 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
726 return;
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
727 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
728 else {
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
729 /* 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
730 css_path = NULL;
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
32463
235fc4971d5e get_theme_files --> get_variant_files.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32461
diff changeset
733 all = get_variant_files (style);
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
734
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
735 if (all) {
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
736 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
737 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
738 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
739
32454
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
740 for (iter = all; iter; iter = g_list_next (iter))
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
741 g_free (iter->data);
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
742
324980898d8e temporary commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32453
diff changeset
743 g_list_free (all);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
744 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
745
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
746 static gboolean
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
747 plugin_load(PurplePlugin *plugin)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
748 {
32466
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
749 style_set_default ();
b57f7265dc37 theme detection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32465
diff changeset
750 if (!cur_style_dir) return FALSE; /* couldn't find a style */
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
751
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
752 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
753 "displaying-im-msg",
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
754 webkit_plugin_get_handle (),
32452
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
755 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
756 NULL);
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
757
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
758 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
759 "displaying-chat-msg",
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
760 webkit_plugin_get_handle (),
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
761 PURPLE_CALLBACK(webkit_on_displaying_chat_msg),
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
762 NULL);
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
763
c4f3d02a3122 Well, chat is sorta kinda working.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32451
diff changeset
764 purple_signal_connect (pidgin_conversations_get_handle (),
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
765 "conversation-displayed",
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
766 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
767 PURPLE_CALLBACK(webkit_on_conversation_displayed),
32450
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
768 NULL);
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
769
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
770 purple_signal_connect (pidgin_conversations_get_handle (),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
771 "conversation-switched",
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
772 webkit_plugin_get_handle (),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
773 PURPLE_CALLBACK(webkit_on_conversation_switched),
f91c5f54b29a create conversation with signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32449
diff changeset
774 NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
775
32451
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
776 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
777 "conversation-hiding",
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
778 webkit_plugin_get_handle (),
5474e644e2bd * removed delete_conversation uiops and instead used signals.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32450
diff changeset
779 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
780 NULL);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
781
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
782 /* 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
783 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
784 GList* list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
785 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
786 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
787
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
788 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
789 return TRUE;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
790 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
791
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
792 static gboolean
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
793 plugin_unload(PurplePlugin *plugin)
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 GList *list;
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
796
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
797 webkit_plugin_free_handle ();
32469
ba275d3188c7 unset cur_style_dir when unloading.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32468
diff changeset
798 cur_style_dir = NULL;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
799 list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
800 while (list) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
801 finalize_theme_for_webkit(list->data);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
802 list = g_list_next(list);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
803 }
32448
2a5e5d1dde23 use displaying-im-msg instead of write_conv uiops.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32444
diff changeset
804
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
805 return TRUE;
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
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
808 static void
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
809 style_changed (GtkWidget* combobox, gpointer null)
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
810 {
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
811 char *name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox));
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
812 GtkWidget *dialog;
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
813 GList *styles = get_style_directory_list (), *iter;
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
814
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
815 /* find the full path for this name, I wish I could store this info in the combobox itself. :( */
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
816 for (iter = styles; iter; iter = g_list_next(iter)) {
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
817 char* basename = g_path_get_basename (iter->data);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
818 if (g_str_equal (basename, name)) {
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
819 g_free (basename);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
820 break;
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
821 }
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
822 g_free (basename);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
823 }
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
824
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
825 g_assert (iter);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
826 g_free (name);
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
827 g_free (cur_style_dir);
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
828 cur_style_dir = g_strdup (iter->data);;
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
829
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
830 /* inform the user that existing conversations haven't changed */
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
831 dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "The style for existing conversations have not been changed. Please close and re-open the conversation for the changes to take effect.");
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
832 g_assert (dialog);
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
833 gtk_widget_show (dialog);
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
834 g_signal_connect_swapped (dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
32468
b7f42b3c683d some code for style_changed and also default any empty file to "" rather than NULL.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32467
diff changeset
835 }
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
836
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
837 static GtkWidget*
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
838 get_style_config_frame ()
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
839 {
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
840 GtkWidget *combobox = gtk_combo_box_new_text ();
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
841 GList *styles = get_style_directory_list (), *iter;
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
842 int index = 0, selected = 0;
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
843
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
844 for (iter = styles; iter; iter = g_list_next (iter)) {
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
845 PidginMessageStyle *style = pidgin_message_style_load (iter->data);
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
846
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
847 if (style) {
32476
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
848 char *text = g_path_get_basename (iter->data);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
849 gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), text);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
850 g_free (text);
03712ece5275 Show only the MessageStyle name and not the entire path.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32475
diff changeset
851
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
852 if (g_str_equal (iter->data, cur_style_dir))
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
853 selected = index;
32473
1cf735223afe Inform the user about how the theme change takes effect.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32472
diff changeset
854 index++;
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
855 pidgin_message_style_unref (style);
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
856 }
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
857 }
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
858 gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), selected);
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
859 g_signal_connect_after (G_OBJECT(combobox), "changed", G_CALLBACK(style_changed), NULL);
32467
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
860 return combobox;
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
861 }
9c3c14c44803 some code to get a list of styles and blah blah.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32466
diff changeset
862
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
863 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
864 variant_update_conversation (PurpleConversation *conv)
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
865 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
866 PidginConversation *gtkconv = PIDGIN_CONVERSATION (conv);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
867 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
868 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
869 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
870
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
871 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
872
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
873 script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path);
32461
72fe247cc953 Yep, tested, and changed some code from previous commit. This is a hard
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32460
diff changeset
874 gtk_webview_safe_execute_script (GTK_WEBVIEW(webview), script);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
875 g_free (script);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
876 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
877
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
878 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
879 variant_changed (GtkWidget* combobox, gpointer 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 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
882 char *css_path;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
883 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
884 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
885
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
886 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
887
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
888 /* 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
889 * 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
890
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
891 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
892 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
893 g_free (name);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
894
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
895 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
896
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
897 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
898 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
899 }
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
900
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
901 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
902 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
903 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
904
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
905 /* update each conversation */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
906 list = purple_get_conversations ();
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
907 while (list) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
908 variant_update_conversation (list->data);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
909 list = g_list_next(list);
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
910 }
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
911
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
912 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
913 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
914 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
915 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
916 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
917
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
918 static GtkWidget *
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
919 get_variant_config_frame()
32456
f1b670241892 Ok, good part of this work of moving global variables to defined styles is
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32455
diff changeset
920 {
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
921 PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
32477
f36b9ed704b1 Removed some unused code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32476
diff changeset
922 GList *variants = get_variant_files(style), *iter;
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
923 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
924 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
925 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
926
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
927 pidgin_message_style_unref (style);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
928
32477
f36b9ed704b1 Removed some unused code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32476
diff changeset
929 for (iter = variants; iter; iter = g_list_next (iter)) {
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
930 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
931 char *dirname = g_path_get_dirname(iter->data);
32477
f36b9ed704b1 Removed some unused code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32476
diff changeset
932 char *temp = g_strndup (basename, strlen(basename)-4);
f36b9ed704b1 Removed some unused code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32476
diff changeset
933 gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), temp);
f36b9ed704b1 Removed some unused code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32476
diff changeset
934 g_free (temp);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
935
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
936 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
937 def = index;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
938 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
939
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
940 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
941 g_free (dirname);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
942 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
943
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
944 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
945 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
946
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
947 g_free (css_path);
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
948 return combobox;
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
949 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
950
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
951 static void
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
952 style_changed_reset_variants (GtkWidget* combobox, gpointer table)
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
953 {
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
954 /* I hate to do this, I swear. But I don't know how to cleanly clean an existing combobox */
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
955 GtkWidget* variants = g_object_get_data (G_OBJECT(table), "variants-cbox");
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
956 gtk_widget_destroy (variants);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
957 variants = get_variant_config_frame ();
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
958 gtk_table_attach_defaults (GTK_TABLE (table), variants, 1, 2, 1, 2);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
959 gtk_widget_show_all (GTK_WIDGET(table));
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
960
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
961 g_object_set_data (G_OBJECT(table), "variants-cbox", variants);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
962 }
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
963
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
964 static GtkWidget*
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
965 get_config_frame(PurplePlugin* plugin)
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
966 {
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
967 GtkWidget *table = gtk_table_new (2, 2, FALSE);
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
968 GtkWidget *style_config = get_style_config_frame ();
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
969 GtkWidget *variant_config = get_variant_config_frame ();
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
970
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
971 gtk_table_attach_defaults (GTK_TABLE(table), gtk_label_new ("Message Style"), 0, 1, 0, 1);
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
972 gtk_table_attach_defaults (GTK_TABLE(table), style_config, 1, 2, 0, 1);
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
973 gtk_table_attach_defaults (GTK_TABLE(table), gtk_label_new ("Style Variant"), 0, 1, 1, 2);
32475
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
974 gtk_table_attach_defaults (GTK_TABLE(table), variant_config, 1, 2, 1, 2);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
975
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
976
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
977 g_object_set_data (G_OBJECT(table), "variants-cbox", variant_config);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
978 /* to clarify, this is a second signal connected on style config */
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
979 g_signal_connect_after (G_OBJECT(style_config), "changed", G_CALLBACK(style_changed_reset_variants), table);
a76ccc1e443d Reset the list of variants when the MessageStyle is changed.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32474
diff changeset
980
32474
8767057d0426 use a table to display the options neatly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32473
diff changeset
981 return table;
32464
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
982 }
79a2ad758fd5 partial work towards theme selection.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32463
diff changeset
983
32444
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
984 PidginPluginUiInfo ui_info =
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
985 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
986 get_config_frame,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
987 0, /* page_num (Reserved) */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
988
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
989 /* padding */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
990 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
991 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
992 NULL,
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
993 NULL
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
994 };
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
995
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
996
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
997 static PurplePluginInfo info =
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
998 {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
999 PURPLE_PLUGIN_MAGIC, /* Magic */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1000 PURPLE_MAJOR_VERSION, /* Purple Major Version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1001 PURPLE_MINOR_VERSION, /* Purple Minor Version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1002 PURPLE_PLUGIN_STANDARD, /* plugin type */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1003 PIDGIN_PLUGIN_TYPE, /* ui requirement */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1004 0, /* flags */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1005 NULL, /* dependencies */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1006 PURPLE_PRIORITY_DEFAULT, /* priority */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1007
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1008 PLUGIN_ID, /* plugin id */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1009 NULL, /* name */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1010 "0.1", /* version */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1011 NULL, /* summary */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1012 NULL, /* description */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1013 PLUGIN_AUTHOR, /* author */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1014 "http://pidgin.im", /* website */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1015
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1016 plugin_load, /* load */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1017 plugin_unload, /* unload */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1018 NULL, /* destroy */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1019
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1020 &ui_info, /* ui_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1021 NULL, /* extra_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1022 NULL, /* prefs_info */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1023 NULL, /* actions */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1024 NULL, /* reserved 1 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1025 NULL, /* reserved 2 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1026 NULL, /* reserved 3 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1027 NULL /* reserved 4 */
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1028 };
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1029
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1030 static void
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1031 init_plugin(PurplePlugin *plugin) {
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1032 info.name = "Adium IMs";
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1033 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
1034 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
1035
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1036 purple_prefs_add_none ("/plugins");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1037 purple_prefs_add_none ("/plugins/gtk");
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1038 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
1039 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
1040 }
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1041
69e11efb2ba6 other files that missed my main major commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1042 PURPLE_INIT_PLUGIN(webkit, init_plugin, info)

mercurial