Skip to content

Commit

Permalink
[View] Add two widgets num-rows/num-filtered-rows
Browse files Browse the repository at this point in the history
Issue: #1026
  • Loading branch information
DaveDavenport committed Nov 7, 2019
1 parent 5f57519 commit c1378e4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/rofi-theme-selector.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 7 additions & 1 deletion doc/rofi-theme.5
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -1153,6 +1153,12 @@ listview
.IP "\(bu" 4
mode\-switcher
.
.IP "\(bu" 4
num\-rows
.
.IP "\(bu" 4
num\-filtered\-rows
.
.IP "" 0
.
.P
Expand Down
2 changes: 2 additions & 0 deletions doc/rofi-theme.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions include/view-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
23 changes: 23 additions & 0 deletions source/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit c1378e4

Please sign in to comment.