added parsing xml
authortanya <tanyshk@gmail.com>
Mon, 9 Aug 2010 07:55:02 +0000 (10:55 +0300)
committertanya <tanyshk@gmail.com>
Mon, 9 Aug 2010 07:55:02 +0000 (10:55 +0300)
applet/src/livewp-exthemes.c
applet/src/livewp-exthemes.h

index 7be0d39..d6610f7 100644 (file)
 GHashTable  * 
 parse_theme(gchar *file){
     GHashTable  *hash;
+    xmlDoc *doc;
+    xmlNode *root, *first_child, *node;
+    doc = xmlReadFile(file, NULL, 0);
+    root = xmlDocGetRootElement(doc);
+    first_child = root->children;
     hash = g_hash_table_new(g_str_hash, g_str_equal);
-    g_hash_table_insert(hash, g_strdup("name"),  g_strdup("Xsnow"));
-    g_hash_table_insert(hash, g_strdup("exec_path"),  g_strdup("/usr/bin/xsnow"));
+    for (node = first_child; node; node = node->next){
+        if (node->type == XML_ELEMENT_NODE){ 
+            fprintf(stderr, "%s => %s\n", node->name, xmlNodeGetContent(node));
+            g_hash_table_insert(hash, node->name, xmlNodeGetContent(node));
+        }
+    }
+    xmlFreeDoc(doc);
+    xmlCleanupParser();
+    //g_hash_table_insert(hash, g_strdup("name"),  g_strdup("Xsnow"));
+    //g_hash_table_insert(hash, g_strdup("exec_path"),  g_strdup("/usr/bin/xsnow"));
     return hash;
 }
 
@@ -48,7 +61,7 @@ get_list_exthemes(void){
             if(!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
                 continue;
             if(dp->d_type == DT_REG || dp->d_type == DT_LNK){
-                store = g_slist_append(store, parse_theme(dp->d_name));
+                store = g_slist_append(store, parse_theme(g_strdup_printf("%s%s", EXTHEME_PATH, dp->d_name)));
             }
         }
         closedir(dir_fd);
index 94b36f0..37a4aa1 100644 (file)
@@ -25,6 +25,7 @@
 #include "livewp-common.h"
 #include <dirent.h>                                                                                                              
 #include <linux/fs.h>                                                                                                                    
+#include <libxml/parser.h>
 typedef struct dirent Dirent;
 /*******************************************************************************/