From 8562034e30e8b319a746009859cbefc1f41b41f5 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 15:28:22 -0500 Subject: glib already prints a verbose error message when execute fails. don't add a second level of useless verbosity to that --- openbox/actions/execute.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'openbox/actions') diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c index eb1b461d..f87fe00c 100644 --- a/openbox/actions/execute.c +++ b/openbox/actions/execute.c @@ -143,7 +143,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 { @@ -162,7 +162,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) -- cgit v1.2.3 From 527ecafab95e66a6f0cedd6967fe2c61dfe85101 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 16:04:28 -0500 Subject: the #ifdef was backwards for using SM or not --- openbox/actions/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'openbox/actions') diff --git a/openbox/actions/session.c b/openbox/actions/session.c index 2c373654..fc66d25b 100644 --- a/openbox/actions/session.c +++ b/openbox/actions/session.c @@ -35,7 +35,7 @@ static void prompt_cb(ObPrompt *p, gint result, gpointer data) { Options *o = data; if (result) { -#ifndef USE_SM +#ifdef USE_SM session_request_logout(o->silent); #else g_message(_("The SessionLogout actions is not available since Openbox was built without session management support")); -- cgit v1.2.3 From bb557f06a6828a95ee94c7579919dec1ee014484 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 16:11:05 -0500 Subject: add a cleanup callback to the prompt interface. when the prompt's callback returns TRUE, then the cleanup function is called. likewise when the prompt system is shutdown (openbox is exiting), then the cleanup function is also called. it should unref/destroy the prompt and any memory associated with it --- openbox/actions/execute.c | 9 +++++++-- openbox/actions/exit.c | 9 +++++++-- openbox/actions/session.c | 11 ++++++++--- 3 files changed, 22 insertions(+), 7 deletions(-) (limited to 'openbox/actions') diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c index f87fe00c..636dbebf 100644 --- a/openbox/actions/execute.c +++ b/openbox/actions/execute.c @@ -98,11 +98,15 @@ static Options* dup_options(Options *in) static gboolean run_func(ObActionsData *data, gpointer options); -static void prompt_cb(ObPrompt *p, gint result, gpointer options) +static gboolean prompt_cb(ObPrompt *p, gint result, gpointer options) { if (result) run_func(NULL, options); + return TRUE; /* call the cleanup func */ +} +static void prompt_cleanup(ObPrompt *p, gpointer options) +{ prompt_unref(p); free_func(options); } @@ -126,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, answers, 2, 0, 0, + prompt_cb, prompt_cleanup, ocp); prompt_show(p, NULL, FALSE); return FALSE; diff --git a/openbox/actions/exit.c b/openbox/actions/exit.c index 747514f6..67545cd2 100644 --- a/openbox/actions/exit.c +++ b/openbox/actions/exit.c @@ -29,10 +29,15 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) return o; } -static void prompt_cb(ObPrompt *p, gint result, gpointer data) +static gboolean prompt_cb(ObPrompt *p, gint result, gpointer data) { if (result) ob_exit(0); + return TRUE; /* call the cleanup func */ +} + +static void prompt_cleanup(ObPrompt *p, gpointer data) +{ prompt_unref(p); } @@ -49,7 +54,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) }; p = prompt_new(_("Are you sure you want to exit Openbox?"), - answers, 2, 0, 0, prompt_cb, NULL); + answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL); prompt_show(p, NULL, FALSE); } else diff --git a/openbox/actions/session.c b/openbox/actions/session.c index fc66d25b..ef1497c1 100644 --- a/openbox/actions/session.c +++ b/openbox/actions/session.c @@ -31,7 +31,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) return o; } -static void prompt_cb(ObPrompt *p, gint result, gpointer data) +static gboolean prompt_cb(ObPrompt *p, gint result, gpointer data) { Options *o = data; if (result) { @@ -41,7 +41,12 @@ static void prompt_cb(ObPrompt *p, gint result, gpointer data) g_message(_("The SessionLogout actions is not available since Openbox was built without session management support")); #endif } - g_free(o); + return TRUE; /* call cleanup func */ +} + +static void prompt_cleanup(ObPrompt *p, gpointer data) +{ + g_free(data); prompt_unref(p); } @@ -60,7 +65,7 @@ static gboolean logout_func(ObActionsData *data, gpointer options) o2 = g_memdup(o, sizeof(Options)); p = prompt_new(_("Are you sure you want to log out?"), - answers, 2, 0, 0, prompt_cb, o2); + answers, 2, 0, 0, prompt_cb, prompt_cleanup, o2); prompt_show(p, NULL, FALSE); } else -- cgit v1.2.3 From 9d9ca8d1cf76a63767aef4bd74f5caceaad5ff23 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 17:12:11 -0500 Subject: allow prompts to have titles specified. show a prompt when there are syntax errors in the xml config files. --- openbox/actions/execute.c | 2 +- openbox/actions/exit.c | 1 + openbox/actions/session.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'openbox/actions') diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c index 636dbebf..cb3ab247 100644 --- a/openbox/actions/execute.c +++ b/openbox/actions/execute.c @@ -130,7 +130,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) }; ocp = dup_options(options); - p = prompt_new(o->prompt, answers, 2, 0, 0, + p = prompt_new(o->prompt, _("Execute"), answers, 2, 0, 0, prompt_cb, prompt_cleanup, ocp); prompt_show(p, NULL, FALSE); diff --git a/openbox/actions/exit.c b/openbox/actions/exit.c index 67545cd2..875a181a 100644 --- a/openbox/actions/exit.c +++ b/openbox/actions/exit.c @@ -54,6 +54,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) }; p = prompt_new(_("Are you sure you want to exit Openbox?"), + _("Exit Openbox"), answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL); prompt_show(p, NULL, FALSE); } diff --git a/openbox/actions/session.c b/openbox/actions/session.c index ef1497c1..8fb4f4d7 100644 --- a/openbox/actions/session.c +++ b/openbox/actions/session.c @@ -64,7 +64,7 @@ static gboolean logout_func(ObActionsData *data, gpointer options) }; o2 = g_memdup(o, sizeof(Options)); - p = prompt_new(_("Are you sure you want to log out?"), + p = prompt_new(_("Are you sure you want to log out?"), NULL, answers, 2, 0, 0, prompt_cb, prompt_cleanup, o2); prompt_show(p, NULL, FALSE); } -- cgit v1.2.3 From f542c5143ac115937c5ee8f3a229e557383cd180 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 17:19:39 -0500 Subject: add a title to the session logout confirm prompt --- openbox/actions/session.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'openbox/actions') diff --git a/openbox/actions/session.c b/openbox/actions/session.c index 8fb4f4d7..9bc9ea80 100644 --- a/openbox/actions/session.c +++ b/openbox/actions/session.c @@ -64,7 +64,8 @@ static gboolean logout_func(ObActionsData *data, gpointer options) }; o2 = g_memdup(o, sizeof(Options)); - p = prompt_new(_("Are you sure you want to log out?"), NULL, + p = prompt_new(_("Are you sure you want to log out?"), + _("Log out"), answers, 2, 0, 0, prompt_cb, prompt_cleanup, o2); prompt_show(p, NULL, FALSE); } -- cgit v1.2.3