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