1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[#1079]: Option to hide listview elements when not filtered (#1622)

* [listview] Optional don't show elements when not filtered (#1079)

* [Listview] Fix auto-complete error.
This commit is contained in:
Dave Davenport 2022-04-20 23:24:52 +02:00 committed by GitHub
parent e2a7cfdd52
commit f5fce95330
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 0 deletions

View file

@ -267,6 +267,13 @@ void listview_toggle_ellipsizing(listview *lv);
*/
void listview_set_ellipsize_start(listview *lv);
/**
* @param lv Handler to the listview object.
* @param filtered boolean indicating if list is filtered.
*
*/
void listview_set_filtered ( listview *lv, gboolean filtered );
/** @} */
#endif // ROFI_LISTVIEW_H

View file

@ -1134,6 +1134,8 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) {
}
TICK_N("Filter tokenize");
if (state->text && strlen(state->text->text) > 0) {
listview_set_filtered(state->list_view, TRUE);
unsigned int j = 0;
gchar *pattern = mode_preprocess_input(state->sw, state->text->text);
glong plen = pattern ? g_utf8_strlen(pattern, -1) : 0;
@ -1199,6 +1201,7 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) {
state->filtered_lines = j;
g_free(pattern);
} else {
listview_set_filtered(state->list_view, FALSE);
for (unsigned int i = 0; i < state->num_lines; i++) {
state->line_map[i] = i;
}

View file

@ -98,6 +98,9 @@ struct _listview {
unsigned int dynamic;
unsigned int eh;
unsigned int reverse;
gboolean require_input;
gboolean filtered;
gboolean cycle;
gboolean multi_select;
@ -559,6 +562,9 @@ void listview_set_num_elements(listview *lv, unsigned int rows) {
}
TICK_N("listview_set_num_elements");
lv->req_elements = rows;
if ( lv->require_input && !lv->filtered ) {
lv->req_elements = 0;
}
listview_set_selected(lv, lv->selected);
TICK_N("Set selected");
listview_recompute_elements(lv);
@ -748,6 +754,8 @@ listview *listview_create(widget *parent, const char *name,
lv->fixed_columns =
rofi_theme_get_boolean(WIDGET(lv), "fixed-columns", FALSE);
lv->require_input =
rofi_theme_get_boolean(WIDGET(lv), "require-input", FALSE);
lv->type = rofi_theme_get_orientation(WIDGET(lv), "layout",
ROFI_ORIENTATION_VERTICAL);
if (lv->type == LISTVIEW) {
@ -1081,3 +1089,10 @@ void listview_toggle_ellipsizing(listview *lv) {
}
}
}
void listview_set_filtered ( listview *lv, gboolean filtered )
{
if ( lv ) {
lv->filtered = filtered;
}
}