pidgin/gtkconv-theme.c

Tue, 29 Oct 2013 19:01:56 +0100

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Tue, 29 Oct 2013 19:01:56 +0100
changeset 34502
433382371e89
parent 33941
80fcf7f86e4a
child 35060
195dbb3b6432
permissions
-rw-r--r--

Request API: datasheet field

32536
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
1 /*
91b09760ab0c 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
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
3 *
91b09760ab0c 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
91b09760ab0c 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
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
6 * source distribution.
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
7 *
91b09760ab0c 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
91b09760ab0c 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
91b09760ab0c 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
91b09760ab0c 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.
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
12 *
91b09760ab0c 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,
91b09760ab0c 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
91b09760ab0c 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
91b09760ab0c 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.
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
17 *
91b09760ab0c 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
91b09760ab0c 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
91b09760ab0c 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
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
21 */
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
22
33898
0f4b2e3ac978 win32: fix all warnings about improper winsock2.h include point
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
23 #include "internal.h"
0f4b2e3ac978 win32: fix all warnings about improper winsock2.h include point
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
24
32536
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
25 #include "gtkconv-theme.h"
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
26
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
27 #include "conversation.h"
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
28 #include "debug.h"
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
29 #include "prefs.h"
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
30 #include "xmlnode.h"
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
31
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
32 #include "pidgin.h"
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
33 #include "gtkconv.h"
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
34 #include "gtkwebview.h"
32536
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
35
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
36 #include <stdlib.h>
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
37 #include <string.h>
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
38
32536
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
39 #define PIDGIN_CONV_THEME_GET_PRIVATE(Gobject) \
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
40 (G_TYPE_INSTANCE_GET_PRIVATE((Gobject), PIDGIN_TYPE_CONV_THEME, PidginConvThemePrivate))
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
41
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
42 /******************************************************************************
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
43 * Structs
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
44 *****************************************************************************/
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
45
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
46 typedef struct {
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
47 /* current config options */
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
48 char *variant; /* allowed to be NULL if there are no variants */
32562
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
49 GList *variants;
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
50
32545
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
51 /* Info.plist keys/values */
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
52 GHashTable *info;
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
53
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
54 /* caches */
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
55 char *template_html;
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
56 char *header_html;
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
57 char *footer_html;
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
58 char *topic_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
59 char *status_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
60 char *content_html;
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
61 char *incoming_content_html;
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
62 char *outgoing_content_html;
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
63 char *incoming_next_content_html;
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
64 char *outgoing_next_content_html;
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
65 char *incoming_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
66 char *outgoing_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
67 char *incoming_next_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
68 char *outgoing_next_context_html;
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
69 char *basestyle_css;
33384
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
70
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
71 GArray *nick_colors;
32536
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
72 } PidginConvThemePrivate;
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
73
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
74 /******************************************************************************
32545
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
75 * Enums
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
76 *****************************************************************************/
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
77
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
78 enum {
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
79 PROP_ZERO = 0,
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
80 PROP_INFO,
32598
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
81 PROP_VARIANT,
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
82 PROP_LAST
32545
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
83 };
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
84
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
85 /******************************************************************************
32598
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
86 * Globals
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
87 *****************************************************************************/
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
88
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
89 static GObjectClass *parent_class = NULL;
32639
ed0e39d65ddc Fix compile with glib<2.26.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32638
diff changeset
90 #if GLIB_CHECK_VERSION(2,26,0)
32598
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
91 static GParamSpec *properties[PROP_LAST];
32639
ed0e39d65ddc Fix compile with glib<2.26.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32638
diff changeset
92 #endif
32598
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
93
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
94 /******************************************************************************
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
95 * Helper Functions
32536
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
96 *****************************************************************************/
91b09760ab0c Add some boilerplate Conversation theme GObjects. These don't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
97
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
98 static const GValue *
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
99 get_key(PidginConvThemePrivate *priv, const char *key, gboolean specific)
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
100 {
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
101 GValue *val = NULL;
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
102
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
103 /* Try variant-specific key */
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
104 if (specific && priv->variant) {
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
105 char *name = g_strdup_printf("%s:%s", key, priv->variant);
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
106 val = g_hash_table_lookup(priv->info, name);
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
107 g_free(name);
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
108 }
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
109
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
110 /* Try generic key */
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
111 if (!val) {
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
112 val = g_hash_table_lookup(priv->info, key);
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
113 }
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
114
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
115 return val;
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
116 }
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
117
32725
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
118 /* The template path can either come from the theme, or can
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
119 * be stock Template.html that comes with Pidgin */
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
120 static char *
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
121 get_template_path(const char *dir)
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
122 {
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
123 char *file;
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
124
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
125 file = g_build_filename(dir, "Contents", "Resources", "Template.html", NULL);
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
126
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
127 if (!g_file_test(file, G_FILE_TEST_EXISTS)) {
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
128 g_free(file);
33941
80fcf7f86e4a win32: globally define _WIN32_WINNT macro, tune config, move gtkconv themes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33898
diff changeset
129 #ifdef _WIN32
80fcf7f86e4a win32: globally define _WIN32_WINNT macro, tune config, move gtkconv themes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33898
diff changeset
130 file = g_build_filename(DATADIR, "theme", "Template.html", NULL);
80fcf7f86e4a win32: globally define _WIN32_WINNT macro, tune config, move gtkconv themes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33898
diff changeset
131 #else
32960
1beafd9dbad4 Add a simple theme that replicates our current look.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32775
diff changeset
132 file = g_build_filename(DATADIR, "pidgin", "theme", "Template.html", NULL);
33941
80fcf7f86e4a win32: globally define _WIN32_WINNT macro, tune config, move gtkconv themes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33898
diff changeset
133 #endif
32725
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
134 }
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
135
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
136 return file;
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
137 }
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
138
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
139 static const char *
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
140 get_template_html(PidginConvThemePrivate *priv, const char *dir)
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
141 {
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
142 char *file;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
143
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
144 if (priv->template_html)
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
145 return priv->template_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
146
32725
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
147 file = get_template_path(dir);
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
148
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
149 if (!g_file_get_contents(file, &priv->template_html, NULL, NULL)) {
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
150 purple_debug_error("webkit", "Could not locate a Template.html (%s)\n", file);
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
151 priv->template_html = g_strdup("");
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
152 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
153 g_free(file);
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
154
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
155 return priv->template_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
156 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
157
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
158 static const char *
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
159 get_basestyle_css(PidginConvThemePrivate *priv, const char *dir)
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
160 {
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
161 char *file;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
162
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
163 if (priv->basestyle_css)
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
164 return priv->basestyle_css;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
165
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
166 file = g_build_filename(dir, "Contents", "Resources", "main.css", NULL);
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
167 if (!g_file_get_contents(file, &priv->basestyle_css, NULL, NULL))
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
168 priv->basestyle_css = g_strdup("");
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
169 g_free(file);
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
170
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
171 return priv->basestyle_css;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
172 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
173
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
174 static const char *
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
175 get_header_html(PidginConvThemePrivate *priv, const char *dir)
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
176 {
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
177 char *file;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
178
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
179 if (priv->header_html)
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
180 return priv->header_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
181
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
182 file = g_build_filename(dir, "Contents", "Resources", "Header.html", NULL);
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
183 if (!g_file_get_contents(file, &priv->header_html, NULL, NULL))
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
184 priv->header_html = g_strdup("");
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
185 g_free(file);
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
186
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
187 return priv->header_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
188 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
189
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
190 static const char *
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
191 get_footer_html(PidginConvThemePrivate *priv, const char *dir)
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
192 {
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
193 char *file;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
194
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
195 if (priv->footer_html)
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
196 return priv->footer_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
197
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
198 file = g_build_filename(dir, "Contents", "Resources", "Footer.html", NULL);
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
199 if (!g_file_get_contents(file, &priv->footer_html, NULL, NULL))
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
200 priv->footer_html = g_strdup("");
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
201 g_free(file);
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
202
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
203 return priv->footer_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
204 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
205
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
206 static const char *
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
207 get_topic_html(PidginConvThemePrivate *priv, const char *dir)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
208 {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
209 char *file;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
210
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
211 if (priv->topic_html)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
212 return priv->topic_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
213
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
214 file = g_build_filename(dir, "Contents", "Resources", "Topic.html", NULL);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
215 if (!g_file_get_contents(file, &priv->topic_html, NULL, NULL)) {
32584
7bf37989b484 Add some missing newlines in debug output.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32576
diff changeset
216 purple_debug_info("webkit", "%s could not find Resources/Topic.html\n", dir);
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
217 priv->topic_html = g_strdup("");
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
218 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
219 g_free(file);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
220
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
221 return priv->topic_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
222 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
223
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
224 static const char *
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
225 get_content_html(PidginConvThemePrivate *priv, const char *dir)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
226 {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
227 char *file;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
228
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
229 if (priv->content_html)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
230 return priv->content_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
231
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
232 file = g_build_filename(dir, "Contents", "Resources", "Content.html", NULL);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
233 if (!g_file_get_contents(file, &priv->content_html, NULL, NULL)) {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
234 purple_debug_info("webkit", "%s did not have a Content.html\n", dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
235 priv->content_html = g_strdup("");
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
236 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
237 g_free(file);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
238
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
239 return priv->content_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
240 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
241
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
242 static const char *
32587
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
243 get_status_html(PidginConvThemePrivate *priv, const char *dir)
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
244 {
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
245 char *file;
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
246
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
247 if (priv->status_html)
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
248 return priv->status_html;
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
249
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
250 file = g_build_filename(dir, "Contents", "Resources", "Status.html", NULL);
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
251 if (!g_file_get_contents(file, &priv->status_html, NULL, NULL)) {
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
252 purple_debug_info("webkit", "%s could not find Resources/Status.html\n", dir);
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
253 priv->status_html = g_strdup(get_content_html(priv, dir));
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
254 }
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
255 g_free(file);
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
256
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
257 return priv->status_html;
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
258 }
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
259
27e41510a278 Fix fallback of Status.html to Content.html.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32584
diff changeset
260 static const char *
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
261 get_incoming_content_html(PidginConvThemePrivate *priv, const char *dir)
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
262 {
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
263 char *file;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
264
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
265 if (priv->incoming_content_html)
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
266 return priv->incoming_content_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
267
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
268 file = g_build_filename(dir, "Contents", "Resources", "Incoming", "Content.html", NULL);
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
269 if (!g_file_get_contents(file, &priv->incoming_content_html, NULL, NULL)) {
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
270 purple_debug_info("webkit", "%s did not have a Incoming/Content.html\n", dir);
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
271 priv->incoming_content_html = g_strdup(get_content_html(priv, dir));
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
272 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
273 g_free(file);
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
274
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
275 return priv->incoming_content_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
276 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
277
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
278 static const char *
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
279 get_incoming_next_content_html(PidginConvThemePrivate *priv, const char *dir)
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
280 {
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
281 char *file;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
282
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
283 if (priv->incoming_next_content_html)
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
284 return priv->incoming_next_content_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
285
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
286 file = g_build_filename(dir, "Contents", "Resources", "Incoming", "NextContent.html", NULL);
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
287 if (!g_file_get_contents(file, &priv->incoming_next_content_html, NULL, NULL)) {
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
288 priv->incoming_next_content_html = g_strdup(get_incoming_content_html(priv, dir));
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
289 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
290 g_free(file);
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
291
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
292 return priv->incoming_next_content_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
293 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
294
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
295 static const char *
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
296 get_incoming_context_html(PidginConvThemePrivate *priv, const char *dir)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
297 {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
298 char *file;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
299
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
300 if (priv->incoming_context_html)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
301 return priv->incoming_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
302
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
303 file = g_build_filename(dir, "Contents", "Resources", "Incoming", "Context.html", NULL);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
304 if (!g_file_get_contents(file, &priv->incoming_context_html, NULL, NULL)) {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
305 purple_debug_info("webkit", "%s did not have a Incoming/Context.html\n", dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
306 priv->incoming_context_html = g_strdup(get_incoming_content_html(priv, dir));
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
307 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
308 g_free(file);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
309
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
310 return priv->incoming_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
311 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
312
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
313 static const char *
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
314 get_incoming_next_context_html(PidginConvThemePrivate *priv, const char *dir)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
315 {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
316 char *file;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
317
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
318 if (priv->incoming_next_context_html)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
319 return priv->incoming_next_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
320
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
321 file = g_build_filename(dir, "Contents", "Resources", "Incoming", "NextContext.html", NULL);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
322 if (!g_file_get_contents(file, &priv->incoming_next_context_html, NULL, NULL)) {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
323 priv->incoming_next_context_html = g_strdup(get_incoming_context_html(priv, dir));
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
324 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
325 g_free(file);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
326
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
327 return priv->incoming_next_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
328 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
329
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
330 static const char *
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
331 get_outgoing_content_html(PidginConvThemePrivate *priv, const char *dir)
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
332 {
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
333 char *file;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
334
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
335 if (priv->outgoing_content_html)
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
336 return priv->outgoing_content_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
337
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
338 file = g_build_filename(dir, "Contents", "Resources", "Outgoing", "Content.html", NULL);
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
339 if (!g_file_get_contents(file, &priv->outgoing_content_html, NULL, NULL)) {
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
340 priv->outgoing_content_html = g_strdup(get_incoming_content_html(priv, dir));
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
341 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
342 g_free(file);
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
343
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
344 return priv->outgoing_content_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
345 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
346
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
347 static const char *
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
348 get_outgoing_next_content_html(PidginConvThemePrivate *priv, const char *dir)
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
349 {
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
350 char *file;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
351
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
352 if (priv->outgoing_next_content_html)
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
353 return priv->outgoing_next_content_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
354
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
355 file = g_build_filename(dir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL);
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
356 if (!g_file_get_contents(file, &priv->outgoing_next_content_html, NULL, NULL)) {
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
357 priv->outgoing_next_content_html = g_strdup(get_outgoing_content_html(priv, dir));
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
358 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
359
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
360 return priv->outgoing_next_content_html;
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
361 }
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
362
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
363 static const char *
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
364 get_outgoing_context_html(PidginConvThemePrivate *priv, const char *dir)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
365 {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
366 char *file;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
367
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
368 if (priv->outgoing_context_html)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
369 return priv->outgoing_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
370
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
371 file = g_build_filename(dir, "Contents", "Resources", "Outgoing", "Context.html", NULL);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
372 if (!g_file_get_contents(file, &priv->outgoing_context_html, NULL, NULL)) {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
373 priv->outgoing_context_html = g_strdup(get_incoming_context_html(priv, dir));
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
374 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
375 g_free(file);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
376
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
377 return priv->outgoing_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
378 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
379
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
380 static const char *
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
381 get_outgoing_next_context_html(PidginConvThemePrivate *priv, const char *dir)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
382 {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
383 char *file;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
384
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
385 if (priv->outgoing_next_context_html)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
386 return priv->outgoing_next_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
387
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
388 file = g_build_filename(dir, "Contents", "Resources", "Outgoing", "NextContext.html", NULL);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
389 if (!g_file_get_contents(file, &priv->outgoing_next_context_html, NULL, NULL)) {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
390 priv->outgoing_next_context_html = g_strdup(get_outgoing_context_html(priv, dir));
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
391 }
32728
bc0b95512380 Fix a small leak.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32725
diff changeset
392 g_free(file);
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
393
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
394 return priv->outgoing_next_context_html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
395 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
396
32598
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
397 static void
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
398 _set_variant(PidginConvTheme *theme, const char *variant)
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
399 {
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
400 PidginConvThemePrivate *priv;
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
401 const GValue *val;
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
402 char *prefname;
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
403
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
404 g_return_if_fail(theme != NULL);
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
405 g_return_if_fail(variant != NULL);
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
406
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
407 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
408
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
409 g_free(priv->variant);
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
410 priv->variant = g_strdup(variant);
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
411
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
412 val = get_key(priv, "CFBundleIdentifier", FALSE);
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
413 prefname = g_strdup_printf(PIDGIN_PREFS_ROOT "/conversations/themes/%s/variant",
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
414 g_value_get_string(val));
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
415 purple_prefs_set_string(prefname, variant);
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
416 g_free(prefname);
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
417 }
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
418
32599
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
419 /******************************************************************************
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
420 * GObject Stuff
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
421 *****************************************************************************/
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
422
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
423 static void
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
424 pidgin_conv_theme_get_property(GObject *obj, guint param_id, GValue *value,
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
425 GParamSpec *psec)
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
426 {
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
427 PidginConvTheme *theme = PIDGIN_CONV_THEME(obj);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
428
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
429 switch (param_id) {
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
430 case PROP_INFO:
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
431 g_value_set_boxed(value, (gpointer)pidgin_conversation_theme_get_info(theme));
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
432 break;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
433
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
434 case PROP_VARIANT:
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
435 g_value_set_string(value, pidgin_conversation_theme_get_variant(theme));
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
436 break;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
437
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
438 default:
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
439 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
440 break;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
441 }
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
442 }
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
443
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
444 static void
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
445 pidgin_conv_theme_set_property(GObject *obj, guint param_id, const GValue *value,
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
446 GParamSpec *psec)
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
447 {
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
448 PidginConvTheme *theme = PIDGIN_CONV_THEME(obj);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
449
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
450 switch (param_id) {
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
451 case PROP_INFO:
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
452 pidgin_conversation_theme_set_info(theme, g_value_get_boxed(value));
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
453 break;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
454
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
455 case PROP_VARIANT:
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
456 _set_variant(theme, g_value_get_string(value));
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
457 break;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
458
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
459 default:
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
460 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
461 break;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
462 }
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
463 }
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
464
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
465 static void
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
466 pidgin_conv_theme_init(GTypeInstance *instance,
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
467 gpointer klass)
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
468 {
33892
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33642
diff changeset
469 #if 0
32599
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
470 PidginConvThemePrivate *priv;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
471
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
472 priv = PIDGIN_CONV_THEME_GET_PRIVATE(instance);
33892
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33642
diff changeset
473 #endif
32599
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
474 }
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
475
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
476 static void
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
477 pidgin_conv_theme_finalize(GObject *obj)
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
478 {
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
479 PidginConvThemePrivate *priv;
32600
26c310f9e08b Don't leak variant name and list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32599
diff changeset
480 GList *list;
32599
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
481
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
482 priv = PIDGIN_CONV_THEME_GET_PRIVATE(obj);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
483
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
484 g_free(priv->template_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
485 g_free(priv->header_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
486 g_free(priv->footer_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
487 g_free(priv->topic_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
488 g_free(priv->status_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
489 g_free(priv->content_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
490 g_free(priv->incoming_content_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
491 g_free(priv->outgoing_content_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
492 g_free(priv->incoming_next_content_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
493 g_free(priv->outgoing_next_content_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
494 g_free(priv->incoming_context_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
495 g_free(priv->outgoing_context_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
496 g_free(priv->incoming_next_context_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
497 g_free(priv->outgoing_next_context_html);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
498 g_free(priv->basestyle_css);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
499
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
500 if (priv->info)
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
501 g_hash_table_destroy(priv->info);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
502
32600
26c310f9e08b Don't leak variant name and list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32599
diff changeset
503 list = priv->variants;
26c310f9e08b Don't leak variant name and list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32599
diff changeset
504 while (list) {
26c310f9e08b Don't leak variant name and list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32599
diff changeset
505 g_free(list->data);
26c310f9e08b Don't leak variant name and list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32599
diff changeset
506 list = g_list_delete_link(list, list);
26c310f9e08b Don't leak variant name and list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32599
diff changeset
507 }
26c310f9e08b Don't leak variant name and list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32599
diff changeset
508 g_free(priv->variant);
26c310f9e08b Don't leak variant name and list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32599
diff changeset
509
33642
a99637d00287 Fix an assertion.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33384
diff changeset
510 if (priv->nick_colors)
a99637d00287 Fix an assertion.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33384
diff changeset
511 g_array_unref(priv->nick_colors);
33384
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
512
32599
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
513 parent_class->finalize(obj);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
514 }
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
515
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
516 static void
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
517 pidgin_conv_theme_class_init(PidginConvThemeClass *klass)
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
518 {
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
519 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
520 GParamSpec *pspec;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
521
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
522 parent_class = g_type_class_peek_parent(klass);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
523
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
524 g_type_class_add_private(klass, sizeof(PidginConvThemePrivate));
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
525
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
526 obj_class->get_property = pidgin_conv_theme_get_property;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
527 obj_class->set_property = pidgin_conv_theme_set_property;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
528 obj_class->finalize = pidgin_conv_theme_finalize;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
529
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
530 /* INFO */
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
531 pspec = g_param_spec_boxed("info", "Info",
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
532 "The information about this theme",
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
533 G_TYPE_HASH_TABLE,
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
534 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
535 g_object_class_install_property(obj_class, PROP_INFO, pspec);
32639
ed0e39d65ddc Fix compile with glib<2.26.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32638
diff changeset
536 #if GLIB_CHECK_VERSION(2,26,0)
32599
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
537 properties[PROP_INFO] = pspec;
32639
ed0e39d65ddc Fix compile with glib<2.26.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32638
diff changeset
538 #endif
32599
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
539
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
540 /* VARIANT */
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
541 pspec = g_param_spec_string("variant", "Variant",
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
542 "The current variant for this theme",
32638
574085136af7 The variant property is not construct-only.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32601
diff changeset
543 NULL, G_PARAM_READWRITE);
32599
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
544 g_object_class_install_property(obj_class, PROP_VARIANT, pspec);
32639
ed0e39d65ddc Fix compile with glib<2.26.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32638
diff changeset
545 #if GLIB_CHECK_VERSION(2,26,0)
32599
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
546 properties[PROP_VARIANT] = pspec;
32639
ed0e39d65ddc Fix compile with glib<2.26.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32638
diff changeset
547 #endif
32599
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
548 }
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
549
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
550 GType
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
551 pidgin_conversation_theme_get_type(void)
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
552 {
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
553 static GType type = 0;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
554 if (type == 0) {
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
555 static const GTypeInfo info = {
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
556 sizeof(PidginConvThemeClass),
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
557 NULL, /* base_init */
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
558 NULL, /* base_finalize */
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
559 (GClassInitFunc)pidgin_conv_theme_class_init, /* class_init */
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
560 NULL, /* class_finalize */
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
561 NULL, /* class_data */
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
562 sizeof(PidginConvTheme),
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
563 0, /* n_preallocs */
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
564 pidgin_conv_theme_init, /* instance_init */
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
565 NULL, /* value table */
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
566 };
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
567 type = g_type_register_static(PURPLE_TYPE_THEME,
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
568 "PidginConvTheme", &info, 0);
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
569 }
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
570 return type;
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
571 }
670b01df8023 Rearrange to drop the prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32598
diff changeset
572
32544
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
573 /*****************************************************************************
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
574 * Public API functions
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
575 *****************************************************************************/
4cf095ee82e3 Copy theme-to-conversation loading stuff into the GObject code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32540
diff changeset
576
32545
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
577 const GHashTable *
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
578 pidgin_conversation_theme_get_info(const PidginConvTheme *theme)
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
579 {
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
580 PidginConvThemePrivate *priv;
32576
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
581
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
582 g_return_val_if_fail(theme != NULL, NULL);
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
583
32545
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
584 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
585 return priv->info;
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
586 }
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
587
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
588 void
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
589 pidgin_conversation_theme_set_info(PidginConvTheme *theme, GHashTable *info)
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
590 {
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
591 PidginConvThemePrivate *priv;
32576
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
592
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
593 g_return_if_fail(theme != NULL);
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
594
32545
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
595 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
596
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
597 if (priv->info)
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
598 g_hash_table_destroy(priv->info);
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
599
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
600 priv->info = info;
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
601 }
1b21192ab58a Move conversation theme loading into the PidginConvThemeLoader GObject
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32544
diff changeset
602
32573
83bf257530d0 Add a function for lookup of Info.plist entries.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32571
diff changeset
603 const GValue *
83bf257530d0 Add a function for lookup of Info.plist entries.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32571
diff changeset
604 pidgin_conversation_theme_lookup(PidginConvTheme *theme, const char *key, gboolean specific)
83bf257530d0 Add a function for lookup of Info.plist entries.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32571
diff changeset
605 {
83bf257530d0 Add a function for lookup of Info.plist entries.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32571
diff changeset
606 PidginConvThemePrivate *priv;
32576
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
607
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
608 g_return_val_if_fail(theme != NULL, NULL);
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
609
32573
83bf257530d0 Add a function for lookup of Info.plist entries.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32571
diff changeset
610 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
83bf257530d0 Add a function for lookup of Info.plist entries.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32571
diff changeset
611
83bf257530d0 Add a function for lookup of Info.plist entries.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32571
diff changeset
612 return get_key(priv, key, specific);
83bf257530d0 Add a function for lookup of Info.plist entries.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32571
diff changeset
613 }
83bf257530d0 Add a function for lookup of Info.plist entries.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32571
diff changeset
614
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
615 const char *
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
616 pidgin_conversation_theme_get_template(PidginConvTheme *theme, PidginConvThemeTemplateType type)
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
617 {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
618 PidginConvThemePrivate *priv;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
619 const char *dir;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
620 const char *html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
621
32576
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
622 g_return_val_if_fail(theme != NULL, NULL);
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
623
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
624 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
625 dir = purple_theme_get_dir(PURPLE_THEME(theme));
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
626
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
627 switch (type) {
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
628 case PIDGIN_CONVERSATION_THEME_TEMPLATE_MAIN:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
629 html = get_template_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
630 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
631 case PIDGIN_CONVERSATION_THEME_TEMPLATE_HEADER:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
632 html = get_header_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
633 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
634 case PIDGIN_CONVERSATION_THEME_TEMPLATE_FOOTER:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
635 html = get_footer_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
636 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
637 case PIDGIN_CONVERSATION_THEME_TEMPLATE_TOPIC:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
638 html = get_topic_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
639 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
640 case PIDGIN_CONVERSATION_THEME_TEMPLATE_STATUS:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
641 html = get_status_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
642 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
643 case PIDGIN_CONVERSATION_THEME_TEMPLATE_CONTENT:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
644 html = get_content_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
645 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
646 case PIDGIN_CONVERSATION_THEME_TEMPLATE_INCOMING_CONTENT:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
647 html = get_incoming_content_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
648 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
649 case PIDGIN_CONVERSATION_THEME_TEMPLATE_INCOMING_NEXT_CONTENT:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
650 html = get_incoming_next_content_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
651 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
652 case PIDGIN_CONVERSATION_THEME_TEMPLATE_INCOMING_CONTEXT:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
653 html = get_incoming_context_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
654 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
655 case PIDGIN_CONVERSATION_THEME_TEMPLATE_INCOMING_NEXT_CONTEXT:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
656 html = get_incoming_next_context_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
657 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
658 case PIDGIN_CONVERSATION_THEME_TEMPLATE_OUTGOING_CONTENT:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
659 html = get_outgoing_content_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
660 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
661 case PIDGIN_CONVERSATION_THEME_TEMPLATE_OUTGOING_NEXT_CONTENT:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
662 html = get_outgoing_next_content_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
663 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
664 case PIDGIN_CONVERSATION_THEME_TEMPLATE_OUTGOING_CONTEXT:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
665 html = get_outgoing_context_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
666 break;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
667 case PIDGIN_CONVERSATION_THEME_TEMPLATE_OUTGOING_NEXT_CONTEXT:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
668 html = get_outgoing_next_context_html(priv, dir);
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
669 break;
32574
56dc04a81f4b Add template lookup for 'basestyle' CSS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32573
diff changeset
670 case PIDGIN_CONVERSATION_THEME_TEMPLATE_BASESTYLE_CSS:
56dc04a81f4b Add template lookup for 'basestyle' CSS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32573
diff changeset
671 html = get_basestyle_css(priv, dir);
56dc04a81f4b Add template lookup for 'basestyle' CSS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32573
diff changeset
672 break;
32571
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
673 default:
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
674 purple_debug_error("gtkconv-theme",
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
675 "Requested invalid template type (%d) for theme %s.\n",
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
676 type, purple_theme_get_name(PURPLE_THEME(theme)));
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
677 html = NULL;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
678 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
679
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
680 return html;
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
681 }
04b564092222 Add an accessor for template data. Also, fix some fallbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32566
diff changeset
682
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
683 void
32564
b711e92242da Fix a leak. pidgin_conversation_theme_add_variant should only be
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32563
diff changeset
684 pidgin_conversation_theme_add_variant(PidginConvTheme *theme, char *variant)
32562
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
685 {
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
686 PidginConvThemePrivate *priv;
32576
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
687
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
688 g_return_if_fail(theme != NULL);
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
689 g_return_if_fail(variant != NULL);
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
690
32562
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
691 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
692
32564
b711e92242da Fix a leak. pidgin_conversation_theme_add_variant should only be
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32563
diff changeset
693 priv->variants = g_list_prepend(priv->variants, variant);
32562
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
694 }
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
695
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
696 const char *
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
697 pidgin_conversation_theme_get_variant(PidginConvTheme *theme)
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
698 {
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
699 PidginConvThemePrivate *priv;
32576
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
700
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
701 g_return_val_if_fail(theme != NULL, NULL);
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
702
32562
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
703 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
704
32601
36daedfec84a Fix a leak. This strdup shouldn't be here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32600
diff changeset
705 return priv->variant;
32562
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
706 }
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
707
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
708 void
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
709 pidgin_conversation_theme_set_variant(PidginConvTheme *theme, const char *variant)
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
710 {
32598
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
711 _set_variant(theme, variant);
32639
ed0e39d65ddc Fix compile with glib<2.26.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32638
diff changeset
712 #if GLIB_CHECK_VERSION(2,26,0)
32598
e824d9bbe6ff Make the current variant a property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
713 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_VARIANT]);
32639
ed0e39d65ddc Fix compile with glib<2.26.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32638
diff changeset
714 #else
ed0e39d65ddc Fix compile with glib<2.26.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32638
diff changeset
715 g_object_notify(G_OBJECT(theme), "variant");
ed0e39d65ddc Fix compile with glib<2.26.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32638
diff changeset
716 #endif
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
717 }
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
718
32562
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
719 const GList *
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
720 pidgin_conversation_theme_get_variants(PidginConvTheme *theme)
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
721 {
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
722 PidginConvThemePrivate *priv;
32576
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
723
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
724 g_return_val_if_fail(theme != NULL, NULL);
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
725
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
726 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
727
32562
9c094ffe9333 Load the list of variants when building the theme.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32561
diff changeset
728 return priv->variants;
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
729 }
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
730
32575
eb4fc932fae9 Apply conversation theme when opening the GTK conversation. All the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32574
diff changeset
731 char *
eb4fc932fae9 Apply conversation theme when opening the GTK conversation. All the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32574
diff changeset
732 pidgin_conversation_theme_get_template_path(PidginConvTheme *theme)
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
733 {
32575
eb4fc932fae9 Apply conversation theme when opening the GTK conversation. All the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32574
diff changeset
734 const char *dir;
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
735
32576
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
736 g_return_val_if_fail(theme != NULL, NULL);
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
737
32575
eb4fc932fae9 Apply conversation theme when opening the GTK conversation. All the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32574
diff changeset
738 dir = purple_theme_get_dir(PURPLE_THEME(theme));
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
739
32725
b8c479aec53b Fix fallback to builtin Template.html file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32639
diff changeset
740 return get_template_path(dir);
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
741 }
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
742
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
743 char *
32575
eb4fc932fae9 Apply conversation theme when opening the GTK conversation. All the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32574
diff changeset
744 pidgin_conversation_theme_get_css_path(PidginConvTheme *theme)
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
745 {
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
746 PidginConvThemePrivate *priv;
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
747 const char *dir;
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
748
32576
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
749 g_return_val_if_fail(theme != NULL, NULL);
06ed3d7e9e72 Add some NULL checks. Now it should not crash even if you don't have
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32575
diff changeset
750
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
751 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
752
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
753 dir = purple_theme_get_dir(PURPLE_THEME(theme));
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
754 if (!priv->variant) {
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
755 return g_build_filename(dir, "Contents", "Resources", "main.css", NULL);
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
756 } else {
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
757 char *file = g_strdup_printf("%s.css", priv->variant);
32558
e9065eebef24 Lookup style key information from the hash table instead of the struct
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32549
diff changeset
758 char *ret = g_build_filename(dir, "Contents", "Resources", "Variants", file, NULL);
32540
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
759 g_free(file);
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
760 return ret;
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
761 }
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
762 }
1e50f90abb9b Attempt to move the message style object from the plugin into the new
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32539
diff changeset
763
33384
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
764 GArray *
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
765 pidgin_conversation_theme_get_nick_colors(PidginConvTheme *theme)
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
766 {
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
767 PidginConvThemePrivate *priv;
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
768 const char *dir;
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
769
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
770 g_return_val_if_fail(theme != NULL, NULL);
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
771
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
772 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
773
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
774 dir = purple_theme_get_dir(PURPLE_THEME(theme));
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
775 if (NULL == priv->nick_colors)
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
776 {
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
777 char *file = g_build_filename(dir, "Contents", "Resources", "Incoming", "SenderColors.txt", NULL);
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
778 char *contents;
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
779 priv->nick_colors = g_array_new(FALSE, FALSE, sizeof(GdkColor));
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
780 if (g_file_get_contents(file, &contents, NULL, NULL)) {
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
781 int i;
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
782 gchar ** color_strings = g_strsplit_set(contents, "\r\n:", -1);
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
783
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
784 for(i=0; color_strings[i]; i++)
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
785 {
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
786 GdkColor color;
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
787 if(gdk_color_parse(color_strings[i], &color))
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
788 {
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
789 g_array_append_val(priv->nick_colors, color);
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
790 }
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
791 }
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
792
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
793 g_strfreev(color_strings);
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
794 g_free(contents);
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
795 }
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
796 g_free(file);
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
797 }
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
798
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
799 if(priv->nick_colors->len)
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
800 return g_array_ref(priv->nick_colors);
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
801 else
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
802 return NULL;
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
803 }
215f0b668ac6 now loads the SenderColors.txt file from the theme if it exists, otherwise falls back to the built-in runtime-generated list
Nathan Walp <nwalp@pidgin.im>
parents: 32960
diff changeset
804

mercurial