annotate libpurple/theme-manager.c @ 23454:0ece981e44f5

Fixed theme-manager to be more of a singleton and less-gobject like
author Justin Rodriguez <ffdragon@soc.pidgin.im>
date Wed, 11 Jun 2008 03:41:35 +0000
parents 6356f402079c
children d5c5512adc69
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
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
31 static GHashTable *theme_table;
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 /*****************************************************************************
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 * 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
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
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 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
39 purple_theme_manager_finalize (GObject *obj)
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 {
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
41 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
42 }
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
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 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
45 purple_theme_manager_class_init (PurpleThemeManagerClass *klass)
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
46 {
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 /*PurpleThemeManagerClass *theme_manager_class = PURPLE_THEME_MANAGER_CLASS(klass);*/
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 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
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
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 /* 2.4 g_type_class_add_private(klass, sizeof(PurpleThemeManagerPrivate));*/
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
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 obj_class->finalize = purple_theme_manager_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
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 }
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
55
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 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
57 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
58 {
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 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
60 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
61 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
62 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
63 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
64 NULL, /* base_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
65 (GClassInitFunc)purple_theme_manager_class_init, /* class_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
66 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
67 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
68 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
69 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
70 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
71 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
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 type = g_type_register_static (G_TYPE_OBJECT,
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 "PurpleThemeManagerType",
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 &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
76 }
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 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
78 }
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
79
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 * 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
82 *****************************************************************************/
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 /* 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
84 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
85 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
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 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
88 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
89 return g_strconcat(type, '/', 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
90 }
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
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 /* 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
93 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
94 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
95 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
96 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
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 return g_str_has_prefix (key, g_strconcat(user_data, '/', 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
99 }
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
100
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 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
102 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
103 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
104 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
105 {
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 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
107 }
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
108
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 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
110 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
111 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
112 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
113 {
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
114 if(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
115 (* 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
116 }
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
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
118 static 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
119 purple_theme_manager_build(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
120 {
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
121
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
122 GDir *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
123 gchar *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
124 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
125 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
126
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
127 rdir = g_dir_open(root, 0, NULL);/*TODO: should have debug error?*/
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_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
130
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
131 /*TODO: This looks messy, leaks*/
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
132 /* Parses directory by root/name/purple/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
133 while((name = g_strdup(g_dir_read_name (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
134
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 dir = g_dir_open(g_strconcat(root, '/', 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
136 '/', "purple", NULL), 0, 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
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 if(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
139 while((type = g_strdup(g_dir_read_name (dir)))) {
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
140 if((loader = g_hash_table_lookup (theme_table, type)))
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
141 purple_theme_manager_add_theme(purple_theme_loader_build(loader, g_strconcat(root, '/', 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
142 "purple", '/', 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
143
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
144 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
145 }
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 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
148 }
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
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
150 g_free(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
151 }
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
152
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
153 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
154
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
155 }
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 /*****************************************************************************
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 * 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
159 *****************************************************************************/
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
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
161 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
162 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
163 {
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
164 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
165 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
166
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
167 theme_table = g_hash_table_new_full (g_str_hash,
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
168 g_str_equal,
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
169 g_free,
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
170 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
171
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
172 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
173 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
174 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
175 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
176
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
177 /* TODO: add themes properly */
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
178 purple_theme_manager_build(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
179 }
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
180
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
181
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 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
183 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
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 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
186
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 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
188
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 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
190 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
191
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
192 /* if something is already there do nothing */
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
193 if(! g_hash_table_lookup (theme_table, type))
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
194 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
195
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
196 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
197 }
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 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
200 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
201 {
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 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
203
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 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
205
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 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
207 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
208
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
209 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
210
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
211 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
212
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
213 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
214 (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
215 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 }/* 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
217
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 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
219 }
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 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
222 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
223 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
224 {
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 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
226 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
227
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
228 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
229 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
230 }
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 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
234 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
235 {
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 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
237
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
238 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
239
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 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
241 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
242
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 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
244
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
245 /* if something is already there do nothing */
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
246 if(! g_hash_table_lookup (theme_table, key))
0ece981e44f5 Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23453
diff changeset
247 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
248
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 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
250 }
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 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
253 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
254 {
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 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
256
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 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
258
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 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
260 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
261
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 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
263
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
264 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
265
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 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
267 }
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 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
270 purple_theme_manager_refresh()
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
271 {
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
272 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
273 (GHRFunc) purple_theme_manager_is_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
274 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
275
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 /* TODO: this also needs to be fixed the same as new */
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
277 purple_theme_manager_build(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
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 }
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
280
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
281 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
282 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
283 {
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
284 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
285
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
286 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
287 (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
288 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
289 }
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
290