X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=parser%2Fparse.c;h=167456509e63a44e983ba1660dfb0f4669700ef4;hb=5aea44adc96555614ec1f4adb1058f4825e98009;hp=011808fb0d3a8ab16656af775391eea1880db243;hpb=2442cdfd85e5229c7ee4ac49ca66a7d55ffcb919;p=chaz%2Fopenbox diff --git a/parser/parse.c b/parser/parse.c index 011808fb..16745650 100644 --- a/parser/parse.c +++ b/parser/parse.c @@ -79,29 +79,26 @@ void parse_register(ObParseInst *i, const gchar *tag, g_hash_table_insert(i->callbacks, c->tag, c); } -gboolean parse_load_rc(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root, - gchar **fileused) +gboolean parse_load_rc(const gchar *type, xmlDocPtr *doc, xmlNodePtr *root) { GSList *it; gboolean r = FALSE; + gchar *fname; - *fileused = NULL; + if (type == NULL) + fname = g_strdup("rc.xml"); + else + fname = g_strdup_printf("rc-%s.xml", type); - if (file) { - if ((r = parse_load(file, "openbox_config", doc, root))) - *fileused = g_strdup(file); - } else { - /* this won't run if the above code loaded a config */ - for (it = xdg_config_dir_paths; !r && it; it = g_slist_next(it)) { - gchar *path; + for (it = xdg_config_dir_paths; !r && it; it = g_slist_next(it)) { + gchar *path; - path = g_build_filename(it->data, "openbox", "rc.xml", NULL); - if ((r = parse_load(path, "openbox_config", doc, root))) - *fileused = path; - else - g_free(path); - } + path = g_build_filename(it->data, "openbox", fname, NULL); + r = parse_load(path, "openbox_config", doc, root); + g_free(path); } + g_free(fname); + return r; } @@ -111,20 +108,35 @@ gboolean parse_load_theme(const gchar *name, xmlDocPtr *doc, xmlNodePtr *root, GSList *it; gchar *path; gboolean r = FALSE; + gchar *eng; /* backward compatibility.. */ path = g_build_filename(g_get_home_dir(), ".themes", name, "openbox-3", "themerc.xml", NULL); - if ((r = parse_load(path, "openbox_theme", doc, root))) - *retpath = g_path_get_dirname(path); + if (parse_load(path, "openbox_theme", doc, root) && + parse_attr_string("engine", *root, &eng)) + { + if (!strcmp(eng, "box")) { + *retpath = g_path_get_dirname(path); + r = TRUE; + } + g_free(eng); + } g_free(path); if (!r) { for (it = xdg_data_dir_paths; !r && it; it = g_slist_next(it)) { path = g_build_filename(it->data, "themes", name, "openbox-3", "themerc.xml", NULL); - if ((r = parse_load(path, "openbox_theme", doc, root))) - *retpath = g_path_get_dirname(path); + if (parse_load(path, "openbox_theme", doc, root) && + parse_attr_string("engine", *root, &eng)) + { + if (!strcmp(eng, "box")) { + *retpath = g_path_get_dirname(path); + r = TRUE; + } + g_free(eng); + } g_free(path); } }