summaryrefslogtreecommitdiffstats
path: root/source/dialogs
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-07-09 13:32:56 +0200
committerDave Davenport <qball@gmpclient.org>2017-07-09 13:32:56 +0200
commitb5d6751ce36c55fd1256d42a7b81f46996b0d03e (patch)
treeda05d3e5023abf415657d8d90572a5fa449f9a9a /source/dialogs
parenta76120d540e85f740ea3c4c22994479dbf11ced9 (diff)
[Dmenu] Allow multi-select in no-custom mode in dmenu.
Fixes: #596
Diffstat (limited to 'source/dialogs')
-rw-r--r--source/dialogs/dmenu.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index 011920a6..3ded41b3 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -560,7 +560,25 @@ static void dmenu_finalize ( RofiViewState *state )
restart = ( find_arg ( "-only-match" ) >= 0 );
}
else if ( pd->selected_line != UINT32_MAX ) {
- if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && cmd_list[pd->selected_line] != NULL ) {
+ if ( ( mretv & MENU_CUSTOM_ACTION ) && pd->multi_select ) {
+ restart = TRUE;
+ if ( pd->selected_list == NULL ) {
+ pd->selected_list = g_malloc0 ( sizeof ( uint32_t ) * ( pd->cmd_list_length / 32 + 1 ) );
+ }
+ pd->selected_count += ( bitget ( pd->selected_list, pd->selected_line ) ? ( -1 ) : ( 1 ) );
+ bittoggle ( pd->selected_list, pd->selected_line );
+ // Move to next line.
+ pd->selected_line = MIN ( next_pos, cmd_list_length - 1 );
+ if ( pd->selected_count > 0 ) {
+ char *str = g_strdup_printf ( "%u/%u", pd->selected_count, pd->cmd_list_length );
+ rofi_view_set_overlay ( state, str );
+ g_free ( str );
+ }
+ else {
+ rofi_view_set_overlay ( state, NULL );
+ }
+ }
+ else if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && cmd_list[pd->selected_line] != NULL ) {
dmenu_print_results ( pd, input );
retv = TRUE;
if ( ( mretv & MENU_QUICK_SWITCH ) ) {
@@ -570,7 +588,9 @@ static void dmenu_finalize ( RofiViewState *state )
dmenu_finish ( state, retv );
return;
}
- pd->selected_line = next_pos - 1;
+ else {
+ pd->selected_line = next_pos - 1;
+ }
}
// Restart
rofi_view_restart ( state );