summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-12-12 08:52:27 +0100
committerDave Davenport <qball@gmpclient.org>2016-12-12 08:52:27 +0100
commit47125daecfc9f65c5dca19c798728d2f6f8bac8a (patch)
treea6fce922c5ddd329725eeee6c224e16ffcc212fa
parent18793612505ebc38da0116176746bff569d52257 (diff)
Reset user input on script selection.
Fixes: #513
-rw-r--r--include/mode.h4
-rw-r--r--include/view.h8
-rw-r--r--source/dialogs/script.c4
-rw-r--r--source/rofi.c3
-rw-r--r--source/view.c8
5 files changed, 22 insertions, 5 deletions
diff --git a/include/mode.h b/include/mode.h
index 59930a60..b8ee36c4 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -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;
/**
diff --git a/include/view.h b/include/view.h
index 1a6a00fa..6e30ed8a 100644
--- a/include/view.h
+++ b/include/view.h
@@ -216,6 +216,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.
*
* Creates the internal 'Cached' window that gets reused between views.
@@ -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
diff --git a/source/dialogs/script.c b/source/dialogs/script.c
index c57fb5bd..dcbed2e3 100644
--- a/source/dialogs/script.c
+++ b/source/dialogs/script.c
@@ -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;
}
diff --git a/source/rofi.c b/source/rofi.c
index f89c64d4..69bdc22a 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -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;
}
diff --git a/source/view.c b/source/view.c
index 693bd9e3..eff30fba 100644
--- a/source/view.c
+++ b/source/view.c
@@ -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;