From 7cccef790beaba2ffda9901b5b648a1f8702d468 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 24 Jul 2019 13:16:58 -0400 Subject: [PATCH] elm_test: add keybinds to rapidly flip between tests when not using --test-win-only, allow opening new tests forward and backward with alt+. and alt+, Reviewed-by: Marcel Hollerbach Differential Revision: https://phab.enlightenment.org/D9406 --- src/bin/elementary/test.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c index 3222fad..8856c7c 100644 --- a/src/bin/elementary/test.c +++ b/src/bin/elementary/test.c @@ -405,7 +405,7 @@ static void _list_udpate(void); static Evas_Object *win, *tbx, *entry; // TODO: refactoring static void *tt; -static Eina_List *tests; +static Eina_List *tests, *cur_test;; static Eina_Bool hide_legacy = EINA_FALSE; static Eina_Bool hide_beta = EINA_FALSE; @@ -643,6 +643,32 @@ _space_removed_string_get(const char *name) return ret; } +static Eina_Bool +_my_win_key_up(void *d EINA_UNUSED, int type EINA_UNUSED, Ecore_Event_Key *ev) +{ + struct elm_test *t; + + if (eina_streq(ev->key, "comma") && (ev->modifiers & ECORE_EVENT_MODIFIER_ALT)) + { + if (cur_test) + cur_test = eina_list_prev(cur_test); + if (!cur_test) + cur_test = eina_list_last(tests); + t = eina_list_data_get(cur_test); + t->cb(NULL, NULL, NULL); + } + else if (eina_streq(ev->key, "period") && (ev->modifiers & ECORE_EVENT_MODIFIER_ALT)) + { + if (cur_test) + cur_test = eina_list_next(cur_test); + if (!cur_test) + cur_test = tests; + t = eina_list_data_get(cur_test); + t->cb(NULL, NULL, NULL); + } + return ECORE_CALLBACK_RENEW; +} + static void my_win_main(const char *autorun, Eina_Bool test_win_only) { @@ -1300,7 +1326,10 @@ add_tests: } if (tests) - _menu_create(NULL); + { + _menu_create(NULL); + ecore_event_handler_add(ECORE_EVENT_KEY_UP, (Ecore_Event_Handler_Cb)_my_win_key_up, NULL); + } /* bring in autorun frame */ if (autorun) -- 2.7.4