xkb config put into core. xkb layout is set on startup now (last one

used). removed setting up and deletion of keybindings - now its in
normal keybindings config territory. set them up yourself. much more
solid now. happy.



SVN revision: 70552
devs/princeamd/enlightenment-0.17-elive
Carsten Haitzler 11 years ago
parent 70d21a1f44
commit 5a00507e2b
  1. 11
      config/illume/e.src
  2. 11
      config/standard/e.src
  3. 1
      po/POTFILES.in
  4. 2
      src/bin/Makefile.am
  5. 29
      src/bin/e_actions.c
  6. 48
      src/bin/e_config.c
  7. 24
      src/bin/e_config.h
  8. 1
      src/bin/e_includes.h
  9. 7
      src/bin/e_main.c
  10. 181
      src/bin/e_xkb.c
  11. 19
      src/bin/e_xkb.h
  12. 4
      src/modules/xkbswitch/Makefile.am
  13. 93
      src/modules/xkbswitch/e_mod_config.c
  14. 194
      src/modules/xkbswitch/e_mod_keybindings.c
  15. 16
      src/modules/xkbswitch/e_mod_keybindings.h
  16. 394
      src/modules/xkbswitch/e_mod_main.c
  17. 87
      src/modules/xkbswitch/e_mod_main.h

@ -1,5 +1,5 @@
group "E_Config" struct {
value "config_version" int: 65864;
value "config_version" int: 65865;
value "show_splash" int: 1;
value "init_default_theme" string: "default.edj";
value "desktop_default_name" string: "Desktop %i, %i";
@ -1763,4 +1763,13 @@ group "E_Config" struct {
value "icon" string: "DESKTOP";
}
}
group "xkb.used_layouts" list {
group "E_Config_XKB_Layout" struct {
value "name" string: "us";
value "model" string: "default";
value "variant" string: "basic";
}
}
value "xkb.only_label" int: 0;
value "xkb.default_model" string: "default";
}

@ -1,5 +1,5 @@
group "E_Config" struct {
value "config_version" int: 65864;
value "config_version" int: 65865;
value "show_splash" int: 1;
value "init_default_theme" string: "default.edj";
value "desktop_default_name" string: "Desktop %i, %i";
@ -1978,4 +1978,13 @@ group "E_Config" struct {
value "priority" int: 0;
}
}
group "xkb.used_layouts" list {
group "E_Config_XKB_Layout" struct {
value "name" string: "us";
value "model" string: "default";
value "variant" string: "basic";
}
}
value "xkb.only_label" int: 0;
value "xkb.default_model" string: "default";
}

@ -125,6 +125,7 @@ src/bin/e_widget_table.c
src/bin/e_widget_textblock.c
src/bin/e_win.c
src/bin/e_xinerama.c
src/bin/e_xkb.c
src/bin/e_zone.c
src/modules/battery/e_mod_config.c
src/modules/battery/e_mod_main.c

@ -183,6 +183,7 @@ e_widget_toolbar.h \
e_widget_toolbook.h \
e_win.h \
e_xinerama.h \
e_xkb.h \
e_xsettings.h \
e_zone.h
@ -337,6 +338,7 @@ e_widget_toolbar.c \
e_widget_toolbook.c \
e_win.c \
e_xinerama.c \
e_xkb.c \
e_xsettings.c \
e_zone.c \
$(ENLIGHTENMENTHEADERS)

@ -2672,6 +2672,22 @@ ACT_FN_GO(backlight_adjust, )
e_backlight_level_set(zone, e_backlight_level_get(zone) + ((double)v / 100.0), -1.0);
}
ACT_FN_GO(kbd_layout, )
{
if (!params) return;
// e_xkb_layout_set(params);
}
ACT_FN_GO(kbd_layout_next, __UNUSED__)
{
// e_xkb_layout_next();
}
ACT_FN_GO(kbd_layout_prev, __UNUSED__)
{
// e_xkb_layout_prev();
}
/* local subsystem globals */
static Eina_Hash *actions = NULL;
static Eina_List *action_list = NULL;
@ -3133,6 +3149,19 @@ e_actions_init(void)
ACT_END_KEY(delayed_action);
ACT_END_MOUSE(delayed_action);
/* xkb */
ACT_GO(kbd_layout);
e_action_predef_name_set(N_("Keyboard Layouts"),
N_("Use keyboard layout"), "kbd_layout",
NULL, "syntax: Keyboard-layout-name, example: us", 1);
ACT_GO(kbd_layout_next);
e_action_predef_name_set(N_("Keyboard Layouts"),
N_("Next keyboard layout"), "kbd_layout_next",
NULL, NULL, 0);
ACT_GO(kbd_layout_prev);
e_action_predef_name_set(N_("Keyboard Layouts"),
N_("Previous keyboard layout"), "kbd_layout_prev",
NULL, NULL, 0);
return 1;
}

@ -58,6 +58,8 @@ static E_Config_DD *_e_config_randr_serialized_output_policy_edd = NULL;
static E_Config_DD *_e_config_randr_serialized_output_edd = NULL;
static E_Config_DD *_e_config_randr_mode_info_edd = NULL;
static E_Config_DD *_e_config_randr_serialized_crtc_edd = NULL;
static E_Config_DD *_e_config_xkb_layout_edd = NULL;
static E_Config_DD *_e_config_xkb_option_edd = NULL;
EAPI int E_EVENT_CONFIG_ICON_THEME = 0;
@ -605,6 +607,24 @@ e_config_init(void)
E_CONFIG_LIST(D, T, serialized_setups_12, _e_config_randr_serialized_setup_12_edd);
E_CONFIG_LIST(D, T, outputs_policies, _e_config_randr_serialized_output_policy_edd);
_e_config_xkb_layout_edd = E_CONFIG_DD_NEW("E_Config_XKB_Layout",
E_Config_XKB_Layout);
#undef T
#undef D
#define T E_Config_XKB_Layout
#define D _e_config_xkb_layout_edd
E_CONFIG_VAL(D, T, name, STR);
E_CONFIG_VAL(D, T, model, STR);
E_CONFIG_VAL(D, T, variant, STR);
_e_config_xkb_option_edd = E_CONFIG_DD_NEW("E_Config_XKB_Option",
E_Config_XKB_Option);
#undef T
#undef D
#define T E_Config_XKB_Option
#define D _e_config_xkb_option_edd
E_CONFIG_VAL(D, T, name, STR);
_e_config_edd = E_CONFIG_DD_NEW("E_Config", E_Config);
#undef T
#undef D
@ -891,7 +911,12 @@ e_config_init(void)
E_CONFIG_VAL(D, T, update.check, UCHAR);
E_CONFIG_VAL(D, T, update.later, UCHAR);
E_CONFIG_LIST(D, T, xkb.used_layouts, _e_config_xkb_layout_edd);
E_CONFIG_LIST(D, T, xkb.used_options, _e_config_xkb_option_edd);
E_CONFIG_VAL(D, T, xkb.only_label, INT);
E_CONFIG_VAL(D, T, xkb.default_model, STR);
e_config_load();
e_config_save_queue();
@ -924,6 +949,8 @@ e_config_shutdown(void)
E_CONFIG_DD_FREE(_e_config_mime_icon_edd);
E_CONFIG_DD_FREE(_e_config_syscon_action_edd);
E_CONFIG_DD_FREE(_e_config_env_var_edd);
E_CONFIG_DD_FREE(_e_config_xkb_layout_edd);
E_CONFIG_DD_FREE(_e_config_xkb_option_edd);
//E_CONFIG_DD_FREE(_e_config_randr_serialized_setup_edd);
return 1;
}
@ -1870,9 +1897,28 @@ _e_config_free(E_Config *ecf)
E_Path_Dir *epd;
E_Remember *rem;
E_Config_Env_Var *evr;
E_Config_XKB_Layout *cl;
E_Config_XKB_Option *op;
if (!ecf) return;
if (e_config->xkb.default_model)
eina_stringshare_del(e_config->xkb.default_model);
EINA_LIST_FREE(e_config->xkb.used_layouts, cl)
{
eina_stringshare_del(cl->name);
eina_stringshare_del(cl->model);
eina_stringshare_del(cl->variant);
E_FREE(cl);
}
EINA_LIST_FREE(e_config->xkb.used_options, op)
{
eina_stringshare_del(op->name);
E_FREE(op);
}
EINA_LIST_FREE(ecf->modules, em)
{
if (em->name) eina_stringshare_del(em->name);

@ -20,6 +20,9 @@ typedef struct _E_Config_Shelf_Desk E_Config_Shelf_Desk;
typedef struct _E_Config_Mime_Icon E_Config_Mime_Icon;
typedef struct _E_Config_Syscon_Action E_Config_Syscon_Action;
typedef struct _E_Config_Env_Var E_Config_Env_Var;
typedef struct _E_Config_XKB_Layout E_Config_XKB_Layout;
typedef struct _E_Config_XKB_Option E_Config_XKB_Option;
typedef struct _E_Event_Config_Icon_Theme E_Event_Config_Icon_Theme;
#else
@ -33,7 +36,7 @@ typedef struct _E_Event_Config_Icon_Theme E_Event_Config_Icon_Theme;
/* increment this whenever a new set of config values are added but the users
* config doesn't need to be wiped - simply new values need to be put in
*/
#define E_CONFIG_FILE_GENERATION 0x0148
#define E_CONFIG_FILE_GENERATION 0x0149
#define E_CONFIG_FILE_VERSION ((E_CONFIG_FILE_EPOCH << 16) | E_CONFIG_FILE_GENERATION)
struct _E_Config
@ -340,6 +343,13 @@ struct _E_Config
unsigned char check; // INTERNAL
unsigned char later; // INTERNAL
} update;
struct {
Eina_List *used_layouts;
Eina_List *used_options;
int only_label;
const char *default_model;
} xkb;
};
struct _E_Config_Env_Var
@ -512,6 +522,18 @@ struct _E_Event_Config_Icon_Theme
const char *icon_theme;
};
struct _E_Config_XKB_Layout
{
const char *name;
const char *model;
const char *variant;
};
struct _E_Config_XKB_Option
{
const char *name;
};
EINTERN int e_config_init(void);
EINTERN int e_config_shutdown(void);

@ -142,3 +142,4 @@
#include "e_deskenv.h"
#include "e_xsettings.h"
#include "e_update.h"
#include "e_xkb.h"

@ -819,6 +819,13 @@ main(int argc, char **argv)
_e_main_shutdown(-1);
}
TS("E_Mouse Init Done");
TS("E_Xkb Init");
if (!e_xkb_init())
{
e_error_message_show(_("Enlightenment cannot setup XKB Keyboard layouts."));
_e_main_shutdown(-1);
}
TS("E_Xkb Init Done");
if (e_config->show_splash)
e_init_status_set(_("Setup Bindings"));

@ -0,0 +1,181 @@
#include "e.h"
static void _e_xkb_update_event(void);
EAPI int E_EVENT_XKB_CHANGED = 0;
/* externally accessible functions */
EAPI int
e_xkb_init(void)
{
E_EVENT_XKB_CHANGED = ecore_event_type_new();
e_xkb_update();
return 1;
}
EAPI int
e_xkb_shutdown(void)
{
return 1;
}
EAPI void
e_xkb_update(void)
{
E_Config_XKB_Layout *cl;
E_Config_XKB_Option *op;
Eina_List *l;
Eina_Strbuf *buf;
if (!e_config->xkb.used_layouts) return;
/* We put an empty -option here in order to override all previously
* set options.
*/
buf = eina_strbuf_new();
eina_strbuf_append(buf, "setxkbmap '");
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
{
eina_strbuf_append(buf, cl->name);
break;
//if (l->next) eina_strbuf_append(buf, ",");
}
eina_strbuf_append(buf, "'");
eina_strbuf_append(buf, " -variant '");
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
{
eina_strbuf_append(buf, cl->variant);
eina_strbuf_append(buf, ",");
break;
}
eina_strbuf_append(buf, "'");
cl = eina_list_data_get(e_config->xkb.used_layouts);
if (cl->model)
{
eina_strbuf_append(buf, " -model '");
if (strcmp(cl->model, "default"))
eina_strbuf_append(buf, cl->model);
else if ((e_config->xkb.default_model) &&
(strcmp(e_config->xkb.default_model, "default")))
eina_strbuf_append(buf, e_config->xkb.default_model);
else
eina_strbuf_append(buf, "default");
eina_strbuf_append(buf, "'");
}
EINA_LIST_FOREACH(e_config->xkb.used_options, l, op)
{
if (op->name)
{
eina_strbuf_append(buf, " -option '");
eina_strbuf_append(buf, op->name);
eina_strbuf_append(buf, "'");
}
break;
}
ecore_exe_run(eina_strbuf_string_get(buf), NULL);
eina_strbuf_free(buf);
}
EAPI void
e_xkb_layout_next(void)
{
void *odata, *ndata;
Eina_List *l;
odata = eina_list_data_get(e_config->xkb.used_layouts);
EINA_LIST_FOREACH(eina_list_next(e_config->xkb.used_layouts), l, ndata)
{
eina_list_data_set(eina_list_prev(l), ndata);
}
eina_list_data_set(eina_list_last(e_config->xkb.used_layouts), odata);
e_xkb_update();
_e_xkb_update_event();
e_config_save_queue();
}
EAPI void
e_xkb_layout_prev(void)
{
void *odata, *ndata;
Eina_List *l;
odata = eina_list_data_get(eina_list_last(e_config->xkb.used_layouts));
for (l = e_config->xkb.used_layouts, ndata = eina_list_data_get(l);
l; l = eina_list_next(l))
{
if (eina_list_next(l))
ndata = eina_list_data_set(eina_list_next(l), ndata);
}
eina_list_data_set(e_config->xkb.used_layouts, odata);
e_xkb_update();
_e_xkb_update_event();
e_config_save_queue();
}
EAPI void
e_xkb_layout_set(const char *name)
{
Eina_List *l;
E_Config_XKB_Layout *cl;
if (!name) return;
EINA_LIST_FOREACH(eina_list_next(e_config->xkb.used_layouts), l, cl)
{
if (!cl->name) continue;
if (!strcmp(cl->name, name))
{
e_config->xkb.used_layouts =
eina_list_remove_list(e_config->xkb.used_layouts, l);
e_config->xkb.used_layouts =
eina_list_prepend(e_config->xkb.used_layouts, cl);
e_xkb_update();
_e_xkb_update_event();
break;
}
}
e_config_save_queue();
}
EAPI const char *
e_xkb_layout_name_reduce(const char *name)
{
if ((name) && (strchr(name, '/'))) name = strchr(name, '/') + 1;
return name;
}
EAPI void
e_xkb_e_icon_flag_setup(Evas_Object *eicon, const char *name)
{
int w, h;
char buf[PATH_MAX];
e_xkb_flag_file_get(buf, sizeof(buf), name);
e_icon_file_set(eicon, buf);
e_icon_size_get(eicon, &w, &h);
edje_extern_object_aspect_set(eicon, EDJE_ASPECT_CONTROL_BOTH, w, h);
}
EAPI void
e_xkb_flag_file_get(char *buf, size_t bufsize, const char *name)
{
name = e_xkb_layout_name_reduce(name);
snprintf(buf, bufsize, "%s/data/flags/%s_flag.png",
e_prefix_data_get(), name ? name : "unknown");
if (!ecore_file_exists(buf))
snprintf(buf, bufsize, "%s/data/flags/unknown_flag.png",
e_prefix_data_get());
}
static void
_e_xkb_update_event(void)
{
ecore_event_add(E_EVENT_XKB_CHANGED, NULL, NULL, NULL);
}

@ -0,0 +1,19 @@
#ifdef E_TYPEDEFS
#else
#ifndef E_XKB_H
#define E_XKB_H
EAPI int e_xkb_init(void);
EAPI int e_xkb_shutdown(void);
EAPI void e_xkb_update(void);
EAPI void e_xkb_layout_next(void);
EAPI void e_xkb_layout_prev(void);
EAPI void e_xkb_layout_set(const char *name);
EAPI const char *e_xkb_layout_name_reduce(const char *name);
EAPI void e_xkb_e_icon_flag_setup(Evas_Object *eicon, const char *name);
EAPI void e_xkb_flag_file_get(char *buf, size_t bufsize, const char *name);
extern EAPI int E_EVENT_XKB_CHANGED;
#endif
#endif

@ -22,9 +22,7 @@ module_la_SOURCES = e_mod_main.c \
e_mod_main.h \
e_mod_config.c \
e_mod_parse.c \
e_mod_parse.h \
e_mod_keybindings.c \
e_mod_keybindings.h
e_mod_parse.h
module_la_LIBADD = @e_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version

@ -2,6 +2,30 @@
#include "e_mod_main.h"
#include "e_mod_parse.h"
struct _E_Config_Dialog_Data
{
Evas *evas, *dlg_evas;
Evas_Object *layout_list, *used_list;
Evas_Object *dmodel_list, *model_list, *variant_list;
Evas_Object *btn_add, *btn_del, *btn_up, *btn_down;
Ecore_Timer *fill_delay;
Ecore_Timer *dlg_fill_delay;
Eina_List *cfg_layouts;
Eina_List *cfg_options;
const char *default_model;
int only_label;
E_Dialog *dlg_add_new;
};
typedef struct _E_XKB_Dialog_Option
{
int enabled;
const char *name;
} E_XKB_Dialog_Option;
/* Local prototypes */
static void *_create_data(E_Config_Dialog *cfd);
@ -32,7 +56,7 @@ static Eina_Bool _cb_fill_delay(void *data);
/* Externals */
E_Config_Dialog *
e_xkb_cfg_dialog(E_Container *con, const char *params __UNUSED__)
_xkb_cfg_dialog(E_Container *con, const char *params __UNUSED__)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
@ -47,11 +71,11 @@ e_xkb_cfg_dialog(E_Container *con, const char *params __UNUSED__)
v->basic.apply_cfdata = _basic_apply;
cfd = e_config_dialog_new(con, _("XKB Switcher Module"), "XKB Switcher",
"keyboard_and_mouse/xkbswitch", "preferences-desktop-locale",
"keyboard_and_mouse/xkbswitch",
"preferences-desktop-locale",
0, v, NULL);
e_dialog_resizable_set(cfd->dia, 1);
e_xkb_cfg->cfd = cfd;
_xkb.cfd = cfd;
return cfd;
}
@ -62,19 +86,20 @@ _create_data(E_Config_Dialog *cfd __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
Eina_List *l, *ll, *lll;
E_XKB_Config_Layout *cl, *nl;
E_Config_XKB_Layout *cl, *nl;
E_XKB_Dialog_Option *od;
E_XKB_Option *op;
E_XKB_Option_Group *gr;
find_rules();
parse_rules(); /* XXX: handle in case nothing was found? */
cfdata = E_NEW(E_Config_Dialog_Data, 1);
cfdata->cfg_layouts = NULL;
EINA_LIST_FOREACH(e_xkb_cfg->used_layouts, l, cl)
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
{
nl = E_NEW(E_XKB_Config_Layout, 1);
nl = E_NEW(E_Config_XKB_Layout, 1);
nl->name = eina_stringshare_add(cl->name);
nl->model = eina_stringshare_add(cl->model);
nl->variant = eina_stringshare_add(cl->variant);
@ -84,10 +109,10 @@ _create_data(E_Config_Dialog *cfd __UNUSED__)
/* Initialize options */
cfdata->only_label = e_xkb_cfg->only_label;
cfdata->only_label = e_config->xkb.only_label;
cfdata->cfg_options = NULL;
lll = e_xkb_cfg->used_options;
lll = e_config->xkb.used_options;
EINA_LIST_FOREACH(optgroups, l, gr)
{
EINA_LIST_FOREACH(gr->options, ll, op)
@ -95,7 +120,8 @@ _create_data(E_Config_Dialog *cfd __UNUSED__)
od = E_NEW(E_XKB_Dialog_Option, 1);
od->name = eina_stringshare_add(op->name);
if (lll &&
(od->name == ((E_XKB_Config_Option*)eina_list_data_get(lll))->name))
(od->name == ((E_Config_XKB_Option *)
eina_list_data_get(lll))->name))
{
od->enabled = 1;
lll = eina_list_next(lll);
@ -111,10 +137,10 @@ _create_data(E_Config_Dialog *cfd __UNUSED__)
static void
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
E_XKB_Config_Layout *cl;
E_Config_XKB_Layout *cl;
E_XKB_Dialog_Option *od;
e_xkb_cfg->cfd = NULL;
_xkb.cfd = NULL;
EINA_LIST_FREE(cfdata->cfg_layouts, cl)
{
@ -139,11 +165,11 @@ static int
_basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
Eina_List *l;
E_XKB_Config_Layout *cl, *nl;
E_XKB_Config_Option *oc;
E_Config_XKB_Layout *cl, *nl;
E_Config_XKB_Option *oc;
E_XKB_Dialog_Option *od;
EINA_LIST_FREE(e_xkb_cfg->used_layouts, cl)
EINA_LIST_FREE(e_config->xkb.used_layouts, cl)
{
eina_stringshare_del(cl->name);
eina_stringshare_del(cl->model);
@ -153,24 +179,24 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
EINA_LIST_FOREACH(cfdata->cfg_layouts, l, cl)
{
nl = E_NEW(E_XKB_Config_Layout, 1);
nl = E_NEW(E_Config_XKB_Layout, 1);
nl->name = eina_stringshare_add(cl->name);
nl->model = eina_stringshare_add(cl->model);
nl->variant = eina_stringshare_add(cl->variant);
e_xkb_cfg->used_layouts =
eina_list_append(e_xkb_cfg->used_layouts, nl);
e_config->xkb.used_layouts =
eina_list_append(e_config->xkb.used_layouts, nl);
}
if (e_xkb_cfg->default_model)
eina_stringshare_del(e_xkb_cfg->default_model);
if (e_config->xkb.default_model)
eina_stringshare_del(e_config->xkb.default_model);
e_xkb_cfg->default_model = eina_stringshare_add(cfdata->default_model);
e_config->xkb.default_model = eina_stringshare_add(cfdata->default_model);
/* Save options */
e_xkb_cfg->only_label = cfdata->only_label;
e_config->xkb.only_label = cfdata->only_label;
EINA_LIST_FREE(e_xkb_cfg->used_options, oc)
EINA_LIST_FREE(e_config->xkb.used_options, oc)
{
eina_stringshare_del(oc->name);
E_FREE(oc);
@ -180,13 +206,12 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
if (!od->enabled) continue;
oc = E_NEW(E_XKB_Config_Option, 1);
oc = E_NEW(E_Config_XKB_Option, 1);
oc->name = eina_stringshare_add(od->name);
e_xkb_cfg->used_options = eina_list_append(e_xkb_cfg->used_options, oc);
e_config->xkb.used_options = eina_list_append(e_config->xkb.used_options, oc);
}
e_xkb_update_icon();
e_xkb_update_layout();
e_xkb_update();
e_config_save_queue();
return 1;
@ -278,7 +303,7 @@ _basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data
EINA_LIST_FOREACH(group->options, ll, option)
{
Evas_Object *chk = e_widget_check_add(evas, option->description,
&(((E_XKB_Dialog_Option*)
&(((E_XKB_Dialog_Option *)
eina_list_data_get(lll))->enabled));
e_widget_framelist_object_append(grp, chk);
lll = eina_list_next(lll);
@ -433,7 +458,7 @@ _dlg_add_new(E_Config_Dialog_Data *cfdata)
Evas *evas;
Evas_Coord mw, mh;
if (!(dlg = e_dialog_new(e_xkb_cfg->cfd->con, "E", "xkbswitch_config_add_dialog"))) return NULL;
if (!(dlg = e_dialog_new(_xkb.cfd->con, "E", "xkbswitch_config_add_dialog"))) return NULL;
dlg->data = cfdata;
@ -499,7 +524,7 @@ static void
_dlg_add_cb_ok(void *data __UNUSED__, E_Dialog *dlg)
{
E_Config_Dialog_Data *cfdata = dlg->data;
E_XKB_Config_Layout *cl;
E_Config_XKB_Layout *cl;
char buf[PATH_MAX];
/* Configuration information */
const char *layout = e_widget_ilist_selected_value_get(cfdata->layout_list);
@ -507,7 +532,7 @@ _dlg_add_cb_ok(void *data __UNUSED__, E_Dialog *dlg)
const char *variant = e_widget_ilist_selected_value_get(cfdata->variant_list);
/* The new configuration */
cl = E_NEW(E_XKB_Config_Layout, 1);
cl = E_NEW(E_Config_XKB_Layout, 1);
cl->name = eina_stringshare_add(layout);
cl->model = eina_stringshare_add(model);
cl->variant = eina_stringshare_add(variant);
@ -665,7 +690,7 @@ _cb_fill_delay(void *data)
{
E_Config_Dialog_Data *cfdata;
Eina_List *l;
E_XKB_Config_Layout *cl;
E_Config_XKB_Layout *cl;
E_XKB_Model *model;
int n = 0;
char buf[PATH_MAX];
@ -703,7 +728,7 @@ _cb_fill_delay(void *data)
snprintf(buf, sizeof(buf), "%s (%s)", model->description, model->name);
e_widget_ilist_append(cfdata->dmodel_list, NULL, buf, NULL,
cfdata, model->name);
if (model->name == e_xkb_cfg->default_model)
if (model->name == e_config->xkb.default_model)
e_widget_ilist_selected_set(cfdata->dmodel_list, n);
n++;
}

@ -1,194 +0,0 @@
#include "e.h"
#include "e_mod_main.h"
#include "e_mod_keybindings.h"
#define E_XKB_ACTION_GROUP _("Keyboard Layouts")
#define E_XKB_ACTION_NEXT _("Switch to the next layout")
#define E_XKB_ACTION_PREV _("Switch to the previous layout")
#define ACT_FN_GO(act) \
static void _e_actions_act_##act##_go(E_Object *obj, const char *params)
#define ACT_GO(name) \
{ \
act = e_action_add(#name); \
if (act) act->func.go = _e_actions_act_##name##_go; \
}
ACT_FN_GO(e_xkb_layout_next);
ACT_FN_GO(e_xkb_layout_prev);
static void _e_xkb_register_module_keybinding(E_Config_Binding_Key *key, const char *action);
static void _e_xkb_unregister_module_keybinding(E_Config_Binding_Key *key, int save);
int
e_xkb_register_module_actions(void)
{
E_Action *act;
e_action_predef_name_set(E_XKB_ACTION_GROUP, E_XKB_ACTION_NEXT, E_XKB_NEXT_ACTION,
NULL, NULL, 0);
e_action_predef_name_set(E_XKB_ACTION_GROUP, E_XKB_ACTION_PREV, E_XKB_PREV_ACTION,
NULL, NULL, 0);
ACT_GO(e_xkb_layout_next);
ACT_GO(e_xkb_layout_prev);
return 1;
}
int
e_xkb_unregister_module_actions(void)
{
e_action_del(E_XKB_NEXT_ACTION);
e_action_del(E_XKB_PREV_ACTION);
e_action_predef_name_del(E_XKB_ACTION_GROUP, E_XKB_ACTION_NEXT);
e_action_predef_name_del(E_XKB_ACTION_GROUP, E_XKB_ACTION_PREV);
return 1;
}
// XXX: i dont think module should register bindings imho. leave that up to
// standard profiles?
int
e_xkb_register_module_keybindings(void)
{
e_managers_keys_ungrab();
_e_xkb_register_module_keybinding(&(e_xkb_cfg->layout_next_key), E_XKB_NEXT_ACTION);
_e_xkb_register_module_keybinding(&(e_xkb_cfg->layout_prev_key), E_XKB_PREV_ACTION);
e_managers_keys_grab();
return 1;
}
int
e_xkb_unregister_module_keybindings(void)
{
e_managers_keys_ungrab();
_e_xkb_unregister_module_keybinding(&(e_xkb_cfg->layout_next_key), 1);
_e_xkb_unregister_module_keybinding(&(e_xkb_cfg->layout_prev_key), 1);
e_managers_keys_grab();
return 1;
}
static void
_e_xkb_unregister_module_keybinding(E_Config_Binding_Key *key, int save)
{
E_Config_Binding_Key *eb;
Eina_List *l;
Eina_Bool done = EINA_FALSE;
Eina_Bool found = EINA_FALSE;
if (!key) return;
while (!done)
{
done = EINA_TRUE;
EINA_LIST_FOREACH(e_config->key_bindings, l, eb)
{
if (eb && eb->action && eb->action[0] &&
(!strcmp(!eb->action ? "" : eb->action,
!key->action ? "" : key->action)))
{
if (save)
{
eina_stringshare_del(key->key);
eina_stringshare_del(key->params);
key->context = eb->context;
key->key = eina_stringshare_add(eb->key);
key->modifiers = eb->modifiers;
key->any_mod = eb->any_mod;
key->params = (!eb->params ? NULL : eina_stringshare_add(eb->params));
}
e_bindings_key_del(eb->context, eb->key, eb->modifiers, eb->any_mod, eb->action, eb->params);
eina_stringshare_del(eb->key);
eina_stringshare_del(eb->action);
eina_stringshare_del(eb->params);
E_FREE(eb);
e_config->key_bindings = eina_list_remove_list(e_config->key_bindings, l);
found = EINA_TRUE;
done = EINA_FALSE;
break;
}
}
}
if (!found)
{
eina_stringshare_del(key->key);
eina_stringshare_del(key->params);
key->key = NULL;
key->context = E_BINDING_CONTEXT_ANY;
key->modifiers = E_BINDING_MODIFIER_NONE;
key->any_mod = 0;
}
}
static void
_e_xkb_register_module_keybinding(E_Config_Binding_Key *key, const char *action)
{
E_Config_Binding_Key *eb;
E_Config_Binding_Key *t;
Eina_List *l;
Eina_Bool found = EINA_FALSE;
if (!key || !key->key || !key->key[0] || !action) return;
eb = E_NEW(E_Config_Binding_Key, 1);
eb->context = key->context;
eb->key = eina_stringshare_add(key->key);
eb->modifiers = key->modifiers;
eb->any_mod = key->any_mod;
eb->action = (!action ? NULL : eina_stringshare_add(action));
eb->params = (!key->params ? NULL : eina_stringshare_add(key->params));
EINA_LIST_FOREACH(e_config->key_bindings, l, t)
{
if (found) break;
if (!strcmp(!t->action ? "" : t->action, eb->action) && !strcmp(!t->params ? "" : t->params, !eb->params ? "" : eb->params)) found = EINA_TRUE;
}
if (!found)
{
e_config->key_bindings = eina_list_append(e_config->key_bindings, eb);
e_bindings_key_add(key->context, key->key, key->modifiers,
key->any_mod, action, key->params);
}
else
{
eina_stringshare_del(eb->key);
eina_stringshare_del(eb->action);
eina_stringshare_del(eb->params);
E_FREE(eb);
}
}
ACT_FN_GO(e_xkb_layout_next)
{
e_xkb_layout_next();
return;
obj = 0; params = 0;
}
ACT_FN_GO(e_xkb_layout_prev)
{
e_xkb_layout_prev();
return;
obj = 0; params = 0;
}

@ -1,16 +0,0 @@
#ifdef E_TYPEDEFS
#else
#ifndef E_MOD_KEYBIND_H
#define E_MOD_KEYBIND_H
#define E_XKB_NEXT_ACTION "e_xkb_layout_next"
#define E_XKB_PREV_ACTION "e_xkb_layout_prev"
int e_xkb_register_module_actions(void);
int e_xkb_unregister_module_actions(void);
int e_xkb_register_module_keybindings(void);
int e_xkb_unregister_module_keybindings(void);
#endif
#endif

@ -1,38 +1,20 @@
#include "e.h"
#include "e_mod_main.h"
#include "e_mod_parse.h"
#include "e_mod_keybindings.h"
/* Static functions
* The static functions specific to the current code unit.
*/
/* GADCON */
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_orient (E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
static const char *_gc_label (E_Gadcon_Client_Class *client_class);
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
static const char *_gc_label(E_Gadcon_Client_Class *client_class);
static const char *_gc_id_new(E_Gadcon_Client_Class *client_class __UNUSED__);
static Evas_Object *_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas);
/* CONFIG */
static void _e_xkb_cfg_new (void);
static void _e_xkb_cfg_free(void);
static Eina_Bool _e_xkb_cfg_timer(void *data);
/* EVENTS */
static Eina_Bool _xkb_changed(void *data, int type, void *event_info);
static void _e_xkb_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
static void _e_xkb_cb_menu_post(void *data, E_Menu *menu __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_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED__);
@ -56,18 +38,12 @@ typedef struct _Instance
/* LIST OF INSTANCES */
static Eina_List *instances = NULL;
/* EET STRUCTURES */
static E_Config_DD *e_xkb_cfg_edd = NULL;
static E_Config_DD *e_xkb_cfg_layout_edd = NULL;
static E_Config_DD *e_xkb_cfg_option_edd = NULL;
/* Global variables
* Global variables shared across the module.
*/
/* CONFIG STRUCTURE */
E_XKB_Config *e_xkb_cfg = NULL;
Xkb _xkb = { NULL, NULL };
static const E_Gadcon_Client_Class _gc_class =
{
@ -98,100 +74,11 @@ e_modapi_init(E_Module *m)
e_configure_registry_item_add("keyboard_and_mouse/xkbswitch", 110,
_("XKB Switcher"), NULL,
"preferences-desktop-locale",
e_xkb_cfg_dialog);
e_xkb_cfg_layout_edd = E_CONFIG_DD_NEW("E_XKB_Config_Layout", E_XKB_Config_Layout);
#undef T
#undef D
#define T E_XKB_Config_Layout
#define D e_xkb_cfg_layout_edd
E_CONFIG_VAL(D, T, name, STR);
E_CONFIG_VAL(D, T, model, STR);
E_CONFIG_VAL(D, T, variant, STR);
e_xkb_cfg_option_edd = E_CONFIG_DD_NEW("E_XKB_Config_Option", E_XKB_Config_Option);
#undef T
#undef D
#define T E_XKB_Config_Option
#define D e_xkb_cfg_option_edd
E_CONFIG_VAL(D, T, name, STR);
e_xkb_cfg_edd = E_CONFIG_DD_NEW("e_xkb_cfg", E_XKB_Config);
#undef T
#undef D
#define T E_XKB_Config
#define D e_xkb_cfg_edd
E_CONFIG_LIST(D, T, used_layouts, e_xkb_cfg_layout_edd);
E_CONFIG_LIST(D, T, used_options, e_xkb_cfg_option_edd);
E_CONFIG_VAL(D, T, layout_next_key.context, INT);
E_CONFIG_VAL(D, T, layout_next_key.modifiers, INT);
E_CONFIG_VAL(D, T, layout_next_key.key, STR);
E_CONFIG_VAL(D, T, layout_next_key.action, STR);
E_CONFIG_VAL(D, T, layout_next_key.params, STR);
E_CONFIG_VAL(D, T, layout_next_key.any_mod, UCHAR);
E_CONFIG_VAL(D, T, layout_prev_key.context, INT);
E_CONFIG_VAL(D, T, layout_prev_key.modifiers, INT);
E_CONFIG_VAL(D, T, layout_prev_key.key, STR);
E_CONFIG_VAL(D, T, layout_prev_key.action, STR);
E_CONFIG_VAL(D, T, layout_prev_key.params, STR);
E_CONFIG_VAL(D, T, layout_prev_key.any_mod, UCHAR);
E_CONFIG_VAL(D, T, default_model, STR);
E_CONFIG_VAL(D, T, only_label, INT);
E_CONFIG_VAL(D, T, version, INT);
/* Version check */
e_xkb_cfg = e_config_domain_load("module.xkbswitch", e_xkb_cfg_edd);
if (e_xkb_cfg)
{
/* Check config version */
if ((e_xkb_cfg->version >> 16) < MOD_CONFIG_FILE_EPOCH)
{
/* config too old */
_e_xkb_cfg_free();
ecore_timer_add(1.0, _e_xkb_cfg_timer,
_("XKB Switcher Module Configuration data needed "
"upgrading. Your old configuration<br> has been"
" wiped and a new set of defaults initialized. "
"This<br>will happen regularly during "
"development, so don't report a<br>bug. "
"This simply means the module needs "
"new configuration<br>data by default for "
"usable functionality that your old<br>"
"configuration simply lacks. This new set of "
"defaults will fix<br>that by adding it in. "
"You can re-configure things now to your<br>"
"liking. Sorry for the inconvenience.<br>"));
}
/* Ardvarks */
else if (e_xkb_cfg->version > MOD_CONFIG_FILE_VERSION)
{
/* config too new...wtf ? */
_e_xkb_cfg_free();
ecore_timer_add(1.0, _e_xkb_cfg_timer,
_("Your XKB Switcher Module configuration is NEWER "
"than the module version. This is "
"very<br>strange. This should not happen unless"
" you downgraded<br>the module or "
"copied the configuration from a place where"
"<br>a newer version of the module "
"was running. This is bad and<br>as a "
"precaution your configuration has been now "
"restored to<br>defaults. Sorry for the "
"inconvenience.<br>"));
}
}
if (!e_xkb_cfg) _e_xkb_cfg_new();
e_xkb_cfg->module = m;
/* Rules */
find_rules();
/* Update the layout - can't update icon, gadgets are not there yet */
e_xkb_update_layout();
_xkb_cfg_dialog);
_xkb.module = m;
_xkb.evh = ecore_event_handler_add(E_EVENT_XKB_CHANGED, _xkb_changed, NULL);
/* Gadcon */
e_gadcon_provider_register(&_gc_class);
/* Bindings */
e_xkb_register_module_actions();
e_xkb_register_module_keybindings();
return m;
}
@ -202,48 +89,15 @@ e_modapi_init(E_Module *m)
EAPI int
e_modapi_shutdown(E_Module *m __UNUSED__)
{
E_XKB_Config_Layout *cl;
E_XKB_Config_Option *op;
e_configure_registry_item_del("keyboard_and_mouse/xkbswitch");
e_configure_registry_category_del("keyboard_and_mouse");
if (e_xkb_cfg->cfd) e_object_del(E_OBJECT(e_xkb_cfg->cfd));
e_xkb_cfg->cfd = NULL;
e_xkb_cfg->module = NULL;
if (_xkb.evh) ecore_event_handler_del(_xkb.evh);
if (_xkb.cfd) e_object_del(E_OBJECT(_xkb.cfd));
_xkb.cfd = NULL;
_xkb.module = NULL;
e_gadcon_provider_unregister(&_gc_class);
e_xkb_unregister_module_actions();
e_xkb_unregister_module_keybindings();
EINA_LIST_FREE(e_xkb_cfg->used_layouts, cl)
{
eina_stringshare_del(cl->name);
eina_stringshare_del(cl->model);
eina_stringshare_del(cl->variant);
E_FREE(cl);
}
EINA_LIST_FREE(e_xkb_cfg->used_options, op)
{
eina_stringshare_del(op->name);
E_FREE(op);
}
if (e_xkb_cfg->default_model)
eina_stringshare_del(e_xkb_cfg->default_model);
E_FREE(e_xkb_cfg);
E_CONFIG_DD_FREE(e_xkb_cfg_layout_edd);
E_CONFIG_DD_FREE(e_xkb_cfg_option_edd);
E_CONFIG_DD_FREE(e_xkb_cfg_edd);
clear_rules();
return 1;
}
@ -253,7 +107,6 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
EAPI int
e_modapi_save(E_Module *m __UNUSED__)
{
e_config_domain_save("module.xkbswitch", e_xkb_cfg_edd, e_xkb_cfg);
return 1;
}
@ -261,17 +114,19 @@ e_modapi_save(E_Module *m __UNUSED__)
* current layout state.
*/
void
e_xkb_update_icon(void)
_xkb_update_icon(void)
{
Instance *inst;
Instance *inst;
Eina_List *l;
const char *name;
if (!e_xkb_cfg->used_layouts) return;
const char *name = ((E_XKB_Config_Layout*)eina_list_data_get(e_xkb_cfg->used_layouts))->name;
if (!e_config->xkb.used_layouts) return;
name = ((E_Config_XKB_Layout*)
eina_list_data_get(e_config->xkb.used_layouts))->name;
if ((name) && (strchr(name, '/'))) name = strchr(name, '/') + 1;
if (e_xkb_cfg->only_label)
if (e_config->xkb.only_label)
{
EINA_LIST_FOREACH(instances, l, inst)
{
@ -302,129 +157,6 @@ e_xkb_update_icon(void)
}
}
void
e_xkb_update_layout(void)
{
E_XKB_Config_Layout *cl;
E_XKB_Config_Option *op;
Eina_List *l;
Eina_Strbuf *buf;
if (!e_xkb_cfg->used_layouts) return;
/* We put an empty -option here in order to override all previously
* set options.
*/
buf = eina_strbuf_new();
eina_strbuf_append(buf, "setxkbmap '");
EINA_LIST_FOREACH(e_xkb_cfg->used_layouts, l, cl)
{
eina_strbuf_append(buf, cl->name);
break;
//if (l->next) eina_strbuf_append(buf, ",");
}
eina_strbuf_append(buf, "'");
eina_strbuf_append(buf, " -variant '");
EINA_LIST_FOREACH(e_xkb_cfg->used_layouts, l, cl)
{
eina_strbuf_append(buf, cl->variant);
eina_strbuf_append(buf, ",");
break;
}
eina_strbuf_append(buf, "'");
eina_strbuf_append(buf, " -model '");
cl = eina_list_data_get(e_xkb_cfg->used_layouts);
if (strcmp(cl->model, "default"))
eina_strbuf_append(buf, cl->model);
else if (strcmp(e_xkb_cfg->default_model, "default"))
eina_strbuf_append(buf, e_xkb_cfg->default_model);
else
eina_strbuf_append(buf, "default");
eina_strbuf_append(buf, "'");
EINA_LIST_FOREACH(e_xkb_cfg->used_options, l, op)
{
eina_strbuf_append(buf, " -option '");
eina_strbuf_append(buf, op->name);
eina_strbuf_append(buf, "'");
break;
}
printf("RUN: '%s'\n", eina_strbuf_string_get(buf));
ecore_exe_run(eina_strbuf_string_get(buf), NULL);
eina_strbuf_free(buf);
}
void
e_xkb_layout_next(void)
{
void *odata, *ndata;
Eina_List *l;
odata = eina_list_data_get(e_xkb_cfg->used_layouts);
EINA_LIST_FOREACH(eina_list_next(e_xkb_cfg->used_layouts), l, ndata)
{
eina_list_data_set(eina_list_prev(l), ndata);
}
eina_list_data_set(eina_list_last(e_xkb_cfg->used_layouts), odata);
e_xkb_update_icon();
e_xkb_update_layout();
}
void
e_xkb_layout_prev(void)
{
void *odata, *ndata;
Eina_List *l;
odata = eina_list_data_get(eina_list_last(e_xkb_cfg->used_layouts));
for (l = e_xkb_cfg->used_layouts, ndata = eina_list_data_get(l);
l; l = eina_list_next(l))
{
if (eina_list_next(l))
ndata = eina_list_data_set(eina_list_next(l), ndata);
}
eina_list_data_set(e_xkb_cfg->used_layouts, odata);
e_xkb_update_icon();