]> Dogcows Code - chaz/openbox/commitdiff
Merge branch 'backport' into work
authorDana Jansens <danakj@orodu.net>
Thu, 28 Feb 2008 02:07:10 +0000 (21:07 -0500)
committerDana Jansens <danakj@orodu.net>
Thu, 28 Feb 2008 02:07:10 +0000 (21:07 -0500)
Conflicts:

openbox/actions/execute.c

1  2 
openbox/actions/execute.c
openbox/actions/exit.c
po/POTFILES.in

index ff73bf2bce288eb13e5804372f48b44f286c6669,4197109fba0ec0bc2c6bc948f280583926fe3364..fa66a484a8b4828f0ab5ead4487f827163046c1a
@@@ -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)
  {
      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 662c984a6a41abfe63002daf79483790777be0da,8430729b16ed0121a94045b397565249ccace581..f5af8a12beabadcecde3870d68b47716d87a51d3
@@@ -1,20 -1,58 +1,58 @@@
  #include "openbox/actions.h"
  #include "openbox/openbox.h"
+ #include "openbox/prompt.h"
+ #include "gettext.h"
  
 -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+ typedef struct {
+     gboolean prompt;
+ } Options;
++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 6de409fcda3932eef7a2c06eb2161af6802e7166,85938dee820228b3550891eb7f726e6f5fd76367..200e9ca31ef74786f8c22244af7628992c8b0b57
@@@ -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
This page took 0.034877 seconds and 4 git commands to generate.