2006-08-23 05:49:11 -07:00
|
|
|
#include "e.h"
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
#define TEXT_NO_PARAMS _("<None>")
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
#define EXAMPLE_STRING "example : "
|
2006-08-23 05:49:11 -07:00
|
|
|
#define E_BINDING_CONTEXT_NUMBER 10
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
|
|
|
|
#define TEXT_PRESS_MOUSE_BINIDING_SEQUENCE _("Please hold any modifier you want<br>" \
|
|
|
|
"and press any button on your mouse,<br> or roll a" \
|
|
|
|
" wheel, to assign mouse binding." \
|
|
|
|
"<br>Press <hilight>Escape</highlight> to abort.")
|
|
|
|
|
2006-08-23 05:49:11 -07:00
|
|
|
static void *_create_data(E_Config_Dialog *cfd);
|
|
|
|
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
|
|
|
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
|
|
|
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
|
|
|
|
|
|
|
static void _fill_data(E_Config_Dialog_Data *cfdata);
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
static void _fill_actions_list(E_Config_Dialog_Data *cfdata);
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
|
|
|
|
/******************* Callbacks *************/
|
2006-08-30 21:16:43 -07:00
|
|
|
static void _binding_change_cb(void *data);
|
|
|
|
static void _action_change_cb(void *data);
|
2006-10-23 13:43:11 -07:00
|
|
|
static void _delete_mouse_binding_cb(void *data, void *data2);
|
|
|
|
static void _delete_all_mouse_binding_cb(void *data, void *data2);
|
|
|
|
static void _restore_mouse_binding_defaults_cb(void *data, void *data2);
|
2006-08-30 21:16:43 -07:00
|
|
|
static void _add_mouse_binding_cb(void *data, void *data2);
|
|
|
|
static void _modify_mouse_binding_cb(void *data, void *data2);
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
/******************* Updates *****************/
|
|
|
|
static void _update_action_list(E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _update_action_params(E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _update_mouse_binding_list(E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _update_buttons(E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _update_binding_context(E_Config_Dialog_Data *cfdata);
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
/****************** Helper *****************/
|
|
|
|
static void _find_key_binding_action(const char *action, const char *params, int *g, int *a, int *n);
|
2006-08-30 21:16:43 -07:00
|
|
|
static char *_helper_button_name_get(E_Config_Binding_Mouse *eb);
|
|
|
|
static char *_helper_wheel_name_get(E_Config_Binding_Wheel *bw);
|
|
|
|
static char *_helper_modifier_name_get(int mod);
|
2006-10-23 13:43:11 -07:00
|
|
|
static void _auto_apply_changes(E_Config_Dialog_Data *cfdata);
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
/********* Sorting ***************/
|
2006-08-30 21:16:43 -07:00
|
|
|
static int _mouse_binding_sort_cb(void *d1, void *d2);
|
|
|
|
static int _wheel_binding_sort_cb(void *d1, void *d2);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
/********* grab window **********/
|
|
|
|
static void _grab_wnd_show(E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _grab_wnd_hide(E_Config_Dialog_Data *cfdata);
|
|
|
|
static int _grab_mouse_down_cb(void *data, int type, void *event);
|
|
|
|
static int _grab_mouse_wheel_cb(void *data, int type, void *event);
|
|
|
|
static int _grab_key_down_cb(void *data, int type, void *event);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
|
|
|
struct _E_Config_Dialog_Data
|
|
|
|
{
|
|
|
|
E_Config_Dialog *cfd;
|
|
|
|
|
|
|
|
Evas *evas;
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
Evas_List *mouse;
|
|
|
|
Evas_List *wheel;
|
|
|
|
} binding;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
char *binding;
|
|
|
|
char *action;
|
|
|
|
char *params;
|
|
|
|
int context;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
char *cur;
|
|
|
|
int add; //just to distinguesh among two buttons add/modify
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
E_Dialog *dia;
|
2006-10-23 13:43:11 -07:00
|
|
|
Ecore_X_Window bind_win;
|
2006-08-30 21:16:43 -07:00
|
|
|
Evas_List *handlers;
|
|
|
|
} locals;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
2006-08-30 21:16:43 -07:00
|
|
|
Evas_Object *o_binding_list;
|
|
|
|
Evas_Object *o_action_list;
|
|
|
|
Evas_Object *o_add;
|
|
|
|
Evas_Object *o_mod;
|
|
|
|
Evas_Object *o_del;
|
2006-10-23 13:43:11 -07:00
|
|
|
Evas_Object *o_del_all;
|
2006-08-30 21:16:43 -07:00
|
|
|
Evas_Object *o_params;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
struct {
|
2006-08-23 05:49:11 -07:00
|
|
|
Evas_Object *o_any, *o_border, *o_menu, *o_winlist, *o_popup, *o_zone,
|
|
|
|
*o_container, *o_manager, *o_none;
|
|
|
|
} context;
|
|
|
|
} gui;
|
|
|
|
};
|
|
|
|
|
|
|
|
EAPI E_Config_Dialog *
|
|
|
|
e_int_config_mousebindings(E_Container *con)
|
|
|
|
{
|
2006-10-08 01:04:18 -07:00
|
|
|
E_Config_Dialog *cfd;
|
|
|
|
E_Config_Dialog_View *v;
|
|
|
|
|
|
|
|
if (e_config_dialog_find("E", "_config_mousebindings_dialog")) return NULL;
|
|
|
|
v = E_NEW(E_Config_Dialog_View, 1);
|
|
|
|
|
|
|
|
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 = 0;
|
|
|
|
|
|
|
|
cfd = e_config_dialog_new(con,
|
|
|
|
_("Mouse Binding Settings"),
|
|
|
|
"E", "_config_mousebindings_dialog",
|
|
|
|
"enlightenment/mouse_clean", 0, v, NULL);
|
|
|
|
return cfd;
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_fill_data(E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
E_Config_Binding_Mouse *eb, *eb2;
|
|
|
|
E_Config_Binding_Wheel *bw, *bw2;
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
cfdata->locals.binding = strdup("");
|
|
|
|
cfdata->locals.action = strdup("");
|
|
|
|
cfdata->locals.params = strdup("");
|
|
|
|
cfdata->locals.context = E_BINDING_CONTEXT_ANY;
|
|
|
|
cfdata->binding.mouse = NULL;
|
|
|
|
cfdata->binding.wheel = NULL;
|
2006-10-23 13:43:11 -07:00
|
|
|
cfdata->locals.bind_win = 0;
|
2006-08-30 21:16:43 -07:00
|
|
|
cfdata->locals.handlers = NULL;
|
|
|
|
cfdata->locals.dia = NULL;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
|
|
|
for (l = e_config->mouse_bindings; l; l = l->next)
|
|
|
|
{
|
|
|
|
eb = l->data;
|
|
|
|
|
|
|
|
eb2 = E_NEW(E_Config_Binding_Mouse, 1);
|
|
|
|
eb2->context = eb->context;
|
|
|
|
eb2->button = eb->button;
|
|
|
|
eb2->modifiers = eb->modifiers;
|
|
|
|
eb2->any_mod = eb->any_mod;
|
|
|
|
eb2->action = eb->action == NULL ? NULL : evas_stringshare_add(eb->action);
|
|
|
|
eb2->params = eb->params == NULL ? NULL : evas_stringshare_add(eb->params);
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
cfdata->binding.mouse = evas_list_append(cfdata->binding.mouse, eb2);
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (l = e_config->wheel_bindings; l; l = l->next)
|
|
|
|
{
|
|
|
|
bw = l->data;
|
|
|
|
|
|
|
|
bw2 = E_NEW(E_Config_Binding_Wheel, 1);
|
|
|
|
bw2->context = bw->context;
|
|
|
|
bw2->direction = bw->direction;
|
|
|
|
bw2->z = bw->z;
|
|
|
|
bw2->modifiers = bw->modifiers;
|
|
|
|
bw2->any_mod = bw->any_mod;
|
|
|
|
bw2->action = bw->action == NULL ? NULL : evas_stringshare_add(bw->action);
|
|
|
|
bw2->params = bw->params == NULL ? NULL : evas_stringshare_add(bw->params);
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
cfdata->binding.wheel = evas_list_append(cfdata->binding.wheel, bw2);
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
_create_data(E_Config_Dialog *cfd)
|
|
|
|
{
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
|
|
|
|
|
|
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
|
|
|
|
|
|
|
_fill_data(cfdata);
|
|
|
|
cfdata->cfd = cfd;
|
|
|
|
return cfdata;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
2006-08-30 21:16:43 -07:00
|
|
|
E_Config_Binding_Mouse *eb;
|
2006-08-23 05:49:11 -07:00
|
|
|
E_Config_Binding_Wheel *bw;
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
while (cfdata->binding.mouse)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-08-30 21:16:43 -07:00
|
|
|
eb = cfdata->binding.mouse->data;
|
|
|
|
if (eb->action) evas_stringshare_del(eb->action);
|
|
|
|
if (eb->params) evas_stringshare_del(eb->params);
|
|
|
|
E_FREE(eb);
|
|
|
|
cfdata->binding.mouse =
|
|
|
|
evas_list_remove_list(cfdata->binding.mouse, cfdata->binding.mouse);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (cfdata->binding.wheel)
|
|
|
|
{
|
|
|
|
bw = cfdata->binding.wheel->data;
|
|
|
|
if (bw->action) evas_stringshare_del(bw->action);
|
|
|
|
if (bw->params) evas_stringshare_del(bw->params);
|
|
|
|
E_FREE(bw);
|
|
|
|
cfdata->binding.wheel =
|
|
|
|
evas_list_remove_list(cfdata->binding.wheel, cfdata->binding.wheel);
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
if (cfdata->locals.binding) free(cfdata->locals.binding);
|
|
|
|
if (cfdata->locals.action) free(cfdata->locals.action);
|
|
|
|
if (cfdata->locals.params) free(cfdata->locals.params);
|
|
|
|
if (cfdata->locals.cur) free(cfdata->locals.cur);
|
2006-08-23 05:49:11 -07:00
|
|
|
free(cfdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
2006-08-30 21:16:43 -07:00
|
|
|
E_Config_Binding_Mouse *eb, *eb2;
|
2006-08-23 05:49:11 -07:00
|
|
|
E_Config_Binding_Wheel *bw, *bw2;
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
_auto_apply_changes(cfdata);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
|
|
|
|
|
|
|
e_border_button_bindings_ungrab_all();
|
|
|
|
while (e_config->mouse_bindings)
|
|
|
|
{
|
2006-08-30 21:16:43 -07:00
|
|
|
eb = e_config->mouse_bindings->data;
|
|
|
|
e_bindings_mouse_del(eb->context, eb->button, eb->modifiers, eb->any_mod,
|
|
|
|
eb->action, eb->params);
|
|
|
|
if (eb->action) evas_stringshare_del(eb->action);
|
|
|
|
if (eb->params) evas_stringshare_del(eb->params);
|
|
|
|
E_FREE(eb);
|
|
|
|
e_config->mouse_bindings =
|
|
|
|
evas_list_remove_list(e_config->mouse_bindings, e_config->mouse_bindings);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (l = cfdata->binding.mouse; l; l = l->next)
|
|
|
|
{
|
|
|
|
eb = l->data;
|
|
|
|
|
|
|
|
eb2 = E_NEW(E_Config_Binding_Mouse, 1);
|
|
|
|
eb2->context = eb->context;
|
|
|
|
eb2->button = eb->button;
|
|
|
|
eb2->modifiers = eb->modifiers;
|
|
|
|
eb2->any_mod = eb->any_mod;
|
|
|
|
eb2->action = eb->action == NULL ? NULL : evas_stringshare_add(eb->action);
|
|
|
|
eb2->params = eb->params == NULL ? NULL : evas_stringshare_add(eb->params);
|
|
|
|
|
|
|
|
e_config->mouse_bindings = evas_list_append(e_config->mouse_bindings, eb2);
|
|
|
|
e_bindings_mouse_add(eb2->context, eb2->button, eb2->modifiers, eb2->any_mod,
|
|
|
|
eb2->action, eb2->params);
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
while (e_config->wheel_bindings)
|
|
|
|
{
|
|
|
|
bw = e_config->wheel_bindings->data;
|
|
|
|
e_bindings_wheel_del(bw->context, bw->direction, bw->z, bw->modifiers, bw->any_mod,
|
|
|
|
bw->action, bw->params);
|
|
|
|
if (bw->action) evas_stringshare_del(bw->action);
|
|
|
|
if (bw->params) evas_stringshare_del(bw->params);
|
|
|
|
E_FREE(bw);
|
2006-08-30 21:16:43 -07:00
|
|
|
|
|
|
|
e_config->wheel_bindings =
|
|
|
|
evas_list_remove_list(e_config->wheel_bindings, e_config->wheel_bindings);
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
for (l = cfdata->binding.wheel; l; l = l->next)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-08-30 21:16:43 -07:00
|
|
|
bw = l->data;
|
|
|
|
|
|
|
|
bw2 = E_NEW(E_Config_Binding_Wheel, 1);
|
|
|
|
bw2->context = bw->context;
|
|
|
|
bw2->direction = bw->direction;
|
|
|
|
bw2->z = bw->z;
|
|
|
|
bw2->modifiers = bw->modifiers;
|
|
|
|
bw2->any_mod = bw->any_mod;
|
|
|
|
bw2->action = bw->action == NULL ? NULL : evas_stringshare_add(bw->action);
|
|
|
|
bw2->params = bw->params == NULL ? NULL : evas_stringshare_add(bw->params);
|
|
|
|
|
|
|
|
e_config->wheel_bindings = evas_list_append(e_config->wheel_bindings, bw2);
|
|
|
|
e_bindings_wheel_add(bw2->context, bw2->direction, bw2->z, bw2->modifiers,
|
|
|
|
bw2->any_mod, bw2->action, bw2->params);
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
e_border_button_bindings_grab_all();
|
|
|
|
|
|
|
|
e_config_save_queue();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
2006-08-30 21:16:43 -07:00
|
|
|
Evas_Object *o, *ol, *ol2, *ol3, *of;
|
2006-08-23 05:49:11 -07:00
|
|
|
E_Radio_Group *rg;
|
|
|
|
|
|
|
|
cfdata->evas = evas;
|
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
ol = e_widget_list_add(evas, 0, 1);
|
|
|
|
of = e_widget_framelist_add(evas, _("Mouse Bindings"), 0);
|
|
|
|
|
|
|
|
o = e_widget_ilist_add(evas, 32, 32, &(cfdata->locals.binding));
|
|
|
|
cfdata->gui.o_binding_list = o;
|
|
|
|
e_widget_min_size_set(o, 250, 280);
|
2006-08-23 05:49:11 -07:00
|
|
|
e_widget_ilist_go(o);
|
2006-08-30 21:16:43 -07:00
|
|
|
e_widget_framelist_object_append(of, o);
|
|
|
|
|
|
|
|
ol2 = e_widget_list_add(evas, 1, 1);
|
2006-10-23 13:43:11 -07:00
|
|
|
o = e_widget_button_add(evas, _("Add Mouse"), "enlightenment/e",
|
|
|
|
_add_mouse_binding_cb, cfdata, NULL);
|
2006-08-23 05:49:11 -07:00
|
|
|
cfdata->gui.o_add = o;
|
2006-08-30 21:16:43 -07:00
|
|
|
e_widget_list_object_append(ol2, o, 1, 1, 0.5);
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
o = e_widget_button_add(evas, _("Delete Mouse"), "enlightenment/e",
|
|
|
|
_delete_mouse_binding_cb, cfdata, NULL);
|
|
|
|
cfdata->gui.o_del = o;
|
|
|
|
e_widget_disabled_set(o, 1);
|
|
|
|
e_widget_list_object_append(ol2, o, 1, 1, 0.5);
|
|
|
|
e_widget_framelist_object_append(of, ol2);
|
|
|
|
|
|
|
|
ol2 = e_widget_list_add(evas, 1, 1);
|
|
|
|
o = e_widget_button_add(evas, _("Modify"), "enlightenment/e",
|
|
|
|
_modify_mouse_binding_cb, cfdata, NULL);
|
2006-08-30 21:16:43 -07:00
|
|
|
cfdata->gui.o_mod = o;
|
|
|
|
e_widget_disabled_set(o, 1);
|
|
|
|
e_widget_list_object_append(ol2, o, 1, 1, 0.5);
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
o = e_widget_button_add(evas, _("Delete All"), "enlightenment/e",
|
|
|
|
_delete_all_mouse_binding_cb, cfdata, NULL);
|
|
|
|
cfdata->gui.o_del_all = o;
|
2006-08-23 05:49:11 -07:00
|
|
|
e_widget_disabled_set(o, 1);
|
2006-08-30 21:16:43 -07:00
|
|
|
e_widget_list_object_append(ol2, o, 1, 1, 0.5);
|
|
|
|
e_widget_framelist_object_append(of, ol2);
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
o = e_widget_button_add(evas, _("Restore Mouse and Wheel Binding Defaults"), "enlightenment/e",
|
|
|
|
_restore_mouse_binding_defaults_cb, cfdata, NULL);
|
2006-08-30 21:16:43 -07:00
|
|
|
e_widget_framelist_object_append(of, o);
|
|
|
|
e_widget_list_object_append(ol, of, 1, 1, 0.5);
|
|
|
|
|
|
|
|
|
2006-08-23 05:49:11 -07:00
|
|
|
ol2 = e_widget_list_add(evas, 0, 0);
|
2006-08-30 21:16:43 -07:00
|
|
|
of = e_widget_framelist_add(evas, _("Action"), 0);
|
|
|
|
o = e_widget_ilist_add(evas, 24, 24, &(cfdata->locals.action));
|
2006-08-23 05:49:11 -07:00
|
|
|
cfdata->gui.o_action_list = o;
|
2006-10-23 13:43:11 -07:00
|
|
|
e_widget_min_size_set(o, 250, 210);
|
2006-08-30 21:16:43 -07:00
|
|
|
e_widget_ilist_go(o);
|
|
|
|
e_widget_framelist_object_append(of, o);
|
|
|
|
e_widget_list_object_append(ol2, of, 1, 1, 0.5);
|
|
|
|
|
|
|
|
of = e_widget_framelist_add(evas, _("Action Params"), 0);
|
|
|
|
o = e_widget_entry_add(evas, &(cfdata->locals.params));
|
2006-08-23 05:49:11 -07:00
|
|
|
e_widget_disabled_set(o, 1);
|
|
|
|
cfdata->gui.o_params = o;
|
2006-08-30 21:16:43 -07:00
|
|
|
e_widget_framelist_object_append(of, o);
|
|
|
|
e_widget_list_object_append(ol2, of, 1, 1, 0.5);
|
|
|
|
|
|
|
|
of = e_widget_framelist_add(evas, _("Action Context"), 1);
|
|
|
|
rg = e_widget_radio_group_new(&(cfdata->locals.context));
|
|
|
|
ol3 = e_widget_list_add(evas, 0, 0);
|
|
|
|
|
|
|
|
o = e_widget_radio_add(evas, _("Any"), E_BINDING_CONTEXT_ANY, rg);
|
|
|
|
cfdata->gui.context.o_any = o;
|
2006-08-23 05:49:11 -07:00
|
|
|
e_widget_disabled_set(o, 1);
|
2006-08-30 21:16:43 -07:00
|
|
|
e_widget_list_object_append(ol3, o, 1, 1, 0.5);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
o = e_widget_radio_add(evas, _("Border"), E_BINDING_CONTEXT_BORDER, rg);
|
|
|
|
cfdata->gui.context.o_border = o;
|
|
|
|
e_widget_disabled_set(o, 1);
|
|
|
|
e_widget_list_object_append(ol3, o, 1, 1, 0.5);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
o = e_widget_radio_add(evas, _("Menu"), E_BINDING_CONTEXT_MENU, rg);
|
|
|
|
cfdata->gui.context.o_menu = o;
|
|
|
|
e_widget_disabled_set(o, 1);
|
|
|
|
e_widget_list_object_append(ol3, o, 1, 1, 0.5);
|
|
|
|
e_widget_framelist_object_append(of, ol3);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
ol3 = e_widget_list_add(evas, 0, 0);
|
|
|
|
o = e_widget_radio_add(evas, _("Win List"), E_BINDING_CONTEXT_WINLIST, rg);
|
|
|
|
cfdata->gui.context.o_winlist = o;
|
|
|
|
e_widget_disabled_set(o, 1);
|
|
|
|
e_widget_list_object_append(ol3, o, 1, 1, 0.5);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
o = e_widget_radio_add(evas, _("Popup"), E_BINDING_CONTEXT_POPUP, rg);
|
|
|
|
cfdata->gui.context.o_popup = o;
|
|
|
|
e_widget_disabled_set(o, 1);
|
|
|
|
e_widget_list_object_append(ol3, o, 1, 1, 0.5);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
o = e_widget_radio_add(evas, _("Zone"), E_BINDING_CONTEXT_ZONE, rg);
|
|
|
|
cfdata->gui.context.o_zone = o;
|
|
|
|
e_widget_disabled_set(o, 1);
|
|
|
|
e_widget_list_object_append(ol3, o, 1, 1, 0.5);
|
|
|
|
e_widget_framelist_object_append(of, ol3);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
ol3 = e_widget_list_add(evas, 0, 0);
|
|
|
|
o = e_widget_radio_add(evas, _("Container"), E_BINDING_CONTEXT_CONTAINER, rg);
|
|
|
|
cfdata->gui.context.o_container = o;
|
|
|
|
e_widget_disabled_set(o, 1);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
e_widget_list_object_append(ol3, o, 1, 1, 0.5);
|
|
|
|
o = e_widget_radio_add(evas, _("Manager"), E_BINDING_CONTEXT_MANAGER, rg);
|
|
|
|
cfdata->gui.context.o_manager = o;
|
|
|
|
e_widget_disabled_set(o, 1);
|
|
|
|
e_widget_list_object_append(ol3, o, 1, 1, 0.5);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
o = e_widget_radio_add(evas, _("None"), E_BINDING_CONTEXT_NONE, rg);
|
|
|
|
cfdata->gui.context.o_none = o;
|
|
|
|
e_widget_disabled_set(o, 1);
|
|
|
|
e_widget_list_object_append(ol3, o, 1, 1, 0.5);
|
|
|
|
e_widget_framelist_object_append(of, ol3);
|
|
|
|
e_widget_list_object_append(ol2, of, 1, 1, 0.5);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-08-30 21:16:43 -07:00
|
|
|
e_widget_list_object_append(ol, ol2, 1, 1, 0.5);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
_update_mouse_binding_list(cfdata);
|
2006-08-30 21:16:43 -07:00
|
|
|
_fill_actions_list(cfdata);
|
|
|
|
|
|
|
|
return ol;
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-30 21:16:43 -07:00
|
|
|
_fill_actions_list(E_Config_Dialog_Data *cfdata)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-08-30 21:16:43 -07:00
|
|
|
char buf[1024];
|
2006-10-23 13:43:11 -07:00
|
|
|
Evas_List *l, *l2;
|
|
|
|
E_Action_Group *actg;
|
|
|
|
E_Action_Description *actd;
|
|
|
|
int g, a;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-11-27 08:05:37 -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);
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
e_widget_ilist_clear(cfdata->gui.o_action_list);
|
|
|
|
for (l = e_action_groups_get(), g = 0; l; l = l->next, g++)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
actg = l->data;
|
|
|
|
|
|
|
|
if (!actg->acts) continue;
|
|
|
|
|
|
|
|
e_widget_ilist_header_append(cfdata->gui.o_action_list, NULL, actg->act_grp);
|
|
|
|
|
|
|
|
for (l2 = actg->acts, a = 0; l2; l2 = l2->next, a++)
|
|
|
|
{
|
|
|
|
actd = l2->data;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%d %d", g, a);
|
|
|
|
e_widget_ilist_append(cfdata->gui.o_action_list, NULL, actd->act_name,
|
|
|
|
_action_change_cb, cfdata, buf);
|
|
|
|
}
|
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
e_widget_ilist_go(cfdata->gui.o_action_list);
|
2006-11-27 08:05:37 -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-08-23 05:49:11 -07:00
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
/******************* Callbacks *************/
|
2006-08-30 21:16:43 -07:00
|
|
|
static void
|
2006-10-23 13:43:11 -07:00
|
|
|
_add_mouse_binding_cb(void *data, void *data2)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
cfdata = data;
|
|
|
|
_auto_apply_changes(cfdata);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
cfdata->locals.add = 1;
|
|
|
|
_grab_wnd_show(cfdata);
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
_modify_mouse_binding_cb(void *data, void *data2)
|
|
|
|
{
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
cfdata = data;
|
|
|
|
_auto_apply_changes(cfdata);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
cfdata->locals.add = 0;
|
|
|
|
_grab_wnd_show(cfdata);
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
_action_change_cb(void *data)
|
|
|
|
{
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
cfdata = data;
|
|
|
|
_update_action_params(cfdata);
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
_binding_change_cb(void *data)
|
|
|
|
{
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
cfdata = data;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
_auto_apply_changes(cfdata);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (cfdata->locals.cur) free(cfdata->locals.cur);
|
|
|
|
cfdata->locals.cur = NULL;
|
|
|
|
|
|
|
|
if (cfdata->locals.binding[0])
|
|
|
|
cfdata->locals.cur = strdup(cfdata->locals.binding);
|
|
|
|
|
|
|
|
_update_buttons(cfdata);
|
|
|
|
_update_action_list(cfdata);
|
|
|
|
_update_binding_context(cfdata);
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
static void
|
|
|
|
_delete_all_mouse_binding_cb(void *data, void *data2)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-08-23 05:49:11 -07:00
|
|
|
E_Config_Binding_Mouse *eb;
|
|
|
|
E_Config_Binding_Wheel *bw;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
cfdata = data;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
//FIXME: need confirmation dialog
|
|
|
|
|
|
|
|
while (cfdata->binding.mouse)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
eb = cfdata->binding.mouse->data;
|
|
|
|
if (eb->action) evas_stringshare_del(eb->action);
|
|
|
|
if (eb->params) evas_stringshare_del(eb->params);
|
|
|
|
E_FREE(eb);
|
|
|
|
cfdata->binding.mouse =
|
|
|
|
evas_list_remove_list(cfdata->binding.mouse, cfdata->binding.mouse);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
|
|
|
|
while (cfdata->binding.wheel)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
bw = cfdata->binding.wheel->data;
|
|
|
|
if (bw->action) evas_stringshare_del(bw->action);
|
|
|
|
if (bw->params) evas_stringshare_del(bw->params);
|
|
|
|
E_FREE(bw);
|
|
|
|
cfdata->binding.wheel =
|
|
|
|
evas_list_remove_list(cfdata->binding.wheel, cfdata->binding.wheel);
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (cfdata->locals.cur) free(cfdata->locals.cur);
|
|
|
|
cfdata->locals.cur = NULL;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
_update_buttons(cfdata);
|
|
|
|
_update_binding_context(cfdata);
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
static void
|
2006-10-23 13:43:11 -07:00
|
|
|
_delete_mouse_binding_cb(void *data, void *data2)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-08-30 21:16:43 -07:00
|
|
|
Evas_List *l;
|
2006-10-23 13:43:11 -07:00
|
|
|
int sel, n;
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-08-23 05:49:11 -07:00
|
|
|
E_Config_Binding_Mouse *eb;
|
|
|
|
E_Config_Binding_Wheel *bw;
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
cfdata = data;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
sel = e_widget_ilist_selected_get(cfdata->gui.o_binding_list);
|
|
|
|
if (cfdata->locals.binding[0] == 'm')
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
sscanf(cfdata->locals.binding, "m%d", &n);
|
|
|
|
l = evas_list_nth_list(cfdata->binding.mouse, n);
|
|
|
|
if (l)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
eb = l->data;
|
|
|
|
if (eb->action) evas_stringshare_del(eb->action);
|
|
|
|
if (eb->params) evas_stringshare_del(eb->params);
|
|
|
|
E_FREE(eb);
|
|
|
|
cfdata->binding.mouse = evas_list_remove_list(cfdata->binding.mouse, l);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
else if (cfdata->locals.binding[0] == 'w')
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
sscanf(cfdata->locals.binding, "w%d", &n);
|
|
|
|
l = evas_list_nth_list(cfdata->binding.wheel, n);
|
|
|
|
if (l)
|
|
|
|
{
|
|
|
|
bw = l->data;
|
|
|
|
if (bw->action) evas_stringshare_del(bw->action);
|
|
|
|
if (bw->params) evas_stringshare_del(bw->params);
|
|
|
|
E_FREE(bw);
|
|
|
|
cfdata->binding.wheel = evas_list_remove_list(cfdata->binding.wheel, l);
|
|
|
|
}
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
else
|
|
|
|
return;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
_update_mouse_binding_list(cfdata);
|
|
|
|
if (sel >= e_widget_ilist_count(cfdata->gui.o_binding_list))
|
|
|
|
sel = e_widget_ilist_count(cfdata->gui.o_binding_list) - 1;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (cfdata->locals.cur) free(cfdata->locals.cur);
|
|
|
|
cfdata->locals.cur = NULL;
|
|
|
|
if (!e_widget_ilist_count(cfdata->gui.o_binding_list))
|
|
|
|
{
|
|
|
|
|
|
|
|
_update_binding_context(cfdata);
|
|
|
|
_update_buttons(cfdata);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (e_widget_ilist_nth_is_header(cfdata->gui.o_binding_list, sel)) sel++;
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_binding_list, sel);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
|
|
|
}
|
2006-08-23 05:49:11 -07:00
|
|
|
static void
|
2006-10-23 13:43:11 -07:00
|
|
|
_restore_mouse_binding_defaults_cb(void *data, void *data2)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
E_Config_Binding_Mouse *eb;
|
|
|
|
E_Config_Binding_Wheel *bw;
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
|
|
|
|
|
|
|
cfdata = data;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
while (cfdata->binding.mouse)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
eb = cfdata->binding.mouse->data;
|
|
|
|
if (eb->action) evas_stringshare_del(eb->action);
|
|
|
|
if (eb->params) evas_stringshare_del(eb->params);
|
|
|
|
E_FREE(eb);
|
|
|
|
cfdata->binding.mouse =
|
|
|
|
evas_list_remove_list(cfdata->binding.mouse, cfdata->binding.mouse);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
while (cfdata->binding.wheel)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
bw = cfdata->binding.wheel->data;
|
|
|
|
if (bw->action) evas_stringshare_del(bw->action);
|
|
|
|
if (bw->params) evas_stringshare_del(bw->params);
|
|
|
|
E_FREE(bw);
|
|
|
|
cfdata->binding.wheel =
|
|
|
|
evas_list_remove_list(cfdata->binding.wheel, cfdata->binding.wheel);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
#define CFG_MOUSEBIND_DFLT(_context, _button, _modifiers, _anymod, _action, _params) \
|
|
|
|
eb = E_NEW(E_Config_Binding_Mouse, 1); \
|
|
|
|
eb->context = _context; \
|
|
|
|
eb->button = _button; \
|
|
|
|
eb->modifiers = _modifiers; \
|
|
|
|
eb->any_mod = _anymod; \
|
|
|
|
eb->action = _action == NULL ? NULL : evas_stringshare_add(_action); \
|
|
|
|
eb->params = _params == NULL ? NULL : evas_stringshare_add(_params); \
|
|
|
|
cfdata->binding.mouse = evas_list_append(cfdata->binding.mouse, eb)
|
|
|
|
|
|
|
|
CFG_MOUSEBIND_DFLT(E_BINDING_CONTEXT_BORDER, 1, E_BINDING_MODIFIER_ALT, 0, "window_move", NULL);
|
|
|
|
CFG_MOUSEBIND_DFLT(E_BINDING_CONTEXT_BORDER, 2, E_BINDING_MODIFIER_ALT, 0, "window_resize", NULL);
|
|
|
|
CFG_MOUSEBIND_DFLT(E_BINDING_CONTEXT_BORDER, 3, E_BINDING_MODIFIER_ALT, 0, "window_menu", NULL);
|
|
|
|
CFG_MOUSEBIND_DFLT(E_BINDING_CONTEXT_ZONE, 1, 0, 0, "menu_show", "main");
|
|
|
|
CFG_MOUSEBIND_DFLT(E_BINDING_CONTEXT_ZONE, 2, 0, 0, "menu_show", "clients");
|
2006-11-07 14:46:24 -08:00
|
|
|
#ifdef ENABLE_FAVORITES
|
2006-10-23 13:43:11 -07:00
|
|
|
CFG_MOUSEBIND_DFLT(E_BINDING_CONTEXT_ZONE, 3, 0, 0, "menu_show", "favorites");
|
2006-11-07 14:46:24 -08:00
|
|
|
#endif
|
2006-10-23 13:43:11 -07:00
|
|
|
|
|
|
|
#define CFG_WHEELBIND_DFLT(_context, _direction, _z, _modifiers, _anymod, _action, _params) \
|
|
|
|
bw = E_NEW(E_Config_Binding_Wheel, 1); \
|
|
|
|
bw->context = _context; \
|
|
|
|
bw->direction = _direction; \
|
|
|
|
bw->z = _z; \
|
|
|
|
bw->modifiers = _modifiers; \
|
|
|
|
bw->any_mod = _anymod; \
|
|
|
|
bw->action = _action == NULL ? NULL : evas_stringshare_add(_action); \
|
|
|
|
bw->params = _params == NULL ? NULL : evas_stringshare_add(_params); \
|
|
|
|
cfdata->binding.wheel = evas_list_append(cfdata->binding.wheel, bw)
|
|
|
|
|
|
|
|
CFG_WHEELBIND_DFLT(E_BINDING_CONTEXT_CONTAINER, 0, -1, E_BINDING_MODIFIER_ALT, 0,
|
|
|
|
"desk_linear_flip_by", "-1");
|
|
|
|
CFG_WHEELBIND_DFLT(E_BINDING_CONTEXT_CONTAINER, 1, -1, E_BINDING_MODIFIER_ALT, 0,
|
|
|
|
"desk_linear_flip_by", "-1");
|
|
|
|
CFG_WHEELBIND_DFLT(E_BINDING_CONTEXT_CONTAINER, 0, 1, E_BINDING_MODIFIER_ALT, 0,
|
|
|
|
"desk_linear_flip_by", "1");
|
|
|
|
CFG_WHEELBIND_DFLT(E_BINDING_CONTEXT_CONTAINER, 1, 1, E_BINDING_MODIFIER_ALT, 0,
|
|
|
|
"desk_linear_flip_by", "1");
|
|
|
|
CFG_WHEELBIND_DFLT(E_BINDING_CONTEXT_BORDER, 0, -1, E_BINDING_MODIFIER_ALT, 0,
|
|
|
|
"desk_linear_flip_by", "-1");
|
|
|
|
CFG_WHEELBIND_DFLT(E_BINDING_CONTEXT_BORDER, 1, -1, E_BINDING_MODIFIER_ALT, 0,
|
|
|
|
"desk_linear_flip_by", "-1");
|
|
|
|
CFG_WHEELBIND_DFLT(E_BINDING_CONTEXT_BORDER, 0, 1, E_BINDING_MODIFIER_ALT, 0,
|
|
|
|
"desk_linear_flip_by", "1");
|
|
|
|
CFG_WHEELBIND_DFLT(E_BINDING_CONTEXT_BORDER, 1, 1, E_BINDING_MODIFIER_ALT, 0,
|
|
|
|
"desk_linear_flip_by", "1");
|
|
|
|
|
|
|
|
if (cfdata->locals.cur) free(cfdata->locals.cur);
|
|
|
|
cfdata->locals.cur = NULL;
|
|
|
|
|
|
|
|
_update_mouse_binding_list(cfdata);
|
|
|
|
_update_buttons(cfdata);
|
|
|
|
_update_binding_context(cfdata);
|
|
|
|
|
|
|
|
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-08-30 21:16:43 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
|
|
|
|
/******************* Updates *****************/
|
|
|
|
|
2006-08-23 05:49:11 -07:00
|
|
|
static void
|
2006-10-23 13:43:11 -07:00
|
|
|
_update_action_list(E_Config_Dialog_Data *cfdata)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
|
|
|
E_Config_Binding_Mouse *eb;
|
|
|
|
E_Config_Binding_Wheel *bw;
|
2006-10-23 13:43:11 -07:00
|
|
|
E_Action_Group *actg;
|
|
|
|
E_Action_Description *actd;
|
|
|
|
Evas_List *l, *l2;
|
|
|
|
const char *action, *params;
|
|
|
|
int j = -1, i, n;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
|
|
|
if (!cfdata->locals.cur) return;
|
|
|
|
|
|
|
|
if (cfdata->locals.cur[0] == 'm')
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
sscanf(cfdata->locals.cur, "m%d", &n);
|
|
|
|
eb = evas_list_nth(cfdata->binding.mouse, n);
|
|
|
|
if (!eb)
|
|
|
|
{
|
|
|
|
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 = eb->action;
|
|
|
|
params = eb->params;
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
else if (cfdata->locals.cur[0] == 'w')
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
sscanf(cfdata->locals.cur, "w%d", &n);
|
|
|
|
bw = evas_list_nth(cfdata->binding.wheel, n);
|
|
|
|
if (!bw)
|
|
|
|
{
|
|
|
|
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 = bw->action;
|
|
|
|
params = bw->params;
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
else
|
|
|
|
return;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
_find_key_binding_action(action, params, 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++;
|
|
|
|
}
|
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
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);
|
|
|
|
if (cfdata->locals.action) free(cfdata->locals.action);
|
|
|
|
cfdata->locals.action = strdup("");
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
}
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
static void
|
2006-10-23 13:43:11 -07:00
|
|
|
_update_mouse_binding_list(E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
|
|
|
char *icon = NULL, *button, *mods;
|
|
|
|
char label[1024], val[10];
|
|
|
|
int i;
|
|
|
|
Evas_List *l;
|
2006-08-30 21:16:43 -07:00
|
|
|
E_Config_Binding_Mouse *eb;
|
|
|
|
E_Config_Binding_Wheel *bw;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-11-27 08:05:37 -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);
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
e_widget_ilist_clear(cfdata->gui.o_binding_list);
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (cfdata->binding.mouse)
|
|
|
|
{
|
|
|
|
cfdata->binding.mouse = evas_list_sort(cfdata->binding.mouse,
|
|
|
|
evas_list_count(cfdata->binding.mouse), _mouse_binding_sort_cb);
|
|
|
|
|
|
|
|
e_widget_ilist_header_append(cfdata->gui.o_binding_list, NULL, "Mouse Buttons");
|
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
for (l = cfdata->binding.mouse, i = 0; l; l = l->next, i++)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
Evas_Object *ic;
|
|
|
|
eb = l->data;
|
|
|
|
|
|
|
|
button = _helper_button_name_get(eb);
|
|
|
|
mods = _helper_modifier_name_get(eb->modifiers);
|
|
|
|
|
|
|
|
snprintf(label, sizeof(label), "%s%s%s", button ? button : "", mods[0] ? " + ": "",
|
|
|
|
mods ? mods : "");
|
|
|
|
if (button) free(button);
|
|
|
|
if (mods) free(mods);
|
|
|
|
|
|
|
|
switch (eb->button)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
icon = "enlightenment/mouse_left";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
icon = "enlightenment/mouse_middle";
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
icon = "enlightenment/mouse_right";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
icon = "enlightenment/mouse_extra";
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(val, sizeof(val), "m%d", i);
|
|
|
|
|
|
|
|
ic = edje_object_add(cfdata->evas);
|
|
|
|
e_util_edje_icon_set(ic, icon);
|
|
|
|
e_widget_ilist_append(cfdata->gui.o_binding_list, ic, label, _binding_change_cb,
|
|
|
|
cfdata, val);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
|
|
|
|
if (cfdata->binding.wheel)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
cfdata->binding.wheel = evas_list_sort(cfdata->binding.wheel,
|
|
|
|
evas_list_count(cfdata->binding.wheel), _wheel_binding_sort_cb);
|
|
|
|
|
|
|
|
e_widget_ilist_header_append(cfdata->gui.o_binding_list, NULL, "Mouse Wheels");
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
for (l = cfdata->binding.wheel, i = 0; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
Evas_Object *ic;
|
|
|
|
bw = l->data;
|
|
|
|
|
|
|
|
button = _helper_wheel_name_get(bw);
|
|
|
|
mods = _helper_modifier_name_get(bw->modifiers);
|
|
|
|
|
|
|
|
snprintf(label, sizeof(label), "%s%s%s", button ? button : "", mods[0] ? " + ": "",
|
|
|
|
mods ? mods : "");
|
|
|
|
if (button) free(button);
|
|
|
|
if (mods) free(mods);
|
|
|
|
|
|
|
|
snprintf(val, sizeof(val), "w%d", i);
|
|
|
|
|
|
|
|
ic = edje_object_add(cfdata->evas);
|
|
|
|
e_util_edje_icon_set(ic, "enlightenment/mouse_wheel");
|
|
|
|
e_widget_ilist_append(cfdata->gui.o_binding_list, ic, label, _binding_change_cb,
|
|
|
|
cfdata, val);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
|
|
|
|
e_widget_ilist_go(cfdata->gui.o_binding_list);
|
2006-11-27 08:05:37 -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));
|
2006-10-23 13:43:11 -07:00
|
|
|
|
|
|
|
if (evas_list_count(cfdata->binding.mouse) + evas_list_count(cfdata->binding.wheel))
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_del_all, 0);
|
2006-08-30 21:16:43 -07:00
|
|
|
else
|
2006-10-23 13:43:11 -07:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_del_all, 1);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-08-23 05:49:11 -07:00
|
|
|
static void
|
2006-10-23 13:43:11 -07:00
|
|
|
_update_action_params(E_Config_Dialog_Data *cfdata)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
int g, a, b;
|
|
|
|
E_Action_Group *actg;
|
|
|
|
E_Action_Description *actd;
|
2006-08-30 21:16:43 -07:00
|
|
|
E_Config_Binding_Mouse *eb;
|
|
|
|
E_Config_Binding_Wheel *bw;
|
2006-10-23 13:43:11 -07:00
|
|
|
const char *action, *params;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
#define MB_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-08-30 21:16:43 -07:00
|
|
|
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if ((!cfdata->locals.action) || (!cfdata->locals.action[0]))
|
|
|
|
{
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
}
|
|
|
|
sscanf(cfdata->locals.action, "%d %d", &g, &a);
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
actg = evas_list_nth(e_action_groups_get(), g);
|
|
|
|
if (!actg) return;
|
|
|
|
actd = evas_list_nth(actg->acts, a);
|
|
|
|
if (!actd) return;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (actd->act_params)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
e_widget_entry_text_set(cfdata->gui.o_params, actd->act_params);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((!cfdata->locals.cur) || (!cfdata->locals.cur[0]))
|
|
|
|
{
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
MB_EXAMPLE_PARAMS;
|
|
|
|
return;
|
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (!actd->editable)
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
else
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 0);
|
|
|
|
|
|
|
|
if (cfdata->locals.cur[0] == 'm')
|
|
|
|
{
|
|
|
|
sscanf(cfdata->locals.cur, "m%d", &b);
|
|
|
|
eb = evas_list_nth(cfdata->binding.mouse, b);
|
|
|
|
if (!eb)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
MB_EXAMPLE_PARAMS;
|
|
|
|
return;
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
action = eb->action;
|
|
|
|
params = eb->params;
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
else if (cfdata->locals.cur[0] = 'w')
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
sscanf(cfdata->locals.cur, "w%d", &b);
|
|
|
|
bw = evas_list_nth(cfdata->binding.wheel, b);
|
|
|
|
if (!bw)
|
|
|
|
{
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
MB_EXAMPLE_PARAMS;
|
2006-08-30 21:16:43 -07:00
|
|
|
return;
|
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
action = bw->action;
|
|
|
|
params = bw->params;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
MB_EXAMPLE_PARAMS;
|
|
|
|
return;
|
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (action)
|
|
|
|
{
|
|
|
|
if (!strcmp(action, actd->act_cmd))
|
|
|
|
{
|
|
|
|
if ((!params) || (!params[0]))
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
MB_EXAMPLE_PARAMS;
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
|
|
|
else
|
2006-10-23 13:43:11 -07:00
|
|
|
e_widget_entry_text_set(cfdata->gui.o_params, params);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
|
|
|
else
|
2006-10-23 13:43:11 -07:00
|
|
|
{
|
|
|
|
MB_EXAMPLE_PARAMS;
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
MB_EXAMPLE_PARAMS;
|
|
|
|
}
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-23 13:43:11 -07:00
|
|
|
_update_buttons(E_Config_Dialog_Data *cfdata)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
if (e_widget_ilist_count(cfdata->gui.o_binding_list))
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_del_all, 0);
|
|
|
|
else
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_del_all, 1);
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (!cfdata->locals.cur)
|
|
|
|
{
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_mod, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_del, 1);
|
|
|
|
return;
|
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
e_widget_disabled_set(cfdata->gui.o_mod, 0);
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_del, 0);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
|
|
|
static void
|
2006-10-23 13:43:11 -07:00
|
|
|
_update_binding_context(E_Config_Dialog_Data *cfdata)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
int n;
|
2006-08-30 21:16:43 -07:00
|
|
|
E_Config_Binding_Mouse *eb;
|
|
|
|
E_Config_Binding_Wheel *bw;
|
2006-10-23 13:43:11 -07:00
|
|
|
E_Binding_Context ctxt;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
// disable all the radios.
|
|
|
|
e_widget_radio_toggle_set(cfdata->gui.context.o_any, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_any, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_border, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_menu, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_winlist, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_popup, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_zone, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_container, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_manager, 1);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_none, 1);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (!cfdata->locals.cur) return;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (cfdata->locals.cur[0] == 'm')
|
|
|
|
{
|
|
|
|
sscanf(cfdata->locals.cur, "m%d", &n);
|
|
|
|
eb = evas_list_nth(cfdata->binding.mouse, n);
|
|
|
|
if (!eb) return;
|
|
|
|
ctxt = eb->context;
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
else if (cfdata->locals.cur[0] == 'w')
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
sscanf(cfdata->locals.cur, "w%d", &n);
|
|
|
|
bw = evas_list_nth(cfdata->binding.wheel, n);
|
|
|
|
if (!bw) return;
|
|
|
|
ctxt = bw->context;
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
else
|
|
|
|
return;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_any, 0);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_border, 0);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_menu, 0);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_winlist, 0);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_popup, 0);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_zone, 0);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_container, 0);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_manager, 0);
|
|
|
|
e_widget_disabled_set(cfdata->gui.context.o_none, 0);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (ctxt == E_BINDING_CONTEXT_ANY)
|
|
|
|
e_widget_radio_toggle_set(cfdata->gui.context.o_any, 1);
|
|
|
|
else if (ctxt == E_BINDING_CONTEXT_BORDER)
|
|
|
|
e_widget_radio_toggle_set(cfdata->gui.context.o_border, 1);
|
|
|
|
else if (ctxt == E_BINDING_CONTEXT_MENU)
|
|
|
|
e_widget_radio_toggle_set(cfdata->gui.context.o_menu, 1);
|
|
|
|
else if (ctxt == E_BINDING_CONTEXT_WINLIST)
|
|
|
|
e_widget_radio_toggle_set(cfdata->gui.context.o_winlist, 1);
|
|
|
|
else if (ctxt == E_BINDING_CONTEXT_POPUP)
|
|
|
|
e_widget_radio_toggle_set(cfdata->gui.context.o_popup, 1);
|
|
|
|
else if (ctxt == E_BINDING_CONTEXT_ZONE)
|
|
|
|
e_widget_radio_toggle_set(cfdata->gui.context.o_zone, 1);
|
|
|
|
else if (ctxt == E_BINDING_CONTEXT_CONTAINER)
|
|
|
|
e_widget_radio_toggle_set(cfdata->gui.context.o_container, 1);
|
|
|
|
else if (ctxt == E_BINDING_CONTEXT_MANAGER)
|
|
|
|
e_widget_radio_toggle_set(cfdata->gui.context.o_manager, 1);
|
|
|
|
else if (ctxt == E_BINDING_CONTEXT_NONE)
|
|
|
|
e_widget_radio_toggle_set(cfdata->gui.context.o_none, 1);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
/****************** Helper *****************/
|
2006-08-23 05:49:11 -07:00
|
|
|
static void
|
2006-10-23 13:43:11 -07:00
|
|
|
_auto_apply_changes(E_Config_Dialog_Data *cfdata)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
int n, g, a;
|
2006-08-30 21:16:43 -07:00
|
|
|
E_Config_Binding_Mouse *eb;
|
|
|
|
E_Config_Binding_Wheel *bw;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
E_Action_Group *actg;
|
|
|
|
E_Action_Description *actd;
|
|
|
|
const char **action, **params;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if ((!cfdata->locals.cur) || (!cfdata->locals.cur[0])) return;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (cfdata->locals.cur[0] == 'm')
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
sscanf(cfdata->locals.cur, "m%d", &n);
|
|
|
|
eb = evas_list_nth(cfdata->binding.mouse, n);
|
|
|
|
if (!eb) return;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
eb->context = cfdata->locals.context;
|
|
|
|
action = &(eb->action);
|
|
|
|
params = &(eb->params);
|
|
|
|
}
|
|
|
|
else if (cfdata->locals.cur[0] == 'w')
|
|
|
|
{
|
|
|
|
sscanf(cfdata->locals.cur, "w%d", &n);
|
|
|
|
bw = evas_list_nth(cfdata->binding.wheel, n);
|
|
|
|
if (!bw) return;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
bw->context = cfdata->locals.context;
|
|
|
|
action = &(bw->action);
|
|
|
|
params = &(bw->params);
|
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (*action) evas_stringshare_del(*action);
|
|
|
|
if (*params) evas_stringshare_del(*params);
|
|
|
|
*action = NULL;
|
|
|
|
*params = NULL;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if ((!cfdata->locals.action) || (!cfdata->locals.action[0])) return;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
sscanf(cfdata->locals.action, "%d %d", &g, &a);
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
actg = evas_list_nth(e_action_groups_get(), g);
|
|
|
|
if (!actg) return;
|
|
|
|
actd = evas_list_nth(actg->acts, a);
|
|
|
|
if (!actd) return;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (actd->act_cmd) *action = evas_stringshare_add(actd->act_cmd);
|
|
|
|
if (actd->act_params)
|
|
|
|
*params = evas_stringshare_add(actd->act_params);
|
2006-08-30 21:16:43 -07:00
|
|
|
else
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
int ok = 1;
|
|
|
|
if (cfdata->locals.params)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
if (!strcmp(cfdata->locals.params, TEXT_NO_PARAMS)) ok = 0;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if ((actd->param_example) && (!strcmp(cfdata->locals.params, actd->param_example)))
|
|
|
|
ok = 0;
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
else
|
|
|
|
ok = 0;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (ok)
|
|
|
|
*params = evas_stringshare_add(cfdata->locals.params);
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
static void
|
|
|
|
_find_key_binding_action(const char *action, const char *params, int *g, int *a, int *n)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
Evas_List *l, *l2;
|
|
|
|
int gg = -1, aa = -1, nn = -1, found;
|
|
|
|
E_Action_Group *actg;
|
|
|
|
E_Action_Description *actd;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (g) *g = -1;
|
|
|
|
if (a) *a = -1;
|
|
|
|
if (n) *n = -1;
|
2006-08-30 21:16:43 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
found = 0;
|
|
|
|
for (l = e_action_groups_get(), gg = 0, nn = 0; l; l = l->next, gg++)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
actg = l->data;
|
2006-08-23 05:49:11 -07:00
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
for (l2 = actg->acts, aa = 0; l2; l2 = l2->next, aa++)
|
|
|
|
{
|
|
|
|
actd = l2->data;
|
|
|
|
|
|
|
|
if (!strcmp((!action ? "" : action), (!actd->act_cmd ? "" : actd->act_cmd)))
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
if (!strcmp(params, actd->act_params))
|
|
|
|
{
|
|
|
|
if (g) *g = gg;
|
|
|
|
if (a) *a = aa;
|
|
|
|
if (n) *n = nn;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nn++;
|
|
|
|
}
|
|
|
|
if (found) break;
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
|
|
|
|
2006-10-23 13:43:11 -07:00
|
|
|
if (!found)
|
2006-08-30 21:16:43 -07:00
|
|
|
{
|
2006-10-23 13:43:11 -07:00
|
|
|
if (g) *g = -1;
|
|
|
|
if (a) *a = -1;
|
|
|
|
if (n) *n = -1;
|
2006-08-30 21:16:43 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
static char *
|
|
|
|
_helper_button_name_get(E_Config_Binding_Mouse *eb)
|
|
|
|
{
|
|
|
|
char *name = NULL;
|
|
|
|
char buf[1024]="";
|
|
|
|
|
|
|
|
switch (eb->button)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
name = strdup("Left Button");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
name = strdup("Middle Button");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
name = strdup("Right Button");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snprintf(buf, sizeof(buf), "Extra Button (%d)", eb->button);
|
|
|
|
name = strdup(buf);
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
static char *
|
|
|
|
_helper_wheel_name_get(E_Config_Binding_Wheel *bw)
|
|
|
|
{
|
|
|
|
char *name = NULL;
|
|
|
|
char buf[1024] = "";
|
|
|
|
|
|
|
|
switch (bw->direction)
|
2006-08-23 05:49:11 -07:00
|
|
|
{
|
2006-08-30 21:16:43 -07:00
|
|
|
case 0:
|
|
|
|
if (bw->z >= 0)
|
|
|
|
name = strdup("Mouse Wheel Up");
|
|
|
|
else
|
|
|
|
name = strdup("Mouse Wheel Down");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (bw->z >= 0)
|
|
|
|
snprintf(buf, sizeof(buf), "Extra Wheel (%d) Up", bw->direction);
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "Extra Wheel (%d) Down", bw->direction);
|
|
|
|
name = strdup(buf);
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
return name;
|
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
|
|
|
|
static char *
|
|
|
|
_helper_modifier_name_get(int mod)
|
|
|
|
{
|
|
|
|
char mods[1024]="";
|
|
|
|
|
|
|
|
if (mod & E_BINDING_MODIFIER_SHIFT)
|
|
|
|
snprintf(mods, sizeof(mods), "SHIFT");
|
|
|
|
|
|
|
|
if (mod & E_BINDING_MODIFIER_CTRL)
|
|
|
|
{
|
|
|
|
if (mods[0]) strcat(mods, " + ");
|
|
|
|
strcat(mods, "CTRL");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mod & E_BINDING_MODIFIER_ALT)
|
|
|
|
{
|
|
|
|
if (mods[0]) strcat(mods, " + ");
|
|
|
|
strcat(mods, "ALT");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mod & E_BINDING_MODIFIER_WIN)
|
|
|
|
{
|
|
|
|
if (mods[0]) strcat(mods, " + ");
|
|
|
|
strcat(mods, "WIN");
|
|
|
|
}
|
|
|
|
|
|
|
|
return strdup(mods);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********* Sorting ***************/
|
2006-08-30 21:16:43 -07:00
|
|
|
static int
|
|
|
|
_mouse_binding_sort_cb(void *d1, void *d2)
|
|
|
|
{
|
|
|
|
E_Config_Binding_Mouse *eb, *eb2;
|
|
|
|
|
|
|
|
eb = d1;
|
|
|
|
eb2 = d2;
|
|
|
|
|
|
|
|
if (eb->button < eb2->button) return -1;
|
|
|
|
else if (eb->button > eb2->button) return 1;
|
2006-08-23 05:49:11 -07:00
|
|
|
else
|
|
|
|
{
|
2006-08-30 21:16:43 -07:00
|
|
|
if (eb->modifiers < eb2->modifiers) return -1;
|
|
|
|
else if (eb->modifiers > eb2->modifiers) return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static int
|
|
|
|
_wheel_binding_sort_cb(void *d1, void *d2)
|
|
|
|
{
|
|
|
|
E_Config_Binding_Wheel *bw, *bw2;
|
|
|
|
|
|
|
|
bw = d1;
|
|
|
|
bw2 = d2;
|
|
|
|
|
|
|
|
if (bw->direction < bw2->direction)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (bw->direction > bw2->direction)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((bw->z < 0) && (bw2->z > 0))
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if ((bw->z > 0) && (bw2->z < 0))
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (((bw->z < 0) && (bw2->z < 0)) ||
|
|
|
|
((bw->z > 0) && (bw2->z > 0)))
|
|
|
|
{
|
|
|
|
if (bw->modifiers < bw2->modifiers)
|
|
|
|
return -1;
|
|
|
|
else if (bw->modifiers > bw2->modifiers)
|
|
|
|
return 1;
|
|
|
|
}
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-08-30 21:16:43 -07:00
|
|
|
return 0;
|
2006-08-23 05:49:11 -07:00
|
|
|
}
|
2006-10-23 13:43:11 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_grab_wnd_show(E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
|
|
|
E_Manager *man;
|
|
|
|
|
|
|
|
if (cfdata->locals.bind_win != 0) return;
|
|
|
|
|
|
|
|
man = e_manager_current_get();
|
|
|
|
|
|
|
|
cfdata->locals.dia = e_dialog_new(e_container_current_get(man),
|
|
|
|
"E", "_mousebind_getmouse_dialog");
|
|
|
|
if (!cfdata->locals.dia) return;
|
|
|
|
e_dialog_title_set(cfdata->locals.dia, _("Mouse Binding Sequence"));
|
|
|
|
e_dialog_icon_set(cfdata->locals.dia, "enlightenment/mouse_clean", 48);
|
|
|
|
e_dialog_text_set(cfdata->locals.dia, TEXT_PRESS_MOUSE_BINIDING_SEQUENCE);
|
|
|
|
e_win_centered_set(cfdata->locals.dia->win, 1);
|
|
|
|
e_win_borderless_set(cfdata->locals.dia->win, 1);
|
|
|
|
|
|
|
|
cfdata->locals.bind_win = ecore_x_window_input_new(man->root, 0, 0, 1, 1);
|
|
|
|
ecore_x_window_show(cfdata->locals.bind_win);
|
|
|
|
e_grabinput_get(cfdata->locals.bind_win, 0, cfdata->locals.bind_win);
|
|
|
|
|
|
|
|
cfdata->locals.handlers = evas_list_append(cfdata->locals.handlers,
|
|
|
|
ecore_event_handler_add(ECORE_X_EVENT_KEY_DOWN,
|
|
|
|
_grab_key_down_cb, cfdata));
|
|
|
|
|
|
|
|
cfdata->locals.handlers = evas_list_append(cfdata->locals.handlers,
|
|
|
|
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_BUTTON_DOWN,
|
|
|
|
_grab_mouse_down_cb, cfdata));
|
|
|
|
|
|
|
|
cfdata->locals.handlers = evas_list_append(cfdata->locals.handlers,
|
|
|
|
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_WHEEL,
|
|
|
|
_grab_mouse_wheel_cb, cfdata));
|
|
|
|
|
|
|
|
e_dialog_show(cfdata->locals.dia);
|
|
|
|
ecore_x_icccm_transient_for_set(cfdata->locals.dia->win->evas_win, cfdata->cfd->dia->win->evas_win);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_grab_wnd_hide(E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
|
|
|
while (cfdata->locals.handlers)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(cfdata->locals.handlers->data);
|
|
|
|
cfdata->locals.handlers =
|
|
|
|
evas_list_remove_list(cfdata->locals.handlers, cfdata->locals.handlers);
|
|
|
|
}
|
|
|
|
cfdata->locals.handlers = NULL;
|
|
|
|
e_grabinput_release(cfdata->locals.bind_win, cfdata->locals.bind_win);
|
|
|
|
ecore_x_window_del(cfdata->locals.bind_win);
|
|
|
|
cfdata->locals.bind_win = 0;
|
|
|
|
|
|
|
|
e_object_del(E_OBJECT(cfdata->locals.dia));
|
|
|
|
cfdata->locals.dia = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_grab_mouse_down_cb(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
|
|
|
E_Config_Binding_Mouse *eb;
|
|
|
|
E_Config_Binding_Wheel *bw;
|
|
|
|
int mod = E_BINDING_MODIFIER_NONE, n;
|
|
|
|
|
|
|
|
Ecore_X_Event_Mouse_Button_Down *ev;
|
|
|
|
|
|
|
|
ev = event;
|
|
|
|
cfdata = data;
|
|
|
|
|
|
|
|
if (ev->win != cfdata->locals.bind_win) return 1;
|
|
|
|
|
|
|
|
if (ev->modifiers & ECORE_X_MODIFIER_SHIFT)
|
|
|
|
mod |= E_BINDING_MODIFIER_SHIFT;
|
|
|
|
if (ev->modifiers & ECORE_X_MODIFIER_CTRL)
|
|
|
|
mod |= E_BINDING_MODIFIER_CTRL;
|
|
|
|
if (ev->modifiers & ECORE_X_MODIFIER_ALT)
|
|
|
|
mod |= E_BINDING_MODIFIER_ALT;
|
|
|
|
if (ev->modifiers & ECORE_X_MODIFIER_WIN)
|
|
|
|
mod |= E_BINDING_MODIFIER_WIN;
|
|
|
|
|
|
|
|
|
|
|
|
if (cfdata->locals.add)
|
|
|
|
{
|
|
|
|
eb = E_NEW(E_Config_Binding_Mouse, 1);
|
|
|
|
eb->context = E_BINDING_CONTEXT_ANY;
|
|
|
|
eb->button = ev->button;
|
|
|
|
eb->modifiers = mod;
|
|
|
|
eb->any_mod = 0;
|
|
|
|
eb->action = NULL;
|
|
|
|
eb->params = NULL;
|
|
|
|
|
|
|
|
cfdata->binding.mouse = evas_list_append(cfdata->binding.mouse, eb);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (cfdata->locals.cur[0] == 'm')
|
|
|
|
{
|
|
|
|
sscanf(cfdata->locals.cur, "m%d", &n);
|
|
|
|
eb = evas_list_nth(cfdata->binding.mouse, n);
|
|
|
|
if (eb)
|
|
|
|
{
|
|
|
|
eb->button = ev->button;
|
|
|
|
eb->modifiers = mod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (cfdata->locals.cur[0] == 'w')
|
|
|
|
{
|
|
|
|
sscanf(cfdata->locals.cur, "w%d", &n);
|
|
|
|
l = evas_list_nth_list(cfdata->binding.wheel, n);
|
|
|
|
bw = l->data;
|
|
|
|
|
|
|
|
eb = E_NEW(E_Config_Binding_Mouse, 1);
|
|
|
|
eb->context = bw->context;
|
|
|
|
eb->button = ev->button;
|
|
|
|
eb->modifiers = mod;
|
|
|
|
eb->any_mod = 0;
|
|
|
|
eb->action = bw->action;
|
|
|
|
eb->params = bw->params;
|
|
|
|
|
|
|
|
cfdata->binding.mouse = evas_list_append(cfdata->binding.mouse, eb);
|
|
|
|
|
|
|
|
bw->action = NULL;
|
|
|
|
bw->params = NULL;
|
|
|
|
E_FREE(bw);
|
|
|
|
cfdata->binding.wheel = evas_list_remove_list(cfdata->binding.wheel, l);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
;
|
|
|
|
}
|
|
|
|
_update_mouse_binding_list(cfdata);
|
|
|
|
|
|
|
|
if (cfdata->locals.add)
|
|
|
|
{
|
|
|
|
for (l = cfdata->binding.mouse, n = 0; l; l = l->next, n++)
|
|
|
|
{
|
|
|
|
if (l->data == eb) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_binding_list, n + 1);
|
|
|
|
|
|
|
|
if (cfdata->locals.action) free(cfdata->locals.action);
|
|
|
|
cfdata->locals.action = strdup("");
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (l = cfdata->binding.mouse, n = 0; l; l = l->next, n++)
|
|
|
|
{
|
|
|
|
if (l->data == eb) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cfdata->locals.cur) free(cfdata->locals.cur);
|
|
|
|
cfdata->locals.cur = NULL;
|
|
|
|
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_binding_list, n + 1);
|
|
|
|
}
|
|
|
|
_update_buttons(cfdata);
|
|
|
|
_grab_wnd_hide(cfdata);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_grab_mouse_wheel_cb(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
E_Config_Binding_Wheel *bw;
|
|
|
|
E_Config_Binding_Mouse *eb;
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
|
|
|
Ecore_X_Event_Mouse_Wheel *ev;
|
|
|
|
int mod = E_BINDING_MODIFIER_NONE, n;
|
|
|
|
|
|
|
|
ev = event;
|
|
|
|
cfdata = data;
|
|
|
|
|
|
|
|
if (ev->win != cfdata->locals.bind_win) return 1;
|
|
|
|
|
|
|
|
if (ev->modifiers & ECORE_X_MODIFIER_SHIFT)
|
|
|
|
mod |= E_BINDING_MODIFIER_SHIFT;
|
|
|
|
if (ev->modifiers & ECORE_X_MODIFIER_CTRL)
|
|
|
|
mod |= E_BINDING_MODIFIER_CTRL;
|
|
|
|
if (ev->modifiers & ECORE_X_MODIFIER_ALT)
|
|
|
|
mod |= E_BINDING_MODIFIER_ALT;
|
|
|
|
if (ev->modifiers & ECORE_X_MODIFIER_WIN)
|
|
|
|
mod |= E_BINDING_MODIFIER_WIN;
|
|
|
|
|
|
|
|
|
|
|
|
if (cfdata->locals.add)
|
|
|
|
{
|
|
|
|
bw = E_NEW(E_Config_Binding_Wheel, 1);
|
|
|
|
bw->context = E_BINDING_CONTEXT_ANY;
|
|
|
|
bw->direction = ev->direction;
|
|
|
|
bw->z = ev->z;
|
|
|
|
bw->modifiers = mod;
|
|
|
|
bw->any_mod = 0;
|
|
|
|
bw->action = NULL;
|
|
|
|
bw->params = NULL;
|
|
|
|
|
|
|
|
cfdata->binding.wheel = evas_list_append(cfdata->binding.wheel, bw);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (cfdata->locals.cur[0] == 'm')
|
|
|
|
{
|
|
|
|
sscanf(cfdata->locals.cur, "m%d", &n);
|
|
|
|
l = evas_list_nth_list(cfdata->binding.mouse, n);
|
|
|
|
eb = l->data;
|
|
|
|
|
|
|
|
bw = E_NEW(E_Config_Binding_Wheel, 1);
|
|
|
|
bw->context = eb->context;
|
|
|
|
bw->direction = ev->direction;
|
|
|
|
bw->z = ev->z;
|
|
|
|
bw->modifiers = mod;
|
|
|
|
bw->any_mod = 0;
|
|
|
|
bw->action = eb->action;
|
|
|
|
bw->params = eb->params;
|
|
|
|
|
|
|
|
cfdata->binding.wheel = evas_list_append(cfdata->binding.wheel, bw);
|
|
|
|
|
|
|
|
E_FREE(eb);
|
|
|
|
cfdata->binding.mouse = evas_list_remove_list(cfdata->binding.mouse, l);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (cfdata->locals.cur[0] == 'w')
|
|
|
|
{
|
|
|
|
sscanf(cfdata->locals.cur, "w%d", &n);
|
|
|
|
bw = evas_list_nth(cfdata->binding.wheel, n);
|
|
|
|
if (bw)
|
|
|
|
{
|
|
|
|
bw->direction = ev->direction;
|
|
|
|
bw->z = ev->z;
|
|
|
|
bw->modifiers = mod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
;
|
|
|
|
}
|
|
|
|
_update_mouse_binding_list(cfdata);
|
|
|
|
|
|
|
|
if (cfdata->locals.add)
|
|
|
|
{
|
|
|
|
for (l = cfdata->binding.wheel, n = 0; l; l = l->next, n++)
|
|
|
|
{
|
|
|
|
if (l->data == bw) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (evas_list_count(cfdata->binding.mouse))
|
|
|
|
{
|
|
|
|
n += evas_list_count(cfdata->binding.mouse) + 2;
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_binding_list, n);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_binding_list, n + 1);
|
|
|
|
|
|
|
|
e_widget_ilist_unselect(cfdata->gui.o_action_list);
|
|
|
|
if (cfdata->locals.action) free(cfdata->locals.action);
|
|
|
|
cfdata->locals.action = strdup("");
|
|
|
|
e_widget_entry_clear(cfdata->gui.o_params);
|
|
|
|
e_widget_disabled_set(cfdata->gui.o_params, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (l = cfdata->binding.wheel, n = 0; l; l = l->next, n++)
|
|
|
|
{
|
|
|
|
if (l->data == bw) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cfdata->locals.cur) free(cfdata->locals.cur);
|
|
|
|
cfdata->locals.cur = NULL;
|
|
|
|
|
|
|
|
if (evas_list_count(cfdata->binding.mouse))
|
|
|
|
{
|
|
|
|
n += evas_list_count(cfdata->binding.mouse) + 2;
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_binding_list, n);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
e_widget_ilist_selected_set(cfdata->gui.o_binding_list, n + 1);
|
|
|
|
}
|
|
|
|
_update_buttons(cfdata);
|
|
|
|
|
|
|
|
_grab_wnd_hide(cfdata);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_grab_key_down_cb(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
|
|
|
Ecore_X_Event_Key_Down *ev = event;
|
|
|
|
|
|
|
|
cfdata = data;
|
|
|
|
|
|
|
|
if (ev->win != cfdata->locals.bind_win) return 1;
|
|
|
|
|
|
|
|
if (!strcmp(ev->keyname, "Escape") &&
|
|
|
|
!(ev->modifiers & ECORE_X_MODIFIER_SHIFT) &&
|
|
|
|
!(ev->modifiers & ECORE_X_MODIFIER_CTRL) &&
|
|
|
|
!(ev->modifiers & ECORE_X_MODIFIER_ALT) &&
|
|
|
|
!(ev->modifiers & ECORE_X_MODIFIER_WIN))
|
|
|
|
{
|
|
|
|
_grab_wnd_hide(cfdata);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|