summaryrefslogtreecommitdiffstats
path: root/include/rofi.h
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-01-07 19:47:37 +0100
committerDave Davenport <qball@gmpclient.org>2016-01-07 19:47:37 +0100
commite8daff0f6ad49cd17b225622fa1875ee2960a70f (patch)
tree98573f33b525ffe0acbb378eb0367e8c658fc0cc /include/rofi.h
parent51b5511017b632129df78d2906882abafd92c38a (diff)
First cleanup steps.
Diffstat (limited to 'include/rofi.h')
-rw-r--r--include/rofi.h142
1 files changed, 14 insertions, 128 deletions
diff --git a/include/rofi.h b/include/rofi.h
index 86c37acc..e93eb635 100644
--- a/include/rofi.h
+++ b/include/rofi.h
@@ -9,6 +9,7 @@
#include <cairo-xlib.h>
#include "timings.h"
#include "keyb.h"
+#include "mode.h"
/**
* @defgroup Widgets Widgets
@@ -23,53 +24,13 @@
*/
extern const char *cache_dir;
-typedef struct _Mode Mode;
/**
- * Enum used to sum the possible states of ROFI.
- */
-typedef enum
-{
- /** Exit. */
- MODE_EXIT = 1000,
- /** Skip to the next cycle-able dialog. */
- NEXT_DIALOG = 1001,
- /** Reload current DIALOG */
- RELOAD_DIALOG = 1002,
- /** Previous dialog */
- PREVIOUS_DIALOG = 1003
-} ModeMode;
-
-/**
- * State returned by the rofi window.
- */
-typedef enum
-{
- /** Entry is selected. */
- MENU_OK = 0x00010000,
- /** User canceled the operation. (e.g. pressed escape) */
- MENU_CANCEL = 0x00020000,
- /** User requested a mode switch */
- MENU_NEXT = 0x00040000,
- /** Custom (non-matched) input was entered. */
- MENU_CUSTOM_INPUT = 0x00080000,
- /** User wanted to delete entry from history. */
- MENU_ENTRY_DELETE = 0x00100000,
- /** User wants to jump to another switcher. */
- MENU_QUICK_SWITCH = 0x00200000,
- /** Go to the previous menu. */
- MENU_PREVIOUS = 0x00400000,
- /** Modifiers */
- MENU_SHIFT = 0x10000000,
- /** Mask */
- MENU_LOWER_MASK = 0x0000FFFF
-} MenuReturn;
-
-/**
- * @param sig The caught signal
+ * @param msg The error message to show.
+ * @param markup The error message uses pango markup.
*
- * Catch the exit signal generated by X.
+ * The error message to show.
*/
-void catch_exit ( __attribute__( ( unused ) ) int sig );
+void error_dialog ( const char *msg, int markup );
/**
* @param sw the Mode to show.
@@ -90,90 +51,6 @@ void catch_exit ( __attribute__( ( unused ) ) int sig );
MenuReturn menu ( Mode *sw, char **input, char *prompt, unsigned int *selected_line, unsigned int *next_pos, const char *message )
__attribute__ ( ( nonnull ( 1, 2, 3, 4 ) ) );
-/**
- * @param msg The error message to show.
- * @param markup The error message uses pango markup.
- *
- * The error message to show.
- */
-void error_dialog ( const char *msg, int markup );
-
-typedef void ( *switcher_free )( Mode *data );
-
-typedef char * ( *switcher_get_display_value )( const Mode *sw, unsigned int selected_line, int *state, int get_entry );
-
-typedef char * ( *switcher_get_completion )( const Mode *sw, unsigned int selected_line );
-/**
- * @param tokens List of (input) tokens to match.
- * @param input The entry to match against.
- * @param case_sensitive Whether case is significant.
- * @param index The current selected index.
- * @param data User data.
- *
- * Function prototype for the matching algorithm.
- *
- * @returns 1 when it matches, 0 if not.
- */
-typedef int ( *switcher_token_match )( const Mode *data, char **tokens, int not_ascii, int case_sensitive, unsigned int index );
-
-typedef void ( *switcher_init )( Mode *sw );
-
-typedef unsigned int ( *switcher_get_num_entries )( const Mode *sw );
-
-typedef void ( *switcher_destroy )( Mode *sw );
-
-typedef ModeMode ( *switcher_result )( Mode *sw, int menu_retv, char **input, unsigned int selected_line );
-
-typedef int ( *switcher_is_not_ascii )( const Mode *sw, unsigned int index );
-
-/**
- * Structure defining a switcher.
- * It consists of a name, callback and if enabled
- * a textbox for the sidebar-mode.
- */
-struct _Mode
-{
- /** Name (max 31 char long) */
- char name[32];
- /** Keybindings (keysym and modmask) */
- char * keycfg;
- char * keystr;
- KeySym keysym;
- unsigned int modmask;
-
- /**
- * A switcher normally consists of the following parts:
- */
- /** Initialize the Mode */
- switcher_init init;
- /** Destroy the switcher, e.g. free all its memory. */
- switcher_destroy destroy;
- /** Get number of entries to display. (unfiltered). */
- switcher_get_num_entries get_num_entries;
- /** Check if the element is ascii. */
- switcher_is_not_ascii is_not_ascii;
- /** Process the result of the user selection. */
- switcher_result result;
- /** Token match. */
- switcher_token_match token_match;
- /** Get the string to display for the entry. */
- switcher_get_display_value mgrv;
- /** Get the 'completed' entry. */
- switcher_get_completion get_completion;
-
- /** Pointer to private data. */
- void *private_data;
-
- /**
- * Free SWitcher
- * Only to be used when the switcher object itself is dynamic.
- * And has data in `ed`
- */
- switcher_free free;
- /** Extra fields for script */
- void *ed;
-};
-
/** Reset terminal */
#define color_reset "\033[0m"
/** Set terminal text bold */
@@ -182,6 +59,15 @@ struct _Mode
#define color_italic "\033[2m"
/** Set terminal foreground text green */
#define color_green "\033[0;32m"
+
+/**
+ * @param msg The error message to show.
+ * @param markup If the message contains pango markup.
+ *
+ * Create a dialog showing the msg.
+ *
+ * @returns EXIT_FAILURE if failed to create dialog, EXIT_SUCCESS if succesfull
+ */
int show_error_message ( const char *msg, int markup );
/*@}*/
#endif