]> Dogcows Code - chaz/openbox/blob - openbox/actions/exit.c
8430729b16ed0121a94045b397565249ccace581
[chaz/openbox] / openbox / actions / exit.c
1 #include "openbox/actions.h"
2 #include "openbox/openbox.h"
3 #include "openbox/prompt.h"
4 #include "gettext.h"
5
6 typedef struct {
7 gboolean prompt;
8 } Options;
9
10 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
11 static gboolean run_func(ObActionsData *data, gpointer options);
12
13 void action_exit_startup(void)
14 {
15 actions_register("Exit", setup_func, NULL, run_func, NULL, NULL);
16 }
17
18 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
19 {
20 xmlNodePtr n;
21 Options *o;
22
23 o = g_new0(Options, 1);
24
25 if ((n = parse_find_node("prompt", node)))
26 o->prompt = parse_bool(doc, n);
27
28 return o;
29 }
30
31 static void prompt_cb(ObPrompt *p, gint result, gpointer data)
32 {
33 if (result)
34 ob_exit(0);
35 prompt_unref(p);
36 }
37
38 /* Always return FALSE because its not interactive */
39 static gboolean run_func(ObActionsData *data, gpointer options)
40 {
41 Options *o = options;
42
43 if (o->prompt) {
44 ObPrompt *p;
45 ObPromptAnswer answers[] = {
46 { _("No"), 0 },
47 { _("Yes"), 1 }
48 };
49
50 p = prompt_new(_("Are you sure you want to exit Openbox?"),
51 answers, 2, 0, 0, prompt_cb, NULL);
52 prompt_show(p, NULL, FALSE);
53 }
54 else
55 ob_exit(0);
56
57 return FALSE;
58 }
This page took 0.037165 seconds and 4 git commands to generate.