libpurple/sound-theme-loader.c

Sun, 21 Jun 2009 16:40:15 +0000

author
Richard Laager <rlaager@pidgin.im>
date
Sun, 21 Jun 2009 16:40:15 +0000
changeset 27361
62f1aa8045bb
parent 25875
a98b16817658
child 27444
21add455833a
permissions
-rw-r--r--

propagate from branch 'im.pidgin.pidgin.2.5.7' (head 550e6ec7c9fd15db9956387a5775df07322ec766)
to branch 'im.pidgin.pidgin' (head 3029011cad5ac369187a44041818ef24c4911906)

23640
0d64f321a266 Added skeleton (non-working) sound loader class
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: 25010
diff changeset
2 * SoundThemeLoader for libpurple
23640
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
3 *
0d64f321a266 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
0d64f321a266 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
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
6 * source distribution.
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
7 *
0d64f321a266 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
0d64f321a266 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
0d64f321a266 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
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
12 *
0d64f321a266 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,
0d64f321a266 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
0d64f321a266 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
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
17 *
0d64f321a266 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
0d64f321a266 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
0d64f321a266 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
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
21 */
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
22
25010
57a841ca2450 Fix win32 build. I haven't actually tested any of the functionality, but it
Daniel Atallah <datallah@pidgin.im>
parents: 24378
diff changeset
23 #include "internal.h"
24378
cb0bf512e61d renamed sound-loader.[ch] to sound-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 23972
diff changeset
24 #include "sound-theme-loader.h"
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
25 #include "sound-theme.h"
23641
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
26 #include "util.h"
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
27 #include "xmlnode.h"
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
28
23640
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
29 /*****************************************************************************
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
30 * Sound Theme Builder
23640
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
31 *****************************************************************************/
23641
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
32
23971
9764690b14f2 Changed PurpleTheme build function to only return PurpleTheme*
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23969
diff changeset
33 static PurpleTheme *
23640
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
34 purple_sound_loader_build(const gchar *dir)
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
35 {
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
36 xmlnode *root_node = NULL, *sub_node;
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
37 gchar *filename_full, *data;
23969
0c3fe3967b97 fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23653
diff changeset
38 PurpleSoundTheme *theme = NULL;
23641
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
39
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
40 /* Find the theme file */
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
41 g_return_val_if_fail(dir != NULL, NULL);
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
42 filename_full = g_build_filename(dir, "theme.xml", NULL);
23641
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
43
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
44 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR))
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
45 root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-theme-loader");
23648
a71b9a2345ea fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23647
diff changeset
46
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
47 g_free(filename_full);
23641
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
48 g_return_val_if_fail(root_node != NULL, NULL);
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
49
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
50 /* Parse the tree */
23648
a71b9a2345ea fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23647
diff changeset
51 sub_node = xmlnode_get_child(root_node, "description");
a71b9a2345ea fixed images to appear in pref menu
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23647
diff changeset
52 data = xmlnode_get_data(sub_node);
23641
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
53
23969
0c3fe3967b97 fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23653
diff changeset
54 if (xmlnode_get_attrib(root_node, "name") != NULL) {
0c3fe3967b97 fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23653
diff changeset
55 theme = g_object_new(PURPLE_TYPE_SOUND_THEME,
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
56 "type", "sound",
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
57 "name", xmlnode_get_attrib(root_node, "name"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
58 "author", xmlnode_get_attrib(root_node, "author"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
59 "image", xmlnode_get_attrib(root_node, "image"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
60 "directory", dir,
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
61 "description", data, NULL);
23641
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
62
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
63 sub_node = xmlnode_get_child(root_node, "event");
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
64
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
65 while (sub_node) {
23969
0c3fe3967b97 fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23653
diff changeset
66 purple_sound_theme_set_file(theme,
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
67 xmlnode_get_attrib(sub_node, "name"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
68 xmlnode_get_attrib(sub_node, "file"));
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
69 sub_node = xmlnode_get_next_twin(sub_node);
23969
0c3fe3967b97 fixed some leaks and made theme loading safer
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23653
diff changeset
70 }
23641
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
71 }
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
72
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
73 xmlnode_free(root_node);
23641
cab1a8ff75a1 Added sound builder (implete still needs a good way to go from xml file to xml node)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23640
diff changeset
74 g_free(data);
23971
9764690b14f2 Changed PurpleTheme build function to only return PurpleTheme*
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23969
diff changeset
75 return PURPLE_THEME(theme);
23640
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
76 }
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
77
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
78 /******************************************************************************
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
79 * GObject Stuff
23640
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
80 *****************************************************************************/
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
81
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
82 static void
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
83 purple_sound_theme_loader_class_init(PurpleSoundThemeLoaderClass *klass)
23640
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
84 {
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
85 PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass);
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
86
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
87 loader_klass->purple_theme_loader_build = purple_sound_loader_build;
23640
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
88 }
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
89
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
90 GType
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
91 purple_sound_theme_loader_get_type(void)
23640
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
92 {
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
93 static GType type = 0;
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
94 if (type == 0) {
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
95 static const GTypeInfo info = {
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
96 sizeof(PurpleSoundThemeLoaderClass),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
97 NULL, /* base_init */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
98 NULL, /* base_finalize */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
99 (GClassInitFunc)purple_sound_theme_loader_class_init, /* class_init */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
100 NULL, /* class_finalize */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
101 NULL, /* class_data */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
102 sizeof(PurpleSoundThemeLoader),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
103 0, /* n_preallocs */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
104 NULL, /* instance_init */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
105 NULL, /* value table */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
106 };
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
107 type = g_type_register_static(PURPLE_TYPE_THEME_LOADER,
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
108 "PurpleSoundThemeLoader", &info, 0);
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
109 }
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25010
diff changeset
110 return type;
23640
0d64f321a266 Added skeleton (non-working) sound loader class
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
111 }

mercurial