mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Prepare updates for new APIs.
This commit is contained in:
parent
dd3035a1a6
commit
7972420c30
10 changed files with 66 additions and 8 deletions
|
@ -32,7 +32,16 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
/** ABI version to check if loaded plugin is compatible. */
|
||||
#define ABI_VERSION 6u
|
||||
#define ABI_VERSION 7u
|
||||
|
||||
typedef enum {
|
||||
/** Mode type is not set */
|
||||
MODE_TYPE_UNSET = 0b0000,
|
||||
/** A normal mode. */
|
||||
MODE_TYPE_SWITCHER = 0b0001,
|
||||
/** A mode that can be used to completer */
|
||||
MODE_TYPE_COMPLETER = 0b0010,
|
||||
} ModeType;
|
||||
|
||||
/**
|
||||
* @param data Pointer to #Mode object.
|
||||
|
@ -151,6 +160,28 @@ typedef char *(*_mode_preprocess_input)(Mode *sw, const char *input);
|
|||
*/
|
||||
typedef char *(*_mode_get_message)(const Mode *sw);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of this mode.
|
||||
* Free (free) result after use, after using mode_destroy.
|
||||
*
|
||||
* @returns Instantiate a new instance of this mode.
|
||||
*/
|
||||
typedef Mode *(*_mode_create)( void );
|
||||
|
||||
/**
|
||||
* @param sw The #Mode pointer
|
||||
* @param menu_retv The return value
|
||||
* @param input The input string
|
||||
* @param selected_line The selected line
|
||||
* @param the path that was completed
|
||||
*
|
||||
* Handle the user accepting an entry in completion mode.
|
||||
*
|
||||
* @returns the next action to take
|
||||
*/
|
||||
typedef ModeMode (*_mode_completer_result)(Mode *sw, int menu_retv, char **input,
|
||||
unsigned int selected_line, char **path);
|
||||
/**
|
||||
* Structure defining a switcher.
|
||||
* It consists of a name, callback and if enabled
|
||||
|
@ -197,6 +228,17 @@ struct rofi_mode {
|
|||
* And has data in `ed`
|
||||
*/
|
||||
_mode_free free;
|
||||
|
||||
/**
|
||||
* Create mode.
|
||||
*/
|
||||
_mode_create create;
|
||||
|
||||
/**
|
||||
* If this mode is used as completer.
|
||||
*/
|
||||
_mode_completer_result completer_result;
|
||||
|
||||
/** Extra fields for script */
|
||||
void *ed;
|
||||
|
||||
|
@ -206,6 +248,9 @@ struct rofi_mode {
|
|||
/** Fallack icon.*/
|
||||
uint32_t fallback_icon_fetch_uid;
|
||||
uint32_t fallback_icon_not_found;
|
||||
|
||||
/** type */
|
||||
ModeType type;
|
||||
};
|
||||
G_END_DECLS
|
||||
#endif // ROFI_MODE_PRIVATE_H
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
int mode_init(Mode *mode) {
|
||||
g_return_val_if_fail(mode != NULL, FALSE);
|
||||
g_return_val_if_fail(mode->_init != NULL, FALSE);
|
||||
if ( mode->type == MODE_TYPE_UNSET ) {
|
||||
g_warning("Mode '%s' does not have a type set. Please update mode.", mode->name);
|
||||
}
|
||||
// to make sure this is initialized correctly.
|
||||
mode->fallback_icon_fetch_uid = 0;
|
||||
mode->fallback_icon_not_found = FALSE;
|
||||
|
|
|
@ -342,4 +342,5 @@ Mode combi_mode = {.name = "combi",
|
|||
._get_icon = combi_get_icon,
|
||||
._preprocess_input = combi_preprocess_input,
|
||||
.private_data = NULL,
|
||||
.free = NULL};
|
||||
.free = NULL,
|
||||
.type = MODE_TYPE_SWITCHER };
|
||||
|
|
|
@ -1483,6 +1483,7 @@ Mode drun_mode = {.name = "drun",
|
|||
._get_icon = _get_icon,
|
||||
._preprocess_input = NULL,
|
||||
.private_data = NULL,
|
||||
.free = NULL};
|
||||
.free = NULL,
|
||||
.type = MODE_TYPE_SWITCHER };
|
||||
|
||||
#endif // ENABLE_DRUN
|
||||
|
|
|
@ -729,4 +729,5 @@ Mode file_browser_mode = {
|
|||
._preprocess_input = NULL,
|
||||
.private_data = NULL,
|
||||
.free = NULL,
|
||||
.type = MODE_TYPE_SWITCHER|MODE_TYPE_COMPLETER
|
||||
};
|
||||
|
|
|
@ -118,4 +118,5 @@ Mode help_keys_mode = {.name = "keys",
|
|||
._get_completion = NULL,
|
||||
._get_display_value = _get_display_value,
|
||||
.private_data = NULL,
|
||||
.free = NULL};
|
||||
.free = NULL,
|
||||
.type = MODE_TYPE_SWITCHER };
|
||||
|
|
|
@ -568,4 +568,6 @@ Mode recursive_browser_mode = {
|
|||
._preprocess_input = NULL,
|
||||
.private_data = NULL,
|
||||
.free = NULL,
|
||||
.create = create_new_recursive_browser,
|
||||
.type = MODE_TYPE_SWITCHER|MODE_TYPE_COMPLETER
|
||||
};
|
||||
|
|
|
@ -572,5 +572,6 @@ Mode run_mode = {.name = "run",
|
|||
._get_completion = NULL,
|
||||
._preprocess_input = NULL,
|
||||
.private_data = NULL,
|
||||
.free = NULL};
|
||||
.free = NULL,
|
||||
.type = MODE_TYPE_SWITCHER };
|
||||
/** @}*/
|
||||
|
|
|
@ -645,5 +645,6 @@ Mode ssh_mode = {.name = "ssh",
|
|||
._get_completion = NULL,
|
||||
._preprocess_input = NULL,
|
||||
.private_data = NULL,
|
||||
.free = NULL};
|
||||
.free = NULL,
|
||||
.type = MODE_TYPE_SWITCHER };
|
||||
/**@}*/
|
||||
|
|
|
@ -1134,7 +1134,8 @@ Mode window_mode = {.name = "window",
|
|||
._get_completion = NULL,
|
||||
._preprocess_input = NULL,
|
||||
.private_data = NULL,
|
||||
.free = NULL};
|
||||
.free = NULL,
|
||||
.type = MODE_TYPE_SWITCHER };
|
||||
Mode window_mode_cd = {.name = "windowcd",
|
||||
.cfg_name_key = "display-windowcd",
|
||||
._init = window_mode_init_cd,
|
||||
|
@ -1147,6 +1148,7 @@ Mode window_mode_cd = {.name = "windowcd",
|
|||
._get_completion = NULL,
|
||||
._preprocess_input = NULL,
|
||||
.private_data = NULL,
|
||||
.free = NULL};
|
||||
.free = NULL,
|
||||
.type = MODE_TYPE_SWITCHER };
|
||||
|
||||
#endif // WINDOW_MODE
|
||||
|
|
Loading…
Reference in a new issue