pidgin/gtkblist-theme-loader.c

Thu, 23 Apr 2009 02:31:03 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Thu, 23 Apr 2009 02:31:03 +0000
branch
sadrul.gtkblist-theme
changeset 26842
a36a7b6d0a5c
parent 26803
d48e945e622f
child 26870
517c90cd1d34
permissions
-rw-r--r--

Use stock-id where possible, instead of a pixbuf.

23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
1 /*
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
2 * GTKBlistThemeLoader for Pidgin
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
3 *
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
4 * Pidgin is the legal property of its developers, whose names are too numerous
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
6 * source distribution.
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
7 *
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
12 *
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
17 *
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
21 */
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
22
23659
8251d0f67df5 restructured much of the loader and themes for the buddy list, along with a basic trial of group background
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23658
diff changeset
23 #include <stdlib.h>
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
24 #include <string.h>
23659
8251d0f67df5 restructured much of the loader and themes for the buddy list, along with a basic trial of group background
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23658
diff changeset
25
8251d0f67df5 restructured much of the loader and themes for the buddy list, along with a basic trial of group background
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23658
diff changeset
26 #include "xmlnode.h"
23660
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
27
24377
8d0bfda8402d renamed gtkblist-loader.[ch] to gtblist-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 23972
diff changeset
28 #include "gtkblist-theme-loader.h"
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
29 #include "gtkblist-theme.h"
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
30
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
31 /******************************************************************************
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
32 * Globals
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
33 *****************************************************************************/
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
34
23663
4ee0d825f3b3 Added layout capabilities to blist themes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23660
diff changeset
35 #define DEFAULT_TEXT_COLOR "black"
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
36
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
37 /*****************************************************************************
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
38 * Buddy List Theme Builder
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
39 *****************************************************************************/
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
40
26803
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
41 static PidginThemeFont *
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
42 pidgin_theme_font_parse(xmlnode *node)
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
43 {
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
44 const char *font;
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
45 const char *colordesc;
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
46 GdkColor color;
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
47
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
48 font = xmlnode_get_attrib(node, "font");
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
49
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
50 if ((colordesc = xmlnode_get_attrib(node, "color")) == NULL ||
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
51 !gdk_color_parse(colordesc, &color))
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
52 gdk_color_parse(DEFAULT_TEXT_COLOR, &color);
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
53
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
54 return pidgin_theme_font_new(font, &color);
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
55 }
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
56
23971
9764690b14f2 Changed PurpleTheme build function to only return PurpleTheme*
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23666
diff changeset
57 static PurpleTheme *
23659
8251d0f67df5 restructured much of the loader and themes for the buddy list, along with a basic trial of group background
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23658
diff changeset
58 pidgin_blist_loader_build(const gchar *dir)
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
59 {
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
60 xmlnode *root_node = NULL, *sub_node, *sub_sub_node;
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
61 gchar *filename_full, *data;
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
62 const gchar *temp;
25863
b724badf6cd2 Adding the patch to extend the blist theme to allow coloring of chat nodes with unread messages mentioning your nick.
Paul Aurich <darkrain42@pidgin.im>
parents: 24377
diff changeset
63 gboolean success = TRUE;
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
64 GdkColor bgcolor, expanded_bgcolor, collapsed_bgcolor, contact_color;
26803
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
65 PidginThemeFont *expanded, *collapsed, *contact, *online, *away, *offline, *idle, *message, *message_nick_said, *status;
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
66 PidginBlistLayout layout;
23659
8251d0f67df5 restructured much of the loader and themes for the buddy list, along with a basic trial of group background
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23658
diff changeset
67 PidginBlistTheme *theme;
26803
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
68 int i;
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
69 struct {
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
70 const char *tag;
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
71 PidginThemeFont **font;
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
72 } lookups[] = {
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
73 {"contact_text", &contact},
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
74 {"online_text", &online},
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
75 {"away_text", &away},
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
76 {"offline_text", &offline},
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
77 {"idle_text", &idle},
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
78 {"message_text", &message},
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
79 {"message_nick_said_text", &message_nick_said},
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
80 {"status_text", &status},
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
81 {NULL, NULL}
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
82 };
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
83
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
84 /* Find the theme file */
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
85 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
86 filename_full = g_build_filename(dir, "theme.xml", NULL);
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
87
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
88 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR))
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
89 root_node = xmlnode_from_file(dir, "theme.xml", "buddy list themes", "blist-loader");
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
90
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
91 g_free(filename_full);
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
92 g_return_val_if_fail(root_node != NULL, NULL);
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
93
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
94 sub_node = xmlnode_get_child(root_node, "description");
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
95 data = xmlnode_get_data(sub_node);
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
96
23659
8251d0f67df5 restructured much of the loader and themes for the buddy list, along with a basic trial of group background
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23658
diff changeset
97 /* <blist> */
25863
b724badf6cd2 Adding the patch to extend the blist theme to allow coloring of chat nodes with unread messages mentioning your nick.
Paul Aurich <darkrain42@pidgin.im>
parents: 24377
diff changeset
98 if ((success = (sub_node = xmlnode_get_child(root_node, "blist")) != NULL)) {
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
99 if ((temp = xmlnode_get_attrib(sub_node, "color")) != NULL && gdk_color_parse(temp, &bgcolor))
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
100 gdk_colormap_alloc_color(gdk_colormap_get_system(), &bgcolor, FALSE, TRUE);
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
101 else
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
102 memset(&bgcolor, 0, sizeof(GdkColor));
23660
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
103 }
23658
7a1d0db67fcb build function for pidgin buddy list theme loader
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23656
diff changeset
104
7a1d0db67fcb build function for pidgin buddy list theme loader
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23656
diff changeset
105 /* <groups> */
25863
b724badf6cd2 Adding the patch to extend the blist theme to allow coloring of chat nodes with unread messages mentioning your nick.
Paul Aurich <darkrain42@pidgin.im>
parents: 24377
diff changeset
106 if ((success = (success && (sub_node = xmlnode_get_child(root_node, "groups")) != NULL
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
107 && (sub_sub_node = xmlnode_get_child(sub_node, "expanded")) != NULL)))
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
108 {
26803
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
109 expanded = pidgin_theme_font_parse(sub_sub_node);
23658
7a1d0db67fcb build function for pidgin buddy list theme loader
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23656
diff changeset
110
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
111 if ((temp = xmlnode_get_attrib(sub_sub_node, "background")) != NULL && gdk_color_parse(temp, &expanded_bgcolor))
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
112 gdk_colormap_alloc_color(gdk_colormap_get_system(), &expanded_bgcolor, FALSE, TRUE);
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
113 else
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
114 memset(&expanded_bgcolor, 0, sizeof(GdkColor));
23660
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
115 }
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
116
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
117 if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "collapsed")) != NULL)))
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
118 {
26803
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
119 collapsed = pidgin_theme_font_parse(sub_sub_node);
23663
4ee0d825f3b3 Added layout capabilities to blist themes
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23660
diff changeset
120
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
121 if ((temp = xmlnode_get_attrib(sub_sub_node, "background")) != NULL && gdk_color_parse(temp, &collapsed_bgcolor))
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
122 gdk_colormap_alloc_color(gdk_colormap_get_system(), &collapsed_bgcolor, FALSE, TRUE);
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
123 else
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
124 memset(&collapsed_bgcolor, 0, sizeof(GdkColor));
23660
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
125 }
23658
7a1d0db67fcb build function for pidgin buddy list theme loader
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23656
diff changeset
126
7a1d0db67fcb build function for pidgin buddy list theme loader
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23656
diff changeset
127 /* <buddys> */
25863
b724badf6cd2 Adding the patch to extend the blist theme to allow coloring of chat nodes with unread messages mentioning your nick.
Paul Aurich <darkrain42@pidgin.im>
parents: 24377
diff changeset
128 if ((success = (success && (sub_node = xmlnode_get_child(root_node, "buddys")) != NULL &&
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
129 (sub_sub_node = xmlnode_get_child(sub_node, "placement")) != NULL)))
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
130 {
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
131 layout.status_icon = (temp = xmlnode_get_attrib(sub_sub_node, "status_icon")) != NULL ? atoi(temp) : 0;
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
132 layout.text = (temp = xmlnode_get_attrib(sub_sub_node, "name")) != NULL ? atoi(temp) : 1;
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
133 layout.emblem = (temp = xmlnode_get_attrib(sub_sub_node, "emblem")) != NULL ? atoi(temp) : 2;
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
134 layout.protocol_icon = (temp = xmlnode_get_attrib(sub_sub_node, "protocol_icon")) != NULL ? atoi(temp) : 3;
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
135 layout.buddy_icon = (temp = xmlnode_get_attrib(sub_sub_node, "buddy_icon")) != NULL ? atoi(temp) : 4;
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
136 layout.show_status = (temp = xmlnode_get_attrib(sub_sub_node, "status_icon")) != NULL ? atoi(temp) != 0 : 1;
23660
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
137 }
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
138
25863
b724badf6cd2 Adding the patch to extend the blist theme to allow coloring of chat nodes with unread messages mentioning your nick.
Paul Aurich <darkrain42@pidgin.im>
parents: 24377
diff changeset
139 if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "background")) != NULL))) {
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
140 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), &contact_color))
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
141 gdk_colormap_alloc_color(gdk_colormap_get_system(), &contact_color, FALSE, TRUE);
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
142 else
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
143 memset(&contact_color, 0, sizeof(GdkColor));
23665
c9944e9b97e1 Added text and font coloring for buddies, contacts and chats, as well as fix a few small bugs
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23663
diff changeset
144 }
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
145
26803
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
146 for (i = 0; success && lookups[i].tag; i++) {
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
147 if ((success = (sub_node != NULL &&
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
148 (sub_sub_node = xmlnode_get_child(sub_node, lookups[i].tag)) != NULL))) {
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
149 *(lookups[i].font) = pidgin_theme_font_parse(sub_sub_node);
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
150 } else {
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
151 *(lookups[i].font) = NULL;
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
152 }
23660
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
153 }
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
154
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
155 /* name is required for theme manager */
25863
b724badf6cd2 Adding the patch to extend the blist theme to allow coloring of chat nodes with unread messages mentioning your nick.
Paul Aurich <darkrain42@pidgin.im>
parents: 24377
diff changeset
156 success = (success && xmlnode_get_attrib(root_node, "name") != NULL);
23658
7a1d0db67fcb build function for pidgin buddy list theme loader
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23656
diff changeset
157
7a1d0db67fcb build function for pidgin buddy list theme loader
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23656
diff changeset
158 /* the new theme */
23659
8251d0f67df5 restructured much of the loader and themes for the buddy list, along with a basic trial of group background
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23658
diff changeset
159 theme = g_object_new(PIDGIN_TYPE_BLIST_THEME,
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
160 "type", "blist",
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
161 "name", xmlnode_get_attrib(root_node, "name"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
162 "author", xmlnode_get_attrib(root_node, "author"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
163 "image", xmlnode_get_attrib(root_node, "image"),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
164 "directory", dir,
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
165 "description", data,
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
166 "background-color", &bgcolor,
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
167 "layout", &layout,
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
168 "expanded-color", &expanded_bgcolor,
26803
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
169 "expanded-text", expanded,
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
170 "collapsed-color", &collapsed_bgcolor,
26803
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
171 "collapsed-text", collapsed,
26785
a4411d5d13d1 PidginBlistTheme now copies all its parameters instead of taking ownership.
Paul Aurich <darkrain42@pidgin.im>
parents: 26781
diff changeset
172 "contact-color", &contact_color,
26803
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
173 "contact", contact,
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
174 "online", online,
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
175 "away", away,
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
176 "offline", offline,
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
177 "idle", idle,
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
178 "message", message,
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
179 "message_nick_said", message_nick_said,
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
180 "status", status, NULL);
23660
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
181
26803
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
182 for (i = 0; lookups[i].tag; i++) {
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
183 if (*lookups[i].font) {
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
184 pidgin_theme_font_free(*lookups[i].font);
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
185 }
d48e945e622f Several changes:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26785
diff changeset
186 }
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
187 xmlnode_free(root_node);
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
188 g_free(data);
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
189
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
190 /* malformed xml file - also frees all partial data*/
25863
b724badf6cd2 Adding the patch to extend the blist theme to allow coloring of chat nodes with unread messages mentioning your nick.
Paul Aurich <darkrain42@pidgin.im>
parents: 24377
diff changeset
191 if (!success) {
23660
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
192 g_object_unref(theme);
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
193 theme = NULL;
8637cec033e1 Fixed gtkblist-loader_build to no longer assume xml file is correct, added set methods to gtkblist-theme
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23659
diff changeset
194 }
23665
c9944e9b97e1 Added text and font coloring for buddies, contacts and chats, as well as fix a few small bugs
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23663
diff changeset
195
23971
9764690b14f2 Changed PurpleTheme build function to only return PurpleTheme*
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23666
diff changeset
196 return PURPLE_THEME(theme);
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
197 }
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
198
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
199 /******************************************************************************
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
200 * GObject Stuff
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
201 *****************************************************************************/
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
202
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
203 static void
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
204 pidgin_blist_theme_loader_class_init(PidginBlistThemeLoaderClass *klass)
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
205 {
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
206 PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass);
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
207
23659
8251d0f67df5 restructured much of the loader and themes for the buddy list, along with a basic trial of group background
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23658
diff changeset
208 loader_klass->purple_theme_loader_build = pidgin_blist_loader_build;
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
209 }
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
210
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
211 GType
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23971
diff changeset
212 pidgin_blist_theme_loader_get_type(void)
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
213 {
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
214 static GType type = 0;
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
215 if (type == 0) {
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
216 static const GTypeInfo info = {
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
217 sizeof(PidginBlistThemeLoaderClass),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
218 NULL, /* base_init */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
219 NULL, /* base_finalize */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
220 (GClassInitFunc)pidgin_blist_theme_loader_class_init, /* class_init */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
221 NULL, /* class_finalize */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
222 NULL, /* class_data */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
223 sizeof(PidginBlistThemeLoader),
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
224 0, /* n_preallocs */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
225 NULL, /* instance_init */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
226 NULL, /* value table */
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
227 };
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
228 type = g_type_register_static(PURPLE_TYPE_THEME_LOADER,
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
229 "PidginBlistThemeLoader", &info, 0);
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
230 }
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 25863
diff changeset
231 return type;
23656
d4acd51c1446 start of blist themes (themes have no effect on display)
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
232 }

mercurial