2 * PidginIconThemeLoader for Pidgin
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
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
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
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 #include "gtkicon-theme-loader.h"
24 #include "gtkstatus-icon-theme.h"
29 /*****************************************************************************
31 *****************************************************************************/
34 pidgin_icon_loader_build(const gchar
*dir
)
36 xmlnode
*root_node
= NULL
, *sub_node
;
37 gchar
*filename_full
, *data
= NULL
;
38 PidginIconTheme
*theme
= NULL
;
41 /* Find the theme file */
42 g_return_val_if_fail(dir
!= NULL
, NULL
);
43 filename_full
= g_build_filename(dir
, "theme.xml", NULL
);
45 if (g_file_test(filename_full
, G_FILE_TEST_IS_REGULAR
))
46 root_node
= xmlnode_from_file(dir
, "theme.xml", "icon themes", "icon-theme-loader");
48 g_free(filename_full
);
49 if (root_node
== NULL
)
52 name
= xmlnode_get_attrib(root_node
, "name");
56 sub_node
= xmlnode_get_child(root_node
, "description");
57 data
= xmlnode_get_data(sub_node
);
59 if (xmlnode_get_attrib(root_node
, "name") != NULL
) {
60 theme
= g_object_new(PIDGIN_TYPE_STATUS_ICON_THEME
,
61 "type", "status-icon",
63 "author", xmlnode_get_attrib(root_node
, "author"),
64 "image", xmlnode_get_attrib(root_node
, "image"),
66 "description", data
, NULL
);
68 sub_node
= xmlnode_get_child(root_node
, "icon");
71 pidgin_icon_theme_set_icon(theme
,
72 xmlnode_get_attrib(sub_node
, "id"),
73 xmlnode_get_attrib(sub_node
, "file"));
74 sub_node
= xmlnode_get_next_twin(sub_node
);
79 xmlnode_free(root_node
);
81 return PURPLE_THEME(theme
);
84 /******************************************************************************
86 *****************************************************************************/
89 pidgin_icon_theme_loader_class_init (PidginIconThemeLoaderClass
*klass
)
91 PurpleThemeLoaderClass
*loader_klass
= PURPLE_THEME_LOADER_CLASS(klass
);
93 loader_klass
->purple_theme_loader_build
= pidgin_icon_loader_build
;
98 pidgin_icon_theme_loader_get_type (void)
100 static GType type
= 0;
102 static const GTypeInfo info
= {
103 sizeof(PidginIconThemeLoaderClass
),
104 NULL
, /* base_init */
105 NULL
, /* base_finalize */
106 (GClassInitFunc
)pidgin_icon_theme_loader_class_init
, /* class_init */
107 NULL
, /* class_finalize */
108 NULL
, /* class_data */
109 sizeof (PidginIconThemeLoader
),
111 NULL
, /* instance_init */
112 NULL
, /* value table */
114 type
= g_type_register_static (PURPLE_TYPE_THEME_LOADER
,
115 "PidginIconThemeLoader", &info
, 0);