diff options
| author | Dana Jansens <danakj@orodu.net> | 2008-02-07 00:10:57 -0500 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2008-02-14 14:24:07 -0500 |
| commit | c7af49b5c564d6287a0293ae26fc713fb55b4dc8 (patch) | |
| tree | 2f0da7cd0d8c81919d894c62370a0fbb03f231f4 /openbox/prompt.h | |
| parent | ea28a9e7ab6c81547b2730268097c4ad7d814a80 (diff) | |
let you specify return codes for the different buttons in a prompt, and specify a callback function for the prompt for when it is closed
Diffstat (limited to 'openbox/prompt.h')
| -rw-r--r-- | openbox/prompt.h | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/openbox/prompt.h b/openbox/prompt.h index b31a0c04..c470f101 100644 --- a/openbox/prompt.h +++ b/openbox/prompt.h @@ -19,21 +19,25 @@ #ifndef ob__prompt_h #define ob__prompt_h -typedef struct _ObPrompt ObPrompt; -typedef struct _ObPromptElement ObPromptElement; - #include "window.h" #include "geom.h" #include "render/render.h" #include <glib.h> #include <X11/Xlib.h> +typedef struct _ObPrompt ObPrompt; +typedef struct _ObPromptElement ObPromptElement; +typedef struct _ObPromptAnswer ObPromptAnswer; + +typedef void (*ObPromptCallback)(ObPrompt *p, gint result, gpointer data); + struct _ObPromptElement { gchar *text; Window window; gint x, y, width, height; gboolean pressed; + gint result; }; struct _ObPrompt @@ -55,16 +59,43 @@ struct _ObPrompt /* one for each answer */ ObPromptElement *button; - guint n_buttons; + gint n_buttons; /* points to the button with the focus */ ObPromptElement *focus; + /* the default button to have selected */ + gint default_result; + /* the cancel result if the dialog is closed */ + gint cancel_result; + + ObPromptCallback func; + gpointer data; +}; + +struct _ObPromptAnswer { + const gchar *text; + gint result; }; void prompt_startup(gboolean reconfig); void prompt_shutdown(gboolean reconfig); -ObPrompt* prompt_new(const gchar *msg, const gchar *const *answers); +/*! Create a new prompt + @param answers A number of ObPromptAnswers which define the buttons which + will appear in the dialog from left to right, and the result + returned when they are selected. + @param n_answers The number of answers + @param default_result The result for the answer button selected by default + @param cancel_result The result that is given if the dialog is closed instead + of having a button presssed + @param func The callback function which is called when the dialog is closed + or a button is pressed + @param data User defined data which will be passed to the callback +*/ +ObPrompt* prompt_new(const gchar *msg, + const ObPromptAnswer *answers, gint n_answers, + gint default_result, gint cancel_result, + ObPromptCallback func, gpointer data); void prompt_ref(ObPrompt *self); void prompt_unref(ObPrompt *self); @@ -74,5 +105,6 @@ void prompt_hide(ObPrompt *self); void prompt_key_event(ObPrompt *self, XEvent *e); void prompt_mouse_event(ObPrompt *self, XEvent *e); +void prompt_cancel(ObPrompt *self); #endif |
