Mercurial > pidgin
annotate libpurple/theme-manager.c @ 32775:4acc5b98f143
Remove redundant check (g_free does this for us)
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 04 May 2012 07:33:51 +0000 |
parents | b276701931d9 |
children |
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 /* |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
2 * Themes for libpurple |
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
|
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 */ |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
22 |
25858
1eacf60a73dd
Fix some theme manager assertion failures.
Richard Laager <rlaager@wiktel.com>
parents:
25128
diff
changeset
|
23 #include "internal.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
|
24 #include "theme-manager.h" |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
25 #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
|
26 |
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
|
27 /****************************************************************************** |
0ece981e44f5
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25077
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:
25077
diff
changeset
|
29 *****************************************************************************/ |
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
|
30 |
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
|
31 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
|
32 |
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
|
33 /***************************************************************************** |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
34 * GObject Stuff |
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 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
37 GType |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25107
diff
changeset
|
38 purple_theme_manager_get_type(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
|
39 { |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
40 static GType type = 0; |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
41 if (type == 0) { |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
42 static const GTypeInfo info = { |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
43 sizeof(PurpleThemeManagerClass), |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
44 NULL, /* base_init */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
45 NULL, /* base_finalize */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
46 NULL, /* class_init */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
47 NULL, /* class_finalize */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
48 NULL, /* class_data */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
49 sizeof(PurpleThemeManager), |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
50 0, /* n_preallocs */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
51 NULL, /* instance_init */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
52 NULL, /* Value Table */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
53 }; |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
54 type = g_type_register_static(G_TYPE_OBJECT, |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
55 "PurpleThemeManager", &info, 0); |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
56 } |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
57 return 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
|
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 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
60 /****************************************************************************** |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
61 * 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
|
62 *****************************************************************************/ |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
63 |
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
|
64 /* makes a key of <type> + '/' + <name> */ |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
65 static gchar * |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
66 purple_theme_manager_make_key(const gchar *name, const gchar *type) |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
67 { |
25858
1eacf60a73dd
Fix some theme manager assertion failures.
Richard Laager <rlaager@wiktel.com>
parents:
25128
diff
changeset
|
68 g_return_val_if_fail(name && *name, NULL); |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
69 g_return_val_if_fail(type && *type, NULL); |
25090
5a02912e0bac
more gobject fixed
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25089
diff
changeset
|
70 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
|
71 } |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
72 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
73 /* returns TRUE if theme is of type "user_data" */ |
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
|
74 static gboolean |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
75 purple_theme_manager_is_theme_type(gchar *key, |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
76 gpointer value, |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
77 gchar *user_data) |
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
|
78 { |
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
|
79 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
|
80 } |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
81 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
82 static gboolean |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
83 check_if_theme_or_loader(gchar *key, gpointer value, GSList **loaders) |
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
|
84 { |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
85 if (PURPLE_IS_THEME(value)) |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
86 return TRUE; |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
87 else if (PURPLE_IS_THEME_LOADER(value)) |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
88 *loaders = g_slist_prepend(*loaders, value); |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
89 |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
90 return FALSE; |
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
|
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 |
6356f402079c
Added 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 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
|
94 purple_theme_manager_function_wrapper(gchar *key, |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
95 gpointer value, |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
96 PTFunc user_data) |
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
|
97 { |
25079
d5c5512adc69
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25078
diff
changeset
|
98 if (PURPLE_IS_THEME(value)) |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25107
diff
changeset
|
99 (* user_data)(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
|
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 |
6356f402079c
Added 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 static void |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
103 purple_theme_manager_build_dir(GSList *loaders, 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
|
104 { |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
105 gchar *theme_dir; |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
106 const gchar *name; |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
107 GDir *rdir; |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
108 GSList *tmp; |
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
|
109 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
|
110 |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
111 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
|
112 |
25858
1eacf60a73dd
Fix some theme manager assertion failures.
Richard Laager <rlaager@wiktel.com>
parents:
25128
diff
changeset
|
113 if (!rdir) |
1eacf60a73dd
Fix some theme manager assertion failures.
Richard Laager <rlaager@wiktel.com>
parents:
25128
diff
changeset
|
114 return; |
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
|
115 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
116 while ((name = g_dir_read_name(rdir))) { |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
117 theme_dir = g_build_filename(root, 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
|
118 |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
119 for (tmp = loaders; tmp; tmp = g_slist_next(tmp)) { |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
120 loader = PURPLE_THEME_LOADER(tmp->data); |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
121 |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
122 if (purple_theme_loader_probe(loader, theme_dir)) { |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
123 PurpleTheme *theme = purple_theme_loader_build(loader, theme_dir); |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
124 if (PURPLE_IS_THEME(theme)) |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
125 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
|
126 } |
25079
d5c5512adc69
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25078
diff
changeset
|
127 } |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
128 |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
129 g_free(theme_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
|
130 } |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
131 |
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
|
132 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
|
133 } |
6356f402079c
Added 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 /***************************************************************************** |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
136 * Public API functions |
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
|
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 |
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
|
139 void |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25107
diff
changeset
|
140 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
|
141 { |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25107
diff
changeset
|
142 theme_table = g_hash_table_new_full(g_str_hash, |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
143 g_str_equal, g_free, g_object_unref); |
25085
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
144 } |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
145 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
146 void |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
147 purple_theme_manager_refresh(void) |
25085
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
148 { |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
149 gchar *path; |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
150 const gchar *xdg; |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
151 gint i; |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
152 GSList *loaders = NULL; |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
153 |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
154 g_hash_table_foreach_remove(theme_table, (GHRFunc)check_if_theme_or_loader, |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
155 &loaders); |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
156 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
157 /* Add themes from ~/.purple */ |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
158 path = g_build_filename(purple_user_dir(), "themes", NULL); |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
159 purple_theme_manager_build_dir(loaders, path); |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
160 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
|
161 |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
162 /* look for XDG_DATA_HOME. If we don't have it use ~/.local, and add it */ |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
163 if ((xdg = g_getenv("XDG_DATA_HOME")) != NULL) |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
164 path = g_build_filename(xdg, "themes", NULL); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
165 else |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
166 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
|
167 |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
168 purple_theme_manager_build_dir(loaders, path); |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
169 g_free(path); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
170 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
171 /* 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
|
172 xdg = g_getenv("XDG_DATA_DIRS"); |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
173 if (xdg) { |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
174 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
|
175 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
176 for (i = 0; xdg_dirs[i]; i++) { |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
177 path = g_build_filename(xdg_dirs[i], "themes", NULL); |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
178 purple_theme_manager_build_dir(loaders, path); |
25127
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
179 g_free(path); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
180 } |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
181 |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
182 g_strfreev(xdg_dirs); |
4575b578a54b
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
25107
diff
changeset
|
183 } |
32729
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
184 |
b276701931d9
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
185 g_slist_free(loaders); |
25085
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
186 } |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
187 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
188 void |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
189 purple_theme_manager_uninit(void) |
25085
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
190 { |
fecc8e2612c4
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25084
diff
changeset
|
191 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
|
192 } |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
193 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
194 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
|
195 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
|
196 { |
6356f402079c
Added 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 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
|
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 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
|
200 |
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
|
201 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
|
202 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
|
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 /* if something is already there do nothing */ |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
205 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
|
206 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
|
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 |
6356f402079c
Added 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 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
|
210 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
|
211 { |
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
|
212 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
|
213 |
6356f402079c
Added 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 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
|
215 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
216 type = 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
|
217 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
|
218 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
219 if (g_hash_table_lookup(theme_table, type) == loader) |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
220 { |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25107
diff
changeset
|
221 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
|
222 |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25107
diff
changeset
|
223 g_hash_table_foreach_remove(theme_table, |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
224 (GHRFunc)purple_theme_manager_is_theme_type, (gpointer)type); |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
225 } /* only free if given registered 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
|
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 |
6356f402079c
Added 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 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
|
229 purple_theme_manager_find_theme(const gchar *name, |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
230 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
|
231 { |
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
|
232 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
|
233 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
|
234 |
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
|
235 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
|
236 |
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
|
237 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
|
238 |
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
|
239 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
|
240 |
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
|
241 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
|
242 |
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
|
243 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
|
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 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
246 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
|
247 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
|
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 gchar *key; |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
250 |
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
|
251 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
|
252 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
253 key = purple_theme_manager_make_key(purple_theme_get_name(theme), |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
254 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
|
255 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
256 g_return_if_fail(key); |
25091
655a37bc0eb0
fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25090
diff
changeset
|
257 |
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
|
258 /* if something is already there do nothing */ |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
259 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
|
260 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
|
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 |
6356f402079c
Added 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 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
|
264 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
|
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 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
|
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 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
|
269 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
270 key = purple_theme_manager_make_key(purple_theme_get_name(theme), |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
271 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
|
272 |
6356f402079c
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
273 g_return_if_fail(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
|
274 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
275 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
|
276 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
277 g_free(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
|
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 |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
280 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
|
281 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
|
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 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
|
284 |
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
|
285 g_hash_table_foreach(theme_table, |
25911
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25858
diff
changeset
|
286 (GHFunc) purple_theme_manager_function_wrapper, 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
|
287 } |
27203
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
288 |
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
289 PurpleTheme * |
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
290 purple_theme_manager_load_theme(const gchar *theme_dir, const gchar *type) |
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
291 { |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
28647
diff
changeset
|
292 PurpleThemeLoader *loader; |
27203
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
293 |
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
294 g_return_val_if_fail(theme_dir != NULL && type != NULL, NULL); |
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
295 |
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
296 loader = g_hash_table_lookup(theme_table, type); |
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
297 g_return_val_if_fail(PURPLE_IS_THEME_LOADER(loader), NULL); |
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
298 |
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
299 return purple_theme_loader_build(loader, theme_dir); |
d629a42c8340
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26547
diff
changeset
|
300 } |