1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/action_value.h"
4 #include "openbox/client_set.h"
5 #include "openbox/openbox.h"
6 #include "openbox/prompt.h"
7 #include "openbox/session.h"
14 static gpointer setup_func(GHashTable *config);
15 static void free_func(gpointer o);
16 static gboolean run_func(const ObClientSet *set,
17 const ObActionListRun *data, gpointer options);
19 void action_exit_startup(void)
21 action_register("Exit", OB_ACTION_DEFAULT_FILTER_EMPTY,
22 setup_func, free_func, run_func);
25 static gpointer setup_func(GHashTable *config)
30 o = g_slice_new0(Options);
33 v = g_hash_table_lookup(config, "prompt");
34 if (v && action_value_is_string(v))
35 o->prompt = action_value_bool(v);
40 static void free_func(gpointer o)
42 g_slice_free(Options, o);
45 static void do_exit(void)
47 if (session_connected())
48 session_request_logout(FALSE);
53 static gboolean prompt_cb(ObPrompt *p, gint result, gpointer data)
57 return TRUE; /* call the cleanup func */
60 static void prompt_cleanup(ObPrompt *p, gpointer data)
66 /* Always return FALSE because its not interactive */
67 static gboolean run_func(const ObClientSet *set,
68 const ObActionListRun *data, gpointer options)
74 ObPromptAnswer answers[] = {
79 if (session_connected())
80 p = prompt_new(_("Are you sure you want to log out?"),
82 answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL);
84 p = prompt_new(_("Are you sure you want to exit Openbox?"),
86 answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL);
88 prompt_show(p, NULL, FALSE);