mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-03 04:23:42 -05:00
* [listview] Optional don't show elements when not filtered (#1079) * [Listview] Fix auto-complete error.
This commit is contained in:
parent
e2a7cfdd52
commit
f5fce95330
3 changed files with 25 additions and 0 deletions
|
@ -267,6 +267,13 @@ void listview_toggle_ellipsizing(listview *lv);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void listview_set_ellipsize_start(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
|
#endif // ROFI_LISTVIEW_H
|
||||||
|
|
|
@ -1134,6 +1134,8 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) {
|
||||||
}
|
}
|
||||||
TICK_N("Filter tokenize");
|
TICK_N("Filter tokenize");
|
||||||
if (state->text && strlen(state->text->text) > 0) {
|
if (state->text && strlen(state->text->text) > 0) {
|
||||||
|
|
||||||
|
listview_set_filtered(state->list_view, TRUE);
|
||||||
unsigned int j = 0;
|
unsigned int j = 0;
|
||||||
gchar *pattern = mode_preprocess_input(state->sw, state->text->text);
|
gchar *pattern = mode_preprocess_input(state->sw, state->text->text);
|
||||||
glong plen = pattern ? g_utf8_strlen(pattern, -1) : 0;
|
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;
|
state->filtered_lines = j;
|
||||||
g_free(pattern);
|
g_free(pattern);
|
||||||
} else {
|
} else {
|
||||||
|
listview_set_filtered(state->list_view, FALSE);
|
||||||
for (unsigned int i = 0; i < state->num_lines; i++) {
|
for (unsigned int i = 0; i < state->num_lines; i++) {
|
||||||
state->line_map[i] = i;
|
state->line_map[i] = i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,9 @@ struct _listview {
|
||||||
unsigned int dynamic;
|
unsigned int dynamic;
|
||||||
unsigned int eh;
|
unsigned int eh;
|
||||||
unsigned int reverse;
|
unsigned int reverse;
|
||||||
|
gboolean require_input;
|
||||||
|
gboolean filtered;
|
||||||
|
|
||||||
gboolean cycle;
|
gboolean cycle;
|
||||||
gboolean multi_select;
|
gboolean multi_select;
|
||||||
|
|
||||||
|
@ -559,6 +562,9 @@ void listview_set_num_elements(listview *lv, unsigned int rows) {
|
||||||
}
|
}
|
||||||
TICK_N("listview_set_num_elements");
|
TICK_N("listview_set_num_elements");
|
||||||
lv->req_elements = rows;
|
lv->req_elements = rows;
|
||||||
|
if ( lv->require_input && !lv->filtered ) {
|
||||||
|
lv->req_elements = 0;
|
||||||
|
}
|
||||||
listview_set_selected(lv, lv->selected);
|
listview_set_selected(lv, lv->selected);
|
||||||
TICK_N("Set selected");
|
TICK_N("Set selected");
|
||||||
listview_recompute_elements(lv);
|
listview_recompute_elements(lv);
|
||||||
|
@ -748,6 +754,8 @@ listview *listview_create(widget *parent, const char *name,
|
||||||
lv->fixed_columns =
|
lv->fixed_columns =
|
||||||
rofi_theme_get_boolean(WIDGET(lv), "fixed-columns", FALSE);
|
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",
|
lv->type = rofi_theme_get_orientation(WIDGET(lv), "layout",
|
||||||
ROFI_ORIENTATION_VERTICAL);
|
ROFI_ORIENTATION_VERTICAL);
|
||||||
if (lv->type == LISTVIEW) {
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue