another checkpoint
[manmower/obtheme.git] / main.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <glib.h>
4 #include "obtheme.h"
5
6 static void decor_print(gpointer data, gpointer user_data)
7 {
8         struct decor *decor = data;
9         printf("    decor id %s\n", decor->name);
10         printf("      anchor (%d %d %d)\n", decor->space.anchor.x, decor->space.anchor.y, decor->space.anchor.z);
11         printf("      up     (%d %d %d)\n", decor->space.up.x, decor->space.up.y, decor->space.up.z);
12         if (decor->children)
13                 g_slist_foreach(decor->children, decor_print, NULL);
14 }
15
16 static void style_print(gpointer key, gpointer value, gpointer user_data)
17 {
18         char *stylename = key;
19         struct style *style = value;
20
21         printf("  style %s\n", stylename);
22         g_slist_foreach(style->tree, decor_print, NULL);
23 }
24
25 static void theme_print(gpointer key, gpointer value, gpointer user_data)
26 {
27         char *name = key;
28         struct theme *thm = value;
29         printf("name = %s\n", name);
30         g_hash_table_foreach(thm->styles, style_print, NULL);
31 }
32
33 static void material_print(gpointer key, gpointer value, gpointer user_data)
34 {
35         char *name = key;
36         struct material *mat = value;
37         printf("name = %s\n", name);
38         printf(" opacity = %f\n", mat->opacity);
39 }
40
41 int main(int argc, char **argv)
42 {
43         int err;
44         struct obthemedata themedata;
45
46         themedata.themes = g_hash_table_new(g_str_hash, g_str_equal);
47         themedata.materials = g_hash_table_new(g_str_hash, g_str_equal);
48         err = obtheme_parse(&themedata, argv[1]);
49         printf("err = %d\n", err);
50
51         g_hash_table_foreach(themedata.materials, material_print, NULL);
52
53         g_hash_table_foreach(themedata.themes, theme_print, NULL);
54
55         return 0;
56 }