summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2010-02-11 10:25:35 -0500
committerDana Jansens <danakj@orodu.net>2010-02-11 11:01:18 -0500
commit580e2167f86c821d34bbe7e2c3011e68df3f151e (patch)
tree93d9c1162c369bf6e3eb4139aa0b2778e496e8ec
parent2202f11f239bb33e49c05aa73b51e7418748cb6b (diff)
make the execute action not segfault when using a prompt (bug #4543)
also save the client when using a prompt so it can be used if you choose "yes" from the prompt
-rw-r--r--openbox/actions/execute.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c
index 0e9e7387..ed205364 100644
--- a/openbox/actions/execute.c
+++ b/openbox/actions/execute.c
@@ -18,22 +18,34 @@ typedef struct {
gchar *sn_icon;
gchar *sn_wmclass;
gchar *prompt;
+ ObActionsData *data;
} Options;
static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
-/*
-static gboolean i_input_func(guint initial_state,
- XEvent *e,
- gpointer options,
- gboolean *used);
-static void i_cancel_func(gpointer options);
-*/
+static void shutdown_func(void);
+static void client_dest(ObClient *client, gpointer data);
+
+static GSList *prompt_opts = NULL;
void action_execute_startup(void)
{
actions_register("Execute", setup_func, free_func, run_func);
+ actions_set_shutdown("Execute", shutdown_func);
+
+ client_add_destroy_notify(client_dest, NULL);
+}
+
+static void client_dest(ObClient *client, gpointer data)
+{
+ GSList *it;
+
+ for (it = prompt_opts; it; it = g_slist_next(it)) {
+ Options *o = it->data;
+ if (o->data->client == client)
+ o->data->client = NULL;
+ }
}
static gpointer setup_func(xmlNodePtr node)
@@ -68,21 +80,29 @@ static gpointer setup_func(xmlNodePtr node)
return o;
}
+static void shutdown_func(void)
+{
+ client_remove_destroy_notify(client_dest);
+}
+
static void free_func(gpointer options)
{
Options *o = options;
if (o) {
+ prompt_opts = g_slist_remove(prompt_opts, o);
+
g_free(o->cmd);
g_free(o->sn_name);
g_free(o->sn_icon);
g_free(o->sn_wmclass);
g_free(o->prompt);
+ if (o->data) g_free(o->data);
g_free(o);
}
}
-static Options* dup_options(Options *in)
+static Options* dup_options(Options *in, ObActionsData *data)
{
Options *o = g_new(Options, 1);
o->cmd = g_strdup(in->cmd);
@@ -91,15 +111,15 @@ static Options* dup_options(Options *in)
o->sn_icon = g_strdup(in->sn_icon);
o->sn_wmclass = g_strdup(in->sn_wmclass);
o->prompt = NULL;
+ o->data = g_memdup(data, sizeof(ObActionsData));
return o;
}
-static gboolean run_func(ObActionsData *data, gpointer options);
-
static gboolean prompt_cb(ObPrompt *p, gint result, gpointer options)
{
+ Options *o = options;
if (result)
- run_func(NULL, options);
+ run_func(o->data, o);
return TRUE; /* call the cleanup func */
}
@@ -127,7 +147,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
{ _("Yes"), 1 }
};
- ocp = dup_options(options);
+ ocp = dup_options(options, data);
p = prompt_new(o->prompt, _("Execute"), answers, 2, 0, 0,
prompt_cb, prompt_cleanup, ocp);
prompt_show(p, NULL, FALSE);