rofi/include/view.h

253 lines
5.9 KiB
C
Raw Normal View History

2016-02-06 13:27:36 +00:00
#ifndef ROFI_VIEW_H
#define ROFI_VIEW_H
2016-02-06 12:06:58 +00:00
#include "xkb.h"
2016-02-06 13:27:36 +00:00
/**
* @defgroup View View
*
* The rofi Menu view.
*
2016-02-08 17:16:16 +00:00
* @defgroup ViewHandle ViewHandle
* @ingroup View
*
2016-02-06 13:27:36 +00:00
* @{
*/
2016-02-07 11:31:17 +00:00
typedef struct RofiViewState RofiViewState;
typedef enum
{
2016-02-08 17:16:16 +00:00
/** Create a menu for entering text */
2016-02-10 18:40:19 +00:00
MENU_NORMAL = 0,
2016-02-08 17:16:16 +00:00
/** Create a menu for entering passwords */
2016-02-10 18:40:19 +00:00
MENU_PASSWORD = 1,
/** Create amanaged window. */
MENU_NORMAL_WINDOW = 2,
2016-03-06 15:03:04 +00:00
/** ERROR dialog */
MENU_ERROR_DIALOG = 4,
2016-07-18 21:49:26 +00:00
/** INDICATOR */
MENU_INDICATOR = 8,
/** Show column */
MENU_PROMPT_COLON = 16,
2016-02-07 11:31:17 +00:00
} MenuFlags;
2016-02-06 12:06:58 +00:00
2016-02-07 11:31:17 +00:00
/**
* @param sw the Mode to show.
* @param input A pointer to a string where the inputted data is placed.
* @param message Extra message to display.
* @param flags Flags indicating state of the menu.
2016-02-19 18:29:06 +00:00
* @param finalize the finailze callback
2016-02-07 11:31:17 +00:00
*
* Main menu callback.
*
* @returns The command issued (see MenuReturn)
*/
RofiViewState *rofi_view_create ( Mode *sw, const char *input, const char *message, MenuFlags flags, void ( *finalize )( RofiViewState * ) );
2016-02-07 19:38:34 +00:00
2016-02-06 12:06:58 +00:00
/**
* @param state The Menu Handle
*
* Check if a finalize function is set, and if sets executes it.
*/
void rofi_view_finalize ( RofiViewState *state );
2016-11-15 20:54:31 +00:00
/**
* @param state the Menu handle
*
* Get the return value associated to the users action.
*
* @returns the return value
*/
2016-02-06 13:27:36 +00:00
MenuReturn rofi_view_get_return_value ( const RofiViewState *state );
2016-11-15 20:54:31 +00:00
/**
* @param state the Menu handle
*
* Returns the index of the next visible position.
*
* @return the next position.
*/
2016-02-06 13:27:36 +00:00
unsigned int rofi_view_get_next_position ( const RofiViewState *state );
2016-11-15 20:54:31 +00:00
/**
* @param state the Menu handle
* @param event the event to handle
* @param xkb the keyboard handle
*
* Process an Xevent.
*/
void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, xkb_stuff *xkb );
2016-11-15 20:54:31 +00:00
/**
* @param state the Menu handle
*
* @returns returns if this state is completed.
*/
2016-02-06 13:27:36 +00:00
unsigned int rofi_view_get_completed ( const RofiViewState *state );
2016-11-15 20:54:31 +00:00
/**
* @param state the Menu handle
*
* @returns the raw user input.
*/
2016-02-06 13:27:36 +00:00
const char * rofi_view_get_user_input ( const RofiViewState *state );
2016-02-08 17:16:16 +00:00
/**
* @param state The Menu Handle
* @param selected_line The line to select.
*
* Select a line.
*/
2016-02-06 13:27:36 +00:00
void rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_line );
2016-02-08 17:16:16 +00:00
/**
* @param state The Menu Handle
*
* Get the selected line.
*
* @returns the selected line or UINT32_MAX if none selected.
*/
unsigned int rofi_view_get_selected_line ( const RofiViewState *state );
/**
* @param state The Menu Handle
*
* Restart the menu so it can be displayed again.
* Resets RofiViewState::quit and RofiViewState::retv.
*/
void rofi_view_restart ( RofiViewState *state );
2016-02-06 13:27:36 +00:00
2016-02-08 17:16:16 +00:00
2016-11-15 20:54:31 +00:00
/**
* @param state The handle to the view
* @param action The keyboard action
*
* @returns TRUE if action was handled.
*/
gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction action );
2016-02-08 17:16:16 +00:00
/**
* @param state The handle to the view
*
* Free's the memory allocated for this handle.
* After a call to this function, state is invalid and can no longer be used.
*/
void rofi_view_free ( RofiViewState *state );
/** @} */
/**
* @defgroup ViewGlobal ViewGlobal
* @ingroup View
*
* Global menu view functions.
* These do not work on the view itself but modifies the global state.
* @{
*/
/**
* Get the current active view Handle.
*
* @returns the active view handle or NULL
*/
RofiViewState * rofi_view_get_active ( void );
/**
* @param state the new active view handle, NULL to clear.
*
* Set the current active view Handle.
*
*/
void rofi_view_set_active ( RofiViewState *state );
2016-02-08 08:03:11 +00:00
/**
* @param msg The error message to show.
* @param markup The error message uses pango markup.
*
* The error message to show.
*/
2016-03-03 07:21:28 +00:00
int rofi_view_error_dialog ( const char *msg, int markup );
2016-02-08 17:16:16 +00:00
/**
* Queue a redraw.
* This triggers a X11 Expose Event.
*/
void rofi_view_queue_redraw ( void );
/**
* Cleanup internal data of the view.
*/
void rofi_view_cleanup ( void );
/**
* @param state The handle to the view
*
* Get the mode currently displayed by the view.
*
* @returns the mode currently displayed by the view
*/
2016-02-19 18:29:06 +00:00
Mode * rofi_view_get_mode ( RofiViewState *state );
/**
* Unmap the current view.
*/
void rofi_view_hide ( void );
/**
* Indicate the current view needs to reload its data.
* This can only be done when *more* information is available.
2016-10-14 14:46:54 +00:00
*
* The reloading happens 'lazy', multiple calls might be handled at once.
*/
void rofi_view_reload ( void );
/**
* @param state The handle to the view
* @param mode The new mode to display
2016-10-14 14:46:54 +00:00
*
* Change the current view to show a different mode.
*/
void rofi_view_switch_mode ( RofiViewState *state, Mode *mode );
/**
* @param state The handle to the view
* @param text An UTF-8 encoded character array with the text to overlay.
2016-10-14 14:46:54 +00:00
*
* Overlays text over the current view. Passing NULL for text hides the overlay.
*/
void rofi_view_set_overlay ( RofiViewState *state, const char *text );
/**
* @param state The handle to the view.
*
* Clears the user entry box, set selected to 0.
*/
void rofi_view_clear_input ( RofiViewState *state );
/**
* @param menu_flags The state of the new window.
*
* Creates the internal 'Cached' window that gets reused between views.
2016-11-15 20:54:31 +00:00
* TODO: Internal call to view exposed.
*/
void __create_window ( MenuFlags menu_flags );
/**
* Get the handle of the main window.
*
* @returns the xcb_window_t for rofi's view or XCB_WINDOW_NONE.
*/
xcb_window_t rofi_view_get_window ( void );
2016-02-06 13:27:36 +00:00
/** @} */
2016-02-10 18:40:19 +00:00
/***
* @defgroup ViewThreadPool ViewThreadPool
* @ingroup View
*
* The view can (optionally) keep a set of worker threads around to parallize work.
* This includes filtering and sorting.
*
* @{
*/
/**
* Initialize the threadpool
*/
2016-02-10 18:40:19 +00:00
void rofi_view_workers_initialize ( void );
/**
* Stop all threads and free the resources used by the threadpool
*/
void rofi_view_workers_finalize ( void );
2016-02-10 18:40:19 +00:00
/**@}*/
2016-02-06 13:27:36 +00:00
#endif