annotate libpurple/theme-manager.c @ 23467:655a37bc0eb0

fixed images to appear in pref menu
author Justin Rodriguez <ffdragon@soc.pidgin.im>
date Tue, 24 Jun 2008 02:06:42 +0000
parents 5a02912e0bac
children e8be608b6bab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23453
6356f402079c 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 /*
6356f402079c 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
6356f402079c 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 *
6356f402079c 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
6356f402079c 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
6356f402079c 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.
6356f402079c 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 *
6356f402079c 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
6356f402079c 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
6356f402079c 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
6356f402079c 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.
6356f402079c 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 *
6356f402079c 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,
6356f402079c 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
6356f402079c 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
6356f402079c 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.
6356f402079c 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 *
6356f402079c 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
6356f402079c 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
6356f402079c 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
6356f402079c 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 *
6356f402079c 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 */
6356f402079c 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
6356f402079c 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>
6356f402079c 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"
6356f402079c 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
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
27 /******************************************************************************
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
28 * Globals
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
29 *****************************************************************************/
23453
6356f402079c 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
23464
9ffbfbcf307d Fixed purple sound loader class init function (bug on startup) and added shell sound theme selector
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23463
diff changeset
31 static GHashTable *theme_table = NULL;
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
32
23453
6356f402079c 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 /*****************************************************************************
6356f402079c 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
6356f402079c 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 ****************************************************************************/
6356f402079c 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
6356f402079c 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
6356f402079c 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)
6356f402079c 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 {
6356f402079c 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;
6356f402079c 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) {
6356f402079c 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 = {
6356f402079c 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),
6356f402079c 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 */
6356f402079c 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 */
23461
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
46 NULL, /* class_init */
23453
6356f402079c 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 */
6356f402079c 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 */
6356f402079c 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),
6356f402079c 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 */
6356f402079c 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 */
6356f402079c 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 */
6356f402079c 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 };
6356f402079c 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,
23465
d60c3d1c6966 fixed some gobject stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23464
diff changeset
55 "PurpleThemeManager",
23453
6356f402079c 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);
6356f402079c 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 }
6356f402079c 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;
6356f402079c 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 }
6356f402079c 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
6356f402079c 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 /******************************************************************************
6356f402079c 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
6356f402079c 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 *****************************************************************************/
6356f402079c 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> */
6356f402079c 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 *
6356f402079c 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)
6356f402079c 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 {
23466
5a02912e0bac more gobject fixed
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23465
diff changeset
68 g_return_val_if_fail(name, NULL);
23453
6356f402079c 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);
23466
5a02912e0bac more gobject fixed
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23465
diff changeset
70 return g_strconcat(type, "/", name, NULL);
23453
6356f402079c 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 }
6356f402079c 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
6356f402079c 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" */
6356f402079c 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
6356f402079c 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,
6356f402079c 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,
6356f402079c 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)
6356f402079c 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 {
23466
5a02912e0bac more gobject fixed
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23465
diff changeset
79 return g_str_has_prefix (key, g_strconcat(user_data, "/", NULL));
23453
6356f402079c 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 }
6356f402079c 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
6356f402079c 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
6356f402079c 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,
6356f402079c 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,
6356f402079c 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)
6356f402079c 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 {
6356f402079c 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);
6356f402079c 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 }
6356f402079c 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
6356f402079c 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
6356f402079c 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,
6356f402079c 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,
6356f402079c 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)
6356f402079c 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 {
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
95 if (PURPLE_IS_THEME(value))
23453
6356f402079c 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);
6356f402079c 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 }
6356f402079c 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
6356f402079c 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
23461
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
100 purple_theme_manager_build_dir(const gchar *root)
23453
6356f402079c 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 {
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
102
23453
6356f402079c 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;
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
104 gchar *name, *type, *purple_dir, *theme_dir;
23453
6356f402079c 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;
6356f402079c 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;
6356f402079c 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
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
108 rdir = g_dir_open(root, 0, NULL);
23453
6356f402079c 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
6356f402079c 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);
6356f402079c 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
6356f402079c 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 */
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
113 while ((name = g_strdup(g_dir_read_name (rdir)))){
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
114
23460
623f0b40f6f6 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23455
diff changeset
115 purple_dir = g_build_filename(root, name, "purple", NULL);
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
116 dir = g_dir_open(purple_dir, 0, NULL);
23453
6356f402079c 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
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
118 if (dir) {
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
119 while ((type = g_strdup(g_dir_read_name (dir)))) {
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
120 if ((loader = g_hash_table_lookup (theme_table, type))){
23453
6356f402079c 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
23463
51bdbab30704 Fixed some warnings with loader_build
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23461
diff changeset
122 theme_dir = g_build_filename(purple_dir, type, NULL);
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
123 purple_theme_manager_add_theme(purple_theme_loader_build(loader, theme_dir));
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
124
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
125 }
23453
6356f402079c 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);
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
127
23453
6356f402079c 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 }
6356f402079c 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);
6356f402079c 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
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
131 }
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
132 g_free(purple_dir);
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
133 g_free(name);
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
134
23453
6356f402079c 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 }
6356f402079c 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);
6356f402079c 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
6356f402079c 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 }
6356f402079c 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
6356f402079c 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 /*****************************************************************************
6356f402079c 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 *
6356f402079c 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 *****************************************************************************/
6356f402079c 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
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
144 void
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
145 purple_theme_manager_init (PurpleThemeLoader *loader1, ...)
23453
6356f402079c 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 {
6356f402079c 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;
6356f402079c 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;
6356f402079c 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
23464
9ffbfbcf307d Fixed purple sound loader class init function (bug on startup) and added shell sound theme selector
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23463
diff changeset
150 /*g_return_if_fail(theme_table != NULL);*/
23461
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
151
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
152 theme_table = g_hash_table_new_full (g_str_hash,
23461
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
153 g_str_equal,
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
154 g_free,
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
155 g_object_unref);
23453
6356f402079c 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
6356f402079c 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);
6356f402079c 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 *))
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
159 purple_theme_manager_register_type(loader);
23453
6356f402079c 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);
6356f402079c 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
6356f402079c 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 */
23464
9ffbfbcf307d Fixed purple sound loader class init function (bug on startup) and added shell sound theme selector
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23463
diff changeset
163 purple_theme_manager_build_dir("/usr/share/themes");
23461
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
164 }
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
165
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
166 void
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
167 purple_theme_manager_refresh()
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
168 {
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
169 g_hash_table_foreach_remove (theme_table,
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
170 (GHRFunc) purple_theme_manager_is_theme,
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
171 NULL);
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
172
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
173 /* TODO: this also needs to be fixed the same as new */
23464
9ffbfbcf307d Fixed purple sound loader class init function (bug on startup) and added shell sound theme selector
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23463
diff changeset
174 purple_theme_manager_build_dir("/usr/share/themes");
23461
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
175
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
176 }
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
177
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
178 void
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
179 purple_theme_manager_uninit ()
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
180 {
fecc8e2612c4 Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23460
diff changeset
181 g_hash_table_destroy(theme_table);
23453
6356f402079c 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 }
6356f402079c 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
6356f402079c 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
6356f402079c 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
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
186 purple_theme_manager_register_type(PurpleThemeLoader *loader)
23453
6356f402079c 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 {
6356f402079c 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;
6356f402079c 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
6356f402079c 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));
6356f402079c 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
23464
9ffbfbcf307d Fixed purple sound loader class init function (bug on startup) and added shell sound theme selector
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23463
diff changeset
192 type = g_strdup(purple_theme_loader_get_type_string(loader));
23453
6356f402079c 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);
6356f402079c 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
6356f402079c 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 */
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
196 if (! g_hash_table_lookup (theme_table, type))
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
197 g_hash_table_insert(theme_table, type, loader);
23453
6356f402079c 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 }
6356f402079c 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
6356f402079c 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 void
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
201 purple_theme_manager_unregister_type(PurpleThemeLoader *loader)
23453
6356f402079c 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 {
6356f402079c 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
203 gchar *type;
6356f402079c 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
6356f402079c 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 g_return_if_fail(PURPLE_IS_THEME_LOADER(loader));
6356f402079c 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
6356f402079c 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 type = purple_theme_loader_get_type_string(loader);
6356f402079c 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 g_return_if_fail(type);
6356f402079c 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
23455
d5c5512adc69 Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23454
diff changeset
210 if (g_hash_table_lookup (theme_table, type) == loader){
23453
6356f402079c 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
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
212 g_hash_table_remove (theme_table, type);
23453
6356f402079c 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
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
214 g_hash_table_foreach_remove (theme_table,
23453
6356f402079c 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 (GHRFunc) purple_theme_manager_is_theme_type,
6356f402079c 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
216 type);
6356f402079c 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 }/* only free if given registered loader */
6356f402079c 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
6356f402079c 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 g_free(type);
6356f402079c 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 }
6356f402079c 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
6356f402079c 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 PurpleTheme *
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
223 purple_theme_manager_find_theme(const gchar *name,
23453
6356f402079c 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 const gchar *type)
6356f402079c 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
225 {
6356f402079c 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 g_return_val_if_fail(name, NULL);
6356f402079c 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 g_return_val_if_fail(type, NULL);
6356f402079c 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
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
229 return g_hash_table_lookup (theme_table,
23453
6356f402079c 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 purple_theme_manager_make_key(name, type));
6356f402079c 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
231 }
6356f402079c 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
6356f402079c 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
6356f402079c 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 void
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
235 purple_theme_manager_add_theme(PurpleTheme *theme)
23453
6356f402079c 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 {
6356f402079c 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
237 gchar *key;
23467
655a37bc0eb0 fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23466
diff changeset
238
23453
6356f402079c 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 g_return_if_fail(PURPLE_IS_THEME(theme));
6356f402079c 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
6356f402079c 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 key = purple_theme_manager_make_key(purple_theme_get_name(theme),
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
242 purple_theme_get_type_string(theme));
23453
6356f402079c 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
6356f402079c 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
244 g_return_if_fail(key);
23467
655a37bc0eb0 fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23466
diff changeset
245
23453
6356f402079c 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 /* if something is already there do nothing */
23467
655a37bc0eb0 fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23466
diff changeset
247 if (g_hash_table_lookup(theme_table, key) == NULL)
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
248 g_hash_table_insert(theme_table, key, theme);
23453
6356f402079c 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
249
6356f402079c 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
250 g_free(key);
6356f402079c 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 }
6356f402079c 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
6356f402079c 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 void
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
254 purple_theme_manager_remove_theme(PurpleTheme *theme)
23453
6356f402079c 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 {
6356f402079c 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
256 gchar *key;
6356f402079c 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
6356f402079c 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 g_return_if_fail(PURPLE_IS_THEME(theme));
6356f402079c 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
6356f402079c 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 key = purple_theme_manager_make_key(purple_theme_get_name(theme),
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
261 purple_theme_get_type_string(theme));
23453
6356f402079c 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
6356f402079c 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
263 g_return_if_fail(key);
6356f402079c 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
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
265 g_hash_table_remove(theme_table, key);
23453
6356f402079c 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
6356f402079c 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
267 g_free(key);
6356f402079c 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 }
6356f402079c 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
6356f402079c 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 void
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
271 purple_theme_manager_for_each_theme(PTFunc func)
23453
6356f402079c 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 {
6356f402079c 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
273 g_return_if_fail(func);
6356f402079c 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
23454
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
275 g_hash_table_foreach(theme_table,
23453
6356f402079c 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 (GHFunc) purple_theme_manager_function_wrapper,
6356f402079c 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
277 func);
6356f402079c 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 }
6356f402079c 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