annotate pidgin/gtkconv-theme.c @ 32647:3e27c95ab8e6

Fix a leak. pidgin_conversation_theme_add_variant should only be used by the theme builder, so it's fine if we let it take ownership of the variant name string.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 19 Sep 2011 20:23:13 +0000
parents f857a6db3bd9
children 1caf13175039
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
1 /*
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
2 * Conversation Themes for Pidgin
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
3 *
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
4 * Pidgin is the legal property of its developers, whose names are too numerous
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
6 * source distribution.
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
7 *
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
12 *
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
17 *
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
21 */
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
22
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
23 #include "gtkconv-theme.h"
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
24
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
25 #include "conversation.h"
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
26 #include "debug.h"
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
27 #include "prefs.h"
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
28 #include "xmlnode.h"
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
29
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
30 #include "pidgin.h"
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
31 #include "gtkconv.h"
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
32 #include "gtkwebview.h"
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
33
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
34 #include <stdlib.h>
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
35 #include <string.h>
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
36
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
37 /* GObject data keys - this will probably go away soon... */
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
38 #define MESSAGE_STYLE_KEY "message-style"
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
39
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
40 #define PIDGIN_CONV_THEME_GET_PRIVATE(Gobject) \
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
41 (G_TYPE_INSTANCE_GET_PRIVATE((Gobject), PIDGIN_TYPE_CONV_THEME, PidginConvThemePrivate))
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
42
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
43 /******************************************************************************
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
44 * Structs
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
45 *****************************************************************************/
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
46
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
47 typedef struct {
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
48 /* current config options */
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
49 char *variant; /* allowed to be NULL if there are no variants */
32645
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
50 GList *variants;
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
51
32630
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
52 /* Info.plist keys/values */
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
53 GHashTable *info;
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
54
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
55 /* caches */
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
56 char *template_html;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
57 char *header_html;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
58 char *footer_html;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
59 char *incoming_content_html;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
60 char *outgoing_content_html;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
61 char *incoming_next_content_html;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
62 char *outgoing_next_content_html;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
63 char *status_html;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
64 char *basestyle_css;
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
65 } PidginConvThemePrivate;
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
66
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
67 /******************************************************************************
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
68 * Globals
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
69 *****************************************************************************/
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
70
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
71 static GObjectClass *parent_class = NULL;
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
72
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
73 /******************************************************************************
32630
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
74 * Enums
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
75 *****************************************************************************/
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
76
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
77 enum {
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
78 PROP_ZERO = 0,
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
79 PROP_INFO,
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
80 };
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
81
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
82 /******************************************************************************
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
83 * GObject Stuff
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
84 *****************************************************************************/
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
85
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
86 static void
32630
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
87 pidgin_conv_theme_get_property(GObject *obj, guint param_id, GValue *value,
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
88 GParamSpec *psec)
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
89 {
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
90 PidginConvTheme *theme = PIDGIN_CONV_THEME(obj);
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
91
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
92 switch (param_id) {
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
93 case PROP_INFO:
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
94 g_value_set_boxed(value, (gpointer)pidgin_conversation_theme_get_info(theme));
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
95 break;
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
96 default:
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
97 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
98 break;
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
99 }
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
100 }
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
101
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
102 static void
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
103 pidgin_conv_theme_set_property(GObject *obj, guint param_id, const GValue *value,
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
104 GParamSpec *psec)
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
105 {
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
106 PidginConvTheme *theme = PIDGIN_CONV_THEME(obj);
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
107
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
108 switch (param_id) {
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
109 case PROP_INFO:
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
110 pidgin_conversation_theme_set_info(theme, g_value_get_boxed(value));
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
111 break;
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
112 default:
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
113 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
114 break;
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
115 }
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
116 }
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
117
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
118 static void
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
119 pidgin_conv_theme_init(GTypeInstance *instance,
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
120 gpointer klass)
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
121 {
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
122 PidginConvThemePrivate *priv;
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
123
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
124 priv = PIDGIN_CONV_THEME_GET_PRIVATE(instance);
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
125 }
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
126
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
127 static void
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
128 pidgin_conv_theme_finalize(GObject *obj)
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
129 {
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
130 PidginConvThemePrivate *priv;
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
131
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
132 priv = PIDGIN_CONV_THEME_GET_PRIVATE(obj);
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
133
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
134 g_free(priv->template_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
135 g_free(priv->incoming_content_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
136 g_free(priv->outgoing_content_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
137 g_free(priv->outgoing_next_content_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
138 g_free(priv->status_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
139 g_free(priv->basestyle_css);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
140
32630
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
141 if (priv->info)
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
142 g_hash_table_destroy(priv->info);
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
143
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
144 parent_class->finalize(obj);
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
145 }
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
146
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
147 static void
32622
218a52b8504d Fix small typo and remove unnecessary include.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32619
diff changeset
148 pidgin_conv_theme_class_init(PidginConvThemeClass *klass)
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
149 {
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
150 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
32630
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
151 GParamSpec *pspec;
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
152
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
153 parent_class = g_type_class_peek_parent(klass);
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
154
32630
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
155 g_type_class_add_private(klass, sizeof(PidginConvThemePrivate));
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
156
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
157 obj_class->get_property = pidgin_conv_theme_get_property;
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
158 obj_class->set_property = pidgin_conv_theme_set_property;
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
159 obj_class->finalize = pidgin_conv_theme_finalize;
32630
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
160
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
161 /* INFO */
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
162 pspec = g_param_spec_boxed("info", "Info",
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
163 "The information about this theme",
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
164 G_TYPE_HASH_TABLE,
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
165 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
166 g_object_class_install_property(obj_class, PROP_INFO, pspec);
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
167
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
168 }
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
169
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
170 GType
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
171 pidgin_conversation_theme_get_type(void)
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
172 {
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
173 static GType type = 0;
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
174 if (type == 0) {
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
175 static const GTypeInfo info = {
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
176 sizeof(PidginConvThemeClass),
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
177 NULL, /* base_init */
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
178 NULL, /* base_finalize */
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
179 (GClassInitFunc)pidgin_conv_theme_class_init, /* class_init */
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
180 NULL, /* class_finalize */
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
181 NULL, /* class_data */
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
182 sizeof(PidginConvTheme),
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
183 0, /* n_preallocs */
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
184 pidgin_conv_theme_init, /* instance_init */
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
185 NULL, /* value table */
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
186 };
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
187 type = g_type_register_static(PURPLE_TYPE_THEME,
32630
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
188 "PidginConvTheme", &info, 0);
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
189 }
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
190 return type;
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
191 }
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
192
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
193 /******************************************************************************
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
194 * Helper Functions
32619
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
195 *****************************************************************************/
17c27a527004 Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
196
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
197 static const GValue *
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
198 get_key(PidginConvThemePrivate *priv, const char *key, gboolean specific)
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
199 {
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
200 GValue *val = NULL;
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
201
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
202 /* Try variant-specific key */
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
203 if (specific && priv->variant) {
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
204 char *name = g_strdup_printf("%s:%s", key, priv->variant);
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
205 val = g_hash_table_lookup(priv->info, name);
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
206 g_free(name);
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
207 }
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
208
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
209 /* Try generic key */
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
210 if (!val) {
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
211 val = g_hash_table_lookup(priv->info, key);
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
212 }
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
213
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
214 return val;
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
215 }
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
216
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
217 static const char *
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
218 get_template_html(PidginConvThemePrivate *priv, const char *dir)
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
219 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
220 char *file;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
221
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
222 if (priv->template_html)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
223 return priv->template_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
224
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
225 /* The template path can either come from the theme, or can
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
226 * be stock Template.html that comes with the plugin */
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
227 file = g_build_filename(dir, "Contents", "Resources", "Template.html", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
228
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
229 if (!g_file_test(file, G_FILE_TEST_EXISTS)) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
230 g_free(file);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
231 file = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
232 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
233
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
234 if (!g_file_get_contents(file, &priv->template_html, NULL, NULL)) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
235 purple_debug_error("webkit", "Could not locate a Template.html (%s)\n", file);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
236 priv->template_html = g_strdup("");
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
237 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
238 g_free(file);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
239
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
240 return priv->template_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
241 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
242
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
243 static const char *
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
244 get_status_html(PidginConvThemePrivate *priv, const char *dir)
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
245 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
246 char *file;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
247
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
248 if (priv->status_html)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
249 return priv->status_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
250
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
251 file = g_build_filename(dir, "Contents", "Resources", "Status.html", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
252 if (!g_file_get_contents(file, &priv->status_html, NULL, NULL)) {
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
253 purple_debug_info("webkit", "%s could not find Resources/Status.html", dir);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
254 priv->status_html = g_strdup("");
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
255 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
256 g_free(file);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
257
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
258 return priv->status_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
259 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
260
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
261 static const char *
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
262 get_basestyle_css(PidginConvThemePrivate *priv, const char *dir)
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
263 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
264 char *file;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
265
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
266 if (priv->basestyle_css)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
267 return priv->basestyle_css;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
268
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
269 file = g_build_filename(dir, "Contents", "Resources", "main.css", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
270 if (!g_file_get_contents(file, &priv->basestyle_css, NULL, NULL))
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
271 priv->basestyle_css = g_strdup("");
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
272 g_free(file);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
273
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
274 return priv->basestyle_css;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
275 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
276
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
277 static const char *
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
278 get_header_html(PidginConvThemePrivate *priv, const char *dir)
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
279 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
280 char *file;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
281
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
282 if (priv->header_html)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
283 return priv->header_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
284
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
285 file = g_build_filename(dir, "Contents", "Resources", "Header.html", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
286 if (!g_file_get_contents(file, &priv->header_html, NULL, NULL))
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
287 priv->header_html = g_strdup("");
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
288 g_free(file);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
289
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
290 return priv->header_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
291 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
292
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
293 static const char *
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
294 get_footer_html(PidginConvThemePrivate *priv, const char *dir)
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
295 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
296 char *file;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
297
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
298 if (priv->footer_html)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
299 return priv->footer_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
300
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
301 file = g_build_filename(dir, "Contents", "Resources", "Footer.html", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
302 if (!g_file_get_contents(file, &priv->footer_html, NULL, NULL))
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
303 priv->footer_html = g_strdup("");
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
304 g_free(file);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
305
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
306 return priv->footer_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
307 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
308
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
309 static const char *
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
310 get_incoming_content_html(PidginConvThemePrivate *priv, const char *dir)
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
311 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
312 char *file;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
313
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
314 if (priv->incoming_content_html)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
315 return priv->incoming_content_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
316
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
317 file = g_build_filename(dir, "Contents", "Resources", "Incoming", "Content.html", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
318 if (!g_file_get_contents(file, &priv->incoming_content_html, NULL, NULL)) {
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
319 purple_debug_info("webkit", "%s did not have a Incoming/Content.html\n", dir);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
320 priv->incoming_content_html = g_strdup("");
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
321 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
322 g_free(file);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
323
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
324 return priv->incoming_content_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
325 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
326
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
327 static const char *
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
328 get_incoming_next_content_html(PidginConvThemePrivate *priv, const char *dir)
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
329 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
330 char *file;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
331
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
332 if (priv->incoming_next_content_html)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
333 return priv->incoming_next_content_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
334
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
335 file = g_build_filename(dir, "Contents", "Resources", "Incoming", "NextContent.html", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
336 if (!g_file_get_contents(file, &priv->incoming_next_content_html, NULL, NULL)) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
337 priv->incoming_next_content_html = g_strdup(priv->incoming_content_html);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
338 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
339 g_free(file);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
340
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
341 return priv->incoming_next_content_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
342 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
343
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
344 static const char *
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
345 get_outgoing_content_html(PidginConvThemePrivate *priv, const char *dir)
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
346 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
347 char *file;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
348
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
349 if (priv->outgoing_content_html)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
350 return priv->outgoing_content_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
351
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
352 file = g_build_filename(dir, "Contents", "Resources", "Outgoing", "Content.html", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
353 if (!g_file_get_contents(file, &priv->outgoing_content_html, NULL, NULL)) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
354 priv->outgoing_content_html = g_strdup(priv->incoming_content_html);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
355 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
356 g_free(file);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
357
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
358 return priv->outgoing_content_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
359 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
360
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
361 static const char *
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
362 get_outgoing_next_content_html(PidginConvThemePrivate *priv, const char *dir)
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
363 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
364 char *file;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
365
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
366 if (priv->outgoing_next_content_html)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
367 return priv->outgoing_next_content_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
368
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
369 file = g_build_filename(dir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
370 if (!g_file_get_contents(file, &priv->outgoing_next_content_html, NULL, NULL)) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
371 priv->outgoing_next_content_html = g_strdup(priv->outgoing_content_html);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
372 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
373
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
374 return priv->outgoing_next_content_html;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
375 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
376
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
377 static char *
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
378 replace_header_tokens(const char *text, PurpleConversation *conv)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
379 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
380 GString *str = g_string_new(NULL);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
381 const char *cur = text;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
382 const char *prev = cur;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
383
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
384 if (text == NULL)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
385 return NULL;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
386
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
387 while ((cur = strchr(cur, '%'))) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
388 const char *replace = NULL;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
389 char *fin = NULL;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
390
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
391 if (!strncmp(cur, "%chatName%", strlen("%chatName%"))) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
392 replace = conv->name;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
393 } else if (!strncmp(cur, "%sourceName%", strlen("%sourceName%"))) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
394 replace = purple_account_get_alias(conv->account);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
395 if (replace == NULL)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
396 replace = purple_account_get_username(conv->account);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
397 } else if (!strncmp(cur, "%destinationName%", strlen("%destinationName%"))) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
398 PurpleBuddy *buddy = purple_find_buddy(conv->account, conv->name);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
399 if (buddy) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
400 replace = purple_buddy_get_alias(buddy);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
401 } else {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
402 replace = conv->name;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
403 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
404 } else if (!strncmp(cur, "%incomingIconPath%", strlen("%incomingIconPath%"))) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
405 PurpleBuddyIcon *icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv));
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
406 replace = purple_buddy_icon_get_full_path(icon);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
407 } else if (!strncmp(cur, "%outgoingIconPath%", strlen("%outgoingIconPath%"))) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
408 } else if (!strncmp(cur, "%timeOpened", strlen("%timeOpened"))) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
409 char *format = NULL;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
410 if (*(cur + strlen("%timeOpened")) == '{') {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
411 const char *start = cur + strlen("%timeOpened") + 1;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
412 char *end = strstr(start, "}%");
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
413 if (!end) /* Invalid string */
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
414 continue;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
415 format = g_strndup(start, end - start);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
416 fin = end + 1;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
417 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
418 replace = purple_utf8_strftime(format ? format : "%X", NULL);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
419 g_free(format);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
420 } else {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
421 continue;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
422 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
423
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
424 /* Here we have a replacement to make */
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
425 g_string_append_len(str, prev, cur - prev);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
426 g_string_append(str, replace);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
427
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
428 /* And update the pointers */
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
429 if (fin) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
430 prev = cur = fin + 1;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
431 } else {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
432 prev = cur = strchr(cur + 1, '%') + 1;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
433 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
434 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
435
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
436 /* And wrap it up */
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
437 g_string_append(str, prev);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
438 return g_string_free(str, FALSE);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
439 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
440
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
441 static char *
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
442 replace_template_tokens(PidginConvTheme *theme, const char *text, const char *header, const char *footer)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
443 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
444 PidginConvThemePrivate *priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
445 GString *str = g_string_new(NULL);
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
446 const char *themedir;
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
447
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
448 char **ms = g_strsplit(text, "%@", 6);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
449 char *base = NULL;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
450 char *csspath = pidgin_conversation_theme_get_css(theme);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
451 if (ms[0] == NULL || ms[1] == NULL || ms[2] == NULL || ms[3] == NULL || ms[4] == NULL || ms[5] == NULL) {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
452 g_strfreev(ms);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
453 g_string_free(str, TRUE);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
454 return NULL;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
455 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
456
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
457 themedir = purple_theme_get_dir(PURPLE_THEME(theme));
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
458
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
459 g_string_append(str, ms[0]);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
460 g_string_append(str, "file://");
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
461 base = g_build_filename(themedir, "Contents", "Resources", "Template.html", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
462 g_string_append(str, base);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
463 g_free(base);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
464
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
465 g_string_append(str, ms[1]);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
466
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
467 g_string_append(str, get_basestyle_css(priv, themedir));
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
468
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
469 g_string_append(str, ms[2]);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
470
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
471 g_string_append(str, "file://");
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
472 g_string_append(str, csspath);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
473
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
474 g_string_append(str, ms[3]);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
475 if (header)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
476 g_string_append(str, header);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
477 g_string_append(str, ms[4]);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
478 if (footer)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
479 g_string_append(str, footer);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
480 g_string_append(str, ms[5]);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
481
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
482 g_strfreev(ms);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
483 g_free(csspath);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
484 return g_string_free(str, FALSE);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
485 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
486
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
487 static void
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
488 set_theme_webkit_settings(WebKitWebView *webview, PidginConvTheme *theme)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
489 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
490 PidginConvThemePrivate *priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
491 WebKitWebSettings *settings;
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
492 const GValue *val;
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
493
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
494 g_object_get(G_OBJECT(webview), "settings", &settings, NULL);
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
495
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
496 val = get_key(priv, "DefaultFontFamily", TRUE);
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
497 if (val)
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
498 g_object_set(G_OBJECT(settings), "default-font-family", g_value_get_string(val), NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
499
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
500 val = get_key(priv, "DefaultFontSize", TRUE);
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
501 if (val)
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
502 g_object_set(G_OBJECT(settings), "default-font-size", GINT_TO_POINTER(g_value_get_int(val)), NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
503
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
504 val = get_key(priv, "DefaultBackgroundIsTransparent", TRUE);
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
505 if (val)
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
506 /* this does not work :( */
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
507 webkit_web_view_set_transparent(webview, g_value_get_boolean(val));
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
508 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
509
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
510 /*
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
511 * The style specification says that if the conversation is a group
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
512 * chat then the <div id="Chat"> element will be given a class
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
513 * 'groupchat'. I can't add another '%@' in Template.html because
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
514 * that breaks style-specific Template.html's. I have to either use libxml
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
515 * or conveniently play with WebKit's javascript engine. The javascript
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
516 * engine should work, but it's not an identical behavior.
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
517 */
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
518 static void
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
519 webkit_set_groupchat(GtkWebView *webview)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
520 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
521 gtk_webview_safe_execute_script(webview, "document.getElementById('Chat').className = 'groupchat'");
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
522 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
523
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
524 static void
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
525 webkit_on_webview_destroy(GtkObject *object, gpointer data)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
526 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
527 g_object_unref(G_OBJECT(data));
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
528 g_object_set_data(G_OBJECT(object), MESSAGE_STYLE_KEY, NULL);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
529 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
530
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
531 /*****************************************************************************
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
532 * Public API functions
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
533 *****************************************************************************/
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
534
32630
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
535 const GHashTable *
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
536 pidgin_conversation_theme_get_info(const PidginConvTheme *theme)
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
537 {
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
538 PidginConvThemePrivate *priv;
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
539 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
540 return priv->info;
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
541 }
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
542
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
543 void
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
544 pidgin_conversation_theme_set_info(PidginConvTheme *theme, GHashTable *info)
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
545 {
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
546 PidginConvThemePrivate *priv;
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
547 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
548
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
549 if (priv->info)
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
550 g_hash_table_destroy(priv->info);
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
551
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
552 priv->info = info;
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
553 }
2ca29cd62db8 Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32629
diff changeset
554
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
555 void
32647
3e27c95ab8e6 Fix a leak. pidgin_conversation_theme_add_variant should only be
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32646
diff changeset
556 pidgin_conversation_theme_add_variant(PidginConvTheme *theme, char *variant)
32645
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
557 {
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
558 PidginConvThemePrivate *priv;
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
559 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
560
32647
3e27c95ab8e6 Fix a leak. pidgin_conversation_theme_add_variant should only be
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32646
diff changeset
561 priv->variants = g_list_prepend(priv->variants, variant);
32645
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
562 }
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
563
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
564 const char *
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
565 pidgin_conversation_theme_get_variant(PidginConvTheme *theme)
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
566 {
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
567 PidginConvThemePrivate *priv;
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
568 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
569
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
570 return g_strdup(priv->variant);
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
571 }
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
572
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
573 void
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
574 pidgin_conversation_theme_set_variant(PidginConvTheme *theme, const char *variant)
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
575 {
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
576 PidginConvThemePrivate *priv;
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
577 const GValue *val;
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
578 char *prefname;
32645
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
579 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
580
32645
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
581 g_free(priv->variant);
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
582 priv->variant = g_strdup(variant);
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
583
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
584 val = get_key(priv, "CFBundleIdentifier", FALSE);
32646
f857a6db3bd9 Use a consistent prefs name. It should be conversation*s* to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32645
diff changeset
585 prefname = g_strdup_printf(PIDGIN_PREFS_ROOT "/conversations/themes/%s/variant",
32645
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
586 g_value_get_string(val));
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
587 purple_prefs_set_string(prefname, variant);
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
588 g_free(prefname);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
589 }
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
590
32645
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
591 const GList *
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
592 pidgin_conversation_theme_get_variants(PidginConvTheme *theme)
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
593 {
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
594 PidginConvThemePrivate *priv;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
595 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
596
32645
a7a6770f26e2 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32644
diff changeset
597 return priv->variants;
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
598 }
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
599
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
600 PidginConvTheme *
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
601 pidgin_conversation_theme_copy(const PidginConvTheme *theme)
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
602 {
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
603 PidginConvTheme *ret;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
604 PidginConvThemePrivate *old, *new;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
605
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
606 old = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
607 ret = g_object_new(PIDGIN_TYPE_CONV_THEME, "directory", purple_theme_get_dir(PURPLE_THEME(theme)), NULL);
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
608 new = PIDGIN_CONV_THEME_GET_PRIVATE(ret);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
609
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
610 new->variant = g_strdup(old->variant);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
611
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
612 new->template_html = g_strdup(old->template_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
613 new->header_html = g_strdup(old->header_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
614 new->footer_html = g_strdup(old->footer_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
615 new->incoming_content_html = g_strdup(old->incoming_content_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
616 new->outgoing_content_html = g_strdup(old->outgoing_content_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
617 new->incoming_next_content_html = g_strdup(old->incoming_next_content_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
618 new->outgoing_next_content_html = g_strdup(old->outgoing_next_content_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
619 new->status_html = g_strdup(old->status_html);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
620 new->basestyle_css = g_strdup(old->basestyle_css);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
621
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
622 return ret;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
623 }
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
624
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
625 char *
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
626 pidgin_conversation_theme_get_css(PidginConvTheme *theme)
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
627 {
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
628 PidginConvThemePrivate *priv;
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
629 const char *dir;
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
630
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
631 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
632
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
633 dir = purple_theme_get_dir(PURPLE_THEME(theme));
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
634 if (!priv->variant) {
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
635 return g_build_filename(dir, "Contents", "Resources", "main.css", NULL);
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
636 } else {
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
637 char *file = g_strdup_printf("%s.css", priv->variant);
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
638 char *ret = g_build_filename(dir, "Contents", "Resources", "Variants", file, NULL);
32623
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
639 g_free(file);
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
640 return ret;
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
641 }
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
642 }
2e8c905a5e74 Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32622
diff changeset
643
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
644 /**
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
645 * Called when either a new PurpleConversation is created
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
646 * or when a PidginConversation changes its active PurpleConversation
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
647 * This will not change the theme if the theme is already set.
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
648 * (This is to prevent accidental theme changes if a new
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
649 * PurpleConversation gets added.
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
650 *
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
651 * FIXME: it's not at all clear to me as to how
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
652 * Adium themes handle the case when the PurpleConversation
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
653 * changes.
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
654 */
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
655 void
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
656 pidgin_conversation_theme_apply(PidginConvTheme *theme, PurpleConversation *conv)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
657 {
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
658 GtkWidget *webkit = PIDGIN_CONVERSATION(conv)->webview;
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
659 const char *themedir;
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
660 char *header, *footer;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
661 char *template;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
662 char *basedir;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
663 char *baseuri;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
664 PidginConvTheme *oldTheme;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
665 PidginConvTheme *copy;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
666 PidginConvThemePrivate *priv;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
667
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
668 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
669
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
670 oldTheme = g_object_get_data(G_OBJECT(webkit), MESSAGE_STYLE_KEY);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
671 if (oldTheme)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
672 return;
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
673
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
674 g_assert(theme);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
675
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
676 themedir = purple_theme_get_dir(PURPLE_THEME(theme));
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
677
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
678 header = replace_header_tokens(get_header_html(priv, themedir), conv);
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
679 footer = replace_header_tokens(get_footer_html(priv, themedir), conv);
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
680 template = replace_template_tokens(theme, get_template_html(priv, themedir), header, footer);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
681
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
682 g_assert(template);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
683
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
684 purple_debug_info("webkit", "template: %s\n", template);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
685
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
686 set_theme_webkit_settings(WEBKIT_WEB_VIEW(webkit), theme);
32641
7219f52cdfa3 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32633
diff changeset
687 basedir = g_build_filename(themedir, "Contents", "Resources", "Template.html", NULL);
32629
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
688 baseuri = g_strdup_printf("file://%s", basedir);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
689 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
690
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
691 copy = pidgin_conversation_theme_copy(theme);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
692 g_object_set_data(G_OBJECT(webkit), MESSAGE_STYLE_KEY, copy);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
693
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
694 g_object_unref(G_OBJECT(theme));
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
695 /* I need to unref this style when the webkit object destroys */
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
696 g_signal_connect(G_OBJECT(webkit), "destroy", G_CALLBACK(webkit_on_webview_destroy), copy);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
697
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
698 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
699 webkit_set_groupchat(GTK_WEBVIEW(webkit));
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
700 g_free(basedir);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
701 g_free(baseuri);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
702 g_free(header);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
703 g_free(footer);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
704 g_free(template);
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
705 }
dc835fb3dcd3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32623
diff changeset
706