pidgin/plugins/adiumthemes/webkit.c

Mon, 10 Aug 2009 10:03:47 +0000

author
Arnold Noronha <tdrhq@soc.pidgin.im>
date
Mon, 10 Aug 2009 10:03:47 +0000
branch
soc.2009.webkitmessageview
changeset 32468
b7f42b3c683d
parent 32467
9c3c14c44803
child 32469
ba275d3188c7
permissions
-rw-r--r--

some code for style_changed and also default any empty file to "" rather than NULL.

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

mercurial