| 31 *****************************************************************************/ |
31 *****************************************************************************/ |
| 32 |
32 |
| 33 static PurpleTheme * |
33 static PurpleTheme * |
| 34 pidgin_icon_loader_build(const gchar *theme_dir) |
34 pidgin_icon_loader_build(const gchar *theme_dir) |
| 35 { |
35 { |
| 36 xmlnode *root_node = NULL, *sub_node; |
36 PurpleXmlNode *root_node = NULL, *sub_node; |
| 37 gchar *dir, *filename_full, *data = NULL; |
37 gchar *dir, *filename_full, *data = NULL; |
| 38 PidginIconTheme *theme = NULL; |
38 PidginIconTheme *theme = NULL; |
| 39 const gchar *name; |
39 const gchar *name; |
| 40 |
40 |
| 41 /* Find the theme file */ |
41 /* Find the theme file */ |
| 42 g_return_val_if_fail(theme_dir != NULL, NULL); |
42 g_return_val_if_fail(theme_dir != NULL, NULL); |
| 43 dir = g_build_filename(theme_dir, "purple", "status-icon", NULL); |
43 dir = g_build_filename(theme_dir, "purple", "status-icon", NULL); |
| 44 filename_full = g_build_filename(dir, "theme.xml", NULL); |
44 filename_full = g_build_filename(dir, "theme.xml", NULL); |
| 45 |
45 |
| 46 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR)) |
46 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR)) |
| 47 root_node = xmlnode_from_file(dir, "theme.xml", "icon themes", "icon-theme-loader"); |
47 root_node = purple_xmlnode_from_file(dir, "theme.xml", "icon themes", "icon-theme-loader"); |
| 48 |
48 |
| 49 g_free(filename_full); |
49 g_free(filename_full); |
| 50 if (root_node == NULL) { |
50 if (root_node == NULL) { |
| 51 g_free(dir); |
51 g_free(dir); |
| 52 return NULL; |
52 return NULL; |
| 53 } |
53 } |
| 54 |
54 |
| 55 name = xmlnode_get_attrib(root_node, "name"); |
55 name = purple_xmlnode_get_attrib(root_node, "name"); |
| 56 |
56 |
| 57 if (name) { |
57 if (name) { |
| 58 /* Parse the tree */ |
58 /* Parse the tree */ |
| 59 sub_node = xmlnode_get_child(root_node, "description"); |
59 sub_node = purple_xmlnode_get_child(root_node, "description"); |
| 60 data = xmlnode_get_data(sub_node); |
60 data = purple_xmlnode_get_data(sub_node); |
| 61 |
61 |
| 62 if (xmlnode_get_attrib(root_node, "name") != NULL) { |
62 if (purple_xmlnode_get_attrib(root_node, "name") != NULL) { |
| 63 theme = g_object_new(PIDGIN_TYPE_STATUS_ICON_THEME, |
63 theme = g_object_new(PIDGIN_TYPE_STATUS_ICON_THEME, |
| 64 "type", "status-icon", |
64 "type", "status-icon", |
| 65 "name", name, |
65 "name", name, |
| 66 "author", xmlnode_get_attrib(root_node, "author"), |
66 "author", purple_xmlnode_get_attrib(root_node, "author"), |
| 67 "image", xmlnode_get_attrib(root_node, "image"), |
67 "image", purple_xmlnode_get_attrib(root_node, "image"), |
| 68 "directory", dir, |
68 "directory", dir, |
| 69 "description", data, NULL); |
69 "description", data, NULL); |
| 70 |
70 |
| 71 sub_node = xmlnode_get_child(root_node, "icon"); |
71 sub_node = purple_xmlnode_get_child(root_node, "icon"); |
| 72 |
72 |
| 73 while (sub_node) { |
73 while (sub_node) { |
| 74 pidgin_icon_theme_set_icon(theme, |
74 pidgin_icon_theme_set_icon(theme, |
| 75 xmlnode_get_attrib(sub_node, "id"), |
75 purple_xmlnode_get_attrib(sub_node, "id"), |
| 76 xmlnode_get_attrib(sub_node, "file")); |
76 purple_xmlnode_get_attrib(sub_node, "file")); |
| 77 sub_node = xmlnode_get_next_twin(sub_node); |
77 sub_node = purple_xmlnode_get_next_twin(sub_node); |
| 78 } |
78 } |
| 79 } |
79 } |
| 80 } |
80 } |
| 81 |
81 |
| 82 xmlnode_free(root_node); |
82 purple_xmlnode_free(root_node); |
| 83 g_free(data); |
83 g_free(data); |
| 84 return PURPLE_THEME(theme); |
84 return PURPLE_THEME(theme); |
| 85 } |
85 } |
| 86 |
86 |
| 87 /****************************************************************************** |
87 /****************************************************************************** |