X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=tools%2Fthemetoxml%2Fthemetoxml.c;h=464944d1a2c18c182eab88e5a1ced0a4b83ec983;hb=4940d007cce43a135f1b448902f5a3571dbce62a;hp=e6f947b2759ed96e735aeca94ffe1b98be44a873;hpb=bd272698508dd511266bc6a38d2f04b4b6e3d788;p=chaz%2Fopenbox diff --git a/tools/themetoxml/themetoxml.c b/tools/themetoxml/themetoxml.c index e6f947b2..464944d1 100644 --- a/tools/themetoxml/themetoxml.c +++ b/tools/themetoxml/themetoxml.c @@ -89,8 +89,7 @@ static gboolean read_string(XrmDatabase db, const gchar *rname, if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr != NULL) { - *value = retvalue.addr; - g_strstrip(*value); + *value = g_strstrip(retvalue.addr); ret = TRUE; } @@ -115,7 +114,7 @@ static gboolean parse_color(const gchar *c, gint *r, gint *g, gint *b) c += 4; for (i = 0; i < 3; ++i) { dig1 = hextodec(c[0]); - if (c[1] == '/') { dig2 = dig1; c+=2; } + if (c[1] == '/' || (c[1] == '\0' && i == 2)) { dig2 = dig1; c+=2; } else { dig2 = hextodec(c[1]); c+=3; } if (dig1 < 0 || dig2 < 0) return FALSE; @@ -284,14 +283,15 @@ int main(int argc, char **argv) const gchar *s; int ret = 0; - if (argc > 1) { + if (argc > 2) { fprintf(stderr, "themetoxml (C) 2007 Dana Jansens\n" - "This tool takes an older Openbox3 themerc file on stdin," - " and gives back the\n" - "theme in the newer themerc.xml XML style.\n"); + "This tool takes an older Openbox3 themerc file and prints " + "out the theme in\n" + "theme in the newer XML (themerc.xml) style.\n"); return 0; } - { + + if (argc == 1 || !strcmp(argv[1], "-")) { gchar *buf = g_new(gchar, 1000); gint sz = 1000; gint r = 0, rthis; @@ -311,13 +311,25 @@ int main(int argc, char **argv) } g_free(buf); } + else if (argc == 2) { + if ((db = XrmGetFileDatabase(argv[1])) == NULL) { + fprintf(stderr, "Unable to read the database from %s\n", argv[1]); + return 1; + } + } + doc = xmlNewDoc((const xmlChar*) "1.0"); xmlDocSetRootElement (doc,(root = xmlNewNode(NULL, (const xmlChar*)"openbox_theme"))); + xmlSetProp(root, (const xmlChar*)"engine", (const xmlChar*)"box"); xmlSetProp(root, (const xmlChar*)"version", (const xmlChar*)"1"); xmlSetProp(root, (const xmlChar*)"xmlns", - (const xmlChar*)"http://openbox.org/themerc"); + (const xmlChar*)"http://openbox.org/4.0/themerc"); + CONT2("about", "author", ""); + CONT2("about", "email", ""); + CONT2("about", "webpage", ""); + CONT2("about", "comment", ""); if (read_int(db, "window.handle.width", &i)) CONT2("dimensions", "handle", NUM(i)); @@ -328,21 +340,40 @@ int main(int argc, char **argv) } if (read_int(db, "borderWidth", &i)) { - CONT3("window", "border", "width", NUM(i)); - CONT3("menu", "border", "width", NUM(i)); + CONT3("dimensions", "window", "border", NUM(i)); + CONT3("dimensions", "menu", "border", NUM(i)); } else if (read_int(db, "border.width", &i)) { - CONT3("window", "border", "width", NUM(i)); - CONT3("menu", "border", "width", NUM(i)); + CONT3("dimensions", "window", "border", NUM(i)); + CONT3("dimensions", "menu", "border", NUM(i)); } + if (read_int(db, "menu.border.width", &i)) + CONT3("dimensions", "menu", "border", NUM(i)); if (read_color(db, "border.color", &i, &j, &k)) { - COLOR3("window", "border", "primary", i, j, k, 255); - COLOR3("menu", "border", "primary", i, j, k, 255); + COLOR3("window", "active", "border", i, j, k, 255); + COLOR3("window", "active", "titleseparator", i, j, k, 255); + COLOR3("window", "inactive", "border", i, j, k, 255); + COLOR3("window", "inactive", "titleseparator", i, j, k, 255); + COLOR2("menu", "border", i, j, k, 255); } + if (read_color(db, "window.active.border.color", &i, &j, &k)) { + COLOR3("window", "active", "border", i, j, k, 255); + COLOR3("window", "active", "titleseparator", i, j, k, 255); + } + if (read_color(db, "window.active.title.separator.color", &i, &j, &k)) + COLOR3("window", "active", "titleseparator", i, j, k, 255); + if (read_color(db, "window.inactive.border.color", &i, &j, &k)) { + COLOR3("window", "inactive", "border", i, j, k, 255); + COLOR3("window", "inactive", "titleseparator", i, j, k, 255); + } + if (read_color(db, "window.inactive.title.separator.color", &i, &j, &k)) + COLOR3("window", "inactive", "titleseparator", i, j, k, 255); + if (read_color(db, "menu.border.color", &i, &j, &k)) + COLOR2("menu", "border", i, j, k, 255); if (read_int(db, "window.client.padding.width", &i)) { - ATTR2("window", "clientpadding", "x", NUM(i)); - ATTR2("window", "clientpadding", "y", NUM(i)); + ATTR3("dimensions", "window", "clientpadding", "x", NUM(i)); + ATTR3("dimensions", "window", "clientpadding", "y", NUM(i)); } if (read_string(db, "window.label.text.justify", &s)) { @@ -423,8 +454,12 @@ int main(int argc, char **argv) COLOR3("menu","inactive","primary",i,j,k,255); if (read_color(db, "menu.items.disabled.text.color", - &i, &j, &k)) + &i, &j, &k)) { COLOR3("menu","disabled","primary",i,j,k,255); + read_color(db, "menu.items.active.disabled.text.color", + &i, &j, &k); /* read this if we can */ + COLOR4("menu","active-disabled","text","primary",i,j,k,255); + } if (read_color(db, "menu.items.active.text.color", &i, &j, &k)) @@ -440,6 +475,7 @@ int main(int argc, char **argv) APPEARANCE3("window.inactive.grip.bg", "window", "inactive", "grip"); APPEARANCE2("menu.items.bg", "menu", "entries"); APPEARANCE2("menu.items.active.bg", "menu", "active"); + APPEARANCE2("menu.items.active.bg", "menu", "active-disabled"); APPEARANCE2("menu.title.bg", "menu", "title"); APPEARANCE4("window.active.button.disabled.bg", @@ -539,6 +575,10 @@ int main(int argc, char **argv) ATTR5("menu","active","text","shadow","offset","y",NUM(i)); ATTR4("menu","disabled","shadow","offset","x",NUM(i)); ATTR4("menu","disabled","shadow","offset","y",NUM(i)); + ATTR5("menu","active-disabled","text","shadow","offset","x", + NUM(i)); + ATTR5("menu","active-disabled","text","shadow","offset","y", + NUM(i)); } if ((p = strstr(s, "shadowtint="))) { @@ -548,6 +588,7 @@ int main(int argc, char **argv) COLOR4("menu","inactive","shadow","primary",j,j,j,i); COLOR5("menu","active","text","shadow","primary",j,j,j,i); COLOR4("menu","disabled","shadow","primary",j,j,j,i); + COLOR5("menu","active-disabled","text","shadow","primary",j,j,j,i); } }