From 8562034e30e8b319a746009859cbefc1f41b41f5 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 15:28:22 -0500 Subject: [PATCH 1/7] 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(-) 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) From 7ea56abf05b9e6cd4e806dbfa1146562378edc7b Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 15:37:07 -0500 Subject: [PATCH 2/7] add a RECONFIGURING state, and enter that when doing reconfiguring --- openbox/event.c | 2 ++ openbox/misc.h | 3 ++- openbox/openbox.c | 12 +++++++++--- openbox/openbox.h | 1 + openbox/screen.c | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/openbox/event.c b/openbox/event.c index 5c4700ae..a7f65fcb 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -652,9 +652,11 @@ static void event_process(const XEvent *ec, gpointer data) /* keyboard layout changes for modifier mapping changes. reload the modifier map, and rebind all the key bindings as appropriate */ ob_debug("Kepboard map changed. Reloading keyboard bindings.\n"); + ob_set_state(OB_STATE_RECONFIGURING); modkeys_shutdown(TRUE); modkeys_startup(TRUE); keyboard_rebind(); + ob_set_state(OB_STATE_RUNNING); } else if (e->type == ClientMessage) { /* This is for _NET_WM_REQUEST_FRAME_EXTENTS messages. They come for diff --git a/openbox/misc.h b/openbox/misc.h index c73c9265..c1ec4075 100644 --- a/openbox/misc.h +++ b/openbox/misc.h @@ -60,7 +60,8 @@ typedef enum { OB_STATE_STARTING, OB_STATE_RUNNING, - OB_STATE_EXITING + OB_STATE_EXITING, + OB_STATE_RECONFIGURING } ObState; typedef enum diff --git a/openbox/openbox.c b/openbox/openbox.c index fb1e75d0..eb7934e0 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -121,7 +121,7 @@ gint main(gint argc, gchar **argv) { gchar *program_name; - state = OB_STATE_STARTING; + ob_set_state(OB_STATE_STARTING); /* initialize the locale */ if (!setlocale(LC_ALL, "")) @@ -367,9 +367,10 @@ gint main(gint argc, gchar **argv) reconfigure = FALSE; - state = OB_STATE_RUNNING; + ob_set_state(OB_STATE_RUNNING); ob_main_loop_run(ob_main_loop); - state = OB_STATE_EXITING; + ob_set_state(reconfigure ? + OB_STATE_RECONFIGURING : OB_STATE_EXITING); if (!reconfigure) { dock_remove_all(); @@ -709,3 +710,8 @@ ObState ob_state() { return state; } + +void ob_set_state(ObState s) +{ + state = s; +} diff --git a/openbox/openbox.h b/openbox/openbox.h index 4f2310f8..06d38297 100644 --- a/openbox/openbox.h +++ b/openbox/openbox.h @@ -52,6 +52,7 @@ extern gboolean ob_debug_xinerama; /* The state of execution of the window manager */ ObState ob_state(); +void ob_set_state(ObState state); void ob_restart_other(const gchar *path); void ob_restart(); diff --git a/openbox/screen.c b/openbox/screen.c index 2e48f85c..15b3c8d8 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -492,7 +492,7 @@ void screen_resize(void) PROP_SETA32(RootWindow(ob_display, ob_screen), net_desktop_geometry, cardinal, geometry, 2); - if (ob_state() == OB_STATE_STARTING) + if (ob_state() != OB_STATE_RUNNING) return; screen_update_areas(); From 527ecafab95e66a6f0cedd6967fe2c61dfe85101 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 16:04:28 -0500 Subject: [PATCH 3/7] the #ifdef was backwards for using SM or not --- openbox/actions/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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")); From bb557f06a6828a95ee94c7579919dec1ee014484 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 16:11:05 -0500 Subject: [PATCH 4/7] 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 +++++--- openbox/client.c | 14 ++++++++-- openbox/openbox.c | 4 +-- openbox/prompt.c | 54 +++++++++++++++++++++++++++------------ openbox/prompt.h | 13 ++++++++-- 7 files changed, 85 insertions(+), 29 deletions(-) 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 diff --git a/openbox/client.c b/openbox/client.c index 98d1035b..44b12870 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3400,12 +3400,20 @@ void client_close(ObClient *self) #define OB_KILL_RESULT_NO 0 #define OB_KILL_RESULT_YES 1 -static void client_kill_requested(ObPrompt *p, gint result, gpointer data) +static gboolean client_kill_requested(ObPrompt *p, gint result, gpointer data) { ObClient *self = data; if (result == OB_KILL_RESULT_YES) client_kill(self); + return TRUE; /* call the cleanup func */ +} + +static void client_kill_cleanup(ObPrompt *p, gpointer data) +{ + ObClient *self = data; + + g_assert(p == self->kill_prompt); prompt_unref(self->kill_prompt); self->kill_prompt = NULL; @@ -3456,7 +3464,9 @@ static void client_prompt_kill(ObClient *self) sizeof(answers)/sizeof(answers[0]), OB_KILL_RESULT_NO, /* default = no */ OB_KILL_RESULT_NO, /* cancel = no */ - client_kill_requested, self); + client_kill_requested, + client_kill_cleanup, + self); g_free(m); } diff --git a/openbox/openbox.c b/openbox/openbox.c index eb7934e0..377b2199 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -323,7 +323,6 @@ gint main(gint argc, gchar **argv) grab_startup(reconfigure); group_startup(reconfigure); ping_startup(reconfigure); - prompt_startup(reconfigure); client_startup(reconfigure); dock_startup(reconfigure); moveresize_startup(reconfigure); @@ -331,6 +330,7 @@ gint main(gint argc, gchar **argv) mouse_startup(reconfigure); menu_frame_startup(reconfigure); menu_startup(reconfigure); + prompt_startup(reconfigure); if (!reconfigure) { guint32 xid; @@ -377,6 +377,7 @@ gint main(gint argc, gchar **argv) client_unmanage_all(); } + prompt_shutdown(reconfigure); menu_shutdown(reconfigure); menu_frame_shutdown(reconfigure); mouse_shutdown(reconfigure); @@ -384,7 +385,6 @@ gint main(gint argc, gchar **argv) moveresize_shutdown(reconfigure); dock_shutdown(reconfigure); client_shutdown(reconfigure); - prompt_shutdown(reconfigure); ping_shutdown(reconfigure); group_shutdown(reconfigure); grab_shutdown(reconfigure); diff --git a/openbox/prompt.c b/openbox/prompt.c index 6084d798..e57b1410 100644 --- a/openbox/prompt.c +++ b/openbox/prompt.c @@ -28,7 +28,6 @@ #include "gettext.h" static GList *prompt_list = NULL; -static GList *prompt_msg_list = NULL; /* we construct these */ static RrAppearance *prompt_a_bg; @@ -51,6 +50,7 @@ static void prompt_layout(ObPrompt *self); static void render_all(ObPrompt *self); static void render_button(ObPrompt *self, ObPromptElement *e); static void prompt_resize(ObPrompt *self, gint w, gint h); +static void prompt_run_callback(ObPrompt *self, gint result); void prompt_startup(gboolean reconfig) { @@ -122,8 +122,16 @@ void prompt_startup(gboolean reconfig) void prompt_shutdown(gboolean reconfig) { - while (prompt_msg_list) - prompt_cancel(prompt_msg_list->data); + GList *it; + + if (!reconfig) { + for (it = prompt_list; it; it = g_list_next(it)) { + ObPrompt *p = it->data; + if (p->cleanup) p->cleanup(p, p->data); + } + + g_assert(prompt_list == NULL); + } RrAppearanceFree(prompt_a_button); RrAppearanceFree(prompt_a_focus); @@ -135,7 +143,8 @@ void prompt_shutdown(gboolean reconfig) ObPrompt* prompt_new(const gchar *msg, const ObPromptAnswer *answers, gint n_answers, gint default_result, gint cancel_result, - ObPromptCallback func, gpointer data) + ObPromptCallback func, ObPromptCleanup cleanup, + gpointer data) { ObPrompt *self; XSetWindowAttributes attrib; @@ -146,6 +155,7 @@ ObPrompt* prompt_new(const gchar *msg, self = g_new0(ObPrompt, 1); self->ref = 1; self->func = func; + self->cleanup = cleanup; self->data = data; self->default_result = default_result; self->cancel_result = cancel_result; @@ -524,8 +534,7 @@ gboolean prompt_key_event(ObPrompt *self, XEvent *e) else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN) || e->xkey.keycode == ob_keycode(OB_KEY_SPACE)) { - if (self->func) self->func(self, self->focus->result, self->data); - prompt_hide(self); + prompt_run_callback(self, self->focus->result); } else if (e->xkey.keycode == ob_keycode(OB_KEY_TAB) || e->xkey.keycode == ob_keycode(OB_KEY_LEFT) || @@ -583,10 +592,8 @@ gboolean prompt_mouse_event(ObPrompt *self, XEvent *e) render_button(self, but); } else if (e->type == ButtonRelease) { - if (but->pressed) { - if (self->func) self->func(self, but->result, self->data); - prompt_hide(self); - } + if (but->pressed) + prompt_run_callback(self, but->result); } else if (e->type == MotionNotify) { gboolean press; @@ -604,13 +611,16 @@ gboolean prompt_mouse_event(ObPrompt *self, XEvent *e) void prompt_cancel(ObPrompt *self) { - if (self->func) self->func(self, self->cancel_result, self->data); - prompt_hide(self); + prompt_run_callback(self, self->cancel_result); } -static void prompt_show_message_cb(ObPrompt *p, int res, gpointer data) +static gboolean prompt_show_message_cb(ObPrompt *p, int res, gpointer data) +{ + return TRUE; /* call the cleanup func */ +} + +static void prompt_show_message_cleanup(ObPrompt *p, gpointer data) { - prompt_msg_list = g_list_remove(prompt_msg_list, p); prompt_unref(p); } @@ -621,7 +631,19 @@ void prompt_show_message(const gchar *msg, const gchar *answer) { answer, 0 } }; - p = prompt_new(msg, ans, 1, 0, 0, prompt_show_message_cb, NULL); - prompt_msg_list = g_list_prepend(prompt_msg_list, p); + p = prompt_new(msg, ans, 1, 0, 0, + prompt_show_message_cb, prompt_show_message_cleanup, NULL); prompt_show(p, NULL, FALSE); } + +static void prompt_run_callback(ObPrompt *self, gint result) +{ + prompt_ref(self); + if (self->func) { + gboolean clean = self->func(self, self->focus->result, self->data); + if (clean && self->cleanup) + self->cleanup(self, self->data); + } + prompt_hide(self); + prompt_unref(self); +} diff --git a/openbox/prompt.h b/openbox/prompt.h index c4558ad2..007dae93 100644 --- a/openbox/prompt.h +++ b/openbox/prompt.h @@ -29,7 +29,8 @@ typedef struct _ObPrompt ObPrompt; typedef struct _ObPromptElement ObPromptElement; typedef struct _ObPromptAnswer ObPromptAnswer; -typedef void (*ObPromptCallback)(ObPrompt *p, gint result, gpointer data); +typedef gboolean (*ObPromptCallback)(ObPrompt *p, gint result, gpointer data); +typedef void (*ObPromptCleanup)(ObPrompt *p, gpointer data); struct _ObPromptElement { gchar *text; @@ -69,6 +70,7 @@ struct _ObPrompt gint cancel_result; ObPromptCallback func; + ObPromptCleanup cleanup; gpointer data; }; @@ -90,12 +92,19 @@ void prompt_shutdown(gboolean reconfig); of having a button presssed @param func The callback function which is called when the dialog is closed or a button is pressed + @param cleanup The cleanup function which is called if the prompt system + is shutting down, and someone is still holding a reference to the + prompt. This callback should cause the prompt's refcount to go to + zero so it can be freed, and free any other memory associated with + the prompt. The cleanup function is also called if the prompt's + callback function returns TRUE. @param data User defined data which will be passed to the callback */ ObPrompt* prompt_new(const gchar *msg, const ObPromptAnswer *answers, gint n_answers, gint default_result, gint cancel_result, - ObPromptCallback func, gpointer data); + ObPromptCallback func, ObPromptCleanup cleanup, + gpointer data); void prompt_ref(ObPrompt *self); void prompt_unref(ObPrompt *self); From 14f4a0ba56b5e9619c9d9e65c0a3ede41595276e Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 16:40:40 -0500 Subject: [PATCH 5/7] show an error message when parsing syntax errors are encountered in the openbox config files --- openbox/openbox.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/openbox/openbox.c b/openbox/openbox.c index 377b2199..43549280 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -368,6 +368,20 @@ gint main(gint argc, gchar **argv) reconfigure = FALSE; ob_set_state(OB_STATE_RUNNING); + + /* look for parsing errors */ + { + xmlErrorPtr e = xmlGetLastError(); + if (e) { + gchar *m; + + m = g_strdup_printf(_("One or more XML syntax errors were found while parsing the Openbox configuration files. See stdout for more information. The last error seen was in file \"%s\" line %d, with message: %s"), e->file, e->line, e->message); + prompt_show_message(m, _("Close")); + g_free(m); + xmlResetError(e); + } + } + ob_main_loop_run(ob_main_loop); ob_set_state(reconfigure ? OB_STATE_RECONFIGURING : OB_STATE_EXITING); From 9d9ca8d1cf76a63767aef4bd74f5caceaad5ff23 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 17:12:11 -0500 Subject: [PATCH 6/7] 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 +- openbox/client.c | 2 +- openbox/openbox.c | 10 +++++++++- openbox/prompt.c | 12 +++++++++--- openbox/prompt.h | 5 +++-- 7 files changed, 25 insertions(+), 9 deletions(-) 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); } diff --git a/openbox/client.c b/openbox/client.c index 44b12870..82976f6a 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3460,7 +3460,7 @@ static void client_prompt_kill(ObClient *self) answers[0].text = _("Cancel"); /* "no" */ answers[1].text = y; /* "yes" */ - self->kill_prompt = prompt_new(m, answers, + self->kill_prompt = prompt_new(m, NULL, answers, sizeof(answers)/sizeof(answers[0]), OB_KILL_RESULT_NO, /* default = no */ OB_KILL_RESULT_NO, /* cancel = no */ diff --git a/openbox/openbox.c b/openbox/openbox.c index 43549280..7221556e 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -229,6 +229,8 @@ gint main(gint argc, gchar **argv) if (screen_annex()) { /* it will be ours! */ do { + ObPrompt *xmlprompt = NULL; + modkeys_startup(reconfigure); /* get the keycodes for keys we use */ @@ -376,7 +378,8 @@ gint main(gint argc, gchar **argv) gchar *m; m = g_strdup_printf(_("One or more XML syntax errors were found while parsing the Openbox configuration files. See stdout for more information. The last error seen was in file \"%s\" line %d, with message: %s"), e->file, e->line, e->message); - prompt_show_message(m, _("Close")); + xmlprompt = + prompt_show_message(m, _("Openbox Syntax Error"), _("Close")); g_free(m); xmlResetError(e); } @@ -386,6 +389,11 @@ gint main(gint argc, gchar **argv) ob_set_state(reconfigure ? OB_STATE_RECONFIGURING : OB_STATE_EXITING); + if (xmlprompt) { + prompt_unref(xmlprompt); + xmlprompt = NULL; + } + if (!reconfigure) { dock_remove_all(); client_unmanage_all(); diff --git a/openbox/prompt.c b/openbox/prompt.c index e57b1410..f531b70c 100644 --- a/openbox/prompt.c +++ b/openbox/prompt.c @@ -140,7 +140,7 @@ void prompt_shutdown(gboolean reconfig) RrAppearanceFree(prompt_a_msg); } -ObPrompt* prompt_new(const gchar *msg, +ObPrompt* prompt_new(const gchar *msg, const gchar *title, const ObPromptAnswer *answers, gint n_answers, gint default_result, gint cancel_result, ObPromptCallback func, ObPromptCleanup cleanup, @@ -172,6 +172,10 @@ ObPrompt* prompt_new(const gchar *msg, PROP_SET32(self->super.window, net_wm_window_type, atom, prop_atoms.net_wm_window_type_dialog); + /* set the window's title */ + if (title) + PROP_SETS(self->super.window, net_wm_name, title); + /* listen for key presses on the window */ self->event_mask = KeyPressMask; @@ -624,16 +628,18 @@ static void prompt_show_message_cleanup(ObPrompt *p, gpointer data) prompt_unref(p); } -void prompt_show_message(const gchar *msg, const gchar *answer) +ObPrompt* prompt_show_message(const gchar *msg, const gchar *title, + const gchar *answer) { ObPrompt *p; ObPromptAnswer ans[] = { { answer, 0 } }; - p = prompt_new(msg, ans, 1, 0, 0, + p = prompt_new(msg, title, ans, 1, 0, 0, prompt_show_message_cb, prompt_show_message_cleanup, NULL); prompt_show(p, NULL, FALSE); + return p; } static void prompt_run_callback(ObPrompt *self, gint result) diff --git a/openbox/prompt.h b/openbox/prompt.h index 007dae93..ef199907 100644 --- a/openbox/prompt.h +++ b/openbox/prompt.h @@ -100,7 +100,7 @@ void prompt_shutdown(gboolean reconfig); callback function returns TRUE. @param data User defined data which will be passed to the callback */ -ObPrompt* prompt_new(const gchar *msg, +ObPrompt* prompt_new(const gchar *msg, const gchar *title, const ObPromptAnswer *answers, gint n_answers, gint default_result, gint cancel_result, ObPromptCallback func, ObPromptCleanup cleanup, @@ -116,6 +116,7 @@ gboolean prompt_key_event(ObPrompt *self, XEvent *e); gboolean prompt_mouse_event(ObPrompt *self, XEvent *e); void prompt_cancel(ObPrompt *self); -void prompt_show_message(const gchar *msg, const gchar *answer); +ObPrompt* prompt_show_message(const gchar *msg, const gchar *title, + const gchar *answer); #endif From f542c5143ac115937c5ee8f3a229e557383cd180 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 17:19:39 -0500 Subject: [PATCH 7/7] add a title to the session logout confirm prompt --- openbox/actions/session.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); }