annotate pidgin/gtkicon-theme-loader.c @ 32796:189b9a516d5d

Oscar: Use file-transfer accessor functions
author andrew.victor@mxit.com
date Sun, 30 Oct 2011 15:55:56 +0000
parents 9ad4b5200f24
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * PidginIconThemeLoader for Pidgin
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-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
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-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
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "gtkicon-theme-loader.h"
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 #include "gtkstatus-icon-theme.h"
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 #include "xmlnode.h"
27284
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
27 #include "debug.h"
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 /*****************************************************************************
25402
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
30 * Icon Theme Builder
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 *****************************************************************************/
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 static PurpleTheme *
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 pidgin_icon_loader_build(const gchar *dir)
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 {
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 xmlnode *root_node = NULL, *sub_node;
27284
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
37 gchar *filename_full, *data = NULL;
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 PidginIconTheme *theme = NULL;
27284
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
39 const gchar *name;
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 /* Find the theme file */
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 g_return_val_if_fail(dir != NULL, NULL);
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 filename_full = g_build_filename(dir, "theme.xml", NULL);
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR))
27179
d679d47c82be Fix a copy&paste bug.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25402
diff changeset
46 root_node = xmlnode_from_file(dir, "theme.xml", "icon themes", "icon-theme-loader");
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 g_free(filename_full);
27284
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
49 if (root_node == NULL)
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
50 return NULL;
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
51
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
52 name = xmlnode_get_attrib(root_node, "name");
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53
27284
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
54 if (name) {
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
55 /* Parse the tree */
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
56 sub_node = xmlnode_get_child(root_node, "description");
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
57 data = xmlnode_get_data(sub_node);
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58
27284
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
59 if (xmlnode_get_attrib(root_node, "name") != NULL) {
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
60 theme = g_object_new(PIDGIN_TYPE_STATUS_ICON_THEME,
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
61 "type", "status-icon",
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
62 "name", name,
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
63 "author", xmlnode_get_attrib(root_node, "author"),
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
64 "image", xmlnode_get_attrib(root_node, "image"),
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
65 "directory", dir,
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
66 "description", data, NULL);
25402
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
67
27284
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
68 sub_node = xmlnode_get_child(root_node, "icon");
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
27284
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
70 while (sub_node) {
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
71 pidgin_icon_theme_set_icon(theme,
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
72 xmlnode_get_attrib(sub_node, "id"),
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
73 xmlnode_get_attrib(sub_node, "file"));
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
74 sub_node = xmlnode_get_next_twin(sub_node);
9ad4b5200f24 Better error checking on the theme loaders.
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 27179
diff changeset
75 }
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 }
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 }
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78
25402
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
79 xmlnode_free(root_node);
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 g_free(data);
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 return PURPLE_THEME(theme);
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 }
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 /******************************************************************************
25402
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
85 * GObject Stuff
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 *****************************************************************************/
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 static void
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 pidgin_icon_theme_loader_class_init (PidginIconThemeLoaderClass *klass)
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 {
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass);
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 loader_klass->purple_theme_loader_build = pidgin_icon_loader_build;
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
25402
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
97 GType
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 pidgin_icon_theme_loader_get_type (void)
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 {
25402
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
100 static GType type = 0;
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
101 if (type == 0) {
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
102 static const GTypeInfo info = {
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
103 sizeof(PidginIconThemeLoaderClass),
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
104 NULL, /* base_init */
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
105 NULL, /* base_finalize */
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
106 (GClassInitFunc)pidgin_icon_theme_loader_class_init, /* class_init */
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
107 NULL, /* class_finalize */
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
108 NULL, /* class_data */
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
109 sizeof (PidginIconThemeLoader),
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
110 0, /* n_preallocs */
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
111 NULL, /* instance_init */
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
112 NULL, /* value table */
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
113 };
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
114 type = g_type_register_static (PURPLE_TYPE_THEME_LOADER,
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
115 "PidginIconThemeLoader", &info, 0);
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
116 }
0c7b74fc558e Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents: 25268
diff changeset
117 return type;
25268
7ddaa405936e renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 }