libpurple/theme-manager.c

Tue, 17 Jun 2008 03:26:00 +0000

author
Justin Rodriguez <ffdragon@soc.pidgin.im>
date
Tue, 17 Jun 2008 03:26:00 +0000
branch
soc.2008.themes
changeset 23644
1d7593fc2f5b
parent 23642
ea82d96e4ebd
child 23645
6901039a86fb
permissions
-rw-r--r--

Fixed some warnings with loader_build

23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
1 /*
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
2 * Themes for LibPurple
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
3 *
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
4 * Pidgin is the legal property of its developers, whose names are too numerous
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
6 * source distribution.
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
7 *
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
12 *
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
17 *
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
21 *
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
22 */
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
23
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
24 #include <stdarg.h>
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
25 #include "theme-manager.h"
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
26
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
27 /******************************************************************************
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
28 * Globals
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
29 *****************************************************************************/
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
30
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
31 static GHashTable *theme_table;
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
32
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
33 /*****************************************************************************
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
34 * GObject Stuff
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
35 ****************************************************************************/
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
36
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
37 GType
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
38 purple_theme_manager_get_type (void)
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
39 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
40 static GType type = 0;
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
41 if (type == 0) {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
42 static const GTypeInfo info = {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
43 sizeof (PurpleThemeManagerClass),
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
44 NULL, /* base_init */
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
45 NULL, /* base_finalize */
23642
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
46 NULL, /* class_init */
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
47 NULL, /* class_finalize */
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
48 NULL, /* class_data */
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
49 sizeof (PurpleThemeManager),
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
50 0, /* n_preallocs */
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
51 NULL, /* instance_init */
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
52 NULL, /* Value Table */
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
53 };
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
54 type = g_type_register_static (G_TYPE_OBJECT,
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
55 "PurpleThemeManagerType",
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
56 &info, 0);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
57 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
58 return type;
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
59 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
60
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
61 /******************************************************************************
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
62 * Helpers
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
63 *****************************************************************************/
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
64 /* makes a key of <type> + '/' + <name> */
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
65 static gchar *
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
66 purple_theme_manager_make_key(const gchar *name, const gchar *type)
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
67 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
68 g_return_val_if_fail(name, NULL);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
69 g_return_val_if_fail(type, NULL);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
70 return g_strconcat(type, '/', name, NULL);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
71 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
72
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
73 /* returns TRUE if theme is of type "user_data" */
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
74 static gboolean
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
75 purple_theme_manager_is_theme_type(gchar *key,
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
76 gpointer value,
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
77 gchar *user_data)
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
78 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
79 return g_str_has_prefix (key, g_strconcat(user_data, '/', NULL));
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
80 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
81
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
82 static gboolean
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
83 purple_theme_manager_is_theme(gchar *key,
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
84 gpointer value,
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
85 gchar *user_data)
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
86 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
87 return PURPLE_IS_THEME(value);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
88 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
89
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
90 static void
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
91 purple_theme_manager_function_wrapper(gchar *key,
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
92 gpointer value,
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
93 PTFunc user_data)
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
94 {
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
95 if (PURPLE_IS_THEME(value))
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
96 (* user_data) (value);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
97 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
98
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
99 static void
23642
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
100 purple_theme_manager_build_dir(const gchar *root)
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
101 {
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
102
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
103 GDir *rdir;
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
104 gchar *name, *type, *purple_dir, *theme_dir;
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
105 GDir *dir;
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
106 PurpleThemeLoader *loader;
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
107
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
108 rdir = g_dir_open(root, 0, NULL);
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
109
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
110 g_return_if_fail(rdir);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
111
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
112 /* Parses directory by root/name/purple/type */
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
113 while ((name = g_strdup(g_dir_read_name (rdir)))){
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
114
23641
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23636
diff changeset
115 purple_dir = g_build_filename(root, name, "purple", NULL);
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
116 dir = g_dir_open(purple_dir, 0, NULL);
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
117
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
118 if (dir) {
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
119 while ((type = g_strdup(g_dir_read_name (dir)))) {
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
120 if ((loader = g_hash_table_lookup (theme_table, type))){
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
121
23644
1d7593fc2f5b Fixed some warnings with loader_build
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23642
diff changeset
122 theme_dir = g_build_filename(purple_dir, type, NULL);
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
123 purple_theme_manager_add_theme(purple_theme_loader_build(loader, theme_dir));
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
124
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
125 }
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
126 g_free(type);
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
127
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
128 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
129 g_dir_close(dir);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
130
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
131 }
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
132 g_free(purple_dir);
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
133 g_free(name);
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
134
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
135 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
136 g_dir_close(rdir);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
137
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
138 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
139
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
140 /*****************************************************************************
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
141 * Public API functions *
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
142 *****************************************************************************/
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
143
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
144 void
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
145 purple_theme_manager_init (PurpleThemeLoader *loader1, ...)
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
146 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
147 va_list args;
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
148 PurpleThemeLoader *loader;
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
149
23642
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
150 g_return_if_fail(theme_table != NULL);
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
151
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
152 theme_table = g_hash_table_new_full (g_str_hash,
23642
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
153 g_str_equal,
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
154 g_free,
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
155 g_object_unref);
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
156
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
157 va_start(args, loader1);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
158 for (loader = loader1; loader != NULL; loader = va_arg(args, PurpleThemeLoader *))
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
159 purple_theme_manager_register_type(loader);
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
160 va_end(args);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
161
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
162 /* TODO: add themes properly */
23642
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
163 purple_theme_manager_build_dir(NULL);
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
164 }
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
165
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
166 void
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
167 purple_theme_manager_refresh()
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
168 {
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
169 g_hash_table_foreach_remove (theme_table,
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
170 (GHRFunc) purple_theme_manager_is_theme,
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
171 NULL);
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
172
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
173 /* TODO: this also needs to be fixed the same as new */
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
174 purple_theme_manager_build_dir(NULL);
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
175
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
176 }
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
177
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
178 void
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
179 purple_theme_manager_uninit ()
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
180 {
ea82d96e4ebd Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23641
diff changeset
181 g_hash_table_destroy(theme_table);
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
182 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
183
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
184
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
185 void
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
186 purple_theme_manager_register_type(PurpleThemeLoader *loader)
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
187 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
188 gchar *type;
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
189
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
190 g_return_if_fail(PURPLE_IS_THEME_LOADER(loader));
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
191
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
192 type = purple_theme_loader_get_type_string(loader);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
193 g_return_if_fail(type);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
194
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
195 /* if something is already there do nothing */
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
196 if (! g_hash_table_lookup (theme_table, type))
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
197 g_hash_table_insert(theme_table, type, loader);
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
198
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
199 g_free(type);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
200 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
201
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
202 void
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
203 purple_theme_manager_unregister_type(PurpleThemeLoader *loader)
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
204 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
205 gchar *type;
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
206
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
207 g_return_if_fail(PURPLE_IS_THEME_LOADER(loader));
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
208
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
209 type = purple_theme_loader_get_type_string(loader);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
210 g_return_if_fail(type);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
211
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
212 if (g_hash_table_lookup (theme_table, type) == loader){
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
213
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
214 g_hash_table_remove (theme_table, type);
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
215
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
216 g_hash_table_foreach_remove (theme_table,
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
217 (GHRFunc) purple_theme_manager_is_theme_type,
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
218 type);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
219 }/* only free if given registered loader */
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
220
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
221 g_free(type);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
222 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
223
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
224 PurpleTheme *
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
225 purple_theme_manager_find_theme(const gchar *name,
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
226 const gchar *type)
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
227 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
228 g_return_val_if_fail(name, NULL);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
229 g_return_val_if_fail(type, NULL);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
230
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
231 return g_hash_table_lookup (theme_table,
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
232 purple_theme_manager_make_key(name, type));
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
233 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
234
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
235
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
236 void
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
237 purple_theme_manager_add_theme(PurpleTheme *theme)
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
238 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
239 gchar *key;
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
240
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
241 g_return_if_fail(PURPLE_IS_THEME(theme));
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
242
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
243 key = purple_theme_manager_make_key(purple_theme_get_name(theme),
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
244 purple_theme_get_type_string(theme));
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
245
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
246 g_return_if_fail(key);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
247
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
248 /* if something is already there do nothing */
23636
0ba7de721f35 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23635
diff changeset
249 if (! g_hash_table_lookup (theme_table, key))
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
250 g_hash_table_insert(theme_table, key, theme);
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
251
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
252 g_free(key);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
253 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
254
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
255 void
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
256 purple_theme_manager_remove_theme(PurpleTheme *theme)
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
257 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
258 gchar *key;
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
259
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
260 g_return_if_fail(PURPLE_IS_THEME(theme));
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
261
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
262 key = purple_theme_manager_make_key(purple_theme_get_name(theme),
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
263 purple_theme_get_type_string(theme));
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
264
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
265 g_return_if_fail(key);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
266
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
267 g_hash_table_remove(theme_table, key);
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
268
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
269 g_free(key);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
270 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
271
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
272 void
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
273 purple_theme_manager_for_each_theme(PTFunc func)
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
274 {
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
275 g_return_if_fail(func);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
276
23635
8d9926d33ff9 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23634
diff changeset
277 g_hash_table_foreach(theme_table,
23634
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
278 (GHFunc) purple_theme_manager_function_wrapper,
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
279 func);
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
280 }
cefd759a125b Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
281

mercurial