mirror of
https://github.com/davatorium/rofi.git
synced 2025-02-17 15:45:56 -05:00
[Mode] Add some extra validating of the mode selected to complete.
This commit is contained in:
parent
cf497e8685
commit
a24b68f523
3 changed files with 28 additions and 2 deletions
|
@ -269,6 +269,14 @@ Mode *mode_create(const Mode *mode);
|
||||||
ModeMode mode_completer_result(Mode *sw, int menu_retv, char **input,
|
ModeMode mode_completer_result(Mode *sw, int menu_retv, char **input,
|
||||||
unsigned int selected_line, char **path);
|
unsigned int selected_line, char **path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mode The mode to query.
|
||||||
|
*
|
||||||
|
* Check if mode is a valid completer.
|
||||||
|
*
|
||||||
|
* @returns TRUE if mode can be used as completer.
|
||||||
|
*/
|
||||||
|
gboolean mode_is_completer(const Mode *sw);
|
||||||
/**@}*/
|
/**@}*/
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,9 +45,16 @@ int mode_init(Mode *mode) {
|
||||||
g_return_val_if_fail(mode != NULL, FALSE);
|
g_return_val_if_fail(mode != NULL, FALSE);
|
||||||
g_return_val_if_fail(mode->_init != NULL, FALSE);
|
g_return_val_if_fail(mode->_init != NULL, FALSE);
|
||||||
if (mode->type == MODE_TYPE_UNSET) {
|
if (mode->type == MODE_TYPE_UNSET) {
|
||||||
g_warning("Mode '%s' does not have a type set. Please update mode.",
|
g_warning("Mode '%s' does not have a type set. Please update mode/plugin.",
|
||||||
mode->name);
|
mode->name);
|
||||||
}
|
}
|
||||||
|
if ((mode->type & MODE_TYPE_COMPLETER) == MODE_TYPE_COMPLETER) {
|
||||||
|
if (mode->_completer_result == NULL) {
|
||||||
|
g_error(
|
||||||
|
"Mode '%s' is incomplete and does not implement _completer_result.",
|
||||||
|
mode->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
// to make sure this is initialized correctly.
|
// to make sure this is initialized correctly.
|
||||||
mode->fallback_icon_fetch_uid = 0;
|
mode->fallback_icon_fetch_uid = 0;
|
||||||
mode->fallback_icon_not_found = FALSE;
|
mode->fallback_icon_not_found = FALSE;
|
||||||
|
@ -229,4 +236,13 @@ ModeMode mode_completer_result(Mode *mode, int menu_retv, char **input,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean mode_is_completer(const Mode *mode) {
|
||||||
|
if (mode) {
|
||||||
|
if ((mode->type & MODE_TYPE_COMPLETER) == MODE_TYPE_COMPLETER) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
|
@ -1214,9 +1214,11 @@ int rofi_theme_rasi_validate(const char *filename) {
|
||||||
|
|
||||||
const Mode *rofi_get_completer(void) {
|
const Mode *rofi_get_completer(void) {
|
||||||
const Mode *index = mode_available_lookup(config.completer_mode);
|
const Mode *index = mode_available_lookup(config.completer_mode);
|
||||||
printf("%p\n", index);
|
|
||||||
if (index != NULL) {
|
if (index != NULL) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
const char *name =
|
||||||
|
config.completer_mode == NULL ? "(null)" : config.completer_mode;
|
||||||
|
g_warning("Mode: %s not found or is not valid for use as completer.", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue