X-Git-Url: http://git.openbox.org/?p=mikachu%2Fopenbox.git;a=blobdiff_plain;f=openbox%2Fprompt.h;h=007dae934cedc75b1e6f7b6e7e96dcdeff969495;hp=8d0bc9886d22d7303e335d937a1ada13a672c157;hb=bb557f06a6828a95ee94c7579919dec1ee014484;hpb=457fdc5ccbb65dc4b5e6cd972e048e3218527b91 diff --git a/openbox/prompt.h b/openbox/prompt.h index 8d0bc98..007dae9 100644 --- a/openbox/prompt.h +++ b/openbox/prompt.h @@ -19,19 +19,26 @@ #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 +#include + +typedef struct _ObPrompt ObPrompt; +typedef struct _ObPromptElement ObPromptElement; +typedef struct _ObPromptAnswer ObPromptAnswer; + +typedef gboolean (*ObPromptCallback)(ObPrompt *p, gint result, gpointer data); +typedef void (*ObPromptCleanup)(ObPrompt *p, gpointer data); struct _ObPromptElement { gchar *text; Window window; gint x, y, width, height; + gboolean pressed; + gint result; }; struct _ObPrompt @@ -39,6 +46,8 @@ struct _ObPrompt InternalWindow super; gint ref; + guint event_mask; + /* keep a copy of this because we re-render things that may need it (i.e. the buttons) */ RrAppearance *a_bg; @@ -51,19 +60,62 @@ 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; + ObPromptCleanup cleanup; + 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 cleanup The cleanup function which is called if the prompt system + is shutting down, and someone is still holding a reference to the + prompt. This callback should cause the prompt's refcount to go to + zero so it can be freed, and free any other memory associated with + the prompt. The cleanup function is also called if the prompt's + callback function returns TRUE. + @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, ObPromptCleanup cleanup, + gpointer data); void prompt_ref(ObPrompt *self); void prompt_unref(ObPrompt *self); /*! Show the prompt. It will be centered within the given area rectangle */ -void prompt_show(ObPrompt *self, struct _ObClient *parent); +void prompt_show(ObPrompt *self, struct _ObClient *parent, gboolean modal); void prompt_hide(ObPrompt *self); -void prompt_hide_window(Window window); + +gboolean prompt_key_event(ObPrompt *self, XEvent *e); +gboolean prompt_mouse_event(ObPrompt *self, XEvent *e); +void prompt_cancel(ObPrompt *self); + +void prompt_show_message(const gchar *msg, const gchar *answer); #endif