Reset user input on script selection.

Fixes: #513
This commit is contained in:
Dave Davenport 2016-12-12 08:52:27 +01:00
parent 1879361250
commit 47125daecf
5 changed files with 22 additions and 5 deletions

View File

@ -26,7 +26,9 @@ typedef enum
/** Reload current DIALOG */
RELOAD_DIALOG = 1002,
/** Previous dialog */
PREVIOUS_DIALOG = 1003
PREVIOUS_DIALOG = 1003,
/** Reloads the dialog and unset user input */
RESET_DIALOG = 1004,
} ModeMode;
/**

View File

@ -215,6 +215,13 @@ void rofi_view_switch_mode ( RofiViewState *state, Mode *mode );
*/
void rofi_view_set_overlay ( RofiViewState *state, const char *text );
/**
* @param state The handle to the view.
*
* Clears the user entry box, set selected to 0.
*/
void rofi_view_clear_input ( RofiViewState *state );
/**
* @param menu_flags The state of the new window.
*
@ -247,6 +254,5 @@ void rofi_view_workers_finalize ( void );
* @returns the xcb_window_t for rofi's view or XCB_WINDOW_NONE.
*/
xcb_window_t rofi_view_get_window ( void );
/**@}*/
#endif

View File

@ -146,9 +146,7 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned
rmpd->cmd_list = new_list;
rmpd->cmd_list_length = new_length;
g_free ( *input );
*input = NULL;
retv = RELOAD_DIALOG;
retv = RESET_DIALOG;
}
return retv;
}

View File

@ -214,6 +214,9 @@ void process_result ( RofiViewState *state )
else if ( retv == RELOAD_DIALOG ) {
// do nothing.
}
else if ( retv == RESET_DIALOG ) {
rofi_view_clear_input ( state );
}
else if ( retv < MODE_EXIT ) {
mode = ( retv ) % num_modi;
}

View File

@ -1679,6 +1679,14 @@ void rofi_view_set_overlay ( RofiViewState *state, const char *text )
widget_move ( WIDGET ( state->overlay ), x_offset, state->border );
}
void rofi_view_clear_input ( RofiViewState *state )
{
if ( state->text ){
textbox_text ( state->text, "");
rofi_view_set_selected_line ( state, 0 );
}
}
void rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
{
state->sw = mode;