Mon, 11 Nov 2019 20:43:31 -0600
closing merged branch
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
2 | * Themes for libpurple |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
3 | * |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
4 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
6 | * source distribution. |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
7 | * |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
11 | * (at your option) any later version. |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
12 | * |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
16 | * GNU General Public License for more details. |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
17 | * |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
21 | */ |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
22 | |
|
25005
e86ff053dd10
Fix some theme manager assertion failures.
Richard Laager <rlaager@pidgin.im>
parents:
24139
diff
changeset
|
23 | #include "internal.h" |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
24 | #include "theme-manager.h" |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
25 | #include "util.h" |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
26 | |
|
39547
5c68828a566a
Use G_DECLARE* in themes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38873
diff
changeset
|
27 | struct _PurpleThemeManager { |
|
5c68828a566a
Use G_DECLARE* in themes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38873
diff
changeset
|
28 | GObject parent; |
|
5c68828a566a
Use G_DECLARE* in themes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38873
diff
changeset
|
29 | }; |
|
5c68828a566a
Use G_DECLARE* in themes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38873
diff
changeset
|
30 | |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
31 | /****************************************************************************** |
|
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
32 | * Globals |
|
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
33 | *****************************************************************************/ |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
34 | |
|
23645
6901039a86fb
Fixed purple sound loader class init function (bug on startup) and added shell sound theme selector
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23644
diff
changeset
|
35 | static GHashTable *theme_table = NULL; |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
36 | |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
37 | /***************************************************************************** |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
38 | * GObject Stuff |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
39 | ****************************************************************************/ |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
40 | |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
41 | GType |
|
23972
90e0da03c053
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23664
diff
changeset
|
42 | purple_theme_manager_get_type(void) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
43 | { |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
44 | static GType type = 0; |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
45 | if (type == 0) { |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
46 | static const GTypeInfo info = { |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
47 | sizeof(PurpleThemeManagerClass), |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
48 | NULL, /* base_init */ |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
49 | NULL, /* base_finalize */ |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
50 | NULL, /* class_init */ |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
51 | NULL, /* class_finalize */ |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
52 | NULL, /* class_data */ |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
53 | sizeof(PurpleThemeManager), |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
54 | 0, /* n_preallocs */ |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
55 | NULL, /* instance_init */ |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
56 | NULL, /* Value Table */ |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
57 | }; |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
58 | type = g_type_register_static(G_TYPE_OBJECT, |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
59 | "PurpleThemeManager", &info, 0); |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
60 | } |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
61 | return type; |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
62 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
63 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
64 | /****************************************************************************** |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
65 | * Helpers |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
66 | *****************************************************************************/ |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
67 | |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
68 | /* makes a key of <type> + '/' + <name> */ |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
69 | static gchar * |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
70 | purple_theme_manager_make_key(const gchar *name, const gchar *type) |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
71 | { |
|
25005
e86ff053dd10
Fix some theme manager assertion failures.
Richard Laager <rlaager@pidgin.im>
parents:
24139
diff
changeset
|
72 | g_return_val_if_fail(name && *name, NULL); |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
73 | g_return_val_if_fail(type && *type, NULL); |
|
23647
b856721ba8dd
more gobject fixed
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23646
diff
changeset
|
74 | return g_strconcat(type, "/", name, NULL); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
75 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
76 | |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
77 | /* returns TRUE if theme is of type "user_data" */ |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
78 | static gboolean |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
79 | purple_theme_manager_is_theme_type(gchar *key, |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
80 | gpointer value, |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
81 | gchar *user_data) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
82 | { |
|
23653
79934bf9a349
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:
23651
diff
changeset
|
83 | return g_str_has_prefix(key, g_strconcat(user_data, "/", NULL)); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
84 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
85 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
86 | static gboolean |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
87 | check_if_theme_or_loader(gchar *key, gpointer value, GSList **loaders) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
88 | { |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
89 | if (PURPLE_IS_THEME(value)) |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
90 | return TRUE; |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
91 | else if (PURPLE_IS_THEME_LOADER(value)) |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
92 | *loaders = g_slist_prepend(*loaders, value); |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
93 | |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
94 | return FALSE; |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
95 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
96 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
97 | static void |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
98 | purple_theme_manager_function_wrapper(gchar *key, |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
99 | gpointer value, |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
32956
diff
changeset
|
100 | PurpleThemeFunc user_data) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
101 | { |
|
23636
0ba7de721f35
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23635
diff
changeset
|
102 | if (PURPLE_IS_THEME(value)) |
|
23972
90e0da03c053
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23664
diff
changeset
|
103 | (* user_data)(value); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
104 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
105 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
106 | static void |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
107 | purple_theme_manager_build_dir(GSList *loaders, const gchar *root) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
108 | { |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
109 | gchar *theme_dir; |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
110 | const gchar *name; |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
111 | GDir *rdir; |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
112 | GSList *tmp; |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
113 | PurpleThemeLoader *loader; |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
114 | |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
115 | rdir = g_dir_open(root, 0, NULL); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
116 | |
|
25005
e86ff053dd10
Fix some theme manager assertion failures.
Richard Laager <rlaager@pidgin.im>
parents:
24139
diff
changeset
|
117 | if (!rdir) |
|
e86ff053dd10
Fix some theme manager assertion failures.
Richard Laager <rlaager@pidgin.im>
parents:
24139
diff
changeset
|
118 | return; |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
119 | |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
120 | while ((name = g_dir_read_name(rdir))) { |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
121 | theme_dir = g_build_filename(root, name, NULL); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
122 | |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
123 | for (tmp = loaders; tmp; tmp = g_slist_next(tmp)) { |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
124 | loader = PURPLE_THEME_LOADER(tmp->data); |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
125 | |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
126 | if (purple_theme_loader_probe(loader, theme_dir)) { |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
127 | PurpleTheme *theme = purple_theme_loader_build(loader, theme_dir); |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
128 | if (PURPLE_IS_THEME(theme)) |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
129 | purple_theme_manager_add_theme(theme); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
130 | } |
|
23636
0ba7de721f35
Fixed some leaks formatting
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23635
diff
changeset
|
131 | } |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
132 | |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
133 | g_free(theme_dir); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
134 | } |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
135 | |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
136 | g_dir_close(rdir); |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
137 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
138 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
139 | /***************************************************************************** |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
140 | * Public API functions |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
141 | *****************************************************************************/ |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
142 | |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
143 | void |
|
23972
90e0da03c053
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23664
diff
changeset
|
144 | purple_theme_manager_init(void) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
145 | { |
|
23972
90e0da03c053
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23664
diff
changeset
|
146 | theme_table = g_hash_table_new_full(g_str_hash, |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
147 | g_str_equal, g_free, g_object_unref); |
|
23642
ea82d96e4ebd
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23641
diff
changeset
|
148 | } |
|
ea82d96e4ebd
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23641
diff
changeset
|
149 | |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
150 | void |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
151 | purple_theme_manager_refresh(void) |
|
23642
ea82d96e4ebd
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23641
diff
changeset
|
152 | { |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
153 | gchar *path; |
|
38873
58473fc5ee73
Use GLib XDG dirs functions instead of g_getenv
qarkai <qarkai@gmail.com>
parents:
38870
diff
changeset
|
154 | const gchar *const *xdg_dirs; |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
155 | gint i; |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
156 | GSList *loaders = NULL; |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
157 | |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
158 | g_hash_table_foreach_remove(theme_table, (GHRFunc)check_if_theme_or_loader, |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
159 | &loaders); |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
160 | |
|
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
161 | /* Add themes from ~/.purple */ |
|
39875
3046e8feccaa
Since we're purposely handling old paths, ignore the deprecation warning
Gary Kramlich <grim@reaperworld.com>
parents:
39874
diff
changeset
|
162 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
|
3046e8feccaa
Since we're purposely handling old paths, ignore the deprecation warning
Gary Kramlich <grim@reaperworld.com>
parents:
39874
diff
changeset
|
163 | path = g_build_filename(purple_user_dir(), "themes", NULL); |
|
3046e8feccaa
Since we're purposely handling old paths, ignore the deprecation warning
Gary Kramlich <grim@reaperworld.com>
parents:
39874
diff
changeset
|
164 | G_GNUC_END_IGNORE_DEPRECATIONS |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
165 | purple_theme_manager_build_dir(loaders, path); |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
166 | g_free(path); |
|
23642
ea82d96e4ebd
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23641
diff
changeset
|
167 | |
|
38873
58473fc5ee73
Use GLib XDG dirs functions instead of g_getenv
qarkai <qarkai@gmail.com>
parents:
38870
diff
changeset
|
168 | /* look for XDG_DATA_HOME */ |
|
58473fc5ee73
Use GLib XDG dirs functions instead of g_getenv
qarkai <qarkai@gmail.com>
parents:
38870
diff
changeset
|
169 | /* NOTE: will work on Windows, see g_get_user_data_dir() documentation */ |
|
58473fc5ee73
Use GLib XDG dirs functions instead of g_getenv
qarkai <qarkai@gmail.com>
parents:
38870
diff
changeset
|
170 | path = g_build_filename(g_get_user_data_dir(), "themes", NULL); |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
171 | purple_theme_manager_build_dir(loaders, path); |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
172 | g_free(path); |
|
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
173 | |
|
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
174 | /* now dig through XDG_DATA_DIRS and add those too */ |
|
38873
58473fc5ee73
Use GLib XDG dirs functions instead of g_getenv
qarkai <qarkai@gmail.com>
parents:
38870
diff
changeset
|
175 | /* NOTE: will work on Windows, see g_get_system_data_dirs() documentation */ |
|
58473fc5ee73
Use GLib XDG dirs functions instead of g_getenv
qarkai <qarkai@gmail.com>
parents:
38870
diff
changeset
|
176 | xdg_dirs = g_get_system_data_dirs(); |
|
58473fc5ee73
Use GLib XDG dirs functions instead of g_getenv
qarkai <qarkai@gmail.com>
parents:
38870
diff
changeset
|
177 | for (i = 0; xdg_dirs[i] != NULL; i++) { |
|
58473fc5ee73
Use GLib XDG dirs functions instead of g_getenv
qarkai <qarkai@gmail.com>
parents:
38870
diff
changeset
|
178 | path = g_build_filename(xdg_dirs[i], "themes", NULL); |
|
58473fc5ee73
Use GLib XDG dirs functions instead of g_getenv
qarkai <qarkai@gmail.com>
parents:
38870
diff
changeset
|
179 | purple_theme_manager_build_dir(loaders, path); |
|
58473fc5ee73
Use GLib XDG dirs functions instead of g_getenv
qarkai <qarkai@gmail.com>
parents:
38870
diff
changeset
|
180 | g_free(path); |
|
24138
13f8a8066fb4
cleaned up purple_theme_manager_build_dir
Gary Kramlich <grim@reaperworld.com>
parents:
23664
diff
changeset
|
181 | } |
|
32956
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
182 | |
|
5050f6ab62ef
Use the theme loader probing function when searching directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
183 | g_slist_free(loaders); |
|
23642
ea82d96e4ebd
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23641
diff
changeset
|
184 | } |
|
ea82d96e4ebd
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23641
diff
changeset
|
185 | |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
186 | void |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
187 | purple_theme_manager_uninit(void) |
|
23642
ea82d96e4ebd
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23641
diff
changeset
|
188 | { |
|
ea82d96e4ebd
Fixed some things needed for proper gobfication (init/finalize/etc)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23641
diff
changeset
|
189 | g_hash_table_destroy(theme_table); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
190 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
191 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
192 | void |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
193 | purple_theme_manager_register_type(PurpleThemeLoader *loader) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
194 | { |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
195 | gchar *type; |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
196 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
197 | g_return_if_fail(PURPLE_IS_THEME_LOADER(loader)); |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
198 | |
|
23645
6901039a86fb
Fixed purple sound loader class init function (bug on startup) and added shell sound theme selector
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23644
diff
changeset
|
199 | type = g_strdup(purple_theme_loader_get_type_string(loader)); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
200 | g_return_if_fail(type); |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
201 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
202 | /* if something is already there do nothing */ |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
203 | if (!g_hash_table_lookup(theme_table, type)) |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
204 | g_hash_table_insert(theme_table, type, loader); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
205 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
206 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
207 | void |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
208 | purple_theme_manager_unregister_type(PurpleThemeLoader *loader) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
209 | { |
|
23655
704a67a69ce0
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:
23653
diff
changeset
|
210 | const gchar *type; |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
211 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
212 | g_return_if_fail(PURPLE_IS_THEME_LOADER(loader)); |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
213 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
214 | type = purple_theme_loader_get_type_string(loader); |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
215 | g_return_if_fail(type); |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
216 | |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
217 | if (g_hash_table_lookup(theme_table, type) == loader) |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
218 | { |
|
23972
90e0da03c053
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23664
diff
changeset
|
219 | g_hash_table_remove(theme_table, type); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
220 | |
|
23972
90e0da03c053
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23664
diff
changeset
|
221 | g_hash_table_foreach_remove(theme_table, |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
222 | (GHRFunc)purple_theme_manager_is_theme_type, (gpointer)type); |
|
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
223 | } /* only free if given registered loader */ |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
224 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
225 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
226 | PurpleTheme * |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
227 | purple_theme_manager_find_theme(const gchar *name, |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
228 | const gchar *type) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
229 | { |
|
23653
79934bf9a349
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:
23651
diff
changeset
|
230 | gchar *key; |
|
79934bf9a349
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:
23651
diff
changeset
|
231 | PurpleTheme *theme; |
|
79934bf9a349
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:
23651
diff
changeset
|
232 | |
|
79934bf9a349
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:
23651
diff
changeset
|
233 | key = purple_theme_manager_make_key(name, type); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
234 | |
|
23653
79934bf9a349
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:
23651
diff
changeset
|
235 | g_return_val_if_fail(key, NULL); |
|
79934bf9a349
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:
23651
diff
changeset
|
236 | |
|
79934bf9a349
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:
23651
diff
changeset
|
237 | theme = g_hash_table_lookup(theme_table, key); |
|
79934bf9a349
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:
23651
diff
changeset
|
238 | |
|
79934bf9a349
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:
23651
diff
changeset
|
239 | g_free(key); |
|
79934bf9a349
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:
23651
diff
changeset
|
240 | |
|
79934bf9a349
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:
23651
diff
changeset
|
241 | return theme; |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
242 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
243 | |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
244 | void |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
245 | purple_theme_manager_add_theme(PurpleTheme *theme) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
246 | { |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
247 | gchar *key; |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
248 | |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
249 | g_return_if_fail(PURPLE_IS_THEME(theme)); |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
250 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
251 | key = purple_theme_manager_make_key(purple_theme_get_name(theme), |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
252 | purple_theme_get_type_string(theme)); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
253 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
254 | g_return_if_fail(key); |
|
23648
a71b9a2345ea
fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23647
diff
changeset
|
255 | |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
256 | /* if something is already there do nothing */ |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
257 | if (g_hash_table_lookup(theme_table, key) == NULL) |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
258 | g_hash_table_insert(theme_table, key, theme); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
259 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
260 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
261 | void |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
262 | purple_theme_manager_remove_theme(PurpleTheme *theme) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
263 | { |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
264 | gchar *key; |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
265 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
266 | g_return_if_fail(PURPLE_IS_THEME(theme)); |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
267 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
268 | key = purple_theme_manager_make_key(purple_theme_get_name(theme), |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
269 | purple_theme_get_type_string(theme)); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
270 | |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
271 | g_return_if_fail(key); |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
272 | |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
273 | g_hash_table_remove(theme_table, key); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
274 | |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
275 | g_free(key); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
276 | } |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
277 | |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
278 | void |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
32956
diff
changeset
|
279 | purple_theme_manager_for_each_theme(PurpleThemeFunc func) |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
280 | { |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
281 | g_return_if_fail(func); |
|
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
282 | |
|
23635
8d9926d33ff9
Fixed theme-manager to be more of a singleton and less-gobject like
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23634
diff
changeset
|
283 | g_hash_table_foreach(theme_table, |
|
25875
a98b16817658
Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents:
25005
diff
changeset
|
284 | (GHFunc) purple_theme_manager_function_wrapper, func); |
|
23634
cefd759a125b
Added the theme-manager and basic functionality (needs to be given proper directories to find themes)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
285 | } |
|
27445
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
286 | |
|
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
287 | PurpleTheme * |
|
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
288 | purple_theme_manager_load_theme(const gchar *theme_dir, const gchar *type) |
|
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
289 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
28981
diff
changeset
|
290 | PurpleThemeLoader *loader; |
|
27445
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
291 | |
|
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
292 | g_return_val_if_fail(theme_dir != NULL && type != NULL, NULL); |
|
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
293 | |
|
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
294 | loader = g_hash_table_lookup(theme_table, type); |
|
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
295 | g_return_val_if_fail(PURPLE_IS_THEME_LOADER(loader), NULL); |
|
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
296 | |
|
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
297 | return purple_theme_loader_build(loader, theme_dir); |
|
b8bbf88abd0f
Allow drag-and-drop of all sorts of themes.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
26778
diff
changeset
|
298 | } |