Mercurial > pidgin
annotate libpurple/sound-loader.c @ 25776:e0a596a0a020
propagate from branch 'im.pidgin.pidgin' (head 69cdb2b9e20a69a98389b47c672718d5be222338)
to branch 'im.pidgin.soc.2008.themes' (head 76c4c8e60f9192eff589f0416652aaab2ae9521d)
author | Gary Kramlich <grim@reaperworld.com> |
---|---|
date | Thu, 28 Aug 2008 13:00:23 +0000 |
parents | 9525fb966efb |
children |
rev | line source |
---|---|
25083
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
1 /* |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
2 * SoundThemeLoader for LibPurple |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
3 * |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
4 * Pidgin is the legal property of its developers, whose names are too numerous |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
6 * source distribution. |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
7 * |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
11 * (at your option) any later version. |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
12 * |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
17 * |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
21 * |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
22 */ |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
23 |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
24 #include "sound-loader.h" |
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
|
25 #include "sound-theme.h" |
25084
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
26 #include "util.h" |
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
27 #include "xmlnode.h" |
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
28 |
25083
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
29 /***************************************************************************** |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
30 * Sound Theme Builder |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
31 *****************************************************************************/ |
25084
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
32 |
25121
b37ccfd1697b
Changed PurpleTheme build function to only return PurpleTheme*
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25119
diff
changeset
|
33 static PurpleTheme * |
25083
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
34 purple_sound_loader_build(const gchar *dir) |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
35 { |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
36 xmlnode *root_node = NULL, *sub_node; |
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
37 gchar *filename_full, *data; |
25119
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
38 PurpleSoundTheme *theme = NULL; |
25084
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
39 |
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
40 /* Find the theme file */ |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
41 g_return_val_if_fail(dir != NULL, NULL); |
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
42 filename_full = g_build_filename(dir, "theme.xml", NULL); |
25084
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
43 |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
44 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR)) |
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
45 root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-loader"); |
25091
655a37bc0eb0
fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25090
diff
changeset
|
46 |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
47 g_free(filename_full); |
25084
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
48 g_return_val_if_fail(root_node != NULL, NULL); |
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
49 |
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
|
50 /* Parse the tree */ |
25091
655a37bc0eb0
fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25090
diff
changeset
|
51 sub_node = xmlnode_get_child(root_node, "description"); |
655a37bc0eb0
fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25090
diff
changeset
|
52 data = xmlnode_get_data(sub_node); |
25084
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
53 |
25119
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
54 if (xmlnode_get_attrib(root_node, "name") != NULL) { |
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
55 theme = g_object_new(PURPLE_TYPE_SOUND_THEME, |
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
56 "type", "sound", |
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
57 "name", xmlnode_get_attrib(root_node, "name"), |
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
58 "author", xmlnode_get_attrib(root_node, "author"), |
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
59 "image", xmlnode_get_attrib(root_node, "image"), |
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
60 "directory", dir, |
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
61 "description", data, NULL); |
25084
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
62 |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
63 sub_node = xmlnode_get_child(root_node, "event"); |
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
64 |
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
65 while (sub_node) { |
25119
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
66 purple_sound_theme_set_file(theme, |
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
67 xmlnode_get_attrib(sub_node, "name"), |
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
68 xmlnode_get_attrib(sub_node, "file")); |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
69 sub_node = xmlnode_get_next_twin(sub_node); |
25119
fc8047e1fa39
fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25096
diff
changeset
|
70 } |
25084
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
71 } |
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
72 |
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
73 xmlnode_free(root_node); |
623f0b40f6f6
Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25083
diff
changeset
|
74 g_free(data); |
25121
b37ccfd1697b
Changed PurpleTheme build function to only return PurpleTheme*
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25119
diff
changeset
|
75 return PURPLE_THEME(theme); |
25083
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
76 } |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
77 |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
78 /****************************************************************************** |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
79 * GObject Stuff |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
80 *****************************************************************************/ |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
81 |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
82 static void |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
83 purple_sound_theme_loader_class_init(PurpleSoundThemeLoaderClass *klass) |
25083
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
84 { |
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
|
85 PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass); |
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
|
86 |
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
|
87 loader_klass->purple_theme_loader_build = purple_sound_loader_build; |
25083
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
88 } |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
89 |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
90 |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
91 GType |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
92 purple_sound_theme_loader_get_type(void) |
25083
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
93 { |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
94 static GType type = 0; |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
95 if (type == 0) { |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
96 static const GTypeInfo info = { |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
97 sizeof (PurpleSoundThemeLoaderClass), |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
98 NULL, /* base_init */ |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
99 NULL, /* base_finalize */ |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
100 (GClassInitFunc)purple_sound_theme_loader_class_init, /* class_init */ |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
101 NULL, /* class_finalize */ |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
102 NULL, /* class_data */ |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
103 sizeof (PurpleSoundThemeLoader), |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
104 0, /* n_preallocs */ |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
105 NULL, /* instance_init */ |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
106 NULL, /* value table */ |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
107 }; |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25121
diff
changeset
|
108 type = g_type_register_static(PURPLE_TYPE_THEME_LOADER, |
25089
d60c3d1c6966
fixed some gobject stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25088
diff
changeset
|
109 "PurpleSoundThemeLoader", |
25083
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
110 &info, 0); |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
111 } |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
112 return type; |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
113 } |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
114 |
c1cabd5eb625
Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff
changeset
|
115 |