forked from enlightenment/enlightenment
parent
b4e713d4b7
commit
27e182fb59
|
@ -4,54 +4,54 @@
|
||||||
|
|
||||||
struct _E_Config_Dialog_Data
|
struct _E_Config_Dialog_Data
|
||||||
{
|
{
|
||||||
Evas *evas, *dlg_evas;
|
Evas *evas, *dlg_evas;
|
||||||
Evas_Object *layout_list, *used_list;
|
Evas_Object *layout_list, *used_list;
|
||||||
Evas_Object *dmodel_list, *model_list, *variant_list;
|
Evas_Object *dmodel_list, *model_list, *variant_list;
|
||||||
Evas_Object *btn_add, *btn_del, *btn_up, *btn_down;
|
Evas_Object *btn_add, *btn_del, *btn_up, *btn_down;
|
||||||
Ecore_Timer *fill_delay;
|
Ecore_Timer *fill_delay;
|
||||||
Ecore_Timer *dlg_fill_delay;
|
Ecore_Timer *dlg_fill_delay;
|
||||||
|
|
||||||
Eina_List *cfg_layouts;
|
Eina_List *cfg_layouts;
|
||||||
Eina_List *cfg_options;
|
Eina_List *cfg_options;
|
||||||
const char *default_model;
|
const char *default_model;
|
||||||
|
|
||||||
int only_label;
|
int only_label;
|
||||||
|
|
||||||
E_Dialog *dlg_add_new;
|
E_Dialog *dlg_add_new;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _E_XKB_Dialog_Option
|
typedef struct _E_XKB_Dialog_Option
|
||||||
{
|
{
|
||||||
int enabled;
|
int enabled;
|
||||||
const char *name;
|
const char *name;
|
||||||
} E_XKB_Dialog_Option;
|
} E_XKB_Dialog_Option;
|
||||||
|
|
||||||
/* Local prototypes */
|
/* Local prototypes */
|
||||||
|
|
||||||
static void *_create_data(E_Config_Dialog *cfd);
|
static void *_create_data(E_Config_Dialog *cfd);
|
||||||
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||||
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||||
static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||||
|
|
||||||
static void _cb_add(void *data, void *data2 __UNUSED__);
|
static void _cb_add(void *data, void *data2 __UNUSED__);
|
||||||
static void _cb_del(void *data, void *data2 __UNUSED__);
|
static void _cb_del(void *data, void *data2 __UNUSED__);
|
||||||
|
|
||||||
static void _cb_up(void *data, void *data2 __UNUSED__);
|
static void _cb_up(void *data, void *data2 __UNUSED__);
|
||||||
static void _cb_dn(void *data, void *data2 __UNUSED__);
|
static void _cb_dn(void *data, void *data2 __UNUSED__);
|
||||||
|
|
||||||
static void _dlg_add_cb_ok(void *data, E_Dialog *dlg);
|
static void _dlg_add_cb_ok(void *data, E_Dialog *dlg);
|
||||||
static void _dlg_add_cb_cancel(void *data, E_Dialog *dlg);
|
static void _dlg_add_cb_cancel(void *data, E_Dialog *dlg);
|
||||||
|
|
||||||
static E_Dialog *_dlg_add_new(E_Config_Dialog_Data *cfdata);
|
static E_Dialog *_dlg_add_new(E_Config_Dialog_Data *cfdata);
|
||||||
|
|
||||||
static void _dlg_add_cb_del(void *obj);
|
static void _dlg_add_cb_del(void *obj);
|
||||||
|
|
||||||
static Eina_Bool _cb_dlg_fill_delay(void *data);
|
static Eina_Bool _cb_dlg_fill_delay(void *data);
|
||||||
|
|
||||||
static void _cb_layout_select(void *data);
|
static void _cb_layout_select(void *data);
|
||||||
static void _cb_used_select (void *data);
|
static void _cb_used_select(void *data);
|
||||||
|
|
||||||
static Eina_Bool _cb_fill_delay(void *data);
|
static Eina_Bool _cb_fill_delay(void *data);
|
||||||
|
|
||||||
/* Externals */
|
/* Externals */
|
||||||
|
|
||||||
|
@ -65,10 +65,10 @@ _xkb_cfg_dialog(E_Container *con, const char *params __UNUSED__)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!(v = E_NEW(E_Config_Dialog_View, 1))) return NULL;
|
if (!(v = E_NEW(E_Config_Dialog_View, 1))) return NULL;
|
||||||
|
|
||||||
v->create_cfdata = _create_data;
|
v->create_cfdata = _create_data;
|
||||||
v->free_cfdata = _free_data;
|
v->free_cfdata = _free_data;
|
||||||
v->basic.create_widgets = _basic_create;
|
v->basic.create_widgets = _basic_create;
|
||||||
v->basic.apply_cfdata = _basic_apply;
|
v->basic.apply_cfdata = _basic_apply;
|
||||||
|
|
||||||
cfd = e_config_dialog_new(con, _("Keyboard Settings"), "E",
|
cfd = e_config_dialog_new(con, _("Keyboard Settings"), "E",
|
||||||
"keyboard_and_mouse/xkbswitch",
|
"keyboard_and_mouse/xkbswitch",
|
||||||
|
@ -99,9 +99,9 @@ _create_data(E_Config_Dialog *cfd __UNUSED__)
|
||||||
cfdata->cfg_layouts = NULL;
|
cfdata->cfg_layouts = NULL;
|
||||||
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
|
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
|
||||||
{
|
{
|
||||||
nl = E_NEW(E_Config_XKB_Layout, 1);
|
nl = E_NEW(E_Config_XKB_Layout, 1);
|
||||||
nl->name = eina_stringshare_add(cl->name);
|
nl->name = eina_stringshare_add(cl->name);
|
||||||
nl->model = eina_stringshare_add(cl->model);
|
nl->model = eina_stringshare_add(cl->model);
|
||||||
nl->variant = eina_stringshare_add(cl->variant);
|
nl->variant = eina_stringshare_add(cl->variant);
|
||||||
|
|
||||||
cfdata->cfg_layouts = eina_list_append(cfdata->cfg_layouts, nl);
|
cfdata->cfg_layouts = eina_list_append(cfdata->cfg_layouts, nl);
|
||||||
|
@ -109,7 +109,7 @@ _create_data(E_Config_Dialog *cfd __UNUSED__)
|
||||||
|
|
||||||
/* Initialize options */
|
/* Initialize options */
|
||||||
|
|
||||||
cfdata->only_label = e_config->xkb.only_label;
|
cfdata->only_label = e_config->xkb.only_label;
|
||||||
cfdata->cfg_options = NULL;
|
cfdata->cfg_options = NULL;
|
||||||
|
|
||||||
lll = e_config->xkb.used_options;
|
lll = e_config->xkb.used_options;
|
||||||
|
@ -179,9 +179,9 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||||
|
|
||||||
EINA_LIST_FOREACH(cfdata->cfg_layouts, l, cl)
|
EINA_LIST_FOREACH(cfdata->cfg_layouts, l, cl)
|
||||||
{
|
{
|
||||||
nl = E_NEW(E_Config_XKB_Layout, 1);
|
nl = E_NEW(E_Config_XKB_Layout, 1);
|
||||||
nl->name = eina_stringshare_add(cl->name);
|
nl->name = eina_stringshare_add(cl->name);
|
||||||
nl->model = eina_stringshare_add(cl->model);
|
nl->model = eina_stringshare_add(cl->model);
|
||||||
nl->variant = eina_stringshare_add(cl->variant);
|
nl->variant = eina_stringshare_add(cl->variant);
|
||||||
|
|
||||||
e_config->xkb.used_layouts =
|
e_config->xkb.used_layouts =
|
||||||
|
@ -209,7 +209,7 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||||
oc = E_NEW(E_Config_XKB_Option, 1);
|
oc = E_NEW(E_Config_XKB_Option, 1);
|
||||||
oc->name = eina_stringshare_add(od->name);
|
oc->name = eina_stringshare_add(od->name);
|
||||||
e_config->xkb.used_options = eina_list_append(e_config->xkb.used_options, oc);
|
e_config->xkb.used_options = eina_list_append(e_config->xkb.used_options, oc);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_xkb_update(-1);
|
e_xkb_update(-1);
|
||||||
_xkb_update_icon(0);
|
_xkb_update_icon(0);
|
||||||
|
@ -223,121 +223,121 @@ _basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data
|
||||||
{
|
{
|
||||||
/* Holds the dialog contents, displays a toolbar on the top */
|
/* Holds the dialog contents, displays a toolbar on the top */
|
||||||
Evas_Object *mainn = e_widget_toolbook_add(evas, 24, 24);
|
Evas_Object *mainn = e_widget_toolbook_add(evas, 24, 24);
|
||||||
{
|
{
|
||||||
/* Holds the used layouts ilist and the button table */
|
/* Holds the used layouts ilist and the button table */
|
||||||
Evas_Object *layoutss;
|
Evas_Object *layoutss;
|
||||||
Evas_Object *modelss;
|
Evas_Object *modelss;
|
||||||
Evas_Object *options;
|
Evas_Object *options;
|
||||||
|
|
||||||
layoutss = e_widget_list_add(evas, 0, 0);
|
layoutss = e_widget_list_add(evas, 0, 0);
|
||||||
{
|
{
|
||||||
/* Holds the used layouts */
|
/* Holds the used layouts */
|
||||||
Evas_Object *configs;
|
Evas_Object *configs;
|
||||||
Evas_Object *buttons;
|
Evas_Object *buttons;
|
||||||
|
|
||||||
configs = e_widget_ilist_add(evas, 32, 32, NULL);
|
configs = e_widget_ilist_add(evas, 32, 32, NULL);
|
||||||
|
|
||||||
{
|
{
|
||||||
e_widget_size_min_set(configs, 220, 160);
|
e_widget_size_min_set(configs, 220, 160);
|
||||||
e_widget_ilist_go(configs);
|
e_widget_ilist_go(configs);
|
||||||
|
|
||||||
e_widget_list_object_append(layoutss, configs, 1, 1, 0.5);
|
e_widget_list_object_append(layoutss, configs, 1, 1, 0.5);
|
||||||
cfdata->used_list = configs;
|
cfdata->used_list = configs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Holds the buttons */
|
/* Holds the buttons */
|
||||||
buttons = e_widget_table_add(evas, 1);
|
buttons = e_widget_table_add(evas, 1);
|
||||||
{
|
{
|
||||||
cfdata->btn_up = e_widget_button_add(evas, _("Up"), "go-up", _cb_up, cfdata, NULL);
|
cfdata->btn_up = e_widget_button_add(evas, _("Up"), "go-up", _cb_up, cfdata, NULL);
|
||||||
{
|
{
|
||||||
e_widget_disabled_set(cfdata->btn_up, EINA_TRUE);
|
e_widget_disabled_set(cfdata->btn_up, EINA_TRUE);
|
||||||
e_widget_table_object_append(buttons, cfdata->btn_up, 0, 0, 1, 1, 1, 1, 1, 0);
|
e_widget_table_object_append(buttons, cfdata->btn_up, 0, 0, 1, 1, 1, 1, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdata->btn_down = e_widget_button_add(evas, _("Down"), "go-down", _cb_dn, cfdata, NULL);
|
cfdata->btn_down = e_widget_button_add(evas, _("Down"), "go-down", _cb_dn, cfdata, NULL);
|
||||||
{
|
{
|
||||||
e_widget_disabled_set(cfdata->btn_down, EINA_TRUE);
|
e_widget_disabled_set(cfdata->btn_down, EINA_TRUE);
|
||||||
e_widget_table_object_append(buttons, cfdata->btn_down, 1, 0, 1, 1, 1, 1, 1, 0);
|
e_widget_table_object_append(buttons, cfdata->btn_down, 1, 0, 1, 1, 1, 1, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdata->btn_add = e_widget_button_add(evas, _("Add"), "list-add", _cb_add, cfdata, NULL);
|
cfdata->btn_add = e_widget_button_add(evas, _("Add"), "list-add", _cb_add, cfdata, NULL);
|
||||||
{
|
{
|
||||||
e_widget_table_object_append(buttons, cfdata->btn_add, 0, 1, 1, 1, 1, 1, 1, 0);
|
e_widget_table_object_append(buttons, cfdata->btn_add, 0, 1, 1, 1, 1, 1, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdata->btn_del = e_widget_button_add(evas, _("Remove"), "list-remove", _cb_del, cfdata, NULL);
|
cfdata->btn_del = e_widget_button_add(evas, _("Remove"), "list-remove", _cb_del, cfdata, NULL);
|
||||||
{
|
{
|
||||||
e_widget_disabled_set(cfdata->btn_del, EINA_TRUE);
|
e_widget_disabled_set(cfdata->btn_del, EINA_TRUE);
|
||||||
e_widget_table_object_append(buttons, cfdata->btn_del, 1, 1, 1, 1, 1, 1, 1, 0);
|
e_widget_table_object_append(buttons, cfdata->btn_del, 1, 1, 1, 1, 1, 1, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_widget_list_object_append(layoutss, buttons, 1, 0, 1);
|
e_widget_list_object_append(layoutss, buttons, 1, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_widget_toolbook_page_append(mainn, NULL, _("Configurations"), layoutss, 1, 1, 1, 1, 0.5, 0.0);
|
e_widget_toolbook_page_append(mainn, NULL, _("Configurations"), layoutss, 1, 1, 1, 1, 0.5, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Holds the default models */
|
/* Holds the default models */
|
||||||
modelss = e_widget_ilist_add(evas, 32, 32, &cfdata->default_model);
|
modelss = e_widget_ilist_add(evas, 32, 32, &cfdata->default_model);
|
||||||
{
|
{
|
||||||
e_widget_size_min_set(modelss, 220, 160);
|
e_widget_size_min_set(modelss, 220, 160);
|
||||||
cfdata->dmodel_list = modelss;
|
cfdata->dmodel_list = modelss;
|
||||||
|
|
||||||
e_widget_toolbook_page_append(mainn, NULL, _("Models"), modelss, 1, 1, 1, 1, 0.5, 0.0);
|
e_widget_toolbook_page_append(mainn, NULL, _("Models"), modelss, 1, 1, 1, 1, 0.5, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Holds the options */
|
/* Holds the options */
|
||||||
options = e_widget_list_add(evas, 0, 0);
|
options = e_widget_list_add(evas, 0, 0);
|
||||||
{
|
{
|
||||||
E_XKB_Option *option;
|
E_XKB_Option *option;
|
||||||
E_XKB_Option_Group *group;
|
E_XKB_Option_Group *group;
|
||||||
Eina_List *l, *ll, *lll;
|
Eina_List *l, *ll, *lll;
|
||||||
Evas_Coord mw, mh;
|
Evas_Coord mw, mh;
|
||||||
Evas_Object *general;
|
Evas_Object *general;
|
||||||
Evas_Object *scroller;
|
Evas_Object *scroller;
|
||||||
|
|
||||||
general = e_widget_framelist_add(evas, _("Gadgets"), 0);
|
general = e_widget_framelist_add(evas, _("Gadgets"), 0);
|
||||||
{
|
{
|
||||||
Evas_Object *only_label = e_widget_check_add(evas, _("Label only"), &(cfdata->only_label));
|
Evas_Object *only_label = e_widget_check_add(evas, _("Label only"), &(cfdata->only_label));
|
||||||
{
|
{
|
||||||
e_widget_framelist_object_append(general, only_label);
|
e_widget_framelist_object_append(general, only_label);
|
||||||
}
|
}
|
||||||
e_widget_list_object_append(options, general, 1, 1, 0.0);
|
e_widget_list_object_append(options, general, 1, 1, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
lll = cfdata->cfg_options;
|
lll = cfdata->cfg_options;
|
||||||
|
|
||||||
EINA_LIST_FOREACH(optgroups, l, group)
|
EINA_LIST_FOREACH(optgroups, l, group)
|
||||||
{
|
{
|
||||||
Evas_Object *grp = e_widget_framelist_add(evas, group->description, 0);
|
Evas_Object *grp = e_widget_framelist_add(evas, group->description, 0);
|
||||||
|
|
||||||
EINA_LIST_FOREACH(group->options, ll, option)
|
EINA_LIST_FOREACH(group->options, ll, option)
|
||||||
{
|
{
|
||||||
Evas_Object *chk = e_widget_check_add(evas, option->description,
|
Evas_Object *chk = e_widget_check_add(evas, option->description,
|
||||||
&(((E_XKB_Dialog_Option *)
|
&(((E_XKB_Dialog_Option *)
|
||||||
eina_list_data_get(lll))->enabled));
|
eina_list_data_get(lll))->enabled));
|
||||||
e_widget_framelist_object_append(grp, chk);
|
e_widget_framelist_object_append(grp, chk);
|
||||||
lll = eina_list_next(lll);
|
lll = eina_list_next(lll);
|
||||||
}
|
}
|
||||||
e_widget_list_object_append(options, grp, 1, 1, 0.0);
|
e_widget_list_object_append(options, grp, 1, 1, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_widget_size_min_get(options, &mw, &mh);
|
e_widget_size_min_get(options, &mw, &mh);
|
||||||
|
|
||||||
if (mw < 220) mw = 220;
|
if (mw < 220) mw = 220;
|
||||||
if (mh < 160) mh = 160;
|
if (mh < 160) mh = 160;
|
||||||
|
|
||||||
evas_object_resize(options, mw, mh);
|
evas_object_resize(options, mw, mh);
|
||||||
|
|
||||||
scroller = e_widget_scrollframe_simple_add(evas, options);
|
scroller = e_widget_scrollframe_simple_add(evas, options);
|
||||||
e_widget_size_min_set(scroller, 220, 160);
|
e_widget_size_min_set(scroller, 220, 160);
|
||||||
|
|
||||||
e_widget_toolbook_page_append(mainn, NULL, _("Options"), scroller, 1, 1, 1, 1, 0.5, 0.0);
|
e_widget_toolbook_page_append(mainn, NULL, _("Options"), scroller, 1, 1, 1, 1, 0.5, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display the first page by default */
|
/* Display the first page by default */
|
||||||
e_widget_toolbook_page_show(mainn, 0);
|
e_widget_toolbook_page_show(mainn, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The main evas */
|
/* The main evas */
|
||||||
cfdata->evas = evas;
|
cfdata->evas = evas;
|
||||||
|
@ -482,37 +482,37 @@ _dlg_add_new(E_Config_Dialog_Data *cfdata)
|
||||||
|
|
||||||
/* The main toolbook, holds the lists and tabs */
|
/* The main toolbook, holds the lists and tabs */
|
||||||
mainn = e_widget_toolbook_add(evas, 24, 24);
|
mainn = e_widget_toolbook_add(evas, 24, 24);
|
||||||
{
|
{
|
||||||
/* Holds the available layouts */
|
/* Holds the available layouts */
|
||||||
Evas_Object *available = e_widget_ilist_add(evas, 32, 32, NULL);
|
Evas_Object *available = e_widget_ilist_add(evas, 32, 32, NULL);
|
||||||
Evas_Object *modelss;
|
Evas_Object *modelss;
|
||||||
Evas_Object *variants;
|
Evas_Object *variants;
|
||||||
|
|
||||||
{
|
{
|
||||||
e_widget_size_min_set(available, 220, 160);
|
e_widget_size_min_set(available, 220, 160);
|
||||||
e_widget_ilist_go(available);
|
e_widget_ilist_go(available);
|
||||||
e_widget_toolbook_page_append(mainn, NULL, _("Available"), available, 1, 1, 1, 1, 0.5, 0.0);
|
e_widget_toolbook_page_append(mainn, NULL, _("Available"), available, 1, 1, 1, 1, 0.5, 0.0);
|
||||||
cfdata->layout_list = available;
|
cfdata->layout_list = available;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Holds the available models */
|
/* Holds the available models */
|
||||||
modelss = e_widget_ilist_add(evas, 32, 32, NULL);
|
modelss = e_widget_ilist_add(evas, 32, 32, NULL);
|
||||||
{
|
{
|
||||||
e_widget_toolbook_page_append(mainn, NULL, _("Model"), modelss, 1, 1, 1, 1, 0.5, 0.0);
|
e_widget_toolbook_page_append(mainn, NULL, _("Model"), modelss, 1, 1, 1, 1, 0.5, 0.0);
|
||||||
cfdata->model_list = modelss;
|
cfdata->model_list = modelss;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Holds the available variants */
|
/* Holds the available variants */
|
||||||
variants = e_widget_ilist_add(evas, 32, 32, NULL);
|
variants = e_widget_ilist_add(evas, 32, 32, NULL);
|
||||||
{
|
{
|
||||||
e_widget_toolbook_page_append(mainn, NULL, _("Variant"), variants, 1, 1, 1, 1, 0.5, 0.0);
|
e_widget_toolbook_page_append(mainn, NULL, _("Variant"), variants, 1, 1, 1, 1, 0.5, 0.0);
|
||||||
cfdata->variant_list = variants;
|
cfdata->variant_list = variants;
|
||||||
}
|
}
|
||||||
e_widget_toolbook_page_show(mainn, 0);
|
e_widget_toolbook_page_show(mainn, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_widget_size_min_get(mainn, &mw, &mh);
|
e_widget_size_min_get(mainn, &mw, &mh);
|
||||||
e_dialog_content_set(dlg, mainn, mw, mh);
|
e_dialog_content_set(dlg, mainn, mw, mh);
|
||||||
|
|
||||||
cfdata->dlg_evas = evas;
|
cfdata->dlg_evas = evas;
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ static void
|
||||||
_dlg_add_cb_ok(void *data __UNUSED__, E_Dialog *dlg)
|
_dlg_add_cb_ok(void *data __UNUSED__, E_Dialog *dlg)
|
||||||
{
|
{
|
||||||
E_Config_Dialog_Data *cfdata = dlg->data;
|
E_Config_Dialog_Data *cfdata = dlg->data;
|
||||||
E_Config_XKB_Layout *cl;
|
E_Config_XKB_Layout *cl;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
/* Configuration information */
|
/* Configuration information */
|
||||||
const char *layout = e_widget_ilist_selected_value_get(cfdata->layout_list);
|
const char *layout = e_widget_ilist_selected_value_get(cfdata->layout_list);
|
||||||
|
@ -547,9 +547,9 @@ _dlg_add_cb_ok(void *data __UNUSED__, E_Dialog *dlg)
|
||||||
const char *variant = e_widget_ilist_selected_value_get(cfdata->variant_list);
|
const char *variant = e_widget_ilist_selected_value_get(cfdata->variant_list);
|
||||||
|
|
||||||
/* The new configuration */
|
/* The new configuration */
|
||||||
cl = E_NEW(E_Config_XKB_Layout, 1);
|
cl = E_NEW(E_Config_XKB_Layout, 1);
|
||||||
cl->name = eina_stringshare_add(layout);
|
cl->name = eina_stringshare_add(layout);
|
||||||
cl->model = eina_stringshare_add(model);
|
cl->model = eina_stringshare_add(model);
|
||||||
cl->variant = eina_stringshare_add(variant);
|
cl->variant = eina_stringshare_add(variant);
|
||||||
|
|
||||||
cfdata->cfg_layouts = eina_list_append(cfdata->cfg_layouts, cl);
|
cfdata->cfg_layouts = eina_list_append(cfdata->cfg_layouts, cl);
|
||||||
|
@ -559,18 +559,18 @@ _dlg_add_cb_ok(void *data __UNUSED__, E_Dialog *dlg)
|
||||||
edje_freeze();
|
edje_freeze();
|
||||||
e_widget_ilist_freeze(cfdata->used_list);
|
e_widget_ilist_freeze(cfdata->used_list);
|
||||||
|
|
||||||
{
|
{
|
||||||
Evas_Object *ic = e_icon_add(cfdata->evas);
|
Evas_Object *ic = e_icon_add(cfdata->evas);
|
||||||
const char *name = cl->name;
|
const char *name = cl->name;
|
||||||
|
|
||||||
e_xkb_e_icon_flag_setup(ic, name);
|
e_xkb_e_icon_flag_setup(ic, name);
|
||||||
snprintf(buf, sizeof(buf), "%s (%s, %s)",
|
snprintf(buf, sizeof(buf), "%s (%s, %s)",
|
||||||
cl->name, cl->model, cl->variant);
|
cl->name, cl->model, cl->variant);
|
||||||
e_widget_ilist_append_full(cfdata->used_list, ic, NULL, buf,
|
e_widget_ilist_append_full(cfdata->used_list, ic, NULL, buf,
|
||||||
_cb_used_select, cfdata, NULL);
|
_cb_used_select, cfdata, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_widget_ilist_go (cfdata->used_list);
|
e_widget_ilist_go(cfdata->used_list);
|
||||||
e_widget_ilist_thaw(cfdata->used_list);
|
e_widget_ilist_thaw(cfdata->used_list);
|
||||||
edje_thaw();
|
edje_thaw();
|
||||||
evas_event_thaw(cfdata->evas);
|
evas_event_thaw(cfdata->evas);
|
||||||
|
@ -611,7 +611,7 @@ _cb_dlg_fill_delay(void *data)
|
||||||
edje_freeze();
|
edje_freeze();
|
||||||
|
|
||||||
e_widget_ilist_freeze(cfdata->layout_list);
|
e_widget_ilist_freeze(cfdata->layout_list);
|
||||||
e_widget_ilist_clear (cfdata->layout_list);
|
e_widget_ilist_clear(cfdata->layout_list);
|
||||||
|
|
||||||
EINA_LIST_FOREACH(layouts, l, layout)
|
EINA_LIST_FOREACH(layouts, l, layout)
|
||||||
{
|
{
|
||||||
|
@ -625,7 +625,7 @@ _cb_dlg_fill_delay(void *data)
|
||||||
_cb_layout_select, cfdata, layout->name);
|
_cb_layout_select, cfdata, layout->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_widget_ilist_go (cfdata->layout_list);
|
e_widget_ilist_go(cfdata->layout_list);
|
||||||
e_widget_ilist_thaw(cfdata->layout_list);
|
e_widget_ilist_thaw(cfdata->layout_list);
|
||||||
|
|
||||||
edje_thaw();
|
edje_thaw();
|
||||||
|
@ -657,9 +657,9 @@ _cb_layout_select(void *data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(layout = eina_list_search_unsorted
|
if (!(layout = eina_list_search_unsorted
|
||||||
(layouts, layout_sort_by_name_cb,
|
(layouts, layout_sort_by_name_cb,
|
||||||
e_widget_ilist_nth_value_get(cfdata->layout_list, n)
|
e_widget_ilist_nth_value_get(cfdata->layout_list, n)
|
||||||
))) return;
|
))) return;
|
||||||
|
|
||||||
/* Update the lists */
|
/* Update the lists */
|
||||||
evas_event_freeze(cfdata->dlg_evas);
|
evas_event_freeze(cfdata->dlg_evas);
|
||||||
|
@ -684,7 +684,7 @@ _cb_layout_select(void *data)
|
||||||
|
|
||||||
EINA_LIST_FOREACH(layout->variants, l, variant)
|
EINA_LIST_FOREACH(layout->variants, l, variant)
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "%s (%s)", variant->name, variant->description);
|
snprintf(buf, sizeof(buf), "%s (%s)", variant->name, variant->description);
|
||||||
e_widget_ilist_append(cfdata->variant_list, NULL, buf, NULL, cfdata, variant->name);
|
e_widget_ilist_append(cfdata->variant_list, NULL, buf, NULL, cfdata, variant->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ _cb_layout_select(void *data)
|
||||||
edje_thaw();
|
edje_thaw();
|
||||||
evas_event_thaw(cfdata->dlg_evas);
|
evas_event_thaw(cfdata->dlg_evas);
|
||||||
|
|
||||||
e_widget_ilist_selected_set(cfdata->model_list, 0);
|
e_widget_ilist_selected_set(cfdata->model_list, 0);
|
||||||
e_widget_ilist_selected_set(cfdata->variant_list, 0);
|
e_widget_ilist_selected_set(cfdata->variant_list, 0);
|
||||||
|
|
||||||
e_dialog_button_disable_num_set(cfdata->dlg_add_new, 0, 0);
|
e_dialog_button_disable_num_set(cfdata->dlg_add_new, 0, 0);
|
||||||
|
@ -729,7 +729,7 @@ _cb_fill_delay(void *data)
|
||||||
cl->name, cl->model, cl->variant);
|
cl->name, cl->model, cl->variant);
|
||||||
e_widget_ilist_append_full(cfdata->used_list, ic, NULL, buf,
|
e_widget_ilist_append_full(cfdata->used_list, ic, NULL, buf,
|
||||||
_cb_used_select, cfdata, NULL);
|
_cb_used_select, cfdata, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_widget_ilist_go(cfdata->used_list);
|
e_widget_ilist_go(cfdata->used_list);
|
||||||
e_widget_ilist_thaw(cfdata->used_list);
|
e_widget_ilist_thaw(cfdata->used_list);
|
||||||
|
@ -771,17 +771,18 @@ _cb_used_select(void *data)
|
||||||
|
|
||||||
if (n == (c - 1))
|
if (n == (c - 1))
|
||||||
{
|
{
|
||||||
e_widget_disabled_set(cfdata->btn_up, EINA_FALSE);
|
e_widget_disabled_set(cfdata->btn_up, EINA_FALSE);
|
||||||
e_widget_disabled_set(cfdata->btn_down, EINA_TRUE );
|
e_widget_disabled_set(cfdata->btn_down, EINA_TRUE);
|
||||||
}
|
}
|
||||||
else if (n == 0)
|
else if (n == 0)
|
||||||
{
|
{
|
||||||
e_widget_disabled_set(cfdata->btn_up, EINA_TRUE );
|
e_widget_disabled_set(cfdata->btn_up, EINA_TRUE);
|
||||||
e_widget_disabled_set(cfdata->btn_down, EINA_FALSE);
|
e_widget_disabled_set(cfdata->btn_down, EINA_FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e_widget_disabled_set(cfdata->btn_up, EINA_FALSE);
|
e_widget_disabled_set(cfdata->btn_up, EINA_FALSE);
|
||||||
e_widget_disabled_set(cfdata->btn_down, EINA_FALSE);
|
e_widget_disabled_set(cfdata->btn_down, EINA_FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,22 +2,21 @@
|
||||||
#include "e_mod_main.h"
|
#include "e_mod_main.h"
|
||||||
#include "e_mod_parse.h"
|
#include "e_mod_parse.h"
|
||||||
|
|
||||||
|
|
||||||
/* GADCON */
|
/* GADCON */
|
||||||
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
||||||
static void _gc_shutdown(E_Gadcon_Client *gcc);
|
static void _gc_shutdown(E_Gadcon_Client *gcc);
|
||||||
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
||||||
static const char *_gc_label(const E_Gadcon_Client_Class *client_class);
|
static const char *_gc_label(const E_Gadcon_Client_Class *client_class);
|
||||||
static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class __UNUSED__);
|
static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class __UNUSED__);
|
||||||
static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas);
|
static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas);
|
||||||
|
|
||||||
/* EVENTS */
|
/* EVENTS */
|
||||||
static Eina_Bool _xkb_changed(void *data, int type, void *event_info);
|
static Eina_Bool _xkb_changed(void *data, int type, void *event_info);
|
||||||
static Eina_Bool _xkb_changed_state(void *data __UNUSED__,int type __UNUSED__, void *event);
|
static Eina_Bool _xkb_changed_state(void *data __UNUSED__, int type __UNUSED__, void *event);
|
||||||
static void _e_xkb_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
|
static void _e_xkb_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
|
||||||
static void _e_xkb_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi __UNUSED__);
|
static void _e_xkb_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi __UNUSED__);
|
||||||
static void _e_xkb_cb_lmenu_post(void *data, E_Menu *menu __UNUSED__);
|
static void _e_xkb_cb_lmenu_post(void *data, E_Menu *menu __UNUSED__);
|
||||||
static void _e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED__);
|
static void _e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED__);
|
||||||
|
|
||||||
/* Static variables
|
/* Static variables
|
||||||
* The static variables specific to the current code unit.
|
* The static variables specific to the current code unit.
|
||||||
|
@ -25,14 +24,14 @@ static void _e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *
|
||||||
|
|
||||||
/* GADGET INSTANCE */
|
/* GADGET INSTANCE */
|
||||||
|
|
||||||
typedef struct _Instance
|
typedef struct _Instance
|
||||||
{
|
{
|
||||||
E_Gadcon_Client *gcc;
|
E_Gadcon_Client *gcc;
|
||||||
|
|
||||||
Evas_Object *o_xkbswitch;
|
Evas_Object *o_xkbswitch;
|
||||||
Evas_Object *o_xkbflag;
|
Evas_Object *o_xkbflag;
|
||||||
|
|
||||||
E_Menu *lmenu;
|
E_Menu *lmenu;
|
||||||
} Instance;
|
} Instance;
|
||||||
|
|
||||||
/* LIST OF INSTANCES */
|
/* LIST OF INSTANCES */
|
||||||
|
@ -45,17 +44,17 @@ static Eina_List *instances = NULL;
|
||||||
/* CONFIG STRUCTURE */
|
/* CONFIG STRUCTURE */
|
||||||
Xkb _xkb = { NULL, NULL, NULL };
|
Xkb _xkb = { NULL, NULL, NULL };
|
||||||
|
|
||||||
static const E_Gadcon_Client_Class _gc_class =
|
static const E_Gadcon_Client_Class _gc_class =
|
||||||
{
|
{
|
||||||
GADCON_CLIENT_CLASS_VERSION,
|
GADCON_CLIENT_CLASS_VERSION,
|
||||||
"xkbswitch",
|
"xkbswitch",
|
||||||
{
|
{
|
||||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL, NULL
|
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL, NULL
|
||||||
},
|
},
|
||||||
E_GADCON_CLIENT_STYLE_PLAIN
|
E_GADCON_CLIENT_STYLE_PLAIN
|
||||||
};
|
};
|
||||||
|
|
||||||
EAPI E_Module_Api e_modapi =
|
EAPI E_Module_Api e_modapi =
|
||||||
{
|
{
|
||||||
E_MODULE_API_VERSION,
|
E_MODULE_API_VERSION,
|
||||||
"XKB Switcher"
|
"XKB Switcher"
|
||||||
|
@ -66,18 +65,18 @@ EAPI E_Module_Api e_modapi =
|
||||||
* menus, finds the rules file, initializes gadget icon.
|
* menus, finds the rules file, initializes gadget icon.
|
||||||
*/
|
*/
|
||||||
EAPI void *
|
EAPI void *
|
||||||
e_modapi_init(E_Module *m)
|
e_modapi_init(E_Module *m)
|
||||||
{
|
{
|
||||||
/* Menus and dialogs */
|
/* Menus and dialogs */
|
||||||
e_configure_registry_category_add("keyboard_and_mouse", 80, _("Input"),
|
e_configure_registry_category_add("keyboard_and_mouse", 80, _("Input"),
|
||||||
NULL, "preferences-behavior");
|
NULL, "preferences-behavior");
|
||||||
e_configure_registry_item_add("keyboard_and_mouse/xkbswitch", 110,
|
e_configure_registry_item_add("keyboard_and_mouse/xkbswitch", 110,
|
||||||
_("Keyboard"), NULL,
|
_("Keyboard"), NULL,
|
||||||
"preferences-desktop-keyboard",
|
"preferences-desktop-keyboard",
|
||||||
_xkb_cfg_dialog);
|
_xkb_cfg_dialog);
|
||||||
_xkb.module = m;
|
_xkb.module = m;
|
||||||
_xkb.evh = ecore_event_handler_add(E_EVENT_XKB_CHANGED, _xkb_changed, NULL);
|
_xkb.evh = ecore_event_handler_add(E_EVENT_XKB_CHANGED, _xkb_changed, NULL);
|
||||||
ecore_event_handler_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, _xkb_changed_state, NULL);
|
ecore_event_handler_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, _xkb_changed_state, NULL);
|
||||||
/* Gadcon */
|
/* Gadcon */
|
||||||
e_gadcon_provider_register(&_gc_class);
|
e_gadcon_provider_register(&_gc_class);
|
||||||
return m;
|
return m;
|
||||||
|
@ -95,10 +94,10 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
||||||
|
|
||||||
if (_xkb.evh) ecore_event_handler_del(_xkb.evh);
|
if (_xkb.evh) ecore_event_handler_del(_xkb.evh);
|
||||||
if (_xkb.cfd) e_object_del(E_OBJECT(_xkb.cfd));
|
if (_xkb.cfd) e_object_del(E_OBJECT(_xkb.cfd));
|
||||||
_xkb.cfd = NULL;
|
_xkb.cfd = NULL;
|
||||||
_xkb.module = NULL;
|
_xkb.module = NULL;
|
||||||
e_gadcon_provider_unregister(&_gc_class);
|
e_gadcon_provider_unregister(&_gc_class);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,19 +119,19 @@ _xkb_update_icon(int cur_group)
|
||||||
Instance *inst;
|
Instance *inst;
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
E_Config_XKB_Layout *layout;
|
E_Config_XKB_Layout *layout;
|
||||||
const char *name=NULL;
|
const char *name = NULL;
|
||||||
int grp = -1;
|
int grp = -1;
|
||||||
|
|
||||||
if (!e_config->xkb.used_layouts) return;
|
if (!e_config->xkb.used_layouts) return;
|
||||||
INF("ui: %d",cur_group);
|
INF("ui: %d", cur_group);
|
||||||
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, layout)
|
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, layout)
|
||||||
{
|
{
|
||||||
grp++;
|
grp++;
|
||||||
if (cur_group == grp) name = layout->name;
|
if (cur_group == grp) name = layout->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((name) && (strchr(name, '/'))) name = strchr(name, '/') + 1;
|
if ((name) && (strchr(name, '/'))) name = strchr(name, '/') + 1;
|
||||||
|
|
||||||
if (e_config->xkb.only_label)
|
if (e_config->xkb.only_label)
|
||||||
{
|
{
|
||||||
EINA_LIST_FOREACH(instances, l, inst)
|
EINA_LIST_FOREACH(instances, l, inst)
|
||||||
|
@ -142,8 +141,8 @@ _xkb_update_icon(int cur_group)
|
||||||
evas_object_del(inst->o_xkbflag);
|
evas_object_del(inst->o_xkbflag);
|
||||||
inst->o_xkbflag = NULL;
|
inst->o_xkbflag = NULL;
|
||||||
}
|
}
|
||||||
e_theme_edje_object_set(inst->o_xkbswitch,
|
e_theme_edje_object_set(inst->o_xkbswitch,
|
||||||
"base/theme/modules/xkbswitch",
|
"base/theme/modules/xkbswitch",
|
||||||
"modules/xkbswitch/noflag");
|
"modules/xkbswitch/noflag");
|
||||||
edje_object_part_text_set(inst->o_xkbswitch,
|
edje_object_part_text_set(inst->o_xkbswitch,
|
||||||
"e.text.label", name);
|
"e.text.label", name);
|
||||||
|
@ -156,7 +155,7 @@ _xkb_update_icon(int cur_group)
|
||||||
if (!inst->o_xkbflag)
|
if (!inst->o_xkbflag)
|
||||||
inst->o_xkbflag = e_icon_add(inst->gcc->gadcon->evas);
|
inst->o_xkbflag = e_icon_add(inst->gcc->gadcon->evas);
|
||||||
e_theme_edje_object_set(inst->o_xkbswitch,
|
e_theme_edje_object_set(inst->o_xkbswitch,
|
||||||
"base/theme/modules/xkbswitch",
|
"base/theme/modules/xkbswitch",
|
||||||
"modules/xkbswitch/main");
|
"modules/xkbswitch/main");
|
||||||
e_xkb_e_icon_flag_setup(inst->o_xkbflag, name);
|
e_xkb_e_icon_flag_setup(inst->o_xkbflag, name);
|
||||||
edje_object_part_swallow(inst->o_xkbswitch, "e.swallow.flag",
|
edje_object_part_swallow(inst->o_xkbswitch, "e.swallow.flag",
|
||||||
|
@ -170,13 +169,13 @@ _xkb_update_icon(int cur_group)
|
||||||
/* LOCAL STATIC FUNCTIONS */
|
/* LOCAL STATIC FUNCTIONS */
|
||||||
|
|
||||||
static E_Gadcon_Client *
|
static E_Gadcon_Client *
|
||||||
_gc_init(E_Gadcon *gc, const char *gcname, const char *id, const char *style)
|
_gc_init(E_Gadcon *gc, const char *gcname, const char *id, const char *style)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
if (e_config->xkb.used_layouts)
|
if (e_config->xkb.used_layouts)
|
||||||
name = ((E_Config_XKB_Layout*)
|
name = ((E_Config_XKB_Layout *)
|
||||||
eina_list_data_get(e_config->xkb.used_layouts))->name;
|
eina_list_data_get(e_config->xkb.used_layouts))->name;
|
||||||
else name = NULL;
|
else name = NULL;
|
||||||
|
|
||||||
|
@ -185,12 +184,12 @@ _gc_init(E_Gadcon *gc, const char *gcname, const char *id, const char *style)
|
||||||
/* The gadget */
|
/* The gadget */
|
||||||
inst->o_xkbswitch = edje_object_add(gc->evas);
|
inst->o_xkbswitch = edje_object_add(gc->evas);
|
||||||
if (e_config->xkb.only_label)
|
if (e_config->xkb.only_label)
|
||||||
e_theme_edje_object_set(inst->o_xkbswitch,
|
e_theme_edje_object_set(inst->o_xkbswitch,
|
||||||
"base/theme/modules/xkbswitch",
|
"base/theme/modules/xkbswitch",
|
||||||
"modules/xkbswitch/noflag");
|
"modules/xkbswitch/noflag");
|
||||||
else
|
else
|
||||||
e_theme_edje_object_set(inst->o_xkbswitch,
|
e_theme_edje_object_set(inst->o_xkbswitch,
|
||||||
"base/theme/modules/xkbswitch",
|
"base/theme/modules/xkbswitch",
|
||||||
"modules/xkbswitch/main");
|
"modules/xkbswitch/main");
|
||||||
edje_object_part_text_set(inst->o_xkbswitch, "e.text.label",
|
edje_object_part_text_set(inst->o_xkbswitch, "e.text.label",
|
||||||
e_xkb_layout_name_reduce(name));
|
e_xkb_layout_name_reduce(name));
|
||||||
|
@ -207,34 +206,34 @@ _gc_init(E_Gadcon *gc, const char *gcname, const char *id, const char *style)
|
||||||
inst->o_xkbflag);
|
inst->o_xkbflag);
|
||||||
}
|
}
|
||||||
else inst->o_xkbflag = NULL;
|
else inst->o_xkbflag = NULL;
|
||||||
/* e_config->xkb.used_layout */
|
/* e_config->xkb.used_layout */
|
||||||
/* Hook some menus */
|
/* Hook some menus */
|
||||||
evas_object_event_callback_add(inst->o_xkbswitch, EVAS_CALLBACK_MOUSE_DOWN,
|
evas_object_event_callback_add(inst->o_xkbswitch, EVAS_CALLBACK_MOUSE_DOWN,
|
||||||
_e_xkb_cb_mouse_down, inst);
|
_e_xkb_cb_mouse_down, inst);
|
||||||
/* Make the list know about the instance */
|
/* Make the list know about the instance */
|
||||||
instances = eina_list_append(instances, inst);
|
instances = eina_list_append(instances, inst);
|
||||||
|
|
||||||
return inst->gcc;
|
return inst->gcc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gc_shutdown(E_Gadcon_Client *gcc)
|
_gc_shutdown(E_Gadcon_Client *gcc)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst;
|
||||||
|
|
||||||
if (!(inst = gcc->data)) return;
|
if (!(inst = gcc->data)) return;
|
||||||
instances = eina_list_remove(instances, inst);
|
instances = eina_list_remove(instances, inst);
|
||||||
|
|
||||||
if (inst->lmenu)
|
if (inst->lmenu)
|
||||||
{
|
{
|
||||||
e_menu_post_deactivate_callback_set(inst->lmenu, NULL, NULL);
|
e_menu_post_deactivate_callback_set(inst->lmenu, NULL, NULL);
|
||||||
e_object_del(E_OBJECT(inst->lmenu));
|
e_object_del(E_OBJECT(inst->lmenu));
|
||||||
inst->lmenu = NULL;
|
inst->lmenu = NULL;
|
||||||
}
|
}
|
||||||
if (inst->o_xkbswitch)
|
if (inst->o_xkbswitch)
|
||||||
{
|
{
|
||||||
evas_object_event_callback_del(inst->o_xkbswitch,
|
evas_object_event_callback_del(inst->o_xkbswitch,
|
||||||
EVAS_CALLBACK_MOUSE_DOWN,
|
EVAS_CALLBACK_MOUSE_DOWN,
|
||||||
_e_xkb_cb_mouse_down);
|
_e_xkb_cb_mouse_down);
|
||||||
evas_object_del(inst->o_xkbswitch);
|
evas_object_del(inst->o_xkbswitch);
|
||||||
evas_object_del(inst->o_xkbflag);
|
evas_object_del(inst->o_xkbflag);
|
||||||
|
@ -243,7 +242,7 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__)
|
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__)
|
||||||
{
|
{
|
||||||
e_gadcon_client_aspect_set(gcc, 16, 16);
|
e_gadcon_client_aspect_set(gcc, 16, 16);
|
||||||
e_gadcon_client_min_size_set(gcc, 16, 16);
|
e_gadcon_client_min_size_set(gcc, 16, 16);
|
||||||
|
@ -256,21 +255,21 @@ _gc_label(const E_Gadcon_Client_Class *client_class __UNUSED__)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
_gc_id_new(const E_Gadcon_Client_Class *client_class)
|
_gc_id_new(const E_Gadcon_Client_Class *client_class)
|
||||||
{
|
{
|
||||||
static char buf[4096];
|
static char buf[4096];
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s.%d", client_class->name,
|
snprintf(buf, sizeof(buf), "%s.%d", client_class->name,
|
||||||
eina_list_count(instances) + 1);
|
eina_list_count(instances) + 1);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_gc_icon(const E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
|
_gc_icon(const E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
|
||||||
{
|
{
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s/e-module-xkbswitch.edj", _xkb.module->dir);
|
snprintf(buf, sizeof(buf), "%s/e-module-xkbswitch.edj", _xkb.module->dir);
|
||||||
o = edje_object_add(evas);
|
o = edje_object_add(evas);
|
||||||
edje_object_file_set(o, buf, "icon");
|
edje_object_file_set(o, buf, "icon");
|
||||||
|
@ -283,16 +282,18 @@ _xkb_changed(void *data __UNUSED__, int type __UNUSED__, void *event_info __UNUS
|
||||||
_xkb_update_icon((int)(intptr_t)data);
|
_xkb_update_icon((int)(intptr_t)data);
|
||||||
return ECORE_CALLBACK_PASS_ON;
|
return ECORE_CALLBACK_PASS_ON;
|
||||||
}
|
}
|
||||||
static Eina_Bool
|
|
||||||
_xkb_changed_state(void *data __UNUSED__,int type __UNUSED__,void *event __UNUSED__)
|
|
||||||
{
|
|
||||||
Ecore_X_Event_Xkb *ev=(Ecore_X_Event_Xkb *)event;
|
|
||||||
|
|
||||||
INF("xkb group %d",ev->group);
|
static Eina_Bool
|
||||||
|
_xkb_changed_state(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
|
||||||
|
{
|
||||||
|
Ecore_X_Event_Xkb *ev = (Ecore_X_Event_Xkb *)event;
|
||||||
|
|
||||||
|
INF("xkb group %d", ev->group);
|
||||||
e_config->xkb.cur_group = ev->group;
|
e_config->xkb.cur_group = ev->group;
|
||||||
_xkb_update_icon(ev->group);
|
_xkb_update_icon(ev->group);
|
||||||
return ECORE_CALLBACK_PASS_ON;
|
return ECORE_CALLBACK_PASS_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int
|
static int
|
||||||
_xkb_menu_items_sort(const void *data1, const void *data2)
|
_xkb_menu_items_sort(const void *data1, const void *data2)
|
||||||
|
@ -300,27 +301,28 @@ _xkb_menu_items_sort(const void *data1, const void *data2)
|
||||||
const E_Config_XKB_Layout *cl1 = data1;
|
const E_Config_XKB_Layout *cl1 = data1;
|
||||||
const E_Config_XKB_Layout *cl2 = data2;
|
const E_Config_XKB_Layout *cl2 = data2;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
v = strcmp(cl1->name, cl2->name);
|
v = strcmp(cl1->name, cl2->name);
|
||||||
if (!v) v = strcmp(cl1->model, cl2->model);
|
if (!v) v = strcmp(cl1->model, cl2->model);
|
||||||
if (!v) v = strcmp(cl1->variant, cl2->variant);
|
if (!v) v = strcmp(cl1->variant, cl2->variant);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
static void
|
static void
|
||||||
_e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
_e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
||||||
{
|
{
|
||||||
Evas_Event_Mouse_Down *ev = event;
|
Evas_Event_Mouse_Down *ev = event;
|
||||||
Instance *inst = data;
|
Instance *inst = data;
|
||||||
E_Menu *m;
|
E_Menu *m;
|
||||||
|
|
||||||
if (!inst) return;
|
if (!inst) return;
|
||||||
|
|
||||||
if (ev->button == 3) /* Right-click utility menu */
|
if (ev->button == 3) /* Right-click utility menu */
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
E_Menu_Item *mi;
|
E_Menu_Item *mi;
|
||||||
|
|
||||||
/* The menu and menu item */
|
/* The menu and menu item */
|
||||||
m = e_menu_new();
|
m = e_menu_new();
|
||||||
mi = e_menu_item_new(m);
|
mi = e_menu_item_new(m);
|
||||||
|
@ -329,15 +331,15 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
|
||||||
e_util_menu_item_theme_icon_set(mi, "preferences-system");
|
e_util_menu_item_theme_icon_set(mi, "preferences-system");
|
||||||
e_menu_item_callback_set(mi, _e_xkb_cb_menu_configure, NULL);
|
e_menu_item_callback_set(mi, _e_xkb_cb_menu_configure, NULL);
|
||||||
/* Append into the util menu */
|
/* Append into the util menu */
|
||||||
m = e_gadcon_client_util_menu_items_append(inst->gcc,
|
m = e_gadcon_client_util_menu_items_append(inst->gcc,
|
||||||
m, 0);
|
m, 0);
|
||||||
/* Coords */
|
/* Coords */
|
||||||
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y,
|
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
/* Activate - we show the menu relative to the gadget */
|
/* Activate - we show the menu relative to the gadget */
|
||||||
e_menu_activate_mouse(m,
|
e_menu_activate_mouse(m,
|
||||||
e_util_zone_current_get(e_manager_current_get()),
|
e_util_zone_current_get(e_manager_current_get()),
|
||||||
(x + ev->output.x), (y + ev->output.y), 1, 1,
|
(x + ev->output.x), (y + ev->output.y), 1, 1,
|
||||||
E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
|
E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
|
||||||
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
|
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
|
||||||
EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
||||||
|
@ -346,7 +348,7 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
|
||||||
{
|
{
|
||||||
Evas_Coord x, y, w, h;
|
Evas_Coord x, y, w, h;
|
||||||
int cx, cy;
|
int cx, cy;
|
||||||
|
|
||||||
/* Coordinates and sizing */
|
/* Coordinates and sizing */
|
||||||
evas_object_geometry_get(inst->o_xkbswitch, &x, &y, &w, &h);
|
evas_object_geometry_get(inst->o_xkbswitch, &x, &y, &w, &h);
|
||||||
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy,
|
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy,
|
||||||
|
@ -364,9 +366,9 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
|
||||||
int dir;
|
int dir;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
int grp = -1;
|
int grp = -1;
|
||||||
|
|
||||||
mi = e_menu_item_new(inst->lmenu);
|
mi = e_menu_item_new(inst->lmenu);
|
||||||
|
|
||||||
e_menu_item_label_set(mi, _("Settings"));
|
e_menu_item_label_set(mi, _("Settings"));
|
||||||
e_util_menu_item_theme_icon_set(mi, "preferences-system");
|
e_util_menu_item_theme_icon_set(mi, "preferences-system");
|
||||||
e_menu_item_callback_set(mi, _e_xkb_cb_menu_configure, NULL);
|
e_menu_item_callback_set(mi, _e_xkb_cb_menu_configure, NULL);
|
||||||
|
@ -378,9 +380,9 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
|
||||||
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
|
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
|
||||||
{
|
{
|
||||||
const char *name = cl->name;
|
const char *name = cl->name;
|
||||||
|
|
||||||
mi = e_menu_item_new(inst->lmenu);
|
mi = e_menu_item_new(inst->lmenu);
|
||||||
|
|
||||||
e_menu_item_radio_set(mi, 1);
|
e_menu_item_radio_set(mi, 1);
|
||||||
e_menu_item_radio_group_set(mi, 1);
|
e_menu_item_radio_group_set(mi, 1);
|
||||||
grp++;
|
grp++;
|
||||||
|
@ -388,80 +390,91 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
|
||||||
(mi, (grp == e_config->xkb.cur_group) ? 1 : 0);
|
(mi, (grp == e_config->xkb.cur_group) ? 1 : 0);
|
||||||
e_xkb_flag_file_get(buf, sizeof(buf), name);
|
e_xkb_flag_file_get(buf, sizeof(buf), name);
|
||||||
e_menu_item_icon_file_set(mi, buf);
|
e_menu_item_icon_file_set(mi, buf);
|
||||||
snprintf(buf, sizeof(buf), "%s (%s, %s)", cl->name,
|
snprintf(buf, sizeof(buf), "%s (%s, %s)", cl->name,
|
||||||
cl->model, cl->variant);
|
cl->model, cl->variant);
|
||||||
e_menu_item_label_set(mi, buf);
|
e_menu_item_label_set(mi, buf);
|
||||||
e_menu_item_callback_set(mi, _e_xkb_cb_lmenu_set, cl);
|
e_menu_item_callback_set(mi, _e_xkb_cb_lmenu_set, cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Deactivate callback */
|
/* Deactivate callback */
|
||||||
e_menu_post_deactivate_callback_set(inst->lmenu,
|
e_menu_post_deactivate_callback_set(inst->lmenu,
|
||||||
_e_xkb_cb_lmenu_post, inst);
|
_e_xkb_cb_lmenu_post, inst);
|
||||||
/* Proper menu orientation */
|
/* Proper menu orientation */
|
||||||
switch (inst->gcc->gadcon->orient)
|
switch (inst->gcc->gadcon->orient)
|
||||||
{
|
{
|
||||||
case E_GADCON_ORIENT_TOP:
|
case E_GADCON_ORIENT_TOP:
|
||||||
dir = E_MENU_POP_DIRECTION_DOWN;
|
dir = E_MENU_POP_DIRECTION_DOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_BOTTOM:
|
case E_GADCON_ORIENT_BOTTOM:
|
||||||
dir = E_MENU_POP_DIRECTION_UP;
|
dir = E_MENU_POP_DIRECTION_UP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_LEFT:
|
case E_GADCON_ORIENT_LEFT:
|
||||||
dir = E_MENU_POP_DIRECTION_RIGHT;
|
dir = E_MENU_POP_DIRECTION_RIGHT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_RIGHT:
|
case E_GADCON_ORIENT_RIGHT:
|
||||||
dir = E_MENU_POP_DIRECTION_LEFT;
|
dir = E_MENU_POP_DIRECTION_LEFT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_CORNER_TL:
|
case E_GADCON_ORIENT_CORNER_TL:
|
||||||
dir = E_MENU_POP_DIRECTION_DOWN;
|
dir = E_MENU_POP_DIRECTION_DOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_CORNER_TR:
|
case E_GADCON_ORIENT_CORNER_TR:
|
||||||
dir = E_MENU_POP_DIRECTION_DOWN;
|
dir = E_MENU_POP_DIRECTION_DOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_CORNER_BL:
|
case E_GADCON_ORIENT_CORNER_BL:
|
||||||
dir = E_MENU_POP_DIRECTION_UP;
|
dir = E_MENU_POP_DIRECTION_UP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_CORNER_BR:
|
case E_GADCON_ORIENT_CORNER_BR:
|
||||||
dir = E_MENU_POP_DIRECTION_UP;
|
dir = E_MENU_POP_DIRECTION_UP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_CORNER_LT:
|
case E_GADCON_ORIENT_CORNER_LT:
|
||||||
dir = E_MENU_POP_DIRECTION_RIGHT;
|
dir = E_MENU_POP_DIRECTION_RIGHT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_CORNER_RT:
|
case E_GADCON_ORIENT_CORNER_RT:
|
||||||
dir = E_MENU_POP_DIRECTION_LEFT;
|
dir = E_MENU_POP_DIRECTION_LEFT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_CORNER_LB:
|
case E_GADCON_ORIENT_CORNER_LB:
|
||||||
dir = E_MENU_POP_DIRECTION_RIGHT;
|
dir = E_MENU_POP_DIRECTION_RIGHT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_CORNER_RB:
|
case E_GADCON_ORIENT_CORNER_RB:
|
||||||
dir = E_MENU_POP_DIRECTION_LEFT;
|
dir = E_MENU_POP_DIRECTION_LEFT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_GADCON_ORIENT_FLOAT:
|
case E_GADCON_ORIENT_FLOAT:
|
||||||
case E_GADCON_ORIENT_HORIZ:
|
case E_GADCON_ORIENT_HORIZ:
|
||||||
case E_GADCON_ORIENT_VERT:
|
case E_GADCON_ORIENT_VERT:
|
||||||
default:
|
default:
|
||||||
dir = E_MENU_POP_DIRECTION_AUTO;
|
dir = E_MENU_POP_DIRECTION_AUTO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
e_gadcon_locked_set(inst->gcc->gadcon, 1);
|
e_gadcon_locked_set(inst->gcc->gadcon, 1);
|
||||||
|
|
||||||
/* We display not relatively to the gadget, but similarly to
|
/* We display not relatively to the gadget, but similarly to
|
||||||
* the start menu - thus the need for direction etc.
|
* the start menu - thus the need for direction etc.
|
||||||
*/
|
*/
|
||||||
e_menu_activate_mouse(inst->lmenu,
|
e_menu_activate_mouse(inst->lmenu,
|
||||||
e_util_zone_current_get
|
e_util_zone_current_get
|
||||||
(e_manager_current_get()),
|
(e_manager_current_get()),
|
||||||
x, y, w, h, dir, ev->timestamp);
|
x, y, w, h, dir, ev->timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ev->button == 2) /* Middle click */
|
else if (ev->button == 2) /* Middle click */
|
||||||
e_xkb_layout_next();
|
e_xkb_layout_next();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_xkb_cb_lmenu_post(void *data, E_Menu *menu __UNUSED__)
|
_e_xkb_cb_lmenu_post(void *data, E_Menu *menu __UNUSED__)
|
||||||
{
|
{
|
||||||
Instance *inst = data;
|
Instance *inst = data;
|
||||||
|
|
||||||
|
@ -479,7 +492,7 @@ _e_xkb_cb_menu_configure(void *data __UNUSED__, E_Menu *mn, E_Menu_Item *mi __UN
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
_e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
||||||
{
|
{
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
void *ndata;
|
void *ndata;
|
||||||
|
@ -494,5 +507,6 @@ _e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED_
|
||||||
{
|
{
|
||||||
e_xkb_update(cur_group);
|
e_xkb_update(cur_group);
|
||||||
_xkb_update_icon(cur_group);
|
_xkb_update_icon(cur_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
typedef struct _Xkb
|
typedef struct _Xkb
|
||||||
{
|
{
|
||||||
E_Module *module;
|
E_Module *module;
|
||||||
E_Config_Dialog *cfd;
|
E_Config_Dialog *cfd;
|
||||||
Ecore_Event_Handler *evh;
|
Ecore_Event_Handler *evh;
|
||||||
} Xkb;
|
} Xkb;
|
||||||
|
|
||||||
|
@ -18,13 +18,13 @@ typedef struct _Xkb
|
||||||
|
|
||||||
EAPI extern E_Module_Api e_modapi;
|
EAPI extern E_Module_Api e_modapi;
|
||||||
|
|
||||||
EAPI void *e_modapi_init (E_Module *m);
|
EAPI void *e_modapi_init(E_Module *m);
|
||||||
EAPI int e_modapi_shutdown(E_Module *m);
|
EAPI int e_modapi_shutdown(E_Module *m);
|
||||||
EAPI int e_modapi_save (E_Module *m);
|
EAPI int e_modapi_save(E_Module *m);
|
||||||
|
|
||||||
void _xkb_update_icon(int);
|
void _xkb_update_icon(int);
|
||||||
E_Config_Dialog *_xkb_cfg_dialog(E_Container *con, const char *params);
|
E_Config_Dialog *_xkb_cfg_dialog(E_Container *con, const char *params);
|
||||||
|
|
||||||
extern Xkb _xkb;
|
extern Xkb _xkb;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -68,7 +68,7 @@ parse_rules(void)
|
||||||
models = eina_list_append(models, model);
|
models = eina_list_append(models, model);
|
||||||
|
|
||||||
/* read models here */
|
/* read models here */
|
||||||
for (;;)
|
for (;; )
|
||||||
{
|
{
|
||||||
if (fgets(buf, sizeof(buf), f))
|
if (fgets(buf, sizeof(buf), f))
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ parse_rules(void)
|
||||||
/* means end of section */
|
/* means end of section */
|
||||||
if (!buf[0]) break;
|
if (!buf[0]) break;
|
||||||
/* get rid of initial 2 spaces here */
|
/* get rid of initial 2 spaces here */
|
||||||
p = buf + 2;
|
p = buf + 2;
|
||||||
tmp = strdup(p);
|
tmp = strdup(p);
|
||||||
|
|
||||||
model = E_NEW(E_XKB_Model, 1);
|
model = E_NEW(E_XKB_Model, 1);
|
||||||
|
@ -91,7 +91,8 @@ parse_rules(void)
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
p += strlen(model->name);
|
p += strlen(model->name);
|
||||||
while (p[0] == ' ') ++p;
|
while (p[0] == ' ')
|
||||||
|
++p;
|
||||||
|
|
||||||
model->description = eina_stringshare_add(p);
|
model->description = eina_stringshare_add(p);
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ parse_rules(void)
|
||||||
if (!fgets(buf, sizeof(buf), f)) goto err;
|
if (!fgets(buf, sizeof(buf), f)) goto err;
|
||||||
|
|
||||||
/* read layouts here */
|
/* read layouts here */
|
||||||
for (;;)
|
for (;; )
|
||||||
{
|
{
|
||||||
if (fgets(buf, sizeof(buf), f))
|
if (fgets(buf, sizeof(buf), f))
|
||||||
{
|
{
|
||||||
|
@ -114,11 +115,11 @@ parse_rules(void)
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
n = strchr(buf, '\n');
|
n = strchr(buf, '\n');
|
||||||
if (n) *n = '\0';
|
if (n) *n = '\0';
|
||||||
|
|
||||||
if (!buf[0]) break;
|
if (!buf[0]) break;
|
||||||
|
|
||||||
p = buf + 2;
|
p = buf + 2;
|
||||||
tmp = strdup(p);
|
tmp = strdup(p);
|
||||||
|
|
||||||
layout = E_NEW(E_XKB_Layout, 1);
|
layout = E_NEW(E_XKB_Layout, 1);
|
||||||
|
@ -127,7 +128,8 @@ parse_rules(void)
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
p += strlen(layout->name);
|
p += strlen(layout->name);
|
||||||
while (p[0] == ' ') ++p;
|
while (p[0] == ' ')
|
||||||
|
++p;
|
||||||
|
|
||||||
variant = E_NEW(E_XKB_Variant, 1);
|
variant = E_NEW(E_XKB_Variant, 1);
|
||||||
variant->name = eina_stringshare_add("basic");
|
variant->name = eina_stringshare_add("basic");
|
||||||
|
@ -146,21 +148,21 @@ parse_rules(void)
|
||||||
if (!fgets(buf, sizeof(buf), f)) goto err;
|
if (!fgets(buf, sizeof(buf), f)) goto err;
|
||||||
|
|
||||||
/* read variants here */
|
/* read variants here */
|
||||||
for (;;)
|
for (;; )
|
||||||
{
|
{
|
||||||
if (fgets(buf, sizeof(buf), f))
|
if (fgets(buf, sizeof(buf), f))
|
||||||
{
|
{
|
||||||
char *n;
|
char *n;
|
||||||
char *p;
|
char *p;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
char *tok;
|
char *tok;
|
||||||
|
|
||||||
n = strchr(buf, '\n');
|
n = strchr(buf, '\n');
|
||||||
if (n) *n = '\0';
|
if (n) *n = '\0';
|
||||||
|
|
||||||
if (!buf[0]) break;
|
if (!buf[0]) break;
|
||||||
|
|
||||||
p = buf + 2;
|
p = buf + 2;
|
||||||
tmp = strdup(p);
|
tmp = strdup(p);
|
||||||
|
|
||||||
variant = E_NEW(E_XKB_Variant, 1);
|
variant = E_NEW(E_XKB_Variant, 1);
|
||||||
|
@ -173,7 +175,8 @@ parse_rules(void)
|
||||||
layout->variants = eina_list_append(layout->variants, variant);
|
layout->variants = eina_list_append(layout->variants, variant);
|
||||||
|
|
||||||
p += strlen(variant->name);
|
p += strlen(variant->name);
|
||||||
while (p[0] == ' ') ++p;
|
while (p[0] == ' ')
|
||||||
|
++p;
|
||||||
p += strlen(tok);
|
p += strlen(tok);
|
||||||
p += 2;
|
p += 2;
|
||||||
|
|
||||||
|
@ -189,7 +192,7 @@ parse_rules(void)
|
||||||
if (!fgets(buf, sizeof(buf), f)) goto err;
|
if (!fgets(buf, sizeof(buf), f)) goto err;
|
||||||
|
|
||||||
/* read options here */
|
/* read options here */
|
||||||
for (;;)
|
for (;; )
|
||||||
{
|
{
|
||||||
if (fgets(buf, sizeof(buf), f))
|
if (fgets(buf, sizeof(buf), f))
|
||||||
{
|
{
|
||||||
|
@ -199,46 +202,48 @@ parse_rules(void)
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
n = strchr(buf, '\n');
|
n = strchr(buf, '\n');
|
||||||
if (n) *n = '\0';
|
if (n) *n = '\0';
|
||||||
|
|
||||||
if (!buf[0]) break;
|
if (!buf[0]) break;
|
||||||
|
|
||||||
p = buf + 2;
|
p = buf + 2;
|
||||||
tmp = strdup(p);
|
tmp = strdup(p);
|
||||||
name = strtok(tmp, " ");
|
name = strtok(tmp, " ");
|
||||||
|
|
||||||
p += strlen(name);
|
p += strlen(name);
|
||||||
while (p[0] == ' ') ++p;
|
while (p[0] == ' ')
|
||||||
|
++p;
|
||||||
|
|
||||||
/* skip "grp" options for switching kbd layouts */
|
/* skip "grp" options for switching kbd layouts */
|
||||||
//if (strncmp(name, "grp", 3))
|
//if (strncmp(name, "grp", 3))
|
||||||
{
|
{
|
||||||
if (!strchr(name, ':'))
|
if (!strchr(name, ':'))
|
||||||
{
|
{
|
||||||
group = E_NEW(E_XKB_Option_Group, 1);
|
group = E_NEW(E_XKB_Option_Group, 1);
|
||||||
|
|
||||||
/* A hack to get it to parse right if
|
/* A hack to get it to parse right if
|
||||||
* the group name contains a space
|
* the group name contains a space
|
||||||
*/
|
*/
|
||||||
if (strstr(p, " "))
|
if (strstr(p, " "))
|
||||||
{
|
{
|
||||||
p = strstr(p, " ");
|
p = strstr(p, " ");
|
||||||
while (p[0] == ' ') ++p;
|
while (p[0] == ' ')
|
||||||
}
|
++p;
|
||||||
|
}
|
||||||
|
|
||||||
group->description = eina_stringshare_add(p);
|
group->description = eina_stringshare_add(p);
|
||||||
|
|
||||||
optgroups = eina_list_append(optgroups, group);
|
optgroups = eina_list_append(optgroups, group);
|
||||||
}
|
}
|
||||||
else if (group)
|
else if (group)
|
||||||
{
|
{
|
||||||
option = E_NEW(E_XKB_Option, 1);
|
option = E_NEW(E_XKB_Option, 1);
|
||||||
option->name = eina_stringshare_add(name);
|
option->name = eina_stringshare_add(name);
|
||||||
option->description = eina_stringshare_add(p);
|
option->description = eina_stringshare_add(p);
|
||||||
group->options = eina_list_append(group->options,
|
group->options = eina_list_append(group->options,
|
||||||
option);
|
option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
@ -259,10 +264,10 @@ void
|
||||||
clear_rules(void)
|
clear_rules(void)
|
||||||
{
|
{
|
||||||
E_XKB_Option_Group *og;
|
E_XKB_Option_Group *og;
|
||||||
E_XKB_Variant *v;
|
E_XKB_Variant *v;
|
||||||
E_XKB_Option *o;
|
E_XKB_Option *o;
|
||||||
E_XKB_Layout *la;
|
E_XKB_Layout *la;
|
||||||
E_XKB_Model *m;
|
E_XKB_Model *m;
|
||||||
|
|
||||||
EINA_LIST_FREE(layouts, la)
|
EINA_LIST_FREE(layouts, la)
|
||||||
{
|
{
|
||||||
|
@ -333,3 +338,4 @@ layout_sort_by_name_cb(const void *data1, const void *data2)
|
||||||
|
|
||||||
return strcmp(l1->name, l2);
|
return strcmp(l1->name, l2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,41 +8,41 @@
|
||||||
|
|
||||||
typedef struct _E_XKB_Model
|
typedef struct _E_XKB_Model
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *description;
|
const char *description;
|
||||||
} E_XKB_Model;
|
} E_XKB_Model;
|
||||||
|
|
||||||
typedef struct _E_XKB_Variant
|
typedef struct _E_XKB_Variant
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *description;
|
const char *description;
|
||||||
} E_XKB_Variant;
|
} E_XKB_Variant;
|
||||||
|
|
||||||
typedef struct _E_XKB_Layout
|
typedef struct _E_XKB_Layout
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *description;
|
const char *description;
|
||||||
|
|
||||||
Eina_List *variants;
|
Eina_List *variants;
|
||||||
} E_XKB_Layout;
|
} E_XKB_Layout;
|
||||||
|
|
||||||
typedef struct _E_XKB_Option_Group
|
typedef struct _E_XKB_Option_Group
|
||||||
{
|
{
|
||||||
const char *description;
|
const char *description;
|
||||||
Eina_List *options;
|
Eina_List *options;
|
||||||
} E_XKB_Option_Group;
|
} E_XKB_Option_Group;
|
||||||
|
|
||||||
typedef struct _E_XKB_Option
|
typedef struct _E_XKB_Option
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *description;
|
const char *description;
|
||||||
} E_XKB_Option;
|
} E_XKB_Option;
|
||||||
|
|
||||||
int parse_rules(void);
|
int parse_rules(void);
|
||||||
void clear_rules(void);
|
void clear_rules(void);
|
||||||
void find_rules(void);
|
void find_rules(void);
|
||||||
|
|
||||||
int layout_sort_by_name_cb(const void *data1, const void *data2);
|
int layout_sort_by_name_cb(const void *data1, const void *data2);
|
||||||
|
|
||||||
extern Eina_List *models;
|
extern Eina_List *models;
|
||||||
extern Eina_List *layouts;
|
extern Eina_List *layouts;
|
||||||
|
|
Loading…
Reference in New Issue