- struct HistoryItem *hi;
- gsize ret;
-
- io = g_io_channel_new_file(history_path, "w", &err);
- if (io != NULL) {
- for (it = history; it != NULL; it = it->next) {
- hi = it->data;
- buf = g_string_sized_new(0);
- buf=g_string_append(buf, hi->name);
- g_string_append_c(buf, '\t');
- buf=g_string_append(buf, hi->class);
- g_string_append_c(buf, '\t');
- buf=g_string_append(buf, hi->role);
- g_string_append_c(buf, '\t');
- g_string_append_printf(buf, "%d", hi->x);
- buf=g_string_append_c(buf, '\t');
- g_string_append_printf(buf, "%d", hi->y);
- buf=g_string_append_c(buf, '\n');
- if (g_io_channel_write_chars(io, buf->str, buf->len, &ret, &err) !=
- G_IO_STATUS_NORMAL)
- break;
- g_string_free(buf, TRUE);
+
+ doc = xmlNewDoc(NULL);
+ root = xmlNewNode(NULL, (const xmlChar*) "openbox_history");
+ xmlDocSetRootElement(doc, root);
+
+ for (it = history_list; it; it = g_slist_next(it)) {
+ struct HistoryItem *hi = it->data;
+ g_message("adding %s", hi->name);
+ node = xmlNewChild(root, NULL, (const xmlChar*) "entry", NULL);
+ xmlNewProp(node, (const xmlChar*) "name", (const xmlChar*) hi->name);
+ xmlNewProp(node, (const xmlChar*) "class", (const xmlChar*) hi->class);
+ xmlNewProp(node, (const xmlChar*) "role", (const xmlChar*) hi->role);
+ if (hi->flags & HAVE_POSITION) {
+ s = g_strdup_printf("%d", hi->x);
+ xmlNewTextChild(node, NULL,
+ (const xmlChar*) "x", (const xmlChar*) s);
+ g_free(s);
+ s = g_strdup_printf("%d", hi->y);
+ xmlNewTextChild(node, NULL,
+ (const xmlChar*) "y", (const xmlChar*) s);
+ g_free(s);
+ }
+ if (hi->flags & HAVE_SIZE) {
+ s = g_strdup_printf("%d", hi->w);
+ xmlNewTextChild(node, NULL,
+ (const xmlChar*) "width", (const xmlChar*) s);
+ g_free(s);
+ s = g_strdup_printf("%d", hi->h);
+ xmlNewTextChild(node, NULL,
+ (const xmlChar*) "height", (const xmlChar*) s);
+ g_free(s);
+ }
+ if (hi->flags & HAVE_DESKTOP) {
+ s = g_strdup_printf("%d", hi->desk < 0 ? hi->desk : hi->desk + 1);
+ xmlNewTextChild(node, NULL,
+ (const xmlChar*) "desktop", (const xmlChar*) s);
+ g_free(s);