1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 prompt.h for the Openbox window manager
4 Copyright (c) 2008 Dana Jansens
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.
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.
16 See the COPYING file for a copy of the GNU General Public License.
24 #include "render/render.h"
28 typedef struct _ObPrompt ObPrompt;
29 typedef struct _ObPromptElement ObPromptElement;
30 typedef struct _ObPromptAnswer ObPromptAnswer;
32 typedef void (*ObPromptCallback)(ObPrompt *p, gint result, gpointer data);
34 struct _ObPromptElement {
38 gint x, y, width, height;
45 ObInternalWindow super;
50 /* keep a copy of this because we re-render things that may need it
60 /* one for each answer */
61 ObPromptElement *button;
64 /* points to the button with the focus */
65 ObPromptElement *focus;
66 /* the default button to have selected */
68 /* the cancel result if the dialog is closed */
71 ObPromptCallback func;
75 struct _ObPromptAnswer {
80 void prompt_startup(gboolean reconfig);
81 void prompt_shutdown(gboolean reconfig);
83 /*! Create a new prompt
84 @param answers A number of ObPromptAnswers which define the buttons which
85 will appear in the dialog from left to right, and the result
86 returned when they are selected.
87 @param n_answers The number of answers
88 @param default_result The result for the answer button selected by default
89 @param cancel_result The result that is given if the dialog is closed instead
90 of having a button presssed
91 @param func The callback function which is called when the dialog is closed
92 or a button is pressed
93 @param data User defined data which will be passed to the callback
95 ObPrompt* prompt_new(const gchar *msg,
96 const ObPromptAnswer *answers, gint n_answers,
97 gint default_result, gint cancel_result,
98 ObPromptCallback func, gpointer data);
99 void prompt_ref(ObPrompt *self);
100 void prompt_unref(ObPrompt *self);
102 /*! Show the prompt. It will be centered within the given area rectangle */
103 void prompt_show(ObPrompt *self, struct _ObClient *parent);
104 void prompt_hide(ObPrompt *self);
106 void prompt_key_event(ObPrompt *self, XEvent *e);
107 void prompt_mouse_event(ObPrompt *self, XEvent *e);
108 void prompt_cancel(ObPrompt *self);