2006-02-09 15:24:06 -08:00
|
|
|
#include "e.h"
|
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
#define TEXT_NONE_ACTION_KEY _("<None>")
|
2006-10-11 01:46:52 -07:00
|
|
|
#define TEXT_PRESS_KEY_SEQUENCE _("Please press key sequence,<br><br>" \
|
2010-12-22 16:55:58 -08:00
|
|
|
"or <hilight>Escape</hilight> to abort.")
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
#define TEXT_NO_PARAMS _("<None>")
|
2010-05-02 11:03:33 -07:00
|
|
|
#define TEXT_NO_MODIFIER_HEADER _("Single key")
|
2006-02-22 06:35:04 -08:00
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
static void *_create_data(E_Config_Dialog *cfd);
|
2012-06-08 02:48:19 -07:00
|
|
|
static void _free_data(E_Config_Dialog *cfd,
|
2010-12-22 16:55:58 -08:00
|
|
|
E_Config_Dialog_Data *cfdata);
|
2012-06-08 02:48:19 -07:00
|
|
|
static int _basic_apply_data(E_Config_Dialog *cfd,
|
2010-12-22 16:55:58 -08:00
|
|
|
E_Config_Dialog_Data *cfdata);
|
2012-06-08 02:48:19 -07:00
|
|
|
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd,
|
|
|
|
Evas *evas,
|
2010-12-22 16:55:58 -08:00
|
|
|
E_Config_Dialog_Data *cfdata);
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
/********* private functions ***************/
|
2012-06-08 02:48:19 -07:00
|
|
|
static void _fill_actions_list(E_Config_Dialog_Data *cfdata);
|
2006-10-11 01:46:52 -07:00
|
|
|
|
|
|
|
/**************** Updates ***********/
|
2012-06-08 02:48:19 -07:00
|
|
|
static int _update_key_binding_list(E_Config_Dialog_Data *cfdata,
|
|
|
|
E_Config_Binding_Key *bi);
|
|
|
|
static void _update_action_list(E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _update_action_params(E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _update_buttons(E_Config_Dialog_Data *cfdata);
|
2006-10-11 01:46:52 -07:00
|
|
|
|
|
|
|
/**************** Callbacks *********/
|
2012-06-08 02:48:19 -07:00
|
|
|
static void _binding_change_cb(void *data);
|
|
|
|
static void _action_change_cb(void *data);
|
|
|
|
static void _delete_all_key_binding_cb(void *data,
|
|
|
|
void *data2);
|
|
|
|
static void _delete_key_binding_cb(void *data,
|
|
|
|
void *data2);
|
|
|
|
static void _restore_key_binding_defaults_cb(void *data,
|
|
|
|
void *data2);
|
|
|
|
static void _add_key_binding_cb(void *data,
|
|
|
|
void *data2);
|
|
|
|
static void _modify_key_binding_cb(void *data,
|
|
|
|
void *data2);
|
2006-10-11 01:46:52 -07:00
|
|
|
|
|
|
|
/********* Helper *************************/
|
2012-06-08 02:48:19 -07:00
|
|
|
static char *_key_binding_header_get(int modifiers);
|
|
|
|
static char *_key_binding_text_get(E_Config_Binding_Key *bi);
|
|
|
|
static void _auto_apply_changes(E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _find_key_binding_action(const char *action,
|
|
|
|
const char *params,
|
|
|
|
int *g,
|
|
|
|
int *a,
|
|
|
|
int *n);
|
2006-10-11 01:46:52 -07:00
|
|
|
|
|
|
|
/********* Sorting ************************/
|
2012-06-08 02:48:19 -07:00
|
|
|
static int _key_binding_sort_cb(const void *d1,
|
|
|
|
const void *d2);
|
2006-10-11 01:46:52 -07:00
|
|
|
|
|
|
|
/**************** grab window *******/
|
2010-12-22 16:55:58 -08:00
|
|
|
static void _grab_wnd_show(E_Config_Dialog_Data *cfdata);
|
|
|
|
static Eina_Bool _grab_key_down_cb(void *data,
|
2012-06-08 02:48:19 -07:00
|
|
|
int type,
|
2010-12-22 16:55:58 -08:00
|
|
|
void *event);
|
2006-02-22 06:35:04 -08:00
|
|
|
|
|
|
|
struct _E_Config_Dialog_Data
|
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
Evas *evas;
|
|
|
|
struct
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
|
|
|
Eina_List *key;
|
|
|
|
} binding;
|
2006-10-11 01:46:52 -07:00
|
|
|
struct
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
|
|
|
const char *binding, *action, *cur;
|
|
|
|
char *params;
|
|
|
|
int cur_act, add;
|
2012-12-03 05:22:24 -08:00
|
|
|
Eina_Bool changed : 1;
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
E_Grab_Dialog *eg;
|
2010-12-22 16:55:58 -08:00
|
|
|
} locals;
|
2006-10-11 01:46:52 -07:00
|
|
|
struct
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
|
|
|
Evas_Object *o_add, *o_mod, *o_del, *o_del_all;
|
|
|
|
Evas_Object *o_binding_list, *o_action_list;
|
|
|
|
Evas_Object *o_params;
|
|
|
|
} gui;
|
2006-10-16 02:44:17 -07:00
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
char *params;
|
2006-10-16 02:44:17 -07:00
|
|
|
E_Config_Dialog *cfd;
|
2006-10-11 01:46:52 -07:00
|
|
|
};
|
2006-02-22 06:35:04 -08:00
|
|
|
|
2010-01-22 12:28:39 -08:00
|
|
|
E_Config_Dialog *
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
e_int_config_keybindings(E_Comp *comp,
|
2012-06-08 02:48:19 -07:00
|
|
|
const char *params)
|
2006-02-22 06:35:04 -08:00
|
|
|
{
|
2006-10-08 01:04:18 -07:00
|
|
|
E_Config_Dialog *cfd;
|
|
|
|
E_Config_Dialog_View *v;
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2009-12-04 14:37:18 -08:00
|
|
|
if (e_config_dialog_find("E", "keyboard_and_mouse/key_bindings")) return NULL;
|
2006-10-08 01:04:18 -07:00
|
|
|
v = E_NEW(E_Config_Dialog_View, 1);
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2006-10-08 01:04:18 -07:00
|
|
|
v->create_cfdata = _create_data;
|
|
|
|
v->free_cfdata = _free_data;
|
|
|
|
v->basic.apply_cfdata = _basic_apply_data;
|
|
|
|
v->basic.create_widgets = _basic_create_widgets;
|
|
|
|
v->override_auto_apply = 1;
|
2006-10-11 01:46:52 -07:00
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
cfd = e_config_dialog_new(comp, _("Key Bindings Settings"), "E",
|
2010-12-22 16:55:58 -08:00
|
|
|
"keyboard_and_mouse/key_bindings",
|
|
|
|
"preferences-desktop-keyboard-shortcuts", 0, v, NULL);
|
2007-10-28 23:17:18 -07:00
|
|
|
if ((params) && (params[0]))
|
2007-10-28 12:07:25 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
cfd->cfdata->params = strdup(params);
|
|
|
|
_add_key_binding_cb(cfd->cfdata, NULL);
|
2007-10-28 12:07:25 -07:00
|
|
|
}
|
|
|
|
|
2006-10-08 01:04:18 -07:00
|
|
|
return cfd;
|
2006-02-22 06:35:04 -08:00
|
|
|
}
|
|
|
|
|
2006-02-09 15:24:06 -08:00
|
|
|
static void
|
2006-05-06 02:35:05 -07:00
|
|
|
_fill_data(E_Config_Dialog_Data *cfdata)
|
2006-02-09 15:24:06 -08:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Binding_Key *bi, *bi2;
|
|
|
|
|
2009-03-11 08:13:42 -07:00
|
|
|
cfdata->locals.binding = eina_stringshare_add("");
|
|
|
|
cfdata->locals.action = eina_stringshare_add("");
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata->locals.params = strdup("");
|
|
|
|
cfdata->locals.cur = NULL;
|
|
|
|
cfdata->binding.key = NULL;
|
2012-08-20 01:36:43 -07:00
|
|
|
cfdata->locals.eg = NULL;
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2013-02-01 02:21:54 -08:00
|
|
|
EINA_LIST_FOREACH(e_bindings->key_bindings, l, bi)
|
2006-10-11 01:46:52 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
if (!bi) continue;
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
bi2 = E_NEW(E_Config_Binding_Key, 1);
|
|
|
|
bi2->context = bi->context;
|
|
|
|
bi2->key = eina_stringshare_add(bi->key);
|
|
|
|
bi2->modifiers = bi->modifiers;
|
|
|
|
bi2->any_mod = bi->any_mod;
|
|
|
|
bi2->action = eina_stringshare_ref(bi->action);
|
|
|
|
bi2->params = eina_stringshare_ref(bi->params);
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
cfdata->binding.key = eina_list_append(cfdata->binding.key, bi2);
|
2006-05-06 02:35:05 -07:00
|
|
|
}
|
2006-02-09 15:24:06 -08:00
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2006-02-09 15:24:06 -08:00
|
|
|
static void *
|
|
|
|
_create_data(E_Config_Dialog *cfd)
|
|
|
|
{
|
2006-06-16 02:37:32 -07:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2006-06-16 02:37:32 -07:00
|
|
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
2006-10-16 02:44:17 -07:00
|
|
|
cfdata->cfd = cfd;
|
2012-06-27 00:11:01 -07:00
|
|
|
cfdata->locals.cur_act = -1;
|
2006-06-16 02:37:32 -07:00
|
|
|
_fill_data(cfdata);
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2006-06-16 02:37:32 -07:00
|
|
|
return cfdata;
|
2006-02-09 15:24:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-22 16:55:58 -08:00
|
|
|
_free_data(E_Config_Dialog *cfd __UNUSED__,
|
|
|
|
E_Config_Dialog_Data *cfdata)
|
2006-02-09 15:24:06 -08:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Binding_Key *bi;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2009-03-11 08:13:42 -07:00
|
|
|
EINA_LIST_FREE(cfdata->binding.key, bi)
|
2006-05-06 02:35:05 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
eina_stringshare_del(bi->key);
|
|
|
|
eina_stringshare_del(bi->action);
|
|
|
|
eina_stringshare_del(bi->params);
|
|
|
|
E_FREE(bi);
|
2006-05-06 02:35:05 -07:00
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2009-03-11 08:13:42 -07:00
|
|
|
eina_stringshare_del(cfdata->locals.cur);
|
|
|
|
eina_stringshare_del(cfdata->locals.binding);
|
|
|
|
eina_stringshare_del(cfdata->locals.action);
|
|
|
|
|
2012-12-21 13:31:13 -08:00
|
|
|
free(cfdata->locals.params);
|
|
|
|
free(cfdata->params);
|
2007-01-15 09:43:19 -08:00
|
|
|
E_FREE(cfdata);
|
2006-02-09 15:24:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-22 16:55:58 -08:00
|
|
|
_basic_apply_data(E_Config_Dialog *cfd __UNUSED__,
|
|
|
|
E_Config_Dialog_Data *cfdata)
|
2006-02-09 15:24:06 -08:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Binding_Key *bi, *bi2;
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
_auto_apply_changes(cfdata);
|
2006-05-06 02:35:05 -07:00
|
|
|
|
|
|
|
e_managers_keys_ungrab();
|
2013-02-01 02:21:54 -08:00
|
|
|
EINA_LIST_FREE(e_bindings->key_bindings, bi)
|
2006-05-06 02:35:05 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
e_bindings_key_del(bi->context, bi->key, bi->modifiers, bi->any_mod,
|
|
|
|
bi->action, bi->params);
|
|
|
|
if (bi->key) eina_stringshare_del(bi->key);
|
|
|
|
if (bi->action) eina_stringshare_del(bi->action);
|
|
|
|
if (bi->params) eina_stringshare_del(bi->params);
|
|
|
|
E_FREE(bi);
|
2006-05-06 02:35:05 -07:00
|
|
|
}
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2009-03-11 08:13:42 -07:00
|
|
|
EINA_LIST_FOREACH(cfdata->binding.key, l, bi2)
|
2006-05-06 02:35:05 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
bi2 = l->data;
|
|
|
|
|
|
|
|
if (!bi2->key || !bi2->key[0]) continue;
|
|
|
|
|
|
|
|
bi = E_NEW(E_Config_Binding_Key, 1);
|
|
|
|
bi->context = bi2->context;
|
|
|
|
bi->key = eina_stringshare_add(bi2->key);
|
|
|
|
bi->modifiers = bi2->modifiers;
|
|
|
|
bi->any_mod = bi2->any_mod;
|
|
|
|
bi->action =
|
|
|
|
((!bi2->action) || (!bi2->action[0])) ? NULL : eina_stringshare_ref(bi2->action);
|
|
|
|
bi->params =
|
|
|
|
((!bi2->params) || (!bi2->params[0])) ? NULL : eina_stringshare_ref(bi2->params);
|
|
|
|
|
2013-02-01 02:21:54 -08:00
|
|
|
e_bindings->key_bindings = eina_list_append(e_bindings->key_bindings, bi);
|
2010-12-22 16:55:58 -08:00
|
|
|
e_bindings_key_add(bi->context, bi->key, bi->modifiers, bi->any_mod,
|
|
|
|
bi->action, bi->params);
|
2006-05-06 02:35:05 -07:00
|
|
|
}
|
|
|
|
e_managers_keys_grab();
|
|
|
|
e_config_save_queue();
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2006-05-06 02:35:05 -07:00
|
|
|
return 1;
|
2006-02-09 15:24:06 -08:00
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2006-02-09 15:24:06 -08:00
|
|
|
static Evas_Object *
|
2012-12-03 23:41:20 -08:00
|
|
|
_basic_create_widgets(E_Config_Dialog *cfd,
|
2012-06-08 02:48:19 -07:00
|
|
|
Evas *evas,
|
2010-12-22 16:55:58 -08:00
|
|
|
E_Config_Dialog_Data *cfdata)
|
2006-02-09 15:24:06 -08:00
|
|
|
{
|
2006-12-16 11:54:41 -08:00
|
|
|
Evas_Object *o, *ot, *of, *ob;
|
2006-10-11 01:46:52 -07:00
|
|
|
|
|
|
|
cfdata->evas = evas;
|
2006-12-16 11:54:41 -08:00
|
|
|
o = e_widget_list_add(evas, 0, 1);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2006-12-16 11:54:41 -08:00
|
|
|
of = e_widget_frametable_add(evas, _("Key Bindings"), 0);
|
|
|
|
ob = e_widget_ilist_add(evas, 32, 32, &(cfdata->locals.binding));
|
2010-12-22 16:55:58 -08:00
|
|
|
cfdata->gui.o_binding_list = ob;
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(ob, 200, 200);
|
2006-12-16 11:54:41 -08:00
|
|
|
e_widget_frametable_object_append(of, ob, 0, 0, 2, 1, 1, 1, 1, 1);
|
2012-06-26 16:20:24 -07:00
|
|
|
ob = e_widget_button_add(evas, _("Add"), "list-add", _add_key_binding_cb, cfdata, NULL);
|
2006-12-16 11:54:41 -08:00
|
|
|
cfdata->gui.o_add = ob;
|
2006-12-16 12:32:40 -08:00
|
|
|
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 0, 1, 0);
|
2012-06-26 16:20:24 -07:00
|
|
|
ob = e_widget_button_add(evas, _("Delete"), "list-remove", _delete_key_binding_cb, cfdata, NULL);
|
2006-12-16 11:54:41 -08:00
|
|
|
cfdata->gui.o_del = ob;
|
|
|
|
e_widget_disabled_set(ob, 1);
|
2006-12-16 12:32:40 -08:00
|
|
|
e_widget_frametable_object_append(of, ob, 1, 1, 1, 1, 1, 0, 1, 0);
|
2012-06-26 16:20:24 -07:00
|
|
|
ob = e_widget_button_add(evas, _("Modify"), NULL, _modify_key_binding_cb, cfdata, NULL);
|
2006-12-16 11:54:41 -08:00
|
|
|
cfdata->gui.o_mod = ob;
|
|
|
|
e_widget_disabled_set(ob, 1);
|
2006-12-16 12:32:40 -08:00
|
|
|
e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 0, 1, 0);
|
2012-06-26 16:20:24 -07:00
|
|
|
ob = e_widget_button_add(evas, _("Delete All"), "edit-clear", _delete_all_key_binding_cb, cfdata, NULL);
|
2006-12-16 11:54:41 -08:00
|
|
|
cfdata->gui.o_del_all = ob;
|
|
|
|
e_widget_disabled_set(ob, 1);
|
2006-12-16 12:32:40 -08:00
|
|
|
e_widget_frametable_object_append(of, ob, 1, 2, 1, 1, 1, 0, 1, 0);
|
2009-03-15 10:41:46 -07:00
|
|
|
ob = e_widget_button_add(evas, _("Restore Default Bindings"), "enlightenment", _restore_key_binding_defaults_cb, cfdata, NULL);
|
2006-12-16 12:32:40 -08:00
|
|
|
e_widget_frametable_object_append(of, ob, 0, 3, 2, 1, 1, 0, 1, 0);
|
2006-12-16 11:54:41 -08:00
|
|
|
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2006-12-16 11:54:41 -08:00
|
|
|
ot = e_widget_table_add(evas, 0);
|
2006-10-11 01:46:52 -07:00
|
|
|
of = e_widget_framelist_add(evas, _("Action"), 0);
|
2006-12-16 11:54:41 -08:00
|
|
|
ob = e_widget_ilist_add(evas, 24, 24, &(cfdata->locals.action));
|
|
|
|
cfdata->gui.o_action_list = ob;
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(ob, 200, 280);
|
2006-12-16 11:54:41 -08:00
|
|
|
e_widget_framelist_object_append(of, ob);
|
|
|
|
e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 1);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
of = e_widget_framelist_add(evas, _("Action Params"), 0);
|
2007-10-07 14:26:48 -07:00
|
|
|
ob = e_widget_entry_add(evas, &(cfdata->locals.params), NULL, NULL, NULL);
|
2006-12-16 11:54:41 -08:00
|
|
|
cfdata->gui.o_params = ob;
|
|
|
|
e_widget_disabled_set(ob, 1);
|
|
|
|
e_widget_framelist_object_append(of, ob);
|
2007-04-17 03:11:35 -07:00
|
|
|
e_widget_table_object_append(ot, of, 0, 1, 1, 1, 1, 1, 1, 0);
|
2006-12-16 11:54:41 -08:00
|
|
|
e_widget_list_object_append(o, ot, 1, 1, 0.5);
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2010-06-09 09:40:55 -07:00
|
|
|
_update_key_binding_list(cfdata, NULL);
|
2006-10-11 01:46:52 -07:00
|
|
|
_fill_actions_list(cfdata);
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2012-12-03 23:41:20 -08:00
|
|
|
e_dialog_resizable_set(cfd->dia, 1);
|
2006-12-16 11:54:41 -08:00
|
|
|
return o;
|
2006-03-04 16:30:28 -08:00
|
|
|
}
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-03-04 16:30:28 -08:00
|
|
|
static void
|
2006-10-11 01:46:52 -07:00
|
|
|
_fill_actions_list(E_Config_Dialog_Data *cfdata)
|
2006-03-04 16:30:28 -08:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
char buf[1024];
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l, *l2;
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Action_Group *actg;
|
|
|
|
E_Action_Description *actd;
|
|
|
|
int g, a;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-11-27 08:01:50 -08:00
|
|
|
evas_event_freeze(evas_object_evas_get(cfdata->gui.o_action_list));
|
|
|
|
edje_freeze();
|
|
|
|
e_widget_ilist_freeze(cfdata->gui.o_action_list);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
e_widget_ilist_clear(cfdata->gui.o_action_list);
|
2006-10-11 01:46:52 -07:00
|
|
|
for (l = e_action_groups_get(), g = 0; l; l = l->next, g++)
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
actg = l->data;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
if (!actg->acts) continue;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2011-01-14 01:49:42 -08:00
|
|
|
e_widget_ilist_header_append(cfdata->gui.o_action_list, NULL, _(actg->act_grp));
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
for (l2 = actg->acts, a = 0; l2; l2 = l2->next, a++)
|
|
|
|
{
|
|
|
|
actd = l2->data;
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%d %d", g, a);
|
2011-01-14 01:49:42 -08:00
|
|
|
e_widget_ilist_append(cfdata->gui.o_action_list, NULL, _(actd->act_name),
|
2010-12-22 16:55:58 -08:00
|
|
|
_action_change_cb, cfdata, buf);
|
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
|
|
|
e_widget_ilist_go(cfdata->gui.o_action_list);
|
2006-11-27 08:01:50 -08:00
|
|
|
e_widget_ilist_thaw(cfdata->gui.o_action_list);
|
|
|
|
edje_thaw();
|
|
|
|
evas_event_thaw(evas_object_evas_get(cfdata->gui.o_action_list));
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
/**************** Callbacks *********/
|
2006-03-04 16:30:28 -08:00
|
|
|
|
|
|
|
static void
|
2012-06-08 02:48:19 -07:00
|
|
|
_add_key_binding_cb(void *data,
|
2010-12-22 16:55:58 -08:00
|
|
|
void *data2 __UNUSED__)
|
2006-03-04 16:30:28 -08:00
|
|
|
{
|
2006-05-06 02:35:05 -07:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
|
|
|
|
|
|
|
cfdata = data;
|
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
_auto_apply_changes(cfdata);
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata->locals.add = 1;
|
|
|
|
_grab_wnd_show(cfdata);
|
2006-03-04 16:30:28 -08:00
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2006-03-04 16:30:28 -08:00
|
|
|
static void
|
2012-06-08 02:48:19 -07:00
|
|
|
_modify_key_binding_cb(void *data,
|
2010-12-22 16:55:58 -08:00
|
|
|
void *data2 __UNUSED__)
|
2006-03-04 16:30:28 -08:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata = data;
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
_auto_apply_changes(cfdata);
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata->locals.add = 0;
|
|
|
|
_grab_wnd_show(cfdata);
|
2006-03-04 16:30:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-11 01:46:52 -07:00
|
|
|
_binding_change_cb(void *data)
|
2006-03-04 16:30:28 -08:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata = data;
|
|
|
|
|
2012-12-03 05:22:24 -08:00
|
|
|
if (cfdata->locals.changed) _auto_apply_changes(cfdata);
|
2009-03-11 08:13:42 -07:00
|
|
|
eina_stringshare_del(cfdata->locals.cur);
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata->locals.cur = NULL;
|
2012-06-27 00:11:01 -07:00
|
|
|
cfdata->locals.cur_act = -1;
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2012-12-03 05:22:24 -08:00
|
|
|
cfdata->locals.changed = 0;
|
2010-12-22 16:55:58 -08:00
|
|
|
if ((!cfdata->locals.binding) || (!cfdata->locals.binding[0])) return;
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2012-12-03 05:22:24 -08:00
|
|
|
cfdata->locals.cur = eina_stringshare_ref(cfdata->locals.binding);
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
_update_buttons(cfdata);
|
|
|
|
_update_action_list(cfdata);
|
2006-03-04 16:30:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-11 01:46:52 -07:00
|
|
|
_action_change_cb(void *data)
|
2006-03-04 16:30:28 -08:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata = data;
|
|
|
|
_update_action_params(cfdata);
|
2012-06-27 00:11:01 -07:00
|
|
|
cfdata->locals.cur_act = e_widget_ilist_selected_get(cfdata->gui.o_action_list);
|
2012-12-03 05:22:24 -08:00
|
|
|
cfdata->locals.changed = 1;
|
2006-02-09 15:24:06 -08:00
|
|
|
}
|
|
|
|
|
2006-03-04 16:30:28 -08:00
|
|
|
static void
|
2012-06-08 02:48:19 -07:00
|
|
|
_delete_all_key_binding_cb(void *data,
|
2010-12-22 16:55:58 -08:00
|
|
|
void *data2 __UNUSED__)
|
2006-02-09 15:24:06 -08:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Binding_Key *bi;
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata = data;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2007-03-25 15:45:00 -07:00
|
|
|
/* FIXME: need confirmation dialog */
|
2009-03-11 08:13:42 -07:00
|
|
|
EINA_LIST_FREE(cfdata->binding.key, bi)
|
2006-10-11 01:46:52 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
eina_stringshare_del(bi->key);
|
|
|
|
eina_stringshare_del(bi->action);
|
|
|
|
eina_stringshare_del(bi->params);
|
|
|
|
E_FREE(bi);
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2009-03-11 08:13:42 -07:00
|
|
|
eina_stringshare_del(cfdata->locals.cur);
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata->locals.cur = NULL;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
e_widget_ilist_clear(cfdata->gui.o_binding_list);
|
|
|
|
e_widget_ilist_go(cfdata->gui.o_binding_list);
|
|
|
|
e_widget_ilist_unselect(cfdata->gui.o_action_list);
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
_update_buttons(cfdata);
|
2006-02-09 15:24:06 -08:00
|
|
|
}
|
2007-10-28 12:07:25 -07:00
|
|
|
|
2006-02-09 15:24:06 -08:00
|
|
|
static void
|
2012-06-08 02:48:19 -07:00
|
|
|
_delete_key_binding_cb(void *data,
|
2010-12-22 16:55:58 -08:00
|
|
|
void *data2 __UNUSED__)
|
2006-02-09 15:24:06 -08:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2009-03-11 08:13:42 -07:00
|
|
|
const char *n;
|
2006-10-11 01:46:52 -07:00
|
|
|
int sel;
|
2006-05-22 13:28:33 -07:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Binding_Key *bi;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata = data;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
sel = e_widget_ilist_selected_get(cfdata->gui.o_binding_list);
|
|
|
|
if (cfdata->locals.binding[0] == 'k')
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
n = cfdata->locals.binding;
|
|
|
|
l = eina_list_nth_list(cfdata->binding.key, atoi(++n));
|
|
|
|
|
|
|
|
/* FIXME: need confirmation dialog */
|
|
|
|
if (l)
|
|
|
|
{
|
|
|
|
bi = eina_list_data_get(l);
|
|
|
|
eina_stringshare_del(bi->key);
|
|
|
|
eina_stringshare_del(bi->action);
|
|
|
|
eina_stringshare_del(bi->params);
|
|
|
|
E_FREE(bi);
|
|
|
|
|
|
|
|
cfdata->binding.key = eina_list_remove_list(cfdata->binding.key, l);
|
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2010-06-09 09:40:55 -07:00
|
|
|
_update_key_binding_list(cfdata, NULL);
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (sel >= e_widget_ilist_count(cfdata->gui.o_binding_list))
|
|
|
|
sel = e_widget_ilist_count(cfdata->gui.o_binding_list) - 1;
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2009-03-11 08:13:42 -07:00
|
|
|
eina_stringshare_del(cfdata->locals.cur);
|
2010-12-22 16:55:58 -08:00
|
|
|
cfdata->locals.cur = NULL;
|
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (sel < 0)
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
|
|
|
e_widget_ilist_unselect(cfdata->gui.o_action_list);
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
_update_buttons(cfdata);
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2011-03-16 02:38:46 -07:00
|
|
|
else
|
|
|
|
{
|
2012-06-08 02:48:19 -07:00
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_binding_list, sel);
|
|
|
|
e_widget_ilist_nth_show(cfdata->gui.o_binding_list, sel, 0);
|
2011-03-16 02:38:46 -07:00
|
|
|
}
|
2006-03-04 16:30:28 -08:00
|
|
|
}
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2006-05-06 02:35:05 -07:00
|
|
|
static void
|
2012-06-08 02:48:19 -07:00
|
|
|
_restore_key_binding_defaults_cb(void *data,
|
2010-12-22 16:55:58 -08:00
|
|
|
void *data2 __UNUSED__)
|
2006-03-04 16:30:28 -08:00
|
|
|
{
|
2013-02-01 04:27:07 -08:00
|
|
|
E_Config_Bindings *ecb;
|
|
|
|
Eina_Stringshare *prof;
|
|
|
|
E_Config_Dialog_Data *cfdata = data;
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2013-02-01 04:27:07 -08:00
|
|
|
ecb = e_config_domain_system_load("e_bindings", e_config_descriptor_find("E_Config_Bindings"));
|
|
|
|
if (!ecb)
|
2006-10-11 01:46:52 -07:00
|
|
|
{
|
2014-01-27 08:25:24 -08:00
|
|
|
const char *type;
|
|
|
|
|
2013-02-01 04:27:07 -08:00
|
|
|
prof = eina_stringshare_ref(e_config_profile_get());
|
2014-01-27 08:25:24 -08:00
|
|
|
switch (e_config->config_type)
|
|
|
|
{
|
|
|
|
case E_CONFIG_PROFILE_TYPE_DESKTOP:
|
|
|
|
type = "standard";
|
|
|
|
break;
|
|
|
|
case E_CONFIG_PROFILE_TYPE_MOBILE:
|
|
|
|
type = "mobile";
|
|
|
|
break;
|
|
|
|
//case E_CONFIG_PROFILE_TYPE_TABLET: FIXME - not used
|
|
|
|
default:
|
|
|
|
type = "default";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
e_config_profile_set(type);
|
2013-02-01 04:27:07 -08:00
|
|
|
ecb = e_config_domain_system_load("e_bindings", e_config_descriptor_find("E_Config_Bindings"));
|
|
|
|
e_config_profile_set(prof);
|
|
|
|
eina_stringshare_del(prof);
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2013-02-01 04:27:07 -08:00
|
|
|
if (!ecb) return;
|
|
|
|
E_FREE_LIST(cfdata->binding.key, e_config_binding_key_free);
|
|
|
|
cfdata->binding.key = ecb->key_bindings, ecb->key_bindings = NULL;
|
|
|
|
e_config_bindings_free(ecb);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2009-03-11 08:13:42 -07:00
|
|
|
eina_stringshare_del(cfdata->locals.cur);
|
2006-10-11 01:46:52 -07:00
|
|
|
cfdata->locals.cur = NULL;
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2010-06-09 09:40:55 -07:00
|
|
|
_update_key_binding_list(cfdata, NULL);
|
2006-10-11 01:46:52 -07:00
|
|
|
_update_buttons(cfdata);
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
e_widget_ilist_unselect(cfdata->gui.o_action_list);
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
2006-03-04 16:30:28 -08:00
|
|
|
}
|
2007-10-28 12:07:25 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
/**************** Updates ***********/
|
2006-02-09 15:24:06 -08:00
|
|
|
static void
|
2006-10-11 01:46:52 -07:00
|
|
|
_update_action_list(E_Config_Dialog_Data *cfdata)
|
2006-03-04 16:30:28 -08:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Binding_Key *bi;
|
2011-03-16 02:38:46 -07:00
|
|
|
int j = -1, i, n, cnt;
|
2006-10-23 13:43:11 -07:00
|
|
|
const char *action, *params;
|
2006-10-11 01:46:52 -07:00
|
|
|
|
|
|
|
if (!cfdata->locals.cur) return;
|
|
|
|
|
|
|
|
if (cfdata->locals.cur[0] == 'k')
|
2006-10-23 13:43:11 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
sscanf(cfdata->locals.cur, "k%d", &n);
|
|
|
|
bi = eina_list_nth(cfdata->binding.key, n);
|
|
|
|
if (!bi)
|
|
|
|
{
|
|
|
|
e_widget_ilist_unselect(cfdata->gui.o_action_list);
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
action = bi->action;
|
|
|
|
params = bi->params;
|
2006-10-23 13:43:11 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
_find_key_binding_action(action, params, NULL, NULL, &j);
|
|
|
|
|
|
|
|
if (j >= 0)
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
2012-06-08 02:48:19 -07:00
|
|
|
cnt = e_widget_ilist_count(cfdata->gui.o_action_list);
|
2011-03-16 02:38:46 -07:00
|
|
|
for (i = 0; i < cnt; i++)
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
|
|
|
if (i > j) break;
|
|
|
|
if (e_widget_ilist_nth_is_header(cfdata->gui.o_action_list, i)) j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j >= 0)
|
|
|
|
{
|
|
|
|
if (j == e_widget_ilist_selected_get(cfdata->gui.o_action_list))
|
|
|
|
_update_action_params(cfdata);
|
|
|
|
else
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_action_list, j);
|
2006-10-23 13:43:11 -07:00
|
|
|
}
|
|
|
|
else
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
|
|
|
e_widget_ilist_unselect(cfdata->gui.o_action_list);
|
|
|
|
eina_stringshare_del(cfdata->locals.action);
|
|
|
|
cfdata->locals.action = eina_stringshare_add("");
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
2006-10-23 13:43:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*if (cfdata->locals.cur[0] == 'k')
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
|
|
|
sscanf(cfdata->locals.cur, "k%d", &n);
|
|
|
|
bi = eina_list_nth(cfdata->binding.key, n);
|
|
|
|
if (!bi)
|
|
|
|
{
|
|
|
|
e_widget_ilist_unselect(cfdata->gui.o_action_list);
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_find_key_binding_action(bi, NULL, NULL, &j);
|
|
|
|
if (j >= 0)
|
|
|
|
{
|
|
|
|
for (i = 0; i < e_widget_ilist_count(cfdata->gui.o_action_list); i++)
|
|
|
|
{
|
|
|
|
if (i > j) break;
|
|
|
|
if (e_widget_ilist_nth_is_header(cfdata->gui.o_action_list, i)) j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j >= 0)
|
|
|
|
{
|
|
|
|
if (j == e_widget_ilist_selected_get(cfdata->gui.o_action_list))
|
|
|
|
_update_action_params(cfdata);
|
|
|
|
else
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_action_list, j);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
e_widget_ilist_unselect(cfdata->gui.o_action_list);
|
2012-12-21 13:31:13 -08:00
|
|
|
free(cfdata->locals.action);
|
2010-12-22 16:55:58 -08:00
|
|
|
cfdata->locals.action = strdup("");
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
}
|
|
|
|
}*/
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2007-10-28 12:07:25 -07:00
|
|
|
|
2006-03-04 16:30:28 -08:00
|
|
|
static void
|
2006-10-11 01:46:52 -07:00
|
|
|
_update_action_params(E_Config_Dialog_Data *cfdata)
|
2006-02-09 15:24:06 -08:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
int g, a, b;
|
|
|
|
E_Action_Group *actg;
|
|
|
|
E_Action_Description *actd;
|
|
|
|
E_Config_Binding_Key *bi;
|
2012-06-27 00:11:01 -07:00
|
|
|
const char *action, *params;
|
2006-10-23 13:43:11 -07:00
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
#define KB_EXAMPLE_PARAMS \
|
|
|
|
if ((!actd->param_example) || (!actd->param_example[0])) \
|
|
|
|
e_widget_entry_text_set(cfdata->gui.o_params, TEXT_NO_PARAMS); \
|
|
|
|
else \
|
|
|
|
e_widget_entry_text_set(cfdata->gui.o_params, actd->param_example)
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if ((!cfdata->locals.action) || (!cfdata->locals.action[0]))
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
return;
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
|
|
|
sscanf(cfdata->locals.action, "%d %d", &g, &a);
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
actg = eina_list_nth(e_action_groups_get(), g);
|
2006-10-11 01:46:52 -07:00
|
|
|
if (!actg) return;
|
2008-10-22 04:49:33 -07:00
|
|
|
actd = eina_list_nth(actg->acts, a);
|
2006-10-11 01:46:52 -07:00
|
|
|
if (!actd) return;
|
|
|
|
|
|
|
|
if (actd->act_params)
|
2006-05-06 02:35:05 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
e_widget_entry_text_set(cfdata->gui.o_params, actd->act_params);
|
|
|
|
return;
|
2006-05-06 02:35:05 -07:00
|
|
|
}
|
2010-12-22 16:55:58 -08:00
|
|
|
|
|
|
|
if ((!cfdata->locals.cur) || (!cfdata->locals.cur[0]))
|
|
|
|
{
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
KB_EXAMPLE_PARAMS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-11 05:14:45 -07:00
|
|
|
if (!actd->editable)
|
2006-10-11 01:46:52 -07:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
else
|
2010-12-22 16:55:58 -08:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 0);
|
2006-10-23 13:43:11 -07:00
|
|
|
|
|
|
|
if (cfdata->locals.cur[0] == 'k')
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
sscanf(cfdata->locals.cur, "k%d", &b);
|
|
|
|
bi = eina_list_nth(cfdata->binding.key, b);
|
|
|
|
if (!bi)
|
|
|
|
{
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
KB_EXAMPLE_PARAMS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
action = bi->action;
|
2012-06-27 00:11:01 -07:00
|
|
|
params = bi->params;
|
2006-10-23 13:43:11 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
KB_EXAMPLE_PARAMS;
|
|
|
|
return;
|
2006-10-23 13:43:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action)
|
|
|
|
{
|
2012-09-18 04:30:26 -07:00
|
|
|
if (!e_util_strcmp(action, actd->act_cmd))
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
2012-06-27 00:11:01 -07:00
|
|
|
if ((cfdata->locals.cur_act >= 0) && (cfdata->locals.cur_act != e_widget_ilist_selected_get(cfdata->gui.o_action_list)))
|
2010-12-22 16:55:58 -08:00
|
|
|
KB_EXAMPLE_PARAMS;
|
|
|
|
else
|
2012-06-27 00:11:01 -07:00
|
|
|
e_widget_entry_text_set(cfdata->gui.o_params, params);
|
2010-12-22 16:55:58 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
KB_EXAMPLE_PARAMS;
|
2006-10-23 13:43:11 -07:00
|
|
|
}
|
|
|
|
else
|
2007-10-28 12:07:25 -07:00
|
|
|
KB_EXAMPLE_PARAMS;
|
2006-02-09 15:24:06 -08:00
|
|
|
}
|
2007-10-28 12:07:25 -07:00
|
|
|
|
2010-06-09 09:40:55 -07:00
|
|
|
static int
|
2010-12-22 16:55:58 -08:00
|
|
|
_update_key_binding_list(E_Config_Dialog_Data *cfdata,
|
|
|
|
E_Config_Binding_Key *bi_new)
|
2006-02-09 15:24:06 -08:00
|
|
|
{
|
2006-05-06 02:35:05 -07:00
|
|
|
int i;
|
2006-10-11 01:46:52 -07:00
|
|
|
char *b, b2[64];
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Binding_Key *bi;
|
2010-05-02 11:03:33 -07:00
|
|
|
int modifiers = -1;
|
2010-06-09 09:40:55 -07:00
|
|
|
int bi_pos = 0;
|
|
|
|
int ret = -1;
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2006-11-27 08:01:50 -08:00
|
|
|
evas_event_freeze(evas_object_evas_get(cfdata->gui.o_binding_list));
|
|
|
|
edje_freeze();
|
|
|
|
e_widget_ilist_freeze(cfdata->gui.o_binding_list);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
e_widget_ilist_clear(cfdata->gui.o_binding_list);
|
|
|
|
e_widget_ilist_go(cfdata->gui.o_binding_list);
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (cfdata->binding.key)
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
cfdata->binding.key = eina_list_sort(cfdata->binding.key,
|
|
|
|
eina_list_count(cfdata->binding.key), _key_binding_sort_cb);
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
for (l = cfdata->binding.key, i = 0; l; l = l->next, i++)
|
2006-05-06 02:35:05 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
bi = l->data;
|
|
|
|
if (bi == bi_new) ret = bi_pos;
|
|
|
|
if (ret < 0) bi_pos++;
|
|
|
|
|
2011-08-26 11:34:05 -07:00
|
|
|
if (modifiers != (int)bi->modifiers)
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
|
|
|
modifiers = bi->modifiers;
|
|
|
|
b = _key_binding_header_get(modifiers);
|
|
|
|
if (b)
|
|
|
|
{
|
|
|
|
if (ret < 0) bi_pos++;
|
|
|
|
e_widget_ilist_header_append(cfdata->gui.o_binding_list, NULL, b);
|
|
|
|
free(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
b = _key_binding_text_get(bi);
|
|
|
|
if (!b) continue;
|
|
|
|
|
|
|
|
snprintf(b2, sizeof(b2), "k%d", i);
|
|
|
|
e_widget_ilist_append(cfdata->gui.o_binding_list, NULL, b,
|
|
|
|
_binding_change_cb, cfdata, b2);
|
|
|
|
free(b);
|
2006-05-06 02:35:05 -07:00
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
e_widget_ilist_go(cfdata->gui.o_binding_list);
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-11-27 08:01:50 -08:00
|
|
|
e_widget_ilist_thaw(cfdata->gui.o_binding_list);
|
|
|
|
edje_thaw();
|
|
|
|
evas_event_thaw(evas_object_evas_get(cfdata->gui.o_binding_list));
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
if (eina_list_count(cfdata->binding.key))
|
2006-10-11 01:46:52 -07:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_del_all, 0);
|
|
|
|
else
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_del_all, 1);
|
2010-06-09 09:40:55 -07:00
|
|
|
|
|
|
|
return ret;
|
2006-02-09 15:24:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-11 01:46:52 -07:00
|
|
|
_update_buttons(E_Config_Dialog_Data *cfdata)
|
2006-02-09 15:24:06 -08:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
if (e_widget_ilist_count(cfdata->gui.o_binding_list))
|
2006-10-11 01:46:52 -07:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_del_all, 0);
|
|
|
|
else
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_del_all, 1);
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (!cfdata->locals.cur)
|
2006-05-06 02:35:05 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_mod, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_del, 1);
|
|
|
|
return;
|
2006-05-06 02:35:05 -07:00
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_mod, 0);
|
2010-12-22 16:55:58 -08:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_del, 0);
|
2006-02-09 15:24:06 -08:00
|
|
|
}
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
/*************** Sorting *****************************/
|
2006-05-06 02:35:05 -07:00
|
|
|
static int
|
2010-12-22 16:55:58 -08:00
|
|
|
_key_binding_sort_cb(const void *d1,
|
|
|
|
const void *d2)
|
2006-02-09 15:24:06 -08:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
int i, j;
|
2008-10-27 03:46:43 -07:00
|
|
|
const E_Config_Binding_Key *bi, *bi2;
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
bi = d1;
|
|
|
|
bi2 = d2;
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
i = 0; j = 0;
|
|
|
|
if (bi->modifiers & E_BINDING_MODIFIER_CTRL) i++;
|
|
|
|
if (bi->modifiers & E_BINDING_MODIFIER_ALT) i++;
|
|
|
|
if (bi->modifiers & E_BINDING_MODIFIER_SHIFT) i++;
|
|
|
|
if (bi->modifiers & E_BINDING_MODIFIER_WIN) i++;
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (bi2->modifiers & E_BINDING_MODIFIER_CTRL) j++;
|
|
|
|
if (bi2->modifiers & E_BINDING_MODIFIER_ALT) j++;
|
|
|
|
if (bi2->modifiers & E_BINDING_MODIFIER_SHIFT) j++;
|
|
|
|
if (bi2->modifiers & E_BINDING_MODIFIER_WIN) j++;
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (i < j) return -1;
|
2010-12-22 16:55:58 -08:00
|
|
|
else if (i > j)
|
|
|
|
return 1;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (bi->modifiers < bi2->modifiers) return -1;
|
2010-12-22 16:55:58 -08:00
|
|
|
else if (bi->modifiers > bi2->modifiers)
|
|
|
|
return 1;
|
2006-02-09 15:24:06 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
i = strlen(bi->key ? bi->key : "");
|
|
|
|
j = strlen(bi2->key ? bi2->key : "");
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (i < j) return -1;
|
2010-12-22 16:55:58 -08:00
|
|
|
else if (i > j)
|
|
|
|
return 1;
|
|
|
|
|
2010-01-15 11:36:00 -08:00
|
|
|
i = e_util_strcmp(bi->key, bi2->key);
|
2006-10-11 01:46:52 -07:00
|
|
|
if (i < 0) return -1;
|
2010-12-22 16:55:58 -08:00
|
|
|
else if (i > 0)
|
|
|
|
return 1;
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2006-03-04 16:30:28 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
/**************** grab window *******/
|
2012-08-20 01:36:43 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
static void
|
2012-08-20 01:36:43 -07:00
|
|
|
_grab_wnd_hide(void *data)
|
2006-10-11 01:46:52 -07:00
|
|
|
{
|
2012-08-20 01:36:43 -07:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
|
|
|
|
|
|
|
cfdata = e_object_data_get(data);
|
|
|
|
cfdata->locals.eg = NULL;
|
2006-03-04 16:30:28 -08:00
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2006-03-04 16:30:28 -08:00
|
|
|
static void
|
2012-08-20 01:36:43 -07:00
|
|
|
_grab_wnd_show(E_Config_Dialog_Data *cfdata)
|
2006-03-04 16:30:28 -08:00
|
|
|
{
|
2012-08-20 01:36:43 -07:00
|
|
|
if (cfdata->locals.eg) return;
|
|
|
|
cfdata->locals.eg = e_grab_dialog_show(cfdata->cfd->dia->win, EINA_FALSE, _grab_key_down_cb, NULL, NULL, cfdata);
|
|
|
|
e_object_data_set(E_OBJECT(cfdata->locals.eg), cfdata);
|
|
|
|
e_object_del_attach_func_set(E_OBJECT(cfdata->locals.eg), _grab_wnd_hide);
|
2006-03-04 16:30:28 -08:00
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool
|
2012-06-08 02:48:19 -07:00
|
|
|
_grab_key_down_cb(void *data,
|
2010-12-22 16:55:58 -08:00
|
|
|
__UNUSED__ int type,
|
2012-06-08 02:48:19 -07:00
|
|
|
void *event)
|
2006-03-04 16:30:28 -08:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
2009-03-16 09:24:43 -07:00
|
|
|
Ecore_Event_Key *ev;
|
2006-10-11 01:46:52 -07:00
|
|
|
|
|
|
|
ev = event;
|
|
|
|
cfdata = data;
|
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
if ((ev->keyname) && (ev->key) && (ev->compose))
|
2014-03-13 10:00:57 -07:00
|
|
|
printf("'%s' '%s' '%s'\n", ev->key, ev->key, ev->compose);
|
2012-08-20 01:36:43 -07:00
|
|
|
else if ((ev->keyname) && (ev->key))
|
|
|
|
printf("'%s' '%s'\n", ev->keyname, ev->key);
|
|
|
|
else
|
|
|
|
printf("unknown key!!!!\n");
|
2014-03-13 10:00:57 -07:00
|
|
|
if (!e_util_strcmp(ev->key, "Control_L") || !e_util_strcmp(ev->key, "Control_R") ||
|
|
|
|
!e_util_strcmp(ev->key, "Shift_L") || !e_util_strcmp(ev->key, "Shift_R") ||
|
|
|
|
!e_util_strcmp(ev->key, "Alt_L") || !e_util_strcmp(ev->key, "Alt_R") ||
|
|
|
|
!e_util_strcmp(ev->key, "Super_L") || !e_util_strcmp(ev->key, "Super_R"))
|
2006-04-17 05:24:33 -07:00
|
|
|
{
|
2012-08-20 01:36:43 -07:00
|
|
|
/* Do nothing */
|
2006-04-17 05:24:33 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-20 02:10:31 -07:00
|
|
|
E_Config_Binding_Key *bi = NULL;
|
2012-09-12 06:03:04 -07:00
|
|
|
const Eina_List *l = NULL;
|
2012-08-20 01:36:43 -07:00
|
|
|
unsigned int mod = E_BINDING_MODIFIER_NONE;
|
2012-08-22 09:06:52 -07:00
|
|
|
unsigned int n, found = 0;
|
2012-08-20 02:10:31 -07:00
|
|
|
|
2014-03-13 10:00:57 -07:00
|
|
|
if (!e_bindings_key_allowed(ev->key))
|
2013-06-13 04:10:52 -07:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
2012-08-20 02:16:47 -07:00
|
|
|
if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
|
|
|
|
mod |= E_BINDING_MODIFIER_SHIFT;
|
|
|
|
if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)
|
|
|
|
mod |= E_BINDING_MODIFIER_CTRL;
|
|
|
|
if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT)
|
|
|
|
mod |= E_BINDING_MODIFIER_ALT;
|
|
|
|
if (ev->modifiers & ECORE_EVENT_MODIFIER_WIN)
|
|
|
|
mod |= E_BINDING_MODIFIER_WIN;
|
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
if (cfdata->locals.add)
|
2012-08-20 02:10:31 -07:00
|
|
|
found = !!e_util_binding_match(cfdata->binding.key, ev, &n, NULL);
|
2012-08-20 01:36:43 -07:00
|
|
|
else if (cfdata->locals.cur && cfdata->locals.cur[0])
|
|
|
|
{
|
|
|
|
sscanf(cfdata->locals.cur, "k%d", &n);
|
|
|
|
bi = eina_list_nth(cfdata->binding.key, n);
|
2012-08-20 02:10:31 -07:00
|
|
|
found = !!e_util_binding_match(cfdata->binding.key, ev, &n, bi);
|
2012-08-20 01:36:43 -07:00
|
|
|
}
|
2012-06-08 02:48:19 -07:00
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
if (cfdata->locals.add)
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
2012-08-20 01:36:43 -07:00
|
|
|
bi = E_NEW(E_Config_Binding_Key, 1);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
bi->context = E_BINDING_CONTEXT_ANY;
|
|
|
|
bi->modifiers = mod;
|
2014-03-13 10:00:57 -07:00
|
|
|
bi->key = eina_stringshare_add(ev->key);
|
2012-08-20 01:36:43 -07:00
|
|
|
bi->action = NULL;
|
|
|
|
bi->params = NULL;
|
|
|
|
bi->any_mod = 0;
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
cfdata->binding.key = eina_list_append(cfdata->binding.key, bi);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
n = _update_key_binding_list(cfdata, bi);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_binding_list, n);
|
|
|
|
e_widget_ilist_nth_show(cfdata->gui.o_binding_list, n, 0);
|
|
|
|
e_widget_ilist_unselect(cfdata->gui.o_action_list);
|
|
|
|
eina_stringshare_del(cfdata->locals.action);
|
|
|
|
cfdata->locals.action = eina_stringshare_add("");
|
|
|
|
if ((cfdata->params) && (cfdata->params[0]))
|
|
|
|
{
|
|
|
|
int j, g = -1;
|
|
|
|
_find_key_binding_action("exec", NULL, &g, NULL, &j);
|
|
|
|
if (j >= 0)
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
2012-08-20 01:36:43 -07:00
|
|
|
e_widget_ilist_unselect(cfdata->gui.o_action_list);
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_action_list, (j + g + 1));
|
2010-12-22 16:55:58 -08:00
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
2012-08-20 01:36:43 -07:00
|
|
|
e_widget_entry_text_set(cfdata->gui.o_params, cfdata->params);
|
2010-12-22 16:55:58 -08:00
|
|
|
}
|
|
|
|
}
|
2012-08-20 01:36:43 -07:00
|
|
|
else
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
2012-08-20 01:36:43 -07:00
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
2010-12-22 16:55:58 -08:00
|
|
|
}
|
|
|
|
}
|
2012-08-20 01:36:43 -07:00
|
|
|
else if (cfdata->locals.cur && cfdata->locals.cur[0])
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
2012-08-20 01:36:43 -07:00
|
|
|
char *label;
|
2010-12-22 16:55:58 -08:00
|
|
|
E_Ilist_Item *it;
|
2012-08-20 02:10:31 -07:00
|
|
|
unsigned int i = 0;
|
2012-08-20 01:36:43 -07:00
|
|
|
|
|
|
|
sscanf(cfdata->locals.cur, "k%d", &n);
|
|
|
|
bi = eina_list_nth(cfdata->binding.key, n);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
bi->modifiers = mod;
|
|
|
|
if (bi->key) eina_stringshare_del(bi->key);
|
2014-03-13 10:00:57 -07:00
|
|
|
bi->key = eina_stringshare_add(ev->key);
|
2012-08-20 01:36:43 -07:00
|
|
|
printf("blub\n");
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
label = _key_binding_text_get(bi);
|
2010-12-22 16:55:58 -08:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->gui.o_binding_list), l, it)
|
|
|
|
{
|
|
|
|
if (it->header) n++;
|
2012-05-29 01:36:05 -07:00
|
|
|
if (i++ >= n) break;
|
2010-12-22 16:55:58 -08:00
|
|
|
}
|
|
|
|
|
2012-08-20 01:36:43 -07:00
|
|
|
e_widget_ilist_nth_label_set(cfdata->gui.o_binding_list, n, label);
|
|
|
|
free(label);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-20 02:10:31 -07:00
|
|
|
unsigned int i = 0;
|
2012-08-20 01:36:43 -07:00
|
|
|
E_Ilist_Item *it;
|
|
|
|
#if 0
|
|
|
|
/* this advice is rather irritating as one sees that the
|
|
|
|
key is bound to an action. if you want to set a
|
|
|
|
keybinding you dont care about whether there is
|
|
|
|
sth else set to it. */
|
|
|
|
int g, a, j;
|
|
|
|
const char *label = NULL;
|
|
|
|
E_Action_Group *actg = NULL;
|
|
|
|
E_Action_Description *actd = NULL;
|
|
|
|
|
|
|
|
if (cfdata->locals.add)
|
|
|
|
_find_key_binding_action(bi->action, bi->params, &g, &a, &j);
|
|
|
|
else
|
|
|
|
_find_key_binding_action(bi2->action, bi2->params, &g, &a, &j);
|
|
|
|
|
|
|
|
actg = eina_list_nth(e_action_groups_get(), g);
|
|
|
|
if (actg) actd = eina_list_nth(actg->acts, a);
|
|
|
|
|
|
|
|
if (actd) label = _(actd->act_name);
|
|
|
|
|
|
|
|
e_util_dialog_show(_("Binding Key Error"),
|
|
|
|
_("The binding key sequence, that you choose,"
|
|
|
|
" is already used by <br>"
|
|
|
|
"<hilight>%s</hilight> action.<br>"
|
|
|
|
"Please choose another binding key sequence."),
|
|
|
|
label ? label : _("Unknown"));
|
|
|
|
#endif
|
|
|
|
EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->gui.o_binding_list), l, it)
|
|
|
|
{
|
|
|
|
if (it->header) n++;
|
|
|
|
if (i++ >= n) break;
|
2010-12-22 16:55:58 -08:00
|
|
|
}
|
2012-08-20 01:36:43 -07:00
|
|
|
|
2013-08-15 01:46:06 -07:00
|
|
|
e_widget_ilist_nth_show(cfdata->gui.o_binding_list, n, 1);
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_binding_list, n);
|
2010-12-22 16:55:58 -08:00
|
|
|
}
|
2012-08-20 01:36:43 -07:00
|
|
|
e_object_del(E_OBJECT(cfdata->locals.eg));
|
2006-04-17 05:24:33 -07:00
|
|
|
}
|
2010-06-24 09:19:12 -07:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2006-03-04 16:30:28 -08:00
|
|
|
}
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
/********** Helper *********************************/
|
|
|
|
static void
|
|
|
|
_auto_apply_changes(E_Config_Dialog_Data *cfdata)
|
2006-05-06 02:35:05 -07:00
|
|
|
{
|
2012-12-03 02:28:19 -08:00
|
|
|
int n, g, a, ok = 0;
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Config_Binding_Key *bi;
|
|
|
|
E_Action_Group *actg;
|
|
|
|
E_Action_Description *actd;
|
|
|
|
|
|
|
|
if ((!cfdata->locals.cur) || (!cfdata->locals.cur[0]) ||
|
|
|
|
(!cfdata->locals.action) || (!cfdata->locals.action[0])) return;
|
|
|
|
|
|
|
|
sscanf(cfdata->locals.cur, "k%d", &n);
|
|
|
|
sscanf(cfdata->locals.action, "%d %d", &g, &a);
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
bi = eina_list_nth(cfdata->binding.key, n);
|
2006-10-11 01:46:52 -07:00
|
|
|
if (!bi) return;
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
actg = eina_list_nth(e_action_groups_get(), g);
|
2006-10-11 01:46:52 -07:00
|
|
|
if (!actg) return;
|
2008-10-22 04:49:33 -07:00
|
|
|
actd = eina_list_nth(actg->acts, a);
|
2006-10-11 01:46:52 -07:00
|
|
|
if (!actd) return;
|
|
|
|
|
2012-12-03 02:16:59 -08:00
|
|
|
eina_stringshare_replace(&bi->action, actd->act_cmd);
|
|
|
|
eina_stringshare_replace(&bi->params, actd->act_params);
|
2012-12-03 02:28:19 -08:00
|
|
|
if (bi->params) return;
|
|
|
|
if (cfdata->locals.params)
|
2006-10-11 01:46:52 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
ok = 1;
|
2012-12-03 02:28:19 -08:00
|
|
|
if (!e_util_strcmp(cfdata->locals.params, TEXT_NO_PARAMS))
|
2010-12-22 16:55:58 -08:00
|
|
|
ok = 0;
|
|
|
|
|
2012-12-03 05:22:24 -08:00
|
|
|
else if ((actd->param_example) && (!e_util_strcmp(cfdata->locals.params, actd->param_example)))
|
2012-12-03 02:28:19 -08:00
|
|
|
ok = 0;
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2012-12-03 02:28:19 -08:00
|
|
|
|
|
|
|
if (ok)
|
|
|
|
bi->params = eina_stringshare_add(cfdata->locals.params);
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2007-10-28 12:07:25 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
static void
|
2010-12-22 16:55:58 -08:00
|
|
|
_find_key_binding_action(const char *action,
|
|
|
|
const char *params,
|
2012-06-08 02:48:19 -07:00
|
|
|
int *g,
|
|
|
|
int *a,
|
|
|
|
int *n)
|
2006-10-11 01:46:52 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l, *l2;
|
2006-10-23 13:43:11 -07:00
|
|
|
int gg = -1, aa = -1, nn = -1, found;
|
2006-10-11 01:46:52 -07:00
|
|
|
E_Action_Group *actg;
|
|
|
|
E_Action_Description *actd;
|
|
|
|
|
|
|
|
if (g) *g = -1;
|
|
|
|
if (a) *a = -1;
|
|
|
|
if (n) *n = -1;
|
|
|
|
|
|
|
|
found = 0;
|
|
|
|
for (l = e_action_groups_get(), gg = 0, nn = 0; l; l = l->next, gg++)
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
actg = l->data;
|
|
|
|
|
|
|
|
for (l2 = actg->acts, aa = 0; l2; l2 = l2->next, aa++)
|
|
|
|
{
|
|
|
|
actd = l2->data;
|
2012-09-18 04:30:26 -07:00
|
|
|
if (!e_util_strcmp((!action ? "" : action), (!actd->act_cmd ? "" : actd->act_cmd)))
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
|
|
|
if (!params || !params[0])
|
|
|
|
{
|
|
|
|
if ((!actd->act_params) || (!actd->act_params[0]))
|
|
|
|
{
|
|
|
|
if (g) *g = gg;
|
|
|
|
if (a) *a = aa;
|
|
|
|
if (n) *n = nn;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((!actd->act_params) || (!actd->act_params[0]))
|
|
|
|
{
|
|
|
|
if (g) *g = gg;
|
|
|
|
if (a) *a = aa;
|
|
|
|
if (n) *n = nn;
|
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-18 04:30:26 -07:00
|
|
|
if (!e_util_strcmp(params, actd->act_params))
|
2010-12-22 16:55:58 -08:00
|
|
|
{
|
|
|
|
if (g) *g = gg;
|
|
|
|
if (a) *a = aa;
|
|
|
|
if (n) *n = nn;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nn++;
|
|
|
|
}
|
|
|
|
if (found) break;
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!found)
|
2006-10-23 13:43:11 -07:00
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
if (g) *g = -1;
|
|
|
|
if (a) *a = -1;
|
|
|
|
if (n) *n = -1;
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2006-05-06 02:35:05 -07:00
|
|
|
}
|
2007-10-28 12:07:25 -07:00
|
|
|
|
2010-05-02 11:03:33 -07:00
|
|
|
static char *
|
|
|
|
_key_binding_header_get(int modifiers)
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
char b[256] = "";
|
2010-05-02 11:03:33 -07:00
|
|
|
|
|
|
|
if (modifiers & E_BINDING_MODIFIER_CTRL)
|
|
|
|
strcat(b, _("CTRL"));
|
|
|
|
|
|
|
|
if (modifiers & E_BINDING_MODIFIER_ALT)
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
if (b[0]) strcat(b, " + ");
|
|
|
|
strcat(b, _("ALT"));
|
2010-05-02 11:03:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (modifiers & E_BINDING_MODIFIER_SHIFT)
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
if (b[0]) strcat(b, " + ");
|
|
|
|
strcat(b, _("SHIFT"));
|
2010-05-02 11:03:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (modifiers & E_BINDING_MODIFIER_WIN)
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
if (b[0]) strcat(b, " + ");
|
|
|
|
strcat(b, _("WIN"));
|
2010-05-02 11:03:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!b[0]) return strdup(TEXT_NO_MODIFIER_HEADER);
|
|
|
|
return strdup(b);
|
|
|
|
}
|
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
static char *
|
|
|
|
_key_binding_text_get(E_Config_Binding_Key *bi)
|
2006-05-06 02:35:05 -07:00
|
|
|
{
|
2006-10-11 01:46:52 -07:00
|
|
|
char b[256] = "";
|
|
|
|
|
|
|
|
if (!bi) return NULL;
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (bi->modifiers & E_BINDING_MODIFIER_CTRL)
|
|
|
|
strcat(b, _("CTRL"));
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (bi->modifiers & E_BINDING_MODIFIER_ALT)
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
if (b[0]) strcat(b, " + ");
|
|
|
|
strcat(b, _("ALT"));
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bi->modifiers & E_BINDING_MODIFIER_SHIFT)
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
if (b[0]) strcat(b, " + ");
|
|
|
|
strcat(b, _("SHIFT"));
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bi->modifiers & E_BINDING_MODIFIER_WIN)
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
if (b[0]) strcat(b, " + ");
|
|
|
|
strcat(b, _("WIN"));
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2010-12-22 16:55:58 -08:00
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (bi->key && bi->key[0])
|
|
|
|
{
|
2010-12-22 16:55:58 -08:00
|
|
|
char *l;
|
|
|
|
if (b[0]) strcat(b, " + ");
|
2006-10-11 01:46:52 -07:00
|
|
|
|
2010-12-22 16:55:58 -08:00
|
|
|
l = strdup(bi->key);
|
|
|
|
l[0] = (char)toupper(bi->key[0]);
|
|
|
|
strcat(b, l);
|
|
|
|
free(l);
|
2006-10-11 01:46:52 -07:00
|
|
|
}
|
2006-05-06 02:35:05 -07:00
|
|
|
|
2006-12-14 15:38:33 -08:00
|
|
|
/* see comment in e_bindings on numlock
|
2010-12-22 16:55:58 -08:00
|
|
|
if (bi->modifiers & ECORE_X_LOCK_NUM)
|
|
|
|
{
|
|
|
|
if (b[0]) strcat(b, " ");
|
|
|
|
strcat(b, _("OFF"));
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2006-10-11 01:46:52 -07:00
|
|
|
if (!b[0]) return strdup(TEXT_NONE_ACTION_KEY);
|
|
|
|
return strdup(b);
|
2006-05-06 02:35:05 -07:00
|
|
|
}
|
2010-12-22 16:55:58 -08:00
|
|
|
|