comparison libpurple/sound-theme-loader.c @ 25402:0c7b74fc558e

Lots of minor whitespace and comment changes: * Removed stray whitespace * Changed a few places that used space indentation to use tabs * Changed some places that used tabs for alignment in the middle of a line of code to use spaces * Use two tabs to indent code that spans more than one line instead of a few tabs and a few spaces in an effort to align the subsequent lines with the initial one * Changed "#ifdef _BLAH_H" to "#ifdef BLAH_H" because an underscore followed by a capital letter is reserved for use by the compiler and system libraries. I also changed the path to the sound theme.xml file from root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-loader"); to root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-theme-loader");
author Mark Doliner <mark@kingant.net>
date Sun, 25 Jan 2009 22:55:23 +0000
parents d5852f7208fa
children 9ad4b5200f24
comparison
equal deleted inserted replaced
25401:3d8c53f3108e 25402:0c7b74fc558e
1 /* 1 /*
2 * SoundThemeLoader for LibPurple 2 * SoundThemeLoader for libpurple
3 * 3 *
4 * Pidgin is the legal property of its developers, whose names are too numerous 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 5 * to list here. Please refer to the COPYRIGHT file distributed with this
6 * source distribution. 6 * source distribution.
7 * 7 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 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 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 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
21 *
22 */ 21 */
23 22
24 #include "internal.h" 23 #include "internal.h"
25 #include "sound-theme-loader.h" 24 #include "sound-theme-loader.h"
26 #include "sound-theme.h" 25 #include "sound-theme.h"
27 #include "util.h" 26 #include "util.h"
28 #include "xmlnode.h" 27 #include "xmlnode.h"
29 28
30 /***************************************************************************** 29 /*****************************************************************************
31 * Sound Theme Builder 30 * Sound Theme Builder
32 *****************************************************************************/ 31 *****************************************************************************/
33 32
34 static PurpleTheme * 33 static PurpleTheme *
35 purple_sound_loader_build(const gchar *dir) 34 purple_sound_loader_build(const gchar *dir)
36 { 35 {
41 /* Find the theme file */ 40 /* Find the theme file */
42 g_return_val_if_fail(dir != NULL, NULL); 41 g_return_val_if_fail(dir != NULL, NULL);
43 filename_full = g_build_filename(dir, "theme.xml", NULL); 42 filename_full = g_build_filename(dir, "theme.xml", NULL);
44 43
45 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR)) 44 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR))
46 root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-loader"); 45 root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-theme-loader");
47 46
48 g_free(filename_full); 47 g_free(filename_full);
49 g_return_val_if_fail(root_node != NULL, NULL); 48 g_return_val_if_fail(root_node != NULL, NULL);
50 49
51 /* Parse the tree */ 50 /* Parse the tree */
52 sub_node = xmlnode_get_child(root_node, "description"); 51 sub_node = xmlnode_get_child(root_node, "description");
53 data = xmlnode_get_data(sub_node); 52 data = xmlnode_get_data(sub_node);
54 53
55 if (xmlnode_get_attrib(root_node, "name") != NULL) { 54 if (xmlnode_get_attrib(root_node, "name") != NULL) {
56 theme = g_object_new(PURPLE_TYPE_SOUND_THEME, 55 theme = g_object_new(PURPLE_TYPE_SOUND_THEME,
57 "type", "sound", 56 "type", "sound",
58 "name", xmlnode_get_attrib(root_node, "name"), 57 "name", xmlnode_get_attrib(root_node, "name"),
59 "author", xmlnode_get_attrib(root_node, "author"), 58 "author", xmlnode_get_attrib(root_node, "author"),
60 "image", xmlnode_get_attrib(root_node, "image"), 59 "image", xmlnode_get_attrib(root_node, "image"),
61 "directory", dir, 60 "directory", dir,
62 "description", data, NULL); 61 "description", data, NULL);
63 62
64 sub_node = xmlnode_get_child(root_node, "event"); 63 sub_node = xmlnode_get_child(root_node, "event");
65 64
66 while (sub_node) { 65 while (sub_node) {
67 purple_sound_theme_set_file(theme, 66 purple_sound_theme_set_file(theme,
68 xmlnode_get_attrib(sub_node, "name"), 67 xmlnode_get_attrib(sub_node, "name"),
69 xmlnode_get_attrib(sub_node, "file")); 68 xmlnode_get_attrib(sub_node, "file"));
70 sub_node = xmlnode_get_next_twin(sub_node); 69 sub_node = xmlnode_get_next_twin(sub_node);
71 } 70 }
72 } 71 }
73 72
74 xmlnode_free(root_node); 73 xmlnode_free(root_node);
75 g_free(data); 74 g_free(data);
76 return PURPLE_THEME(theme); 75 return PURPLE_THEME(theme);
77 } 76 }
78 77
79 /****************************************************************************** 78 /******************************************************************************
80 * GObject Stuff 79 * GObject Stuff
81 *****************************************************************************/ 80 *****************************************************************************/
82 81
83 static void 82 static void
84 purple_sound_theme_loader_class_init(PurpleSoundThemeLoaderClass *klass) 83 purple_sound_theme_loader_class_init(PurpleSoundThemeLoaderClass *klass)
85 { 84 {
86 PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass); 85 PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass);
87 86
88 loader_klass->purple_theme_loader_build = purple_sound_loader_build; 87 loader_klass->purple_theme_loader_build = purple_sound_loader_build;
89 } 88 }
90 89
91 90 GType
92 GType
93 purple_sound_theme_loader_get_type(void) 91 purple_sound_theme_loader_get_type(void)
94 { 92 {
95 static GType type = 0; 93 static GType type = 0;
96 if (type == 0) { 94 if (type == 0) {
97 static const GTypeInfo info = { 95 static const GTypeInfo info = {
98 sizeof (PurpleSoundThemeLoaderClass), 96 sizeof(PurpleSoundThemeLoaderClass),
99 NULL, /* base_init */ 97 NULL, /* base_init */
100 NULL, /* base_finalize */ 98 NULL, /* base_finalize */
101 (GClassInitFunc)purple_sound_theme_loader_class_init, /* class_init */ 99 (GClassInitFunc)purple_sound_theme_loader_class_init, /* class_init */
102 NULL, /* class_finalize */ 100 NULL, /* class_finalize */
103 NULL, /* class_data */ 101 NULL, /* class_data */
104 sizeof (PurpleSoundThemeLoader), 102 sizeof(PurpleSoundThemeLoader),
105 0, /* n_preallocs */ 103 0, /* n_preallocs */
106 NULL, /* instance_init */ 104 NULL, /* instance_init */
107 NULL, /* value table */ 105 NULL, /* value table */
108 }; 106 };
109 type = g_type_register_static(PURPLE_TYPE_THEME_LOADER, 107 type = g_type_register_static(PURPLE_TYPE_THEME_LOADER,
110 "PurpleSoundThemeLoader", 108 "PurpleSoundThemeLoader", &info, 0);
111 &info, 0); 109 }
112 } 110 return type;
113 return type;
114 } 111 }
115
116