Mercurial > pidgin.yaz
annotate pidgin/gtkicon-theme-loader.c @ 27179:d679d47c82be
Fix a copy&paste bug.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Thu, 11 Jun 2009 02:21:44 +0000 |
parents | 0c7b74fc558e |
children | 9ad4b5200f24 |
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" |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 /***************************************************************************** |
25402
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
29 * Icon Theme Builder |
25268
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 *****************************************************************************/ |
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 static PurpleTheme * |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 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
|
34 { |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 xmlnode *root_node = NULL, *sub_node; |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 gchar *filename_full, *data; |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 PidginIconTheme *theme = NULL; |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 /* Find the theme file */ |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 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
|
41 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
|
42 |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 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
|
44 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
|
45 |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 g_free(filename_full); |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 g_return_val_if_fail(root_node != NULL, NULL); |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 |
25402
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
49 /* Parse the tree */ |
25268
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 sub_node = xmlnode_get_child(root_node, "description"); |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 data = xmlnode_get_data(sub_node); |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 if (xmlnode_get_attrib(root_node, "name") != NULL) { |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 theme = g_object_new(PIDGIN_TYPE_STATUS_ICON_THEME, |
25402
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
55 "type", "status-icon", |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
56 "name", xmlnode_get_attrib(root_node, "name"), |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
57 "author", xmlnode_get_attrib(root_node, "author"), |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
58 "image", xmlnode_get_attrib(root_node, "image"), |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
59 "directory", dir, |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
60 "description", data, NULL); |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
61 |
25268
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 sub_node = xmlnode_get_child(root_node, "icon"); |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 |
25402
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
64 while (sub_node) { |
25268
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 pidgin_icon_theme_set_icon(theme, |
25402
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
66 xmlnode_get_attrib(sub_node, "id"), |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
67 xmlnode_get_attrib(sub_node, "file")); |
25268
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 sub_node = xmlnode_get_next_twin(sub_node); |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 } |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 } |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 |
25402
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
72 xmlnode_free(root_node); |
25268
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 g_free(data); |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 return PURPLE_THEME(theme); |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 } |
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 /****************************************************************************** |
25402
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
78 * GObject Stuff |
25268
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 *****************************************************************************/ |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 static void |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 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
|
83 { |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 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
|
85 |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 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
|
87 } |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 |
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 |
25402
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
90 GType |
25268
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 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
|
92 { |
25402
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
93 static GType type = 0; |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
94 if (type == 0) { |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
95 static const GTypeInfo info = { |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
96 sizeof(PidginIconThemeLoaderClass), |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
97 NULL, /* base_init */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
98 NULL, /* base_finalize */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
99 (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
|
100 NULL, /* class_finalize */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
101 NULL, /* class_data */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
102 sizeof (PidginIconThemeLoader), |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
103 0, /* n_preallocs */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
104 NULL, /* instance_init */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
105 NULL, /* value table */ |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
106 }; |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
107 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
|
108 "PidginIconThemeLoader", &info, 0); |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
109 } |
0c7b74fc558e
Lots of minor whitespace and comment changes:
Mark Doliner <mark@kingant.net>
parents:
25268
diff
changeset
|
110 return type; |
25268
7ddaa405936e
renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 } |