X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Faction.c;h=2dde0f0bdc997770d28276030065a1ec5972e3a4;hb=d1e355de2c6aae38cea3cdc0e0b902ea2b194e86;hp=d79bf7aec0b86bdda0a6df5495471a8624e3b2a9;hpb=75e691a2a563b488bef8010315fcfb4296b5cccf;p=chaz%2Fopenbox diff --git a/openbox/action.c b/openbox/action.c index d79bf7ae..2dde0f0b 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -548,14 +548,71 @@ Action *action_from_string(char *name) return a; } +Action *action_parse(xmlDocPtr doc, xmlNodePtr node) +{ + char *actname; + Action *act = NULL; + xmlNodePtr n; + + if (parse_attr_string("name", node, &actname)) { + if ((act = action_from_string(actname))) { + if (act->func == action_execute || act->func == action_restart) { + if ((n = parse_find_node("execute", node->xmlChildrenNode))) + act->data.execute.path = parse_string(doc, n); + } else if (act->func == action_showmenu) { + if ((n = parse_find_node("menu", node->xmlChildrenNode))) + act->data.showmenu.name = parse_string(doc, n); + } else if (act->func == action_desktop) { + if ((n = parse_find_node("desktop", node->xmlChildrenNode))) + act->data.desktop.desk = parse_int(doc, n); + if (act->data.desktop.desk > 0) act->data.desktop.desk--; + } else if (act->func == action_send_to_desktop) { + if ((n = parse_find_node("desktop", node->xmlChildrenNode))) + act->data.sendto.desk = parse_int(doc, n); + if (act->data.sendto.desk > 0) act->data.sendto.desk--; + } else if (act->func == action_move_relative_horz || + act->func == action_move_relative_vert || + act->func == action_resize_relative_horz || + act->func == action_resize_relative_vert) { + if ((n = parse_find_node("delta", node->xmlChildrenNode))) + act->data.relative.delta = parse_int(doc, n); + } else if (act->func == action_desktop_right || + act->func == action_desktop_left || + act->func == action_desktop_up || + act->func == action_desktop_down) { + if ((n = parse_find_node("wrap", node->xmlChildrenNode))) { + g_message("WRAP %d", parse_bool(doc, n)); + act->data.desktopdir.wrap = parse_bool(doc, n); + } + } else if (act->func == action_send_to_desktop_right || + act->func == action_send_to_desktop_left || + act->func == action_send_to_desktop_up || + act->func == action_send_to_desktop_down) { + if ((n = parse_find_node("wrap", node->xmlChildrenNode))) + act->data.sendtodir.wrap = parse_bool(doc, n); + if ((n = parse_find_node("follow", node->xmlChildrenNode))) + act->data.sendtodir.follow = parse_bool(doc, n); + } + } + } + return act; +} + void action_execute(union ActionData *data) { GError *e = NULL; - if (data->execute.path) - if (!g_spawn_command_line_async(data->execute.path, &e)) { - g_warning("failed to execute '%s': %s", - data->execute.path, e->message); + char *cmd; + if (data->execute.path) { + cmd = g_filename_from_utf8(data->execute.path, -1, NULL, NULL, NULL); + if (cmd) { + if (!g_spawn_command_line_async(cmd, &e)) { + g_warning("failed to execute '%s': %s", + cmd, e->message); + } + } else { + g_warning("failed to convert '%s' from utf8", data->execute.path); } + } } void action_focus(union ActionData *data)