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 void free_func(gpointer o
);
13 static gboolean
run_func(ObActionsData
*data
, gpointer options
);
15 void action_exit_startup(void)
17 actions_register("Exit", setup_func
, free_func
, run_func
);
18 actions_register("SessionLogout", setup_func
, free_func
, run_func
);
21 static gpointer
setup_func(xmlNodePtr node
)
26 o
= g_slice_new0(Options
);
29 if ((n
= obt_xml_find_node(node
, "prompt")))
30 o
->prompt
= obt_xml_node_bool(n
);
35 static void free_func(gpointer o
)
37 g_slice_free(Options
, o
);
40 static void do_exit(void)
42 if (session_connected())
43 session_request_logout(FALSE
);
48 static gboolean
prompt_cb(ObPrompt
*p
, gint result
, gpointer data
)
52 return TRUE
; /* call the cleanup func */
55 static void prompt_cleanup(ObPrompt
*p
, gpointer data
)
61 /* Always return FALSE because its not interactive */
62 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
68 ObPromptAnswer answers
[] = {
73 if (session_connected())
74 p
= prompt_new(_("Are you sure you want to log out?"),
76 answers
, 2, 0, 0, prompt_cb
, prompt_cleanup
, NULL
);
78 p
= prompt_new(_("Are you sure you want to exit Openbox?"),
80 answers
, 2, 0, 0, prompt_cb
, prompt_cleanup
, NULL
);
82 prompt_show(p
, NULL
, FALSE
);