]> Dogcows Code - chaz/openbox/blob - openbox/actions/session.c
don't let you use left to go "up to parent" on menus which don't have any parent
[chaz/openbox] / openbox / actions / session.c
1 #include "openbox/actions.h"
2 #include "openbox/prompt.h"
3 #include "openbox/session.h"
4 #include "gettext.h"
5
6 #ifndef USE_SM
7 void action_logout_startup(void) {}
8 #else
9
10 typedef struct {
11 gboolean prompt;
12 gboolean silent;
13 } Options;
14
15 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
16 static gboolean logout_func(ObActionsData *data, gpointer options);
17
18 void action_session_startup(void)
19 {
20 actions_register("SessionLogout", setup_func, NULL, logout_func,
21 NULL, NULL);
22 }
23
24 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
25 {
26 xmlNodePtr n;
27 Options *o;
28
29 o = g_new0(Options, 1);
30 o->prompt = TRUE;
31
32 if ((n = parse_find_node("prompt", node)))
33 o->prompt = parse_bool(doc, n);
34
35 return o;
36 }
37
38 static void prompt_cb(ObPrompt *p, gint result, gpointer data)
39 {
40 Options *o = data;
41 if (result)
42 session_request_logout(o->silent);
43 g_free(o);
44 prompt_unref(p);
45 }
46
47 /* Always return FALSE because its not interactive */
48 static gboolean logout_func(ObActionsData *data, gpointer options)
49 {
50 Options *o = options;
51
52 if (o->prompt) {
53 Options *o2;
54 ObPrompt *p;
55 ObPromptAnswer answers[] = {
56 { _("Cancel"), 0 },
57 { _("Log out"), 1 }
58 };
59
60 o2 = g_memdup(o, sizeof(Options));
61 p = prompt_new(_("Are you sure you want to log out?"),
62 answers, 2, 0, 0, prompt_cb, o2);
63 prompt_show(p, NULL, FALSE);
64 }
65 else
66 prompt_cb(NULL, 1, NULL);
67
68 return FALSE;
69 }
70
71 #endif
This page took 0.04123 seconds and 4 git commands to generate.