diff options
author | Dave Davenport <DaveDavenport@users.noreply.github.com> | 2021-09-02 09:55:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-02 09:55:31 +0200 |
commit | 4b3f6f6767c92a62f8ff517b4fbac073f8b3449b (patch) | |
tree | 56febe2429dc5e876250a946757bc5b43999d5b1 /source | |
parent | 3f5d82ff56d092bb7701641e620b0158991f41f0 (diff) |
[I1405] Allow action to be taken on input change. (#1420)
Fixes: #1405
Diffstat (limited to 'source')
-rw-r--r-- | source/view.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/source/view.c b/source/view.c index 5fd269d3..52b75754 100644 --- a/source/view.c +++ b/source/view.c @@ -455,9 +455,9 @@ static gboolean rofi_view_reload_idle(G_GNUC_UNUSED gpointer data) { CacheState.idle_timeout = 0; return G_SOURCE_REMOVE; } -static gboolean rofi_view_user_timeout(G_GNUC_UNUSED gpointer data) { - CacheState.user_timeout = 0; - ThemeWidget *wid = rofi_config_find_widget("timeout", NULL, TRUE); + +static void rofi_view_take_action(const char *name) { + ThemeWidget *wid = rofi_config_find_widget(name, NULL, TRUE); if (wid) { /** Check string property */ Property *p = rofi_theme_find_property(wid, P_STRING, "action", TRUE); @@ -471,6 +471,10 @@ static gboolean rofi_view_user_timeout(G_GNUC_UNUSED gpointer data) { } } } +} +static gboolean rofi_view_user_timeout(G_GNUC_UNUSED gpointer data) { + CacheState.user_timeout = 0; + rofi_view_take_action("timeout"); return G_SOURCE_REMOVE; } @@ -1229,6 +1233,12 @@ void rofi_view_finalize(RofiViewState *state) { } } +/** + * This function should be called when the input of the entry is changed. + * TODO: Evaluate if this needs to be a 'signal' on textbox? + */ +static void rofi_view_input_changed() { rofi_view_take_action("inputchange"); } + static void rofi_view_trigger_global_action(KeyBindingAction action) { RofiViewState *state = rofi_view_get_active(); switch (action) { @@ -1410,6 +1420,7 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) { if (rc == 1) { // Entry changed. state->refilter = TRUE; + rofi_view_input_changed(); } else if (rc == 2) { // Movement. } @@ -1499,6 +1510,7 @@ gboolean rofi_view_trigger_action(RofiViewState *state, BindingsScope scope, void rofi_view_handle_text(RofiViewState *state, char *text) { if (textbox_append_text(state->text, text, strlen(text))) { state->refilter = TRUE; + rofi_view_input_changed(); } } |