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

[View] Add two widgets num-rows/num-filtered-rows

Issue: #1026
This commit is contained in:
Dave Davenport 2019-11-07 11:49:45 +01:00
parent 5f57519940
commit c1378e4c60
5 changed files with 39 additions and 2 deletions

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ROFI\-THEME\-SELECTOR" "1" "May 2019" "" ""
.TH "ROFI\-THEME\-SELECTOR" "1" "January 2018" "" ""
.
.SH "NAME"
\fBrofi\-theme\-selector\fR \- Preview and apply themes for \fBrofi\fR

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ROFI\-THEME" "5" "September 2019" "" ""
.TH "ROFI\-THEME" "5" "November 2019" "" ""
.
.SH "NAME"
\fBrofi\-theme\fR \- Rofi theme format files
@ -1153,6 +1153,12 @@ listview
.IP "\(bu" 4
mode\-switcher
.
.IP "\(bu" 4
num\-rows
.
.IP "\(bu" 4
num\-filtered\-rows
.
.IP "" 0
.
.P

View file

@ -741,6 +741,8 @@ The following widgets are fixed, as they provide core **rofi** functionality:
* message
* listview
* mode-switcher
* num-rows
* num-filtered-rows
The following keywords are defined and can be used to automatically pack a subset of the widgets.
These are used in the default theme as depicted in the figure above.

View file

@ -101,6 +101,12 @@ struct RofiViewState
unsigned int num_modi;
/** Array of #textbox that act as buttons for switching modi */
textbox **modi;
/** Total rows. */
textbox *tb_total_rows;
/** filtered rows */
textbox *tb_filtered_rows;
/** Settings of the menu */
MenuFlags menu_flags;
/** If mouse was within view previously */

View file

@ -1102,6 +1102,19 @@ static void rofi_view_refilter ( RofiViewState *state )
}
listview_set_num_elements ( state->list_view, state->filtered_lines );
if ( state->tb_filtered_rows ) {
char *r = g_strdup_printf("%u", state->filtered_lines);
textbox_text( state->tb_filtered_rows, r );
g_free(r);
}
if ( state->tb_total_rows ) {
char *r = g_strdup_printf("%u", state->num_lines);
textbox_text( state->tb_total_rows, r );
g_free(r);
}
if ( config.auto_select == TRUE && state->filtered_lines == 1 && state->num_lines > 1 ) {
( state->selected_line ) = state->line_map[listview_get_selected ( state->list_view )];
state->retv = MENU_OK;
@ -1616,6 +1629,16 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
box_add ( (box *) parent_widget, WIDGET ( state->prompt ), FALSE );
defaults = NULL;
}
else if ( strcmp ( name, "num-rows" ) == 0 ){
state->tb_total_rows = textbox_create ( parent_widget, WIDGET_TYPE_TEXTBOX_TEXT, name, TB_AUTOWIDTH|TB_AUTOHEIGHT, NORMAL, "", 0, 0 );
box_add ( (box *) parent_widget, WIDGET ( state->tb_total_rows ), FALSE );
defaults = NULL;
}
else if ( strcmp ( name, "num-filtered-rows" ) == 0 ){
state->tb_filtered_rows = textbox_create ( parent_widget, WIDGET_TYPE_TEXTBOX_TEXT, name, TB_AUTOWIDTH|TB_AUTOHEIGHT, NORMAL, "", 0, 0 );
box_add ( (box *) parent_widget, WIDGET ( state->tb_filtered_rows), FALSE );
defaults = NULL;
}
/**
* CASE INDICATOR
*/