forked from enlightenment/efl
efl_ui_item: add keybindings for selecting changes
This started as a small commit, when pressing enter -> set the item as selected. However, it was a bit more complex, it seems that there was never config update code to copy bindings into the user profile. Which lead to the fact that you are missing a lot of keyboard related features if you havnt wiped your config in the last 1-2 years. For me keybindings for Efl.Ui.Scroller Tab_Bar Image_Zoomable (Item) have been missing and were never inserted. WHich is a problem for a user just constantly updating. For now i created a function that copies over the bindings from the system config, and they are merged into the user config. Intentional leaving our of keybinding structs for a user-config will result in them beeing merged again on the next config update. If you want to get rid of key bindings as a user you can just keep the empty struct, which is the signal for "i know what i am doing, i do not want to have them". The problem that the system config is partly invalidated (due to moving the key bindings struct to the user config), is fixed due to the fact that the config is reloaded after that. This function should be called everytime someone updates the config in regards of the keybindings. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9723
This commit is contained in:
parent
c947485bd0
commit
c467dc6e81
|
@ -1,5 +1,5 @@
|
|||
group "Elm_Config" struct {
|
||||
value "config_version" int: 131093;
|
||||
value "config_version" int: 131094;
|
||||
value "entry_select_allow" uchar: 1;
|
||||
value "engine" string: "";
|
||||
value "vsync" uchar: 0;
|
||||
|
@ -2634,6 +2634,29 @@ group "Elm_Config" struct {
|
|||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Efl.Ui.Item";
|
||||
group "key_bindings" list {
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "Return";
|
||||
value "action" string: "select";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "KP_Enter";
|
||||
value "action" string: "select";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "space";
|
||||
value "action" string: "select";
|
||||
value "params" string: "";
|
||||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Efl.Ui.Tab_Bar";
|
||||
group "key_bindings" list {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
group "Elm_Config" struct {
|
||||
value "config_version" int: 131093;
|
||||
value "config_version" int: 131094;
|
||||
value "entry_select_allow" uchar: 1;
|
||||
value "engine" string: "";
|
||||
value "vsync" uchar: 0;
|
||||
|
@ -2631,6 +2631,29 @@ group "Elm_Config" struct {
|
|||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Efl.Ui.Item";
|
||||
group "key_bindings" list {
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "Return";
|
||||
value "action" string: "select";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "KP_Enter";
|
||||
value "action" string: "select";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "space";
|
||||
value "action" string: "select";
|
||||
value "params" string: "";
|
||||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Efl.Ui.Tab_Bar";
|
||||
group "key_bindings" list {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
group "Elm_Config" struct {
|
||||
value "config_version" int: 131093;
|
||||
value "config_version" int: 131094;
|
||||
value "entry_select_allow" uchar: 1;
|
||||
value "engine" string: "";
|
||||
value "vsync" uchar: 0;
|
||||
|
@ -2628,6 +2628,29 @@ group "Elm_Config" struct {
|
|||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Efl.Ui.Item";
|
||||
group "key_bindings" list {
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "Return";
|
||||
value "action" string: "select";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "KP_Enter";
|
||||
value "action" string: "select";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "space";
|
||||
value "action" string: "select";
|
||||
value "params" string: "";
|
||||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Efl.Ui.Tab_Bar";
|
||||
group "key_bindings" list {
|
||||
|
|
|
@ -12,6 +12,20 @@
|
|||
|
||||
#define MY_CLASS_NAME "Efl.Ui.Item"
|
||||
|
||||
static Eina_Bool _key_action_select(Evas_Object *obj, const char *params EINA_UNUSED);
|
||||
|
||||
static const Elm_Action key_actions[] = {
|
||||
{"select", _key_action_select},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static Eina_Bool
|
||||
_key_action_select(Evas_Object *obj, const char *params EINA_UNUSED)
|
||||
{
|
||||
efl_ui_selectable_selected_set(obj, EINA_TRUE);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Efl_Ui_Select_Mode
|
||||
_fetch_state(Eo *obj)
|
||||
{
|
||||
|
@ -194,6 +208,7 @@ _efl_ui_item_item_parent_get(const Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd)
|
|||
return pd->parent;
|
||||
}
|
||||
|
||||
ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_item, Efl_Ui_Item_Data)
|
||||
|
||||
#include "efl_ui_item.eo.c"
|
||||
#include "efl_ui_selectable.eo.c"
|
||||
|
|
|
@ -55,5 +55,6 @@ abstract @beta Efl.Ui.Item extends Efl.Ui.Layout_Base implements Efl.Ui.Selectab
|
|||
Efl.Object.finalize;
|
||||
Efl.Object.destructor;
|
||||
Efl.Ui.Selectable.selected {get; set;}
|
||||
Efl.Ui.Widget.widget_input_event_handler;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2292,6 +2292,35 @@ _elm_key_bindings_update(Elm_Config *cfg, Elm_Config *syscfg EINA_UNUSED)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_key_bindings_copy_missing_bindings(Elm_Config *cfg, Elm_Config *syscfg)
|
||||
{
|
||||
Eina_Hash *safed_bindings = eina_hash_string_superfast_new(NULL);
|
||||
Elm_Config_Bindings_Widget *wd;
|
||||
Eina_List *n, *nnext;
|
||||
Eina_Bool missing_bindings = EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(cfg->bindings, n, wd)
|
||||
{
|
||||
eina_hash_add(safed_bindings, wd->name, wd);
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH_SAFE(syscfg->bindings, n, nnext, wd)
|
||||
{
|
||||
if (!eina_hash_find(safed_bindings, wd->name))
|
||||
{
|
||||
syscfg->bindings = eina_list_remove_list(syscfg->bindings, n);
|
||||
cfg->bindings = eina_list_append(cfg->bindings, wd);
|
||||
printf("Upgraded keybindings for %s!\n", wd->name);
|
||||
missing_bindings = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
if (missing_bindings)
|
||||
{
|
||||
printf("There have been missing Key bindings in the config, config is now adjusted\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_config_update(void)
|
||||
{
|
||||
|
@ -2415,6 +2444,13 @@ _config_update(void)
|
|||
_elm_config->win_no_border = EINA_FALSE;
|
||||
IFCFGEND
|
||||
|
||||
IFCFG(0x0022)
|
||||
|
||||
_elm_key_bindings_copy_missing_bindings(_elm_config, tcfg);
|
||||
/* after this function call, the tcfg is partly invalidated, reload! */
|
||||
_config_free(tcfg);
|
||||
tcfg = _config_system_load();
|
||||
IFCFGEND
|
||||
/**
|
||||
* Fix user config for current ELM_CONFIG_EPOCH here.
|
||||
**/
|
||||
|
|
|
@ -268,7 +268,7 @@ struct _Efl_Ui_Theme_Data
|
|||
* the users config doesn't need to be wiped - simply new values need
|
||||
* to be put in
|
||||
*/
|
||||
# define ELM_CONFIG_FILE_GENERATION 0x0015
|
||||
# define ELM_CONFIG_FILE_GENERATION 0x0016
|
||||
# define ELM_CONFIG_VERSION_EPOCH_OFFSET 16
|
||||
# define ELM_CONFIG_VERSION ((ELM_CONFIG_EPOCH << ELM_CONFIG_VERSION_EPOCH_OFFSET) | \
|
||||
ELM_CONFIG_FILE_GENERATION)
|
||||
|
|
Loading…
Reference in New Issue