Mercurial > pidgin
comparison libpurple/sound-theme-loader.c @ 25778:25af9b1994c8
renamed sound-loader.[ch] to sound-theme-loader.[ch]
other updates for the rename as necessary
author | Gary Kramlich <grim@reaperworld.com> |
---|---|
date | Thu, 28 Aug 2008 13:25:32 +0000 |
parents | |
children | d5852f7208fa |
comparison
equal
deleted
inserted
replaced
25777:7ddaa405936e | 25778:25af9b1994c8 |
---|---|
1 /* | |
2 * SoundThemeLoader for LibPurple | |
3 * | |
4 * Pidgin is the legal property of its developers, whose names are too numerous | |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | |
21 * | |
22 */ | |
23 | |
24 #include "sound-theme-loader.h" | |
25 #include "sound-theme.h" | |
26 #include "util.h" | |
27 #include "xmlnode.h" | |
28 | |
29 /***************************************************************************** | |
30 * Sound Theme Builder | |
31 *****************************************************************************/ | |
32 | |
33 static PurpleTheme * | |
34 purple_sound_loader_build(const gchar *dir) | |
35 { | |
36 xmlnode *root_node = NULL, *sub_node; | |
37 gchar *filename_full, *data; | |
38 PurpleSoundTheme *theme = NULL; | |
39 | |
40 /* Find the theme file */ | |
41 g_return_val_if_fail(dir != NULL, NULL); | |
42 filename_full = g_build_filename(dir, "theme.xml", NULL); | |
43 | |
44 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR)) | |
45 root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-loader"); | |
46 | |
47 g_free(filename_full); | |
48 g_return_val_if_fail(root_node != NULL, NULL); | |
49 | |
50 /* Parse the tree */ | |
51 sub_node = xmlnode_get_child(root_node, "description"); | |
52 data = xmlnode_get_data(sub_node); | |
53 | |
54 if (xmlnode_get_attrib(root_node, "name") != NULL) { | |
55 theme = g_object_new(PURPLE_TYPE_SOUND_THEME, | |
56 "type", "sound", | |
57 "name", xmlnode_get_attrib(root_node, "name"), | |
58 "author", xmlnode_get_attrib(root_node, "author"), | |
59 "image", xmlnode_get_attrib(root_node, "image"), | |
60 "directory", dir, | |
61 "description", data, NULL); | |
62 | |
63 sub_node = xmlnode_get_child(root_node, "event"); | |
64 | |
65 while (sub_node) { | |
66 purple_sound_theme_set_file(theme, | |
67 xmlnode_get_attrib(sub_node, "name"), | |
68 xmlnode_get_attrib(sub_node, "file")); | |
69 sub_node = xmlnode_get_next_twin(sub_node); | |
70 } | |
71 } | |
72 | |
73 xmlnode_free(root_node); | |
74 g_free(data); | |
75 return PURPLE_THEME(theme); | |
76 } | |
77 | |
78 /****************************************************************************** | |
79 * GObject Stuff | |
80 *****************************************************************************/ | |
81 | |
82 static void | |
83 purple_sound_theme_loader_class_init(PurpleSoundThemeLoaderClass *klass) | |
84 { | |
85 PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass); | |
86 | |
87 loader_klass->purple_theme_loader_build = purple_sound_loader_build; | |
88 } | |
89 | |
90 | |
91 GType | |
92 purple_sound_theme_loader_get_type(void) | |
93 { | |
94 static GType type = 0; | |
95 if (type == 0) { | |
96 static const GTypeInfo info = { | |
97 sizeof (PurpleSoundThemeLoaderClass), | |
98 NULL, /* base_init */ | |
99 NULL, /* base_finalize */ | |
100 (GClassInitFunc)purple_sound_theme_loader_class_init, /* class_init */ | |
101 NULL, /* class_finalize */ | |
102 NULL, /* class_data */ | |
103 sizeof (PurpleSoundThemeLoader), | |
104 0, /* n_preallocs */ | |
105 NULL, /* instance_init */ | |
106 NULL, /* value table */ | |
107 }; | |
108 type = g_type_register_static(PURPLE_TYPE_THEME_LOADER, | |
109 "PurpleSoundThemeLoader", | |
110 &info, 0); | |
111 } | |
112 return type; | |
113 } | |
114 | |
115 |