]> Dogcows Code - chaz/openbox/blob - openbox/prompt.h
Add a focus debug message for the frame's visible focus state
[chaz/openbox] / openbox / prompt.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 prompt.h for the Openbox window manager
4 Copyright (c) 2008 Dana Jansens
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #ifndef ob__prompt_h
20 #define ob__prompt_h
21
22 #include "window.h"
23 #include "geom.h"
24 #include "render/render.h"
25 #include <glib.h>
26 #include <X11/Xlib.h>
27
28 typedef struct _ObPrompt ObPrompt;
29 typedef struct _ObPromptElement ObPromptElement;
30 typedef struct _ObPromptAnswer ObPromptAnswer;
31
32 typedef gboolean (*ObPromptCallback)(ObPrompt *p, gint result, gpointer data);
33 typedef void (*ObPromptCleanup)(ObPrompt *p, gpointer data);
34
35 struct _ObPromptElement {
36 gchar *text;
37 Window window;
38
39 gint x, y, width, height;
40 gboolean pressed;
41 gint result;
42 };
43
44 struct _ObPrompt
45 {
46 InternalWindow super;
47 gint ref;
48
49 guint event_mask;
50
51 /* keep a copy of this because we re-render things that may need it
52 (i.e. the buttons) */
53 RrAppearance *a_bg;
54
55 gboolean mapped;
56 gint width, height;
57 gint msg_wbound;
58
59 ObPromptElement msg;
60
61 /* one for each answer */
62 ObPromptElement *button;
63 gint n_buttons;
64
65 /* points to the button with the focus */
66 ObPromptElement *focus;
67 /* the default button to have selected */
68 gint default_result;
69 /* the cancel result if the dialog is closed */
70 gint cancel_result;
71
72 ObPromptCallback func;
73 ObPromptCleanup cleanup;
74 gpointer data;
75 };
76
77 struct _ObPromptAnswer {
78 const gchar *text;
79 gint result;
80 };
81
82 void prompt_startup(gboolean reconfig);
83 void prompt_shutdown(gboolean reconfig);
84
85 /*! Create a new prompt
86 @param answers A number of ObPromptAnswers which define the buttons which
87 will appear in the dialog from left to right, and the result
88 returned when they are selected.
89 @param n_answers The number of answers
90 @param default_result The result for the answer button selected by default
91 @param cancel_result The result that is given if the dialog is closed instead
92 of having a button presssed
93 @param func The callback function which is called when the dialog is closed
94 or a button is pressed
95 @param cleanup The cleanup function which is called if the prompt system
96 is shutting down, and someone is still holding a reference to the
97 prompt. This callback should cause the prompt's refcount to go to
98 zero so it can be freed, and free any other memory associated with
99 the prompt. The cleanup function is also called if the prompt's
100 callback function returns TRUE.
101 @param data User defined data which will be passed to the callback
102 */
103 ObPrompt* prompt_new(const gchar *msg, const gchar *title,
104 const ObPromptAnswer *answers, gint n_answers,
105 gint default_result, gint cancel_result,
106 ObPromptCallback func, ObPromptCleanup cleanup,
107 gpointer data);
108 void prompt_ref(ObPrompt *self);
109 void prompt_unref(ObPrompt *self);
110
111 /*! Show the prompt. It will be centered within the given area rectangle */
112 void prompt_show(ObPrompt *self, struct _ObClient *parent, gboolean modal);
113 void prompt_hide(ObPrompt *self);
114
115 gboolean prompt_key_event(ObPrompt *self, XEvent *e);
116 gboolean prompt_mouse_event(ObPrompt *self, XEvent *e);
117 void prompt_cancel(ObPrompt *self);
118
119 ObPrompt* prompt_show_message(const gchar *msg, const gchar *title,
120 const gchar *answer);
121
122 #endif
This page took 0.043452 seconds and 4 git commands to generate.