1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/action_value.h"
4 #include "openbox/openbox.h"
5 #include "openbox/prompt.h"
6 #include "openbox/session.h"
13 static gpointer setup_func(GHashTable *config);
14 static void free_func(gpointer o);
15 static gboolean run_func(const ObActionListRun *data, gpointer options);
17 void action_exit_startup(void)
19 action_register("Exit", OB_ACTION_DEFAULT_FILTER_EMPTY,
20 setup_func, free_func, run_func);
23 static gpointer setup_func(GHashTable *config)
28 o = g_slice_new0(Options);
31 v = g_hash_table_lookup(config, "prompt");
32 if (v && action_value_is_string(v))
33 o->prompt = action_value_bool(v);
38 static void free_func(gpointer o)
40 g_slice_free(Options, o);
43 static void do_exit(void)
45 if (session_connected())
46 session_request_logout(FALSE);
51 static gboolean prompt_cb(ObPrompt *p, gint result, gpointer data)
55 return TRUE; /* call the cleanup func */
58 static void prompt_cleanup(ObPrompt *p, gpointer data)
64 /* Always return FALSE because its not interactive */
65 static gboolean run_func(const ObActionListRun *data, gpointer options)
71 ObPromptAnswer answers[] = {
76 if (session_connected())
77 p = prompt_new(_("Are you sure you want to log out?"),
79 answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL);
81 p = prompt_new(_("Are you sure you want to exit Openbox?"),
83 answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL);
85 prompt_show(p, NULL, FALSE);