add a reset button to reset the key bindings
This commit is contained in:
parent
bf4a1f4aba
commit
a0b7fae2dd
|
@ -361,6 +361,21 @@ _add_default_keys(Config *config)
|
|||
ADD_KB("KP_Divide", 0, 0, 1, 0, "copy_clipboard");
|
||||
}
|
||||
|
||||
void
|
||||
config_reset_keys(Config *config)
|
||||
{
|
||||
Config_Keys *key;
|
||||
|
||||
EINA_LIST_FREE(config->keys, key)
|
||||
{
|
||||
eina_stringshare_del(key->keyname);
|
||||
eina_stringshare_del(key->cb);
|
||||
free(key);
|
||||
}
|
||||
_add_default_keys(config);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_add_key(Config *config, const char *name, int ctrl, int alt, int shift,
|
||||
int win, const char *cb_name)
|
||||
|
|
|
@ -94,6 +94,7 @@ Config *config_fork(Config *config);
|
|||
Config *config_new();
|
||||
void config_del(Config *config);
|
||||
void config_default_font_set(Config *config, Evas *evas);
|
||||
void config_reset_keys(Config *config);
|
||||
|
||||
const char *config_theme_path_get(const Config *config);
|
||||
const char *config_theme_path_default_get(const Config *config);
|
||||
|
|
|
@ -5,4 +5,34 @@ void options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
|
|||
void (*donecb) (void *data), void *donedata);
|
||||
Eina_Bool options_active_get(void);
|
||||
|
||||
#define OPTIONS_CB(_cfg_name, _inv) \
|
||||
static void \
|
||||
_cb_op_behavior_##_cfg_name(void *data, Evas_Object *obj, \
|
||||
void *event EINA_UNUSED) \
|
||||
{ \
|
||||
Evas_Object *term = data; \
|
||||
Config *config = termio_config_get(term); \
|
||||
if (_inv) \
|
||||
config->_cfg_name = !elm_check_state_get(obj); \
|
||||
else \
|
||||
config->_cfg_name = elm_check_state_get(obj); \
|
||||
termio_config_update(term); \
|
||||
windows_update(); \
|
||||
config_save(config, NULL); \
|
||||
}
|
||||
|
||||
#define OPTIONS_CX(_bx, _lbl, _cfg_name, _inv) \
|
||||
do { \
|
||||
o = elm_check_add(_bx); \
|
||||
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0); \
|
||||
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5); \
|
||||
elm_object_text_set(o, _lbl); \
|
||||
elm_check_state_set(o, _inv ? !config->_cfg_name : config->_cfg_name); \
|
||||
elm_box_pack_end(_bx, o); \
|
||||
evas_object_show(o); \
|
||||
evas_object_smart_callback_add(o, "changed", \
|
||||
_cb_op_behavior_##_cfg_name, term) \
|
||||
} while (0)
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -337,6 +337,16 @@ char *gl_group_text_get(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
return strdup(action->description);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_reset_keys(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *gl = data;
|
||||
|
||||
config_reset_keys(_config);
|
||||
elm_genlist_realized_items_update(gl);
|
||||
}
|
||||
|
||||
void
|
||||
options_keys(Evas_Object *opbox, Evas_Object *term)
|
||||
{
|
||||
|
@ -409,5 +419,11 @@ options_keys(Evas_Object *opbox, Evas_Object *term)
|
|||
action++;
|
||||
}
|
||||
|
||||
/* TODO: reset button ? */
|
||||
o = elm_button_add(bx);
|
||||
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_text_set(o, _("Reset bindings"));
|
||||
elm_box_pack_end(bx, o);
|
||||
evas_object_show(o);
|
||||
evas_object_smart_callback_add(o, "clicked", _cb_reset_keys, gl);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue