From: Dana Jansens Date: Thu, 28 Feb 2008 02:07:10 +0000 (-0500) Subject: Merge branch 'backport' into work X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=8bd02bf4b883fa369dd68df2053974407024ddaf;hp=-c;p=chaz%2Fopenbox Merge branch 'backport' into work Conflicts: openbox/actions/execute.c --- 8bd02bf4b883fa369dd68df2053974407024ddaf diff --combined openbox/actions/execute.c index ff73bf2b,4197109f..fa66a484 --- a/openbox/actions/execute.c +++ b/openbox/actions/execute.c @@@ -1,8 -1,8 +1,9 @@@ #include "openbox/actions.h" #include "openbox/event.h" #include "openbox/startupnotify.h" + #include "openbox/prompt.h" #include "openbox/screen.h" +#include "obt/paths.h" #include "gettext.h" #ifdef HAVE_STDLIB_H @@@ -15,9 -15,10 +16,10 @@@ typedef struct gchar *sn_name; gchar *sn_icon; gchar *sn_wmclass; + gchar *prompt; } Options; -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); +static gpointer setup_func(xmlNodePtr node); static void free_func(gpointer options); static gboolean run_func(ObActionsData *data, gpointer options); /* @@@ -30,34 -31,41 +32,37 @@@ static void i_cancel_func(gpointer void action_execute_startup(void) { - actions_register("Execute", - setup_func, - free_func, - run_func, - NULL, NULL); + actions_register("Execute", setup_func, free_func, run_func, NULL, NULL); } -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; o = g_new0(Options, 1); - if ((n = parse_find_node("command", node)) || - (n = parse_find_node("execute", node))) + if ((n = obt_parse_find_node(node, "command")) || + (n = obt_parse_find_node(node, "execute"))) { - gchar *s = parse_string(doc, n); - o->cmd = parse_expand_tilde(s); + gchar *s = obt_parse_node_string(n); + o->cmd = obt_paths_expand_tilde(s); g_free(s); } - if ((n = parse_find_node("prompt", node))) - o->prompt = parse_string(doc, n); ++ if ((n = obt_parse_find_node(node, "prompt"))) ++ o->prompt = obt_parse_node_string(n); + - if ((n = parse_find_node("startupnotify", node))) { + if ((n = obt_parse_find_node(node, "startupnotify"))) { xmlNodePtr m; - if ((m = parse_find_node("enabled", n->xmlChildrenNode))) - o->sn = parse_bool(doc, m); - if ((m = parse_find_node("name", n->xmlChildrenNode))) - o->sn_name = parse_string(doc, m); - if ((m = parse_find_node("icon", n->xmlChildrenNode))) - o->sn_icon = parse_string(doc, m); - if ((m = parse_find_node("wmclass", n->xmlChildrenNode))) - o->sn_wmclass = parse_string(doc, m); + if ((m = obt_parse_find_node(n->children, "enabled"))) + o->sn = obt_parse_node_bool(m); + if ((m = obt_parse_find_node(n->children, "name"))) + o->sn_name = obt_parse_node_string(m); + if ((m = obt_parse_find_node(n->children, "icon"))) + o->sn_icon = obt_parse_node_string(m); + if ((m = obt_parse_find_node(n->children, "wmclass"))) + o->sn_wmclass = obt_parse_node_string(m); } return o; } @@@ -75,6 -83,36 +80,36 @@@ static void free_func(gpointer options } } + static Options* dup_options(Options *in) + { + Options *o = g_new(Options, 1); + o->cmd = g_strdup(in->cmd); + o->sn = in->sn; + o->sn_name = g_strdup(in->sn_name); + o->sn_icon = g_strdup(in->sn_icon); + o->sn_wmclass = g_strdup(in->sn_wmclass); + o->prompt = NULL; + return o; + } + + static gboolean run_func(ObActionsData *data, gpointer options); + + static void prompt_cb(ObPrompt *p, gint result, gpointer data) + { + Options *options = data; + + if (result) + run_func(NULL, options); + + prompt_unref(p); + + g_free(options->cmd); + g_free(options->sn_name); + g_free(options->sn_icon); + g_free(options->sn_wmclass); + g_free(options); + } + /* Always return FALSE because its not interactive */ static gboolean run_func(ObActionsData *data, gpointer options) { @@@ -84,6 -122,22 +119,22 @@@ Options *o = options; if (!o->cmd) return FALSE; + + if (o->prompt) { + ObPrompt *p; + Options *ocp; + ObPromptAnswer answers[] = { + { _("No"), 0 }, + { _("Yes"), 1 } + }; + + ocp = dup_options(options); + p = prompt_new(o->prompt, answers, 2, 0, 0, prompt_cb, ocp); + prompt_show(p, NULL, FALSE); + + return FALSE; + } + cmd = g_filename_from_utf8(o->cmd, -1, NULL, NULL, NULL); if (!cmd) { g_message(_("Failed to convert the path \"%s\" from utf8"), o->cmd); diff --combined openbox/actions/exit.c index 662c984a,8430729b..f5af8a12 --- a/openbox/actions/exit.c +++ b/openbox/actions/exit.c @@@ -1,20 -1,58 +1,58 @@@ #include "openbox/actions.h" #include "openbox/openbox.h" + #include "openbox/prompt.h" + #include "gettext.h" + typedef struct { + gboolean prompt; + } Options; + -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); ++static gpointer setup_func(xmlNodePtr node); static gboolean run_func(ObActionsData *data, gpointer options); void action_exit_startup(void) { - actions_register("Exit", - NULL, NULL, - run_func, - NULL, NULL); + actions_register("Exit", setup_func, NULL, run_func, NULL, NULL); + } + -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) ++static gpointer setup_func(xmlNodePtr node) + { + xmlNodePtr n; + Options *o; + + o = g_new0(Options, 1); + - if ((n = parse_find_node("prompt", node))) - o->prompt = parse_bool(doc, n); ++ if ((n = obt_parse_find_node(node, "prompt"))) ++ o->prompt = obt_parse_node_bool(n); + + return o; + } + + static void prompt_cb(ObPrompt *p, gint result, gpointer data) + { + if (result) + ob_exit(0); + prompt_unref(p); } /* Always return FALSE because its not interactive */ static gboolean run_func(ObActionsData *data, gpointer options) { - ob_exit(0); + Options *o = options; + + if (o->prompt) { + ObPrompt *p; + ObPromptAnswer answers[] = { + { _("No"), 0 }, + { _("Yes"), 1 } + }; + + p = prompt_new(_("Are you sure you want to exit Openbox?"), + answers, 2, 0, 0, prompt_cb, NULL); + prompt_show(p, NULL, FALSE); + } + else + ob_exit(0); return FALSE; } diff --combined po/POTFILES.in index 6de409fc,85938dee..200e9ca3 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@@ -1,12 -1,12 +1,13 @@@ # List of source files containing translatable strings. openbox/actions.c openbox/actions/execute.c + openbox/actions/exit.c openbox/client.c openbox/client_list_combined_menu.c openbox/client_list_menu.c openbox/client_menu.c openbox/config.c +openbox/debug.c openbox/keyboard.c openbox/menu.c openbox/mouse.c @@@ -15,4 -15,5 +16,4 @@@ openbox/screen. openbox/session.c openbox/startupnotify.c openbox/translate.c -openbox/xerror.c openbox/prompt.c