]> Dogcows Code - chaz/openbox/blobdiff - openbox/actions/execute.c
Combine the Exit and SessionLogout actions
[chaz/openbox] / openbox / actions / execute.c
index 4197109fba0ec0bc2c6bc948f280583926fe3364..cb3ab24796a0e74d0da9ecf87ccdc8cc21bcfed0 100644 (file)
@@ -79,6 +79,7 @@ static void free_func(gpointer options)
         g_free(o->sn_name);
         g_free(o->sn_icon);
         g_free(o->sn_wmclass);
+        g_free(o->prompt);
         g_free(o);
     }
 }
@@ -97,20 +98,17 @@ static Options* dup_options(Options *in)
 
 static gboolean run_func(ObActionsData *data, gpointer options);
 
-static void prompt_cb(ObPrompt *p, gint result, gpointer data)
+static gboolean prompt_cb(ObPrompt *p, gint result, gpointer options)
 {
-    Options *options = data;
-
     if (result)
         run_func(NULL, options);
+    return TRUE; /* call the cleanup func */
+}
 
+static void prompt_cleanup(ObPrompt *p, gpointer 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);
+    free_func(options);
 }
 
 /* Always return FALSE because its not interactive */
@@ -132,7 +130,8 @@ static gboolean run_func(ObActionsData *data, gpointer options)
         };
 
         ocp = dup_options(options);
-        p = prompt_new(o->prompt, answers, 2, 0, 0, prompt_cb, ocp);
+        p = prompt_new(o->prompt, _("Execute"), answers, 2, 0, 0,
+                       prompt_cb, prompt_cleanup, ocp);
         prompt_show(p, NULL, FALSE);
 
         return FALSE;
@@ -149,7 +148,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
     event_cancel_all_key_grabs();
 
     if (!g_shell_parse_argv(cmd, NULL, &argv, &e)) {
-        g_message(_("Failed to execute \"%s\": %s"), o->cmd, e->message);
+        g_message(e->message, o->cmd);
         g_error_free(e);
     }
     else {
@@ -168,7 +167,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
                            G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
                            NULL, NULL, NULL, &e))
         {
-            g_message(_("Failed to execute \"%s\": %s"), o->cmd, e->message);
+            g_message(e->message, o->cmd);
             g_error_free(e);
 
             if (o->sn)
This page took 0.021585 seconds and 4 git commands to generate.