1 #include "openbox/actions.h"
2 #include "openbox/openbox.h"
3 #include "openbox/prompt.h"
4 #include "openbox/session.h"
11 static gpointer setup_func(xmlNodePtr node);
12 static gboolean run_func(ObActionsData *data, gpointer options);
14 void action_exit_startup(void)
16 actions_register("Exit", setup_func, NULL, run_func, NULL, NULL);
17 actions_register("SessionLogout", setup_func, NULL, run_func, NULL, NULL);
20 static gpointer setup_func(xmlNodePtr node)
25 o = g_new0(Options, 1);
28 if ((n = obt_parse_find_node(node, "prompt")))
29 o->prompt = obt_parse_node_bool(n);
34 static void do_exit(void)
36 if (session_connected())
37 session_request_logout(FALSE);
42 static gboolean prompt_cb(ObPrompt *p, gint result, gpointer data)
46 return TRUE; /* call the cleanup func */
49 static void prompt_cleanup(ObPrompt *p, gpointer data)
54 /* Always return FALSE because its not interactive */
55 static gboolean run_func(ObActionsData *data, gpointer options)
61 ObPromptAnswer answers[] = {
66 if (session_connected())
67 p = prompt_new(_("Are you sure you want to log out?"),
69 answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL);
71 p = prompt_new(_("Are you sure you want to exit Openbox?"),
73 answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL);
75 prompt_show(p, NULL, FALSE);