enlightenment/src/modules/xkbswitch/e_mod_config.c

765 lines
22 KiB
C
Raw Normal View History

#include "e.h"
#include "e_mod_main.h"
#include "e_mod_parse.h"
struct _E_Config_Dialog_Data
{
2012-09-20 00:30:07 -07:00
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;
2012-05-23 22:49:08 -07:00
2012-09-20 00:30:07 -07:00
Eina_List *cfg_layouts;
Eina_List *cfg_options;
const char *default_model;
2012-05-23 22:49:08 -07:00
2012-09-20 00:30:07 -07:00
int only_label;
int dont_touch_my_damn_keyboard;
2012-05-23 22:49:08 -07:00
2012-09-20 00:30:07 -07:00
E_Dialog *dlg_add_new;
};
typedef struct _E_XKB_Dialog_Option
{
2012-09-20 00:30:07 -07:00
int enabled;
const char *name;
} E_XKB_Dialog_Option;
/* Local prototypes */
2012-09-20 00:30:07 -07:00
static void *_create_data(E_Config_Dialog *cfd);
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);
2012-09-20 00:30:07 -07:00
static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
2012-09-20 00:30:07 -07:00
static void _cb_add(void *data, void *data2 __UNUSED__);
static void _cb_del(void *data, void *data2 __UNUSED__);
2012-09-20 00:30:07 -07:00
static void _cb_up(void *data, void *data2 __UNUSED__);
static void _cb_dn(void *data, void *data2 __UNUSED__);
2012-09-20 00:30:07 -07:00
static void _dlg_add_cb_ok(void *data, E_Dialog *dlg);
static void _dlg_add_cb_cancel(void *data, E_Dialog *dlg);
2012-09-20 00:30:07 -07:00
static E_Dialog *_dlg_add_new(E_Config_Dialog_Data *cfdata);
2012-09-20 00:30:07 -07:00
static void _dlg_add_cb_del(void *obj);
2012-09-20 00:30:07 -07:00
static Eina_Bool _cb_dlg_fill_delay(void *data);
2012-09-20 00:30:07 -07:00
static void _cb_layout_select(void *data);
static void _cb_used_select(void *data);
2012-09-20 00:30:07 -07:00
static Eina_Bool _cb_fill_delay(void *data);
/* Externals */
E_Config_Dialog *
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
_xkb_cfg_dialog(E_Comp *comp, const char *params __UNUSED__)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
2012-05-23 22:49:08 -07:00
if (e_config_dialog_find("E", "keyboard_and_mouse/xkbswitch"))
return NULL;
if (!(v = E_NEW(E_Config_Dialog_View, 1))) return NULL;
2012-05-23 22:49:08 -07:00
2012-09-20 00:30:07 -07:00
v->create_cfdata = _create_data;
v->free_cfdata = _free_data;
v->basic.create_widgets = _basic_create;
2012-09-20 00:30:07 -07:00
v->basic.apply_cfdata = _basic_apply;
2012-05-23 22:49:08 -07:00
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
cfd = e_config_dialog_new(comp, _("Keyboard Settings"), "E",
"keyboard_and_mouse/xkbswitch",
"preferences-desktop-keyboard",
0, v, NULL);
_xkb.cfd = cfd;
return cfd;
}
/* Locals */
static void *
_create_data(E_Config_Dialog *cfd __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
Eina_List *l, *ll, *lll;
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? */
2012-05-23 22:49:08 -07:00
cfdata = E_NEW(E_Config_Dialog_Data, 1);
2012-05-23 22:49:08 -07:00
cfdata->cfg_layouts = NULL;
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
{
2012-09-20 00:30:07 -07:00
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);
2012-05-23 22:49:08 -07:00
cfdata->cfg_layouts = eina_list_append(cfdata->cfg_layouts, nl);
}
2012-05-23 22:49:08 -07:00
/* Initialize options */
2012-05-23 22:49:08 -07:00
2012-09-20 00:30:07 -07:00
cfdata->only_label = e_config->xkb.only_label;
cfdata->dont_touch_my_damn_keyboard = e_config->xkb.dont_touch_my_damn_keyboard;
cfdata->cfg_options = NULL;
2012-05-23 22:49:08 -07:00
lll = e_config->xkb.used_options;
EINA_LIST_FOREACH(optgroups, l, gr)
{
EINA_LIST_FOREACH(gr->options, ll, op)
{
od = E_NEW(E_XKB_Dialog_Option, 1);
od->name = eina_stringshare_add(op->name);
2012-05-23 22:49:08 -07:00
if (lll &&
(od->name == ((E_Config_XKB_Option *)
eina_list_data_get(lll))->name))
{
od->enabled = 1;
lll = eina_list_next(lll);
}
else od->enabled = 0;
cfdata->cfg_options = eina_list_append(cfdata->cfg_options, od);
}
}
2012-05-23 22:49:08 -07:00
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
E_Config_XKB_Layout *cl;
E_XKB_Dialog_Option *od;
2012-05-23 22:49:08 -07:00
_xkb.cfd = NULL;
2012-05-23 22:49:08 -07:00
EINA_LIST_FREE(cfdata->cfg_layouts, cl)
{
eina_stringshare_del(cl->name);
eina_stringshare_del(cl->model);
eina_stringshare_del(cl->variant);
E_FREE(cl);
}
2012-05-23 22:49:08 -07:00
EINA_LIST_FREE(cfdata->cfg_options, od)
{
eina_stringshare_del(od->name);
E_FREE(od);
}
2012-05-23 22:49:08 -07:00
eina_stringshare_del(cfdata->default_model);
E_FREE(cfdata);
clear_rules();
}
static int
_basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
Eina_List *l;
E_Config_XKB_Layout *cl, *nl;
E_Config_XKB_Option *oc;
E_XKB_Dialog_Option *od;
2012-05-23 22:49:08 -07:00
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);
}
2012-05-23 22:49:08 -07:00
EINA_LIST_FOREACH(cfdata->cfg_layouts, l, cl)
{
2012-09-20 00:30:07 -07:00
nl = E_NEW(E_Config_XKB_Layout, 1);
nl->name = eina_stringshare_ref(cl->name);
nl->model = eina_stringshare_ref(cl->model);
nl->variant = eina_stringshare_ref(cl->variant);
2012-05-23 22:49:08 -07:00
e_config->xkb.used_layouts =
eina_list_append(e_config->xkb.used_layouts, nl);
}
2012-05-23 22:49:08 -07:00
eina_stringshare_replace(&e_config->xkb.default_model, cfdata->default_model);
2012-05-23 22:49:08 -07:00
/* Save options */
e_config->xkb.only_label = cfdata->only_label;
e_config->xkb.dont_touch_my_damn_keyboard = cfdata->dont_touch_my_damn_keyboard;
2012-05-23 22:49:08 -07:00
EINA_LIST_FREE(e_config->xkb.used_options, oc)
{
eina_stringshare_del(oc->name);
E_FREE(oc);
}
2012-05-23 22:49:08 -07:00
EINA_LIST_FOREACH(cfdata->cfg_options, l, od)
{
if (!od->enabled) continue;
2012-05-23 22:49:08 -07:00
oc = E_NEW(E_Config_XKB_Option, 1);
oc->name = eina_stringshare_ref(od->name);
e_config->xkb.used_options = eina_list_append(e_config->xkb.used_options, oc);
2012-09-20 00:30:07 -07:00
}
2012-05-23 22:49:08 -07:00
e_xkb_update(-1);
_xkb_update_icon(0);
2012-05-23 22:49:08 -07:00
e_config_save_queue();
return 1;
}
static Evas_Object *
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *mainn, *layoutss, *modelss, *options, *configs, *buttons,
*general, *scroller, *only_label, *dont_touch_my_damn_keyboard;
E_XKB_Option *option;
E_XKB_Option_Group *group;
Eina_List *l, *ll, *lll;
Evas_Coord mw, mh;
/* Holds the dialog contents, displays a toolbar on the top */
e_dialog_resizable_set(cfd->dia, 1);
mainn = e_widget_toolbook_add(evas, 24, 24);
/* Holds the used layouts ilist and the button table */
layoutss = e_widget_list_add(evas, 0, 0);
/* Holds the used layouts */
configs = e_widget_ilist_add(evas, 32, 32, NULL);
e_widget_size_min_set(configs, 220, 160);
e_widget_ilist_go(configs);
e_widget_list_object_append(layoutss, configs, 1, 1, 0.5);
cfdata->used_list = configs;
/* Holds the buttons */
buttons = e_widget_table_add(evas, 1);
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_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);
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);
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);
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_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_toolbook_page_append(mainn, NULL, _("Configurations"), layoutss, 1, 1, 1, 1, 0.5, 0.0);
/* Holds the default models */
modelss = e_widget_ilist_add(evas, 32, 32, &cfdata->default_model);
e_widget_size_min_set(modelss, 220, 160);
cfdata->dmodel_list = modelss;
e_widget_toolbook_page_append(mainn, NULL, _("Models"), modelss, 1, 1, 1, 1, 0.5, 0.0);
/* Holds the options */
options = e_widget_list_add(evas, 0, 0);
general = e_widget_framelist_add(evas, _("General"), 0);
dont_touch_my_damn_keyboard = e_widget_check_add(evas, _("Do not apply any keyboard settings ever"), &(cfdata->dont_touch_my_damn_keyboard));
e_widget_framelist_object_append(general, dont_touch_my_damn_keyboard);
only_label = e_widget_check_add(evas, _("Label only in gadgets"), &(cfdata->only_label));
e_widget_check_widget_disable_on_checked_add(dont_touch_my_damn_keyboard, only_label);
e_widget_framelist_object_append(general, only_label);
e_widget_list_object_append(options, general, 1, 1, 0.0);
lll = cfdata->cfg_options;
EINA_LIST_FOREACH(optgroups, l, group)
{
Evas_Object *grp;
grp = e_widget_framelist_add(evas, group->description, 0);
EINA_LIST_FOREACH(group->options, ll, option)
{
Evas_Object *chk;
chk = e_widget_check_add(evas, option->description,
&(((E_XKB_Dialog_Option *)
eina_list_data_get(lll))->enabled));
e_widget_check_widget_disable_on_checked_add(dont_touch_my_damn_keyboard, chk);
e_widget_framelist_object_append(grp, chk);
lll = eina_list_next(lll);
}
e_widget_list_object_append(options, grp, 1, 1, 0.0);
}
e_widget_size_min_get(options, &mw, &mh);
if (mw < 220) mw = 220;
if (mh < 160) mh = 160;
evas_object_resize(options, mw, mh);
scroller = e_widget_scrollframe_simple_add(evas, options);
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);
/* Display the first page by default */
e_widget_toolbook_page_show(mainn, 0);
2012-05-23 22:49:08 -07:00
/* The main evas */
cfdata->evas = evas;
2012-05-23 22:49:08 -07:00
/* Clear up any previous timer */
if (cfdata->fill_delay)
ecore_timer_del(cfdata->fill_delay);
2012-05-23 22:49:08 -07:00
/* Trigger the fill */
cfdata->fill_delay = ecore_timer_add(0.2, _cb_fill_delay, cfdata);
2012-05-23 22:49:08 -07:00
return mainn;
}
static void
_cb_add(void *data, void *data2 __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
if (!(cfdata = data)) return;
2012-05-23 22:49:08 -07:00
if (cfdata->dlg_add_new) e_win_raise(cfdata->dlg_add_new->win);
else cfdata->dlg_add_new = _dlg_add_new(cfdata);
}
static void
_cb_del(void *data, void *data2 __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
int n = 0;
2012-05-23 22:49:08 -07:00
if (!(cfdata = data)) return;
if ((n = e_widget_ilist_selected_get(cfdata->used_list)) < 0) return;
2012-05-23 22:49:08 -07:00
cfdata->cfg_layouts = eina_list_remove_list(cfdata->cfg_layouts, eina_list_nth_list(cfdata->cfg_layouts, n));
2012-05-23 22:49:08 -07:00
/* Update the list */
evas_event_freeze(cfdata->evas);
edje_freeze();
e_widget_ilist_freeze(cfdata->used_list);
e_widget_ilist_remove_num(cfdata->used_list, n);
e_widget_ilist_go(cfdata->used_list);
e_widget_ilist_thaw(cfdata->used_list);
edje_thaw();
evas_event_thaw(cfdata->evas);
}
static void
_cb_up(void *data, void *data2 __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
void *nddata;
Evas_Object *ic;
Eina_List *l;
const char *lbl, *file;
int n;
2012-05-23 22:49:08 -07:00
if (!(cfdata = data)) return;
if ((n = e_widget_ilist_selected_get(cfdata->used_list)) < 0) return;
2012-05-23 22:49:08 -07:00
l = eina_list_nth_list(cfdata->cfg_layouts, n);
2012-05-23 22:49:08 -07:00
nddata = eina_list_data_get(eina_list_prev(l));
eina_list_data_set(eina_list_prev(l), eina_list_data_get(l));
eina_list_data_set(l, nddata);
2012-05-23 22:49:08 -07:00
/* Update the list */
2012-05-23 22:49:08 -07:00
evas_event_freeze(cfdata->evas);
edje_freeze();
e_widget_ilist_freeze(cfdata->used_list);
2012-05-23 22:49:08 -07:00
ic = e_icon_add(cfdata->evas);
e_icon_file_get(e_widget_ilist_nth_icon_get(cfdata->used_list, n), &file, NULL);
e_icon_file_set(ic, file);
lbl = e_widget_ilist_nth_label_get(cfdata->used_list, n);
e_widget_ilist_prepend_relative_full(cfdata->used_list, ic, NULL, lbl, _cb_used_select, cfdata, NULL, (n - 1));
e_widget_ilist_remove_num(cfdata->used_list, n);
2012-05-23 22:49:08 -07:00
e_widget_ilist_go(cfdata->used_list);
e_widget_ilist_thaw(cfdata->used_list);
edje_thaw();
evas_event_thaw(cfdata->evas);
2012-05-23 22:49:08 -07:00
e_widget_ilist_selected_set(cfdata->used_list, (n - 1));
}
static void
_cb_dn(void *data, void *data2 __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
void *nddata;
Evas_Object *ic;
Eina_List *l;
const char *lbl, *file;
int n;
2012-05-23 22:49:08 -07:00
if (!(cfdata = data)) return;
if ((n = e_widget_ilist_selected_get(cfdata->used_list)) < 0) return;
2012-05-23 22:49:08 -07:00
l = eina_list_nth_list(cfdata->cfg_layouts, n);
2012-05-23 22:49:08 -07:00
nddata = eina_list_data_get(eina_list_next(l));
eina_list_data_set(eina_list_next(l), eina_list_data_get(l));
eina_list_data_set(l, nddata);
2012-05-23 22:49:08 -07:00
/* Update the list */
2012-05-23 22:49:08 -07:00
evas_event_freeze(cfdata->evas);
edje_freeze();
e_widget_ilist_freeze(cfdata->used_list);
2012-05-23 22:49:08 -07:00
ic = e_icon_add(cfdata->evas);
e_icon_file_get(e_widget_ilist_nth_icon_get(cfdata->used_list, n), &file, NULL);
e_icon_file_set(ic, file);
lbl = e_widget_ilist_nth_label_get(cfdata->used_list, n);
e_widget_ilist_append_relative_full(cfdata->used_list, ic, NULL, lbl, _cb_used_select, cfdata, NULL, n);
e_widget_ilist_remove_num(cfdata->used_list, n);
2012-05-23 22:49:08 -07:00
e_widget_ilist_go(cfdata->used_list);
e_widget_ilist_thaw(cfdata->used_list);
edje_thaw();
evas_event_thaw(cfdata->evas);
2012-05-23 22:49:08 -07:00
e_widget_ilist_selected_set(cfdata->used_list, (n + 1));
}
static E_Dialog *
_dlg_add_new(E_Config_Dialog_Data *cfdata)
{
E_Dialog *dlg;
Evas *evas;
Evas_Coord mw, mh;
Evas_Object *mainn, *available, *modelss, *variants;
2012-05-23 22:49:08 -07:00
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
if (!(dlg = e_dialog_new(_xkb.cfd->comp, "E", "xkbswitch_config_add_dialog"))) return NULL;
2012-05-23 22:49:08 -07:00
e_dialog_resizable_set(dlg, 1);
dlg->data = cfdata;
e_object_del_attach_func_set(E_OBJECT(dlg), _dlg_add_cb_del);
e_win_centered_set(dlg->win, 1);
2012-05-23 22:49:08 -07:00
evas = e_win_evas_get(dlg->win);
e_dialog_title_set(dlg, _("Add New Configuration"));
2012-05-23 22:49:08 -07:00
/* The main toolbook, holds the lists and tabs */
mainn = e_widget_toolbook_add(evas, 24, 24);
/* Holds the available layouts */
available = e_widget_ilist_add(evas, 32, 32, NULL);
e_widget_size_min_set(available, 220, 160);
e_widget_ilist_go(available);
e_widget_toolbook_page_append(mainn, NULL, _("Available"), available, 1, 1, 1, 1, 0.5, 0.0);
cfdata->layout_list = available;
/* Holds the available models */
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);
cfdata->model_list = modelss;
/* Holds the available variants */
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);
cfdata->variant_list = variants;
e_widget_toolbook_page_show(mainn, 0);
2012-05-23 22:49:08 -07:00
e_widget_size_min_get(mainn, &mw, &mh);
2012-09-20 00:30:07 -07:00
e_dialog_content_set(dlg, mainn, mw, mh);
2012-05-23 22:49:08 -07:00
cfdata->dlg_evas = evas;
2012-05-23 22:49:08 -07:00
/* Clear up any previous timer */
if (cfdata->dlg_fill_delay) ecore_timer_del(cfdata->dlg_fill_delay);
2012-05-23 22:49:08 -07:00
/* Trigger the fill */
cfdata->dlg_fill_delay = ecore_timer_add(0.2, _cb_dlg_fill_delay, cfdata);
2012-05-23 22:49:08 -07:00
/* Some buttons */
e_dialog_button_add(dlg, _("OK"), NULL, _dlg_add_cb_ok, cfdata);
e_dialog_button_add(dlg, _("Cancel"), NULL, _dlg_add_cb_cancel, cfdata);
2012-05-23 22:49:08 -07:00
e_dialog_button_disable_num_set(dlg, 0, 1);
e_dialog_button_disable_num_set(dlg, 1, 0);
2012-05-23 22:49:08 -07:00
e_dialog_show(dlg);
2012-05-23 22:49:08 -07:00
return dlg;
}
static void
_dlg_add_cb_ok(void *data __UNUSED__, E_Dialog *dlg)
{
E_Config_Dialog_Data *cfdata = dlg->data;
2012-09-20 00:30:07 -07:00
E_Config_XKB_Layout *cl;
char buf[4096];
Evas_Object *ic;
/* Configuration information */
Eina_Stringshare *layout, *model, *variant;
layout = e_widget_ilist_selected_value_get(cfdata->layout_list);
model = e_widget_ilist_selected_value_get(cfdata->model_list);
variant = e_widget_ilist_selected_value_get(cfdata->variant_list);
2012-05-23 22:49:08 -07:00
/* The new configuration */
2012-09-20 00:30:07 -07:00
cl = E_NEW(E_Config_XKB_Layout, 1);
cl->name = eina_stringshare_ref(layout);
cl->model = eina_stringshare_ref(model);
cl->variant = eina_stringshare_ref(variant);
2012-05-23 22:49:08 -07:00
cfdata->cfg_layouts = eina_list_append(cfdata->cfg_layouts, cl);
2012-05-23 22:49:08 -07:00
/* Update the main list */
evas_event_freeze(cfdata->evas);
edje_freeze();
e_widget_ilist_freeze(cfdata->used_list);
2012-05-23 22:49:08 -07:00
ic = e_icon_add(cfdata->evas);
2012-05-23 22:49:08 -07:00
e_xkb_e_icon_flag_setup(ic, cl->name);
snprintf(buf, sizeof(buf), "%s (%s, %s)",
cl->name, cl->model, cl->variant);
e_widget_ilist_append_full(cfdata->used_list, ic, NULL, buf,
_cb_used_select, cfdata, NULL);
2012-05-23 22:49:08 -07:00
2012-09-20 00:30:07 -07:00
e_widget_ilist_go(cfdata->used_list);
e_widget_ilist_thaw(cfdata->used_list);
edje_thaw();
evas_event_thaw(cfdata->evas);
2012-05-23 22:49:08 -07:00
cfdata->dlg_add_new = NULL;
e_object_unref(E_OBJECT(dlg));
}
static void
_dlg_add_cb_cancel(void *data __UNUSED__, E_Dialog *dlg)
{
E_Config_Dialog_Data *cfdata = dlg->data;
cfdata->dlg_add_new = NULL;
e_object_unref(E_OBJECT(dlg));
}
static void
_dlg_add_cb_del(void *obj)
{
E_Dialog *dlg = obj;
E_Config_Dialog_Data *cfdata = dlg->data;
cfdata->dlg_add_new = NULL;
e_object_unref(E_OBJECT(dlg));
}
static Eina_Bool
_cb_dlg_fill_delay(void *data)
{
E_Config_Dialog_Data *cfdata;
Eina_List *l;
E_XKB_Layout *layout;
char buf[4096];
if (!(cfdata = data)) return ECORE_CALLBACK_RENEW;
/* Update the list of available layouts */
evas_event_freeze(cfdata->dlg_evas);
edje_freeze();
2012-05-23 22:49:08 -07:00
e_widget_ilist_freeze(cfdata->layout_list);
2012-09-20 00:30:07 -07:00
e_widget_ilist_clear(cfdata->layout_list);
2012-05-23 22:49:08 -07:00
EINA_LIST_FOREACH(layouts, l, layout)
{
Evas_Object *ic;
2012-05-23 22:49:08 -07:00
ic = e_icon_add(cfdata->dlg_evas);
e_xkb_e_icon_flag_setup(ic, layout->name);
snprintf(buf, sizeof(buf), "%s (%s)",
layout->description, layout->name);
e_widget_ilist_append_full(cfdata->layout_list, ic, NULL, buf,
_cb_layout_select, cfdata, layout->name);
}
2012-05-23 22:49:08 -07:00
2012-09-20 00:30:07 -07:00
e_widget_ilist_go(cfdata->layout_list);
e_widget_ilist_thaw(cfdata->layout_list);
2012-05-23 22:49:08 -07:00
edje_thaw();
evas_event_thaw(cfdata->dlg_evas);
2012-05-23 22:49:08 -07:00
cfdata->dlg_fill_delay = NULL;
return ECORE_CALLBACK_CANCEL;
}
static void
_cb_layout_select(void *data)
{
E_Config_Dialog_Data *cfdata;
E_XKB_Variant *variant;
E_XKB_Layout *layout;
E_XKB_Model *model;
Eina_List *l;
const char *label;
int n;
char buf[4096];
2012-05-23 22:49:08 -07:00
if (!(cfdata = data)) return;
/* Find the right layout */
2012-05-23 22:49:08 -07:00
if ((n = e_widget_ilist_selected_get(cfdata->layout_list)) < 0)
return;
if (!(label = e_widget_ilist_nth_label_get(cfdata->layout_list, n)))
return;
2012-05-23 22:49:08 -07:00
if (!(layout = eina_list_search_unsorted
2012-09-20 00:30:07 -07:00
(layouts, layout_sort_by_name_cb,
e_widget_ilist_nth_value_get(cfdata->layout_list, n)
2012-09-20 00:30:07 -07:00
))) return;
2012-05-23 22:49:08 -07:00
/* Update the lists */
evas_event_freeze(cfdata->dlg_evas);
edje_freeze();
2012-05-23 22:49:08 -07:00
/* Models */
e_widget_ilist_freeze(cfdata->model_list);
e_widget_ilist_clear(cfdata->model_list);
2012-05-23 22:49:08 -07:00
EINA_LIST_FOREACH(models, l, model)
{
snprintf(buf, sizeof(buf), "%s (%s)", model->description, model->name);
e_widget_ilist_append(cfdata->model_list, NULL, buf, NULL, cfdata, model->name);
}
2012-05-23 22:49:08 -07:00
e_widget_ilist_go(cfdata->model_list);
e_widget_ilist_thaw(cfdata->model_list);
2012-05-23 22:49:08 -07:00
/* Variants */
e_widget_ilist_freeze(cfdata->variant_list);
e_widget_ilist_clear(cfdata->variant_list);
2012-05-23 22:49:08 -07:00
EINA_LIST_FOREACH(layout->variants, l, variant)
{
2012-09-20 00:30:07 -07:00
snprintf(buf, sizeof(buf), "%s (%s)", variant->name, variant->description);
e_widget_ilist_append(cfdata->variant_list, NULL, buf, NULL, cfdata, variant->name);
}
2012-05-23 22:49:08 -07:00
e_widget_ilist_go(cfdata->variant_list);
e_widget_ilist_thaw(cfdata->variant_list);
2012-05-23 22:49:08 -07:00
edje_thaw();
evas_event_thaw(cfdata->dlg_evas);
2012-05-23 22:49:08 -07:00
2012-09-20 00:30:07 -07:00
e_widget_ilist_selected_set(cfdata->model_list, 0);
e_widget_ilist_selected_set(cfdata->variant_list, 0);
2012-05-23 22:49:08 -07:00
e_dialog_button_disable_num_set(cfdata->dlg_add_new, 0, 0);
}
static Eina_Bool
_cb_fill_delay(void *data)
{
E_Config_Dialog_Data *cfdata;
Eina_List *l;
E_Config_XKB_Layout *cl;
E_XKB_Model *model;
int n = 0;
char buf[4096];
2012-05-23 22:49:08 -07:00
if (!(cfdata = data)) return ECORE_CALLBACK_RENEW;
2012-05-23 22:49:08 -07:00
/* Update the list of used layouts */
evas_event_freeze(cfdata->evas);
edje_freeze();
2012-05-23 22:49:08 -07:00
e_widget_ilist_freeze(cfdata->used_list);
e_widget_ilist_clear(cfdata->used_list);
2012-05-23 22:49:08 -07:00
EINA_LIST_FOREACH(cfdata->cfg_layouts, l, cl)
{
Evas_Object *ic = e_icon_add(cfdata->evas);
const char *name = cl->name;
e_xkb_e_icon_flag_setup(ic, name);
snprintf(buf, sizeof(buf), "%s (%s, %s)",
cl->name, cl->model, cl->variant);
e_widget_ilist_append_full(cfdata->used_list, ic, NULL, buf,
_cb_used_select, cfdata, NULL);
2012-09-20 00:30:07 -07:00
}
2012-05-23 22:49:08 -07:00
e_widget_ilist_go(cfdata->used_list);
e_widget_ilist_thaw(cfdata->used_list);
e_widget_ilist_freeze(cfdata->dmodel_list);
e_widget_ilist_clear(cfdata->dmodel_list);
2012-05-23 22:49:08 -07:00
/* Update the global model list */
EINA_LIST_FOREACH(models, l, model)
{
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_config->xkb.default_model)
e_widget_ilist_selected_set(cfdata->dmodel_list, n);
n++;
}
2012-05-23 22:49:08 -07:00
e_widget_ilist_go(cfdata->dmodel_list);
e_widget_ilist_thaw(cfdata->dmodel_list);
edje_thaw();
evas_event_thaw(cfdata->evas);
2012-05-23 22:49:08 -07:00
cfdata->fill_delay = NULL;
return ECORE_CALLBACK_CANCEL;
}
static void
_cb_used_select(void *data)
{
E_Config_Dialog_Data *cfdata;
int n, c;
2012-05-23 22:49:08 -07:00
if (!(cfdata = data)) return;
if ((n = e_widget_ilist_selected_get(cfdata->used_list)) < 0) return;
2012-05-23 22:49:08 -07:00
c = e_widget_ilist_count(cfdata->used_list);
e_widget_disabled_set(cfdata->btn_del, EINA_FALSE);
2012-05-23 22:49:08 -07:00
if (c == 1)
{
e_widget_disabled_set(cfdata->btn_up, EINA_TRUE);
e_widget_disabled_set(cfdata->btn_down, EINA_TRUE);
}
else if (n == (c - 1))
{
2012-09-20 00:30:07 -07:00
e_widget_disabled_set(cfdata->btn_up, EINA_FALSE);
e_widget_disabled_set(cfdata->btn_down, EINA_TRUE);
}
else if (n == 0)
{
2012-09-20 00:30:07 -07:00
e_widget_disabled_set(cfdata->btn_up, EINA_TRUE);
e_widget_disabled_set(cfdata->btn_down, EINA_FALSE);
}
else
{
2012-09-20 00:30:07 -07:00
e_widget_disabled_set(cfdata->btn_up, EINA_FALSE);
e_widget_disabled_set(cfdata->btn_down, EINA_FALSE);
}
}
2012-09-20 00:30:07 -07:00