pidgin/gtkicon-theme-loader.c

Mon, 08 Jun 2009 02:24:49 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Mon, 08 Jun 2009 02:24:49 +0000
changeset 27314
402d25ce01da
parent 25875
a98b16817658
child 27328
0e1d3c207948
permissions
-rw-r--r--

Use the JID for adding a chat/buddy because the name is for descriptive
purpose only, and using it will not fill in the Add Chat dialog correctly.
Because the JID is not visible, the user will not know what to actually put
there instead.

23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
1 /*
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
2 * PidginIconThemeLoader for Pidgin
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
3 *
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
4 * Pidgin is the legal property of its developers, whose names are too numerous
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
6 * source distribution.
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
7 *
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
12 *
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
17 *
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
21 */
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
22
24377
8d0bfda8402d renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 23972
diff changeset
23 #include "gtkicon-theme-loader.h"
23967
cc5667bc8f1e Clean up status icon themes a bit
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23965
diff changeset
24 #include "gtkstatus-icon-theme.h"
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
25
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
26 #include "xmlnode.h"
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
27
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
28 /*****************************************************************************
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
29 * Icon Theme Builder
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
30 *****************************************************************************/
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
31
23971
9764690b14f2 Changed PurpleTheme build function to only return PurpleTheme*
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23967
diff changeset
32 static PurpleTheme *
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
33 pidgin_icon_loader_build(const gchar *dir)
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
34 {
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
35 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
36 gchar *filename_full, *data;
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
37 PidginIconTheme *theme = NULL;
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
38
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
39 /* Find the theme file */
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
40 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
41 filename_full = g_build_filename(dir, "theme.xml", NULL);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
42
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
43 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: 24377
diff changeset
44 root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-theme-loader");
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
45
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
46 g_free(filename_full);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
47 g_return_val_if_fail(root_node != NULL, NULL);
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
48
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
49 /* Parse the tree */
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
50 sub_node = xmlnode_get_child(root_node, "description");
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
51 data = xmlnode_get_data(sub_node);
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
52
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
53 if (xmlnode_get_attrib(root_node, "name") != NULL) {
23967
cc5667bc8f1e Clean up status icon themes a bit
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23965
diff changeset
54 theme = g_object_new(PIDGIN_TYPE_STATUS_ICON_THEME,
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
55 "type", "status-icon",
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
56 "name", xmlnode_get_attrib(root_node, "name"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
57 "author", xmlnode_get_attrib(root_node, "author"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
58 "image", xmlnode_get_attrib(root_node, "image"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
59 "directory", dir,
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
60 "description", data, NULL);
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
61
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
62 sub_node = xmlnode_get_child(root_node, "icon");
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
63
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
64 while (sub_node) {
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
65 pidgin_icon_theme_set_icon(theme,
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
66 xmlnode_get_attrib(sub_node, "id"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
67 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
68 sub_node = xmlnode_get_next_twin(sub_node);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
69 }
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
70 }
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
71
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
72 xmlnode_free(root_node);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
73 g_free(data);
23971
9764690b14f2 Changed PurpleTheme build function to only return PurpleTheme*
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23967
diff changeset
74 return PURPLE_THEME(theme);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
75 }
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
76
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
77 /******************************************************************************
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
78 * GObject Stuff
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
79 *****************************************************************************/
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
80
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
81 static void
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
82 pidgin_icon_theme_loader_class_init (PidginIconThemeLoaderClass *klass)
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
83 {
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
84 PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass);
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
85
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
86 loader_klass->purple_theme_loader_build = pidgin_icon_loader_build;
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
87 }
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
88
13cd30de531b Add the icon theme files, and re-work some things
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: 24377
diff changeset
90 GType
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
91 pidgin_icon_theme_loader_get_type (void)
13cd30de531b Add the icon theme files, and re-work some things
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: 24377
diff changeset
93 static GType type = 0;
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
94 if (type == 0) {
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
95 static const GTypeInfo info = {
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
96 sizeof(PidginIconThemeLoaderClass),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
97 NULL, /* base_init */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
98 NULL, /* base_finalize */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
99 (GClassInitFunc)pidgin_icon_theme_loader_class_init, /* class_init */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
100 NULL, /* class_finalize */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
101 NULL, /* class_data */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
102 sizeof (PidginIconThemeLoader),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
103 0, /* n_preallocs */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
104 NULL, /* instance_init */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
105 NULL, /* value table */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
106 };
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
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: 24377
diff changeset
108 "PidginIconThemeLoader", &info, 0);
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
109 }
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 24377
diff changeset
110 return type;
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
111 }

mercurial