pidgin/plugins/adiumthemes/message-style.c

Thu, 08 Sep 2011 22:04:35 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Thu, 08 Sep 2011 22:04:35 +0000
changeset 32513
9352b4c92d13
parent 32491
c917d2ba4a38
child 32514
2477c1e93890
permissions
-rw-r--r--

Clean up this WebKit stuff. Fix up broken merging, mark unfinished
work with FIXME/TODO, and fix this ungodly formatting.

32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
1 /* pidgin
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
2 *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
3 * Pidgin is the legal property of its developers, whose names are too numerous
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
5 * source distribution.
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
6 *
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
7 * This program is free software; you can redistribute it and/or modify
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
8 * it under the terms of the GNU General Public License as published by
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
10 * (at your option) any later version.
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
11 *
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
12 * This program is distributed in the hope that it will be useful,
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
15 * GNU General Public License for more details.
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
16 *
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
20 *
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
21 */
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
22
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
23 #include "message-style.h"
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
24
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
25 #include <string.h>
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
26
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
27 #include <glib.h>
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
28
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
29 #include <debug.h>
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
30 #include <util.h>
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
31
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
32 static void
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
33 glist_free_all_string(GList *list)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
34 {
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
35 GList *first = list;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
36 for (; list; list = g_list_next(list))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
37 g_free(list->data);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
38 g_list_free(first);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
39 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
40
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
41 static PidginMessageStyle *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
42 pidgin_message_style_new(const char *styledir)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
43 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
44 PidginMessageStyle *ret = g_new0(PidginMessageStyle, 1);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
45
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
46 ret->ref_counter = 1;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
47 ret->style_dir = g_strdup(styledir);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
48
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
49 return ret;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
50 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
51
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
52 /**
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
53 * deallocate any memory used for info.plist options
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
54 */
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
55 static void
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
56 pidgin_message_style_unset_info_plist(PidginMessageStyle *style)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
57 {
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
58 style->message_view_version = 0;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
59 g_free(style->cf_bundle_name);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
60 style->cf_bundle_name = NULL;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
61
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
62 g_free(style->cf_bundle_identifier);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
63 style->cf_bundle_identifier = NULL;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
64
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
65 g_free(style->cf_bundle_get_info_string);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
66 style->cf_bundle_get_info_string = NULL;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
67
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
68 g_free(style->default_font_family);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
69 style->default_font_family = NULL;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
70
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
71 style->default_font_size = 0;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
72 style->shows_user_icons = TRUE;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
73 style->disable_combine_consecutive = FALSE;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
74 style->default_background_is_transparent = FALSE;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
75 style->disable_custom_background = FALSE;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
76
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
77 g_free(style->default_background_color);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
78 style->default_background_color = NULL;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
79
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
80 style->allow_text_colors = TRUE;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
81
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
82 g_free(style->image_mask);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
83 style->image_mask = NULL;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
84 g_free(style->default_variant);
32486
c44fe7ecb3dd load the default variant. Bring back basestyle.css.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32485
diff changeset
85 style->default_variant = NULL;
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
86 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
87
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
88
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
89 void
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
90 pidgin_message_style_unref(PidginMessageStyle *style)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
91 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
92 if (!style)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
93 return;
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
94 g_assert (style->ref_counter > 0);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
95
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
96 style->ref_counter--;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
97 if (style->ref_counter)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
98 return;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
99
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
100 g_free(style->style_dir);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
101 g_free(style->template_path);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
102
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
103 g_free(style->template_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
104 g_free(style->incoming_content_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
105 g_free(style->outgoing_content_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
106 g_free(style->outgoing_next_content_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
107 g_free(style->status_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
108 g_free(style->basestyle_css);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
109
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
110 g_free(style);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
111
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
112 pidgin_message_style_unset_info_plist(style);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
113 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
114
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
115 void
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
116 pidgin_message_style_save_state(const PidginMessageStyle *style)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
117 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
118 char *prefname = g_strdup_printf("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
119 char *variant = g_strdup_printf("%s/variant", prefname);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
120
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
121 purple_debug_info("webkit", "saving state with variant %s\n", style->variant);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
122 purple_prefs_add_none(prefname);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
123 purple_prefs_add_string(variant, "");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
124 purple_prefs_set_string(variant, style->variant);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
125
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
126 g_free(prefname);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
127 g_free(variant);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
128 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
129
32491
c917d2ba4a38 Read AllowTextColors key properly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
130 static void
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
131 pidgin_message_style_load_state(PidginMessageStyle *style)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
132 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
133 char *prefname = g_strdup_printf("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
134 char *variant = g_strdup_printf("%s/variant", prefname);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
135
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
136 const char* value = purple_prefs_get_string(variant);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
137 gboolean changed = !style->variant || !g_str_equal(style->variant, value);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
138
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
139 g_free(style->variant);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
140 style->variant = g_strdup(value);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
141
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
142 if (changed)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
143 pidgin_message_style_read_info_plist(style, style->variant);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
144
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
145 g_free(prefname);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
146 g_free(variant);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
147 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
148
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
149
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
150 static gboolean
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
151 parse_info_plist_key_value(xmlnode* key, gpointer destination, const char* expected)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
152 {
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
153 xmlnode *val = key->next;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
154
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
155 for (; val && val->type != XMLNODE_TYPE_TAG; val = val->next)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
156 ;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
157 if (!val)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
158 return FALSE;
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
159
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
160 if (expected == NULL || g_str_equal(expected, "string")) {
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
161 char **dest = (char **)destination;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
162 if (!g_str_equal(val->name, "string"))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
163 return FALSE;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
164 if (*dest)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
165 g_free(*dest);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
166 *dest = xmlnode_get_data_unescaped(val);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
167 } else if (g_str_equal(expected, "integer")) {
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
168 int *dest = (int *)destination;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
169 char *value = xmlnode_get_data_unescaped(val);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
170
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
171 if (!g_str_equal(val->name, "integer"))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
172 return FALSE;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
173 *dest = atoi(value);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
174 g_free(value);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
175 } else if (g_str_equal(expected, "boolean")) {
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
176 gboolean *dest = (gboolean *)destination;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
177 if (g_str_equal(val->name, "true"))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
178 *dest = TRUE;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
179 else if (g_str_equal(val->name, "false"))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
180 *dest = FALSE;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
181 else
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
182 return FALSE;
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
183 } else return FALSE;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
184
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
185 return TRUE;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
186 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
187
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
188 static gboolean
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
189 str_for_key(const char *key, const char *found, const char *variant)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
190 {
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
191 if (g_str_equal(key, found))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
192 return TRUE;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
193 if (!variant)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
194 return FALSE;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
195 return (g_str_has_prefix(found, key)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
196 && g_str_has_suffix(found, variant)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
197 && strlen(found) == strlen(key) + strlen(variant) + 1);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
198 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
199
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
200 /**
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
201 * Info.plist should be re-read every time the variant changes, this is because
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
202 * the keys that take precedence depend on the value of the current variant.
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
203 */
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
204 void
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
205 pidgin_message_style_read_info_plist(PidginMessageStyle *style, const char *variant)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
206 {
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
207 /* note that if a variant is used the option:VARIANTNAME takes precedence */
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
208 char *contents = g_build_filename(style->style_dir, "Contents", NULL);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
209 xmlnode *plist = xmlnode_from_file(contents, "Info.plist", "Info.plist", "webkit"), *iter;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
210 xmlnode *dict = xmlnode_get_child(plist, "dict");
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
211
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
212 g_assert (dict);
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
213 for (iter = xmlnode_get_child(dict, "key"); iter; iter = xmlnode_get_next_twin(iter)) {
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
214 char* key = xmlnode_get_data_unescaped(iter);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
215 gboolean pr = TRUE;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
216
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
217 if (g_str_equal("MessageViewVersion", key))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
218 pr = parse_info_plist_key_value(iter, &style->message_view_version, "integer");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
219 else if (g_str_equal("CFBundleName", key))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
220 pr = parse_info_plist_key_value(iter, &style->cf_bundle_name, "string");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
221 else if (g_str_equal("CFBundleIdentifier", key))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
222 pr = parse_info_plist_key_value(iter, &style->cf_bundle_identifier, "string");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
223 else if (g_str_equal("CFBundleGetInfoString", key))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
224 pr = parse_info_plist_key_value(iter, &style->cf_bundle_get_info_string, "string");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
225 else if (str_for_key("DefaultFontFamily", key, variant))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
226 pr = parse_info_plist_key_value(iter, &style->default_font_family, "string");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
227 else if (str_for_key("DefaultFontSize", key, variant))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
228 pr = parse_info_plist_key_value(iter, &style->default_font_size, "integer");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
229 else if (str_for_key("ShowsUserIcons", key, variant))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
230 pr = parse_info_plist_key_value(iter, &style->shows_user_icons, "boolean");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
231 else if (str_for_key("DisableCombineConsecutive", key, variant))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
232 pr = parse_info_plist_key_value(iter, &style->disable_combine_consecutive, "boolean");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
233 else if (str_for_key("DefaultBackgroundIsTransparent", key, variant))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
234 pr = parse_info_plist_key_value(iter, &style->default_background_is_transparent, "boolean");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
235 else if (str_for_key("DisableCustomBackground", key, variant))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
236 pr = parse_info_plist_key_value(iter, &style->disable_custom_background, "boolean");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
237 else if (str_for_key("DefaultBackgroundColor", key, variant))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
238 pr = parse_info_plist_key_value(iter, &style->default_background_color, "string");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
239 else if (str_for_key("AllowTextColors", key, variant))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
240 pr = parse_info_plist_key_value(iter, &style->allow_text_colors, "integer");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
241 else if (str_for_key("ImageMask", key, variant))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
242 pr = parse_info_plist_key_value(iter, &style->image_mask, "string");
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
243
32491
c917d2ba4a38 Read AllowTextColors key properly.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32488
diff changeset
244 if (!pr)
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
245 purple_debug_warning("webkit", "Failed to parse key %s\n", key);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
246 g_free(key);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
247 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
248
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
249 xmlnode_free(plist);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
250 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
251
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
252 PidginMessageStyle *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
253 pidgin_message_style_load(const char *styledir)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
254 {
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
255 /*
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
256 * the loading process described:
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
257 *
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
258 * First we load all the style .html files, etc.
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
259 * The we load any config options that have been stored for
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
260 * this variant.
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
261 * Then we load the Info.plist, for the currently decided variant.
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
262 * At this point, if we find that variants exist, yet
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
263 * we don't have a variant selected, we choose DefaultVariant
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
264 * and if that does not exist, we choose the first one in the
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
265 * directory.
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
266 */
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
267 char *file;
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
268 PidginMessageStyle *style = NULL;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
269
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
270 style = pidgin_message_style_new(styledir);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
271
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
272 /* load all other files */
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
273
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
274 /* The template path can either come from the theme, or can
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
275 * be stock Template.html that comes with the plugin */
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
276 style->template_path = g_build_filename(styledir, "Contents", "Resources", "Template.html", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
277
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
278 if (!g_file_test(style->template_path, G_FILE_TEST_EXISTS)) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
279 g_free(style->template_path);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
280 style->template_path = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
281 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
282
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
283 if (!g_file_get_contents(style->template_path, &style->template_html, NULL, NULL)) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
284 purple_debug_error("webkit", "Could not locate a Template.html (%s)\n", style->template_path);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
285 pidgin_message_style_unref(style);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
286 return NULL;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
287 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
288
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
289 file = g_build_filename(styledir, "Contents", "Resources", "Status.html", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
290 if (!g_file_get_contents(file, &style->status_html, NULL, NULL)) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
291 purple_debug_info("webkit", "%s could not find Resources/Status.html", styledir);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
292 pidgin_message_style_unref(style);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
293 g_free(file);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
294 return NULL;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
295 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
296 g_free(file);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
297
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
298 file = g_build_filename(styledir, "Contents", "Resources", "main.css", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
299 if (!g_file_get_contents(file, &style->basestyle_css, NULL, NULL))
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
300 style->basestyle_css = g_strdup("");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
301 g_free(file);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
302
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
303 file = g_build_filename(styledir, "Contents", "Resources", "Header.html", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
304 if (!g_file_get_contents(file, &style->header_html, NULL, NULL))
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
305 style->header_html = g_strdup("");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
306 g_free(file);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
307
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
308 file = g_build_filename(styledir, "Contents", "Resources", "Footer.html", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
309 if (!g_file_get_contents(file, &style->footer_html, NULL, NULL))
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
310 style->footer_html = g_strdup("");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
311 g_free(file);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
312
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
313 file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "Content.html", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
314 if (!g_file_get_contents(file, &style->incoming_content_html, NULL, NULL)) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
315 purple_debug_info("webkit", "%s did not have a Incoming/Content.html\n", styledir);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
316 pidgin_message_style_unref(style);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
317 g_free(file);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
318 return NULL;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
319 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
320 g_free(file);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
321
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
322
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
323 /* according to the spec, the following are optional files */
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
324 file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "NextContent.html", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
325 if (!g_file_get_contents(file, &style->incoming_next_content_html, NULL, NULL)) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
326 style->incoming_next_content_html = g_strdup(style->incoming_content_html);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
327 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
328 g_free(file);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
329
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
330 file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "Content.html", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
331 if (!g_file_get_contents(file, &style->outgoing_content_html, NULL, NULL)) {
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
332 style->outgoing_content_html = g_strdup(style->incoming_content_html);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
333 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
334 g_free(file);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
335
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
336 file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
337 if (!g_file_get_contents(file, &style->outgoing_next_content_html, NULL, NULL)) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
338 style->outgoing_next_content_html = g_strdup(style->outgoing_content_html);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
339 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
340
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
341 pidgin_message_style_read_info_plist(style, NULL);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
342 pidgin_message_style_load_state(style);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
343
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
344 /* non variant dependent Info.plist checks */
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
345 if (style->message_view_version < 3) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
346 purple_debug_info("webkit", "%s is a legacy style (version %d) and will not be loaded\n", style->cf_bundle_name, style->message_view_version);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
347 pidgin_message_style_unref(style);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
348 return NULL;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
349 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
350
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
351 if (!style->variant)
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
352 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
353 GList *variants = pidgin_message_style_get_variants(style);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
354
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
355 if (variants)
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
356 pidgin_message_style_set_variant(style, variants->data);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
357
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
358 glist_free_all_string(variants);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
359 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
360
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
361 return style;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
362 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
363
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
364 PidginMessageStyle *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
365 pidgin_message_style_copy(const PidginMessageStyle *style)
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
366 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
367 PidginMessageStyle *ret = pidgin_message_style_new(style->style_dir);
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
368
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
369 ret->variant = g_strdup(style->variant);
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
370 ret->message_view_version = style->message_view_version;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
371 ret->cf_bundle_name = g_strdup(style->cf_bundle_name);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
372 ret->cf_bundle_identifier = g_strdup(style->cf_bundle_identifier);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
373 ret->cf_bundle_get_info_string = g_strdup(style->cf_bundle_get_info_string);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
374 ret->default_font_family = g_strdup(style->default_font_family);
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
375 ret->default_font_size = style->default_font_size;
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
376 ret->shows_user_icons = style->shows_user_icons;
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
377 ret->disable_combine_consecutive = style->disable_combine_consecutive;
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
378 ret->default_background_is_transparent = style->default_background_is_transparent;
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
379 ret->disable_custom_background = style->disable_custom_background;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
380 ret->default_background_color = g_strdup(style->default_background_color);
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
381 ret->allow_text_colors = style->allow_text_colors;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
382 ret->image_mask = g_strdup(style->image_mask);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
383 ret->default_variant = g_strdup(style->default_variant);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
384
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
385 ret->template_path = g_strdup(style->template_path);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
386 ret->template_html = g_strdup(style->template_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
387 ret->header_html = g_strdup(style->header_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
388 ret->footer_html = g_strdup(style->footer_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
389 ret->incoming_content_html = g_strdup(style->incoming_content_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
390 ret->outgoing_content_html = g_strdup(style->outgoing_content_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
391 ret->incoming_next_content_html = g_strdup(style->incoming_next_content_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
392 ret->outgoing_next_content_html = g_strdup(style->outgoing_next_content_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
393 ret->status_html = g_strdup(style->status_html);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
394 ret->basestyle_css = g_strdup(style->basestyle_css);
32487
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
395 return ret;
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
396 }
13f307997f1a Instead of using references, use copy's. Sigh, I know this is a memory inefficient
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32486
diff changeset
397
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
398 void
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
399 pidgin_message_style_set_variant(PidginMessageStyle *style, const char *variant)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
400 {
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
401 /* I'm not going to test whether this variant is valid! */
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
402 g_free(style->variant);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
403 style->variant = g_strdup(variant);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
404
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
405 pidgin_message_style_read_info_plist(style, variant);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
406
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
407 /* todo, the style has "changed". Ideally, I would like to use signals at this point. */
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
408 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
409
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
410 char *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
411 pidgin_message_style_get_variant(PidginMessageStyle *style)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
412 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
413 return g_strdup(style->variant);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
414 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
415
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
416 /**
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
417 * Get a list of variants supported by the style.
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
418 */
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
419 GList*
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
420 pidgin_message_style_get_variants(PidginMessageStyle *style)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
421 {
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
422 GList *ret = NULL;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
423 GDir *variants;
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
424 const char *css_file;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
425 char *css;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
426 char *variant_dir;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
427
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
428 g_assert(style->style_dir);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
429 variant_dir = g_build_filename(style->style_dir, "Contents", "Resources", "Variants", NULL);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
430
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
431 variants = g_dir_open(variant_dir, 0, NULL);
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
432 if (!variants)
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
433 return NULL;
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
434
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
435 while ((css_file = g_dir_read_name(variants)) != NULL) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
436 if (!g_str_has_suffix(css_file, ".css"))
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
437 continue;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
438
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
439 css = g_strndup(css_file, strlen(css_file) - 4);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
440 ret = g_list_append(ret, css);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
441 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
442
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
443 g_dir_close(variants);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
444 g_free(variant_dir);
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
445
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
446 ret = g_list_sort(ret, (GCompareFunc)g_strcmp0);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
447 return ret;
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
448 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
449
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
450 char *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
451 pidgin_message_style_get_css(PidginMessageStyle *style)
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
452 {
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
453 if (!style->variant) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
454 return g_build_filename(style->style_dir, "Contents", "Resources", "main.css", NULL);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
455 } else {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
456 char *file = g_strdup_printf("%s.css", style->variant);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
457 char *ret = g_build_filename(style->style_dir, "Contents", "Resources", "Variants", file, NULL);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32491
diff changeset
458 g_free(file);
32485
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
459 return ret;
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
460 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
461 }
b932922007bc Separated the MessageStyle loading code from the actual rendering code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
462

mercurial