Mercurial > pidgin
annotate libpurple/theme-manager.c @ 25127:4575b578a54b
cleaned up purple_theme_manager_build_dir
added additional directories to purple_theme_manager_refresh. We should really be using the glib functions for the xdg data dir stuff, but this will work, for now, on !win32...
author | Gary Kramlich <grim@reaperworld.com> |
---|---|
date | Thu, 21 Aug 2008 08:01:08 +0000 |
parents | 748308865dbf |
children | 0de17531e9f2 |
rev | line source |
---|---|
25077
6356f402079c
Added 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 |
25107
748308865dbf
Changed how the prefs handle themes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25098
diff
changeset
|
24 #include <string.h> |
748308865dbf
Changed how the prefs handle themes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25098
diff
changeset
|
25 |
25077
6356f402079c
Added 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 #include "theme-manager.h" |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
27 #include "util.h" |
25077
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
28 |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
29 /****************************************************************************** |
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
30 * Globals |
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
31 *****************************************************************************/ |
25077
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
32 |
25088
9ffbfbcf307d
Fixed purple sound loader class init function (bug on startup) and added shell sound theme selector
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25087
diff
changeset
|
33 static GHashTable *theme_table = NULL; |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
34 |
25077
6356f402079c
Added 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 * 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
|
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 |
6356f402079c
Added 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 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
|
40 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
|
41 { |
6356f402079c
Added 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 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 NULL, /* base_finalize */ |
25085
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
48 NULL, /* class_init */ |
25077
6356f402079c
Added 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 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
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 type = g_type_register_static (G_TYPE_OBJECT, |
25089
d60c3d1c6966
fixed some gobject stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25088
diff
changeset
|
57 "PurpleThemeManager", |
25077
6356f402079c
Added 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 &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
|
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 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
|
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 |
6356f402079c
Added 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 * 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
|
65 *****************************************************************************/ |
6356f402079c
Added 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 /* 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
|
67 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
|
68 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
|
69 { |
25107
748308865dbf
Changed how the prefs handle themes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25098
diff
changeset
|
70 g_return_val_if_fail(name && strlen(name), NULL); |
748308865dbf
Changed how the prefs handle themes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25098
diff
changeset
|
71 g_return_val_if_fail(type && strlen(type), NULL); |
25090
5a02912e0bac
more gobject fixed
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25089
diff
changeset
|
72 return g_strconcat(type, "/", name, NULL); |
25077
6356f402079c
Added 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 } |
6356f402079c
Added 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 |
6356f402079c
Added 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 /* 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 { |
25096
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
81 return g_str_has_prefix(key, g_strconcat(user_data, "/", NULL)); |
25077
6356f402079c
Added 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 |
6356f402079c
Added 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 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
|
85 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
|
86 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
|
87 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
|
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 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
|
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 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
|
93 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
|
94 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
|
95 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
|
96 { |
25079
d5c5512adc69
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25078
diff
changeset
|
97 if (PURPLE_IS_THEME(value)) |
25077
6356f402079c
Added 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 (* 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
|
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 void |
25085
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
102 purple_theme_manager_build_dir(const gchar *root) |
25077
6356f402079c
Added 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 { |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
104 |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
105 gchar *purple_dir, *theme_dir; |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
106 const gchar *name = NULL, *type = NULL; |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
107 GDir *rdir, *tdir; |
25077
6356f402079c
Added 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 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
|
109 |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
110 rdir = g_dir_open(root, 0, NULL); |
25077
6356f402079c
Added 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 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
|
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 /* Parses directory by root/name/purple/type */ |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
115 while((name = g_dir_read_name(rdir))) { |
25084
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:
25079
diff
changeset
|
116 purple_dir = g_build_filename(root, name, "purple", NULL); |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
117 tdir = g_dir_open(purple_dir, 0, NULL); |
25077
6356f402079c
Added 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 |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
119 if(!tdir) { |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
120 g_free(purple_dir); |
25077
6356f402079c
Added 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 |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
122 continue; |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
123 } |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
124 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
125 while((type = g_dir_read_name(tdir))) { |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
126 if((loader = g_hash_table_lookup(theme_table, type))) { |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
127 PurpleTheme *theme = NULL; |
25079
d5c5512adc69
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25078
diff
changeset
|
128 |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
129 theme_dir = g_build_filename(purple_dir, type, NULL); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
130 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
131 theme = purple_theme_loader_build(loader, theme_dir); |
25079
d5c5512adc69
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25078
diff
changeset
|
132 |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
133 if(PURPLE_IS_THEME(theme)) |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
134 purple_theme_manager_add_theme(theme); |
25077
6356f402079c
Added 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 } |
25079
d5c5512adc69
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25078
diff
changeset
|
136 } |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
137 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
138 g_dir_close(tdir); |
25079
d5c5512adc69
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25078
diff
changeset
|
139 g_free(purple_dir); |
25077
6356f402079c
Added 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 } |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
141 |
25077
6356f402079c
Added 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 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
|
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 |
6356f402079c
Added 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 * 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
|
147 *****************************************************************************/ |
6356f402079c
Added 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 |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
149 void |
25098
331a7a69d955
Changed the theme_manager_init function to do less, makes it cleaner and faster (won't have to build
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
150 purple_theme_manager_init (void) |
25077
6356f402079c
Added 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 { |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
152 theme_table = g_hash_table_new_full (g_str_hash, |
25085
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
153 g_str_equal, |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
154 g_free, |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
155 g_object_unref); |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
156 } |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
157 |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
158 void |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
159 purple_theme_manager_refresh() |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
160 { |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
161 gchar *path = NULL; |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
162 const gchar *xdg = NULL; |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
163 gint i = 0; |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
164 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
165 g_hash_table_foreach_remove(theme_table, |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
166 (GHRFunc) purple_theme_manager_is_theme, |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
167 NULL); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
168 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
169 /* Add themes from ~/.purple */ |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
170 path = g_build_filename(purple_user_dir(), "themes", NULL); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
171 purple_theme_manager_build_dir(path); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
172 g_free(path); |
25085
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
173 |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
174 /* look for XDG_DATA_HOME. If we don't have it use ~/.local, and add it */ |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
175 if((xdg = g_getenv("XDG_DATA_HOME")) != NULL) |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
176 path = g_build_filename(xdg, "themes", NULL); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
177 else |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
178 path = g_build_filename(purple_home_dir(), ".local", "themes", NULL); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
179 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
180 purple_theme_manager_build_dir(path); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
181 g_free(path); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
182 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
183 /* now dig through XDG_DATA_DIRS and add those too */ |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
184 xdg = g_getenv("XDG_DATA_DIRS"); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
185 if(xdg) { |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
186 gchar **xdg_dirs = g_strsplit(xdg, G_SEARCHPATH_SEPARATOR_S, 0); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
187 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
188 for(i = 0; xdg_dirs[i]; i++) { |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
189 path = g_build_filename(xdg_dirs[i], "themes", NULL); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
190 purple_theme_manager_build_dir(path); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
191 g_free(path); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
192 } |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
193 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
194 g_strfreev(xdg_dirs); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
195 } |
25085
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
196 } |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
197 |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
198 void |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
199 purple_theme_manager_uninit () |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
200 { |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
201 g_hash_table_destroy(theme_table); |
25077
6356f402079c
Added 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 |
6356f402079c
Added 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 void |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
206 purple_theme_manager_register_type(PurpleThemeLoader *loader) |
25077
6356f402079c
Added 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 { |
6356f402079c
Added 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 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
|
209 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
210 g_return_if_fail(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
|
211 |
25088
9ffbfbcf307d
Fixed purple sound loader class init function (bug on startup) and added shell sound theme selector
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25087
diff
changeset
|
212 type = g_strdup(purple_theme_loader_get_type_string(loader)); |
25077
6356f402079c
Added 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 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
|
214 |
6356f402079c
Added 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 /* if something is already there do nothing */ |
25079
d5c5512adc69
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25078
diff
changeset
|
216 if (! g_hash_table_lookup (theme_table, type)) |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
217 g_hash_table_insert(theme_table, type, loader); |
25077
6356f402079c
Added 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 |
6356f402079c
Added 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 void |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
221 purple_theme_manager_unregister_type(PurpleThemeLoader *loader) |
25077
6356f402079c
Added 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 { |
25098
331a7a69d955
Changed the theme_manager_init function to do less, makes it cleaner and faster (won't have to build
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
223 const gchar *type; |
25077
6356f402079c
Added 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_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
|
226 |
6356f402079c
Added 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 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
|
228 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
|
229 |
25079
d5c5512adc69
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25078
diff
changeset
|
230 if (g_hash_table_lookup (theme_table, type) == loader){ |
25077
6356f402079c
Added 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 |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
232 g_hash_table_remove (theme_table, type); |
25077
6356f402079c
Added 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 |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
234 g_hash_table_foreach_remove (theme_table, |
25077
6356f402079c
Added 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 (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
|
236 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
|
237 }/* 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
|
238 } |
6356f402079c
Added 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 PurpleTheme * |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
241 purple_theme_manager_find_theme(const gchar *name, |
25077
6356f402079c
Added 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 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
|
243 { |
25096
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
244 gchar *key; |
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
245 PurpleTheme *theme; |
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
246 |
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
247 key = purple_theme_manager_make_key(name, type); |
25077
6356f402079c
Added 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 |
25096
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
249 g_return_val_if_fail(key, NULL); |
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
250 |
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
251 theme = g_hash_table_lookup(theme_table, key); |
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
252 |
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
253 g_free(key); |
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
254 |
fbf72bbd1084
Fixed up a few typos, readability, leaks, and bugs, all minor and mostly in theme and theme loader classes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25094
diff
changeset
|
255 return theme; |
25077
6356f402079c
Added 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 |
6356f402079c
Added 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 void |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
260 purple_theme_manager_add_theme(PurpleTheme *theme) |
25077
6356f402079c
Added 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 gchar *key; |
25091
655a37bc0eb0
fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25090
diff
changeset
|
263 |
25077
6356f402079c
Added 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 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
|
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 key = purple_theme_manager_make_key(purple_theme_get_name(theme), |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
267 purple_theme_get_type_string(theme)); |
25077
6356f402079c
Added 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 g_return_if_fail(key); |
25091
655a37bc0eb0
fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25090
diff
changeset
|
270 |
25077
6356f402079c
Added 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 /* if something is already there do nothing */ |
25091
655a37bc0eb0
fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25090
diff
changeset
|
272 if (g_hash_table_lookup(theme_table, key) == NULL) |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
273 g_hash_table_insert(theme_table, key, theme); |
25077
6356f402079c
Added 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 } |
6356f402079c
Added 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 void |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
277 purple_theme_manager_remove_theme(PurpleTheme *theme) |
25077
6356f402079c
Added 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 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
|
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 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
|
282 |
6356f402079c
Added 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 key = purple_theme_manager_make_key(purple_theme_get_name(theme), |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
284 purple_theme_get_type_string(theme)); |
25077
6356f402079c
Added 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 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
286 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
|
287 |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
288 g_hash_table_remove(theme_table, key); |
25077
6356f402079c
Added 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 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
|
291 } |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
292 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
293 void |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
294 purple_theme_manager_for_each_theme(PTFunc func) |
25077
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
295 { |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
296 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
|
297 |
25078
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
diff
changeset
|
298 g_hash_table_foreach(theme_table, |
25077
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
299 (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
|
300 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
|
301 } |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
302 |