enlightenment/src/modules/conf/e_conf.c

506 lines
16 KiB
C
Raw Normal View History

#include "e.h"
2012-06-14 03:07:33 -07:00
typedef struct _E_Configure E_Configure;
typedef struct _E_Configure_CB E_Configure_CB;
typedef struct _E_Configure_Category E_Configure_Category;
2012-06-14 03:07:33 -07:00
typedef struct _E_Configure_Item E_Configure_Item;
#define E_CONFIGURE_TYPE 0xE0b01014
struct _E_Configure
{
2012-06-14 03:07:33 -07:00
E_Object e_obj_inherit;
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
E_Comp *comp;
Evas_Object *win;
2012-06-14 03:07:33 -07:00
Evas *evas;
Evas_Object *edje;
2012-06-14 03:07:33 -07:00
Evas_Object *o_list;
Evas_Object *cat_list;
Evas_Object *item_list;
Evas_Object *close;
2012-06-14 03:07:33 -07:00
Eina_List *cats;
Ecore_Event_Handler *mod_hdl;
};
struct _E_Configure_CB
{
E_Configure *eco;
2012-06-14 03:07:33 -07:00
const char *path;
};
struct _E_Configure_Category
{
E_Configure *eco;
2012-06-14 03:07:33 -07:00
const char *label;
Eina_List *items;
};
struct _E_Configure_Item
{
E_Configure_CB *cb;
2012-06-14 03:07:33 -07:00
const char *label;
const char *icon_file;
const char *icon;
};
2012-06-14 03:07:33 -07:00
static void _e_configure_free(E_Configure *eco);
static void _e_configure_cb_del_req(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
2012-06-14 03:07:33 -07:00
static void _e_configure_cb_close(void *data, void *data2);
static E_Configure_Category *_e_configure_category_add(E_Configure *eco, const char *label, const char *icon_file, const char *icon);
2012-06-14 03:07:33 -07:00
static void _e_configure_category_cb(void *data, void *data2);
static void _e_configure_item_add(E_Configure_Category *cat, const char *label, const char *icon_file, const char *icon, const char *path);
static void _e_configure_item_cb(void *data);
static void _e_configure_focus_cb(void *data, Evas_Object *obj);
static void _e_configure_keydown_cb(void *data, Evas *e, Evas_Object *obj, void *event);
static void _e_configure_fill_cat_list(void *data, const char *sel);
2012-06-14 03:07:33 -07:00
static Eina_Bool _e_configure_module_update_cb(void *data, int type, void *event);
static E_Configure *_e_configure = NULL;
2010-01-22 12:28:39 -08:00
void
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
e_configure_show(E_Comp *comp, const char *params)
{
E_Configure *eco;
Evas_Object *o;
Evas_Modifier_Mask mask;
Eina_Bool kg;
E_Client *ec;
2012-06-14 03:07:33 -07:00
if (_e_configure)
{
2012-06-14 03:07:33 -07:00
E_Zone *z, *z2;
const Eina_List *l;
void *it;
int x = 0;
2012-06-14 03:07:33 -07:00
eco = _e_configure;
ec = e_win_client_get(eco->win);
2015-03-13 14:47:36 -07:00
z = e_zone_current_get();
z2 = ec->zone;
evas_object_show(eco->win);
elm_win_raise(eco->win);
2015-03-13 14:44:24 -07:00
if (e_comp == e_comp)
e_client_desk_set(ec, e_desk_current_get(z));
2012-06-14 03:07:33 -07:00
else
{
if (!ec->sticky)
e_desk_show(ec->desk);
2015-03-13 14:44:24 -07:00
ecore_evas_pointer_warp(e_comp->ee,
2012-06-14 03:07:33 -07:00
z2->x + (z2->w / 2), z2->y + (z2->h / 2));
}
e_client_unshade(ec, ec->shade_dir);
2012-06-14 03:07:33 -07:00
if ((e_config->focus_setting == E_FOCUS_NEW_DIALOG) ||
(e_config->focus_setting == E_FOCUS_NEW_WINDOW))
evas_object_focus_set(ec->frame, 1);
EINA_LIST_FOREACH(e_widget_toolbar_items_get(eco->cat_list), l, it)
{
if (e_widget_toolbar_item_label_get(it) == params)
{
e_widget_toolbar_item_select(eco->cat_list, x);
break;
}
x++;
}
2012-06-14 03:07:33 -07:00
return;
}
eco = E_OBJECT_ALLOC(E_Configure, E_CONFIGURE_TYPE, _e_configure_free);
if (!eco) return;
eco->win = elm_win_add(NULL, NULL, ELM_WIN_BASIC);
2012-06-14 03:07:33 -07:00
if (!eco->win)
{
2012-06-14 03:07:33 -07:00
free(eco);
return;
}
evas_object_data_set(eco->win, "e_conf_win", eco);
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
eco->comp = comp;
eco->evas = evas_object_evas_get(eco->win);
/* Event Handler for Module Updates */
2012-06-14 03:07:33 -07:00
eco->mod_hdl = ecore_event_handler_add(E_EVENT_MODULE_UPDATE,
_e_configure_module_update_cb, eco);
elm_win_title_set(eco->win, _("Settings"));
ecore_evas_name_class_set(e_win_ee_get(eco->win), "E", "_configure");
evas_object_event_callback_add(eco->win, EVAS_CALLBACK_DEL, _e_configure_cb_del_req, eco);
elm_win_center(eco->win, 1, 1);
eco->edje = elm_layout_add(e_win_evas_win_get(eco->evas));
E_EXPAND(eco->edje);
E_FILL(eco->edje);
elm_win_resize_object_add(eco->win, eco->edje);
2012-06-14 03:07:33 -07:00
e_theme_edje_object_set(eco->edje, "base/theme/configure",
"e/widgets/configure/main");
elm_object_part_text_set(eco->edje, "e.text.title", _("Settings"));
eco->o_list = e_widget_list_add(eco->evas, 0, 0);
elm_object_part_content_set(eco->edje, "e.swallow.content", eco->o_list);
/* Event Obj for keydown */
o = evas_object_rectangle_add(eco->evas);
mask = 0;
kg = evas_object_key_grab(o, "Tab", mask, ~mask, 0);
if (!kg)
2012-06-14 03:07:33 -07:00
fprintf(stderr, "ERROR: unable to redirect \"Tab\" key events to object %p.\n", o);
mask = evas_key_modifier_mask_get(evas_object_evas_get(eco->win), "Shift");
kg = evas_object_key_grab(o, "Tab", mask, ~mask, 0);
if (!kg)
2012-06-14 03:07:33 -07:00
fprintf(stderr, "ERROR: unable to redirect \"Tab\" key events to object %p.\n", o);
mask = 0;
kg = evas_object_key_grab(o, "Return", mask, ~mask, 0);
if (!kg)
2012-06-14 03:07:33 -07:00
fprintf(stderr, "ERROR: unable to redirect \"Return\" key events to object %p.\n", o);
mask = 0;
kg = evas_object_key_grab(o, "KP_Enter", mask, ~mask, 0);
if (!kg)
2012-06-14 03:07:33 -07:00
fprintf(stderr, "ERROR: unable to redirect \"KP_Enter\" key events to object %p.\n", o);
mask = 0;
kg = evas_object_key_grab(o, "Escape", mask, ~mask, 0);
if (!kg)
fprintf(stderr, "ERROR: unable to redirect \"Escape\" key events to object %p.\n", o);
2012-06-14 03:07:33 -07:00
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN,
_e_configure_keydown_cb, eco);
_e_configure_fill_cat_list(eco, params);
/* Close Button */
2012-06-14 03:07:33 -07:00
eco->close = e_widget_button_add(eco->evas, _("Close"), NULL,
_e_configure_cb_close, eco, NULL);
e_widget_on_focus_hook_set(eco->close, _e_configure_focus_cb, eco);
elm_object_part_content_set(eco->edje, "e.swallow.button", eco->close);
e_util_win_auto_resize_fill(eco->win);
evas_object_show(eco->edje);
evas_object_show(eco->win);
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
e_win_client_icon_set(eco->win, "preferences-system");
/* Preselect "Appearance" */
e_widget_focus_set(eco->cat_list, 1);
if (!e_widget_toolbar_item_selected_get(eco->cat_list))
e_widget_toolbar_item_select(eco->cat_list, 0);
_e_configure = eco;
}
2012-06-14 03:07:33 -07:00
void
e_configure_del(void)
{
if (_e_configure) e_object_del(E_OBJECT(_e_configure));
_e_configure = NULL;
}
2012-06-14 03:07:33 -07:00
static void
_e_configure_free(E_Configure *eco)
{
if (_e_configure->mod_hdl)
ecore_event_handler_del(_e_configure->mod_hdl);
2007-12-04 18:39:48 -08:00
_e_configure->mod_hdl = NULL;
_e_configure = NULL;
2012-06-14 03:07:33 -07:00
while (eco->cats)
{
2012-06-14 03:07:33 -07:00
E_Configure_Category *cat;
2012-06-14 03:07:33 -07:00
if (!(cat = eco->cats->data)) return;
if (cat->label) eina_stringshare_del(cat->label);
2012-06-14 03:07:33 -07:00
while (cat->items)
{
E_Configure_Item *ci;
2012-06-14 03:07:33 -07:00
if (!(ci = cat->items->data)) continue;
if (ci->label) eina_stringshare_del(ci->label);
if (ci->icon_file) eina_stringshare_del(ci->icon_file);
2012-06-14 03:07:33 -07:00
if (ci->icon) eina_stringshare_del(ci->icon);
if (ci->cb)
{
if (ci->cb->path) eina_stringshare_del(ci->cb->path);
free(ci->cb);
}
cat->items = eina_list_remove_list(cat->items, cat->items);
E_FREE(ci);
}
eco->cats = eina_list_remove_list(eco->cats, eco->cats);
E_FREE(cat);
}
// evas_object_del(eco->close);
// evas_object_del(eco->cat_list);
// evas_object_del(eco->item_list);
// evas_object_del(eco->o_list);
// evas_object_del(eco->edje);
evas_object_del(eco->win);
free(eco);
}
2012-06-14 03:07:33 -07:00
static void
_e_configure_cb_del_req(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
e_object_del(E_OBJECT(data));
}
static void
_e_configure_cb_close(void *data, void *data2 __UNUSED__)
{
E_Configure *eco;
if (!(eco = data)) return;
e_util_defer_object_del(E_OBJECT(eco));
}
static E_Configure_Category *
_e_configure_category_add(E_Configure *eco, const char *label, const char *icon_file, const char *icon)
{
Evas_Object *o = NULL;
E_Configure_Category *cat;
if (!eco) return NULL;
if (!label) return NULL;
cat = E_NEW(E_Configure_Category, 1);
cat->eco = eco;
cat->label = eina_stringshare_add(label);
2012-06-14 03:07:33 -07:00
if (icon)
{
o = e_icon_add(eco->evas);
2012-06-14 03:07:33 -07:00
if (icon_file)
e_icon_file_edje_set(o, icon_file, icon);
else if (!e_util_icon_theme_set(o, icon))
2012-06-14 03:07:33 -07:00
{
evas_object_del(o);
o = e_util_icon_add(icon, eco->evas);
}
}
eco->cats = eina_list_append(eco->cats, cat);
2012-06-14 03:07:33 -07:00
e_widget_toolbar_item_append(eco->cat_list, o, label,
_e_configure_category_cb, cat, NULL);
return cat;
}
static void
_e_configure_category_cb(void *data, void *data2 __UNUSED__)
{
E_Configure_Category *cat;
E_Configure *eco;
Eina_List *l;
Evas_Coord w, h;
if (!(cat = data)) return;
eco = cat->eco;
evas_event_freeze(evas_object_evas_get(eco->item_list));
edje_freeze();
e_widget_ilist_freeze(eco->item_list);
e_widget_ilist_clear(eco->item_list);
/***--- fill ---***/
2012-06-14 03:07:33 -07:00
for (l = cat->items; l; l = l->next)
{
2012-06-14 03:07:33 -07:00
E_Configure_Item *ci;
Evas_Object *o = NULL;
if (!(ci = l->data)) continue;
if (ci->icon)
{
o = e_icon_add(eco->evas);
if (ci->icon_file)
e_icon_file_edje_set(o, ci->icon_file, ci->icon);
2012-06-14 03:07:33 -07:00
else if (!e_util_icon_theme_set(o, ci->icon))
{
evas_object_del(o);
o = e_util_icon_add(ci->icon, eco->evas);
}
}
e_widget_ilist_append(eco->item_list, o, ci->label,
_e_configure_item_cb, ci, NULL);
}
e_widget_ilist_go(eco->item_list);
e_widget_size_min_get(eco->item_list, &w, &h);
e_widget_size_min_set(eco->item_list, w, h);
e_widget_ilist_thaw(eco->item_list);
edje_thaw();
evas_event_thaw(evas_object_evas_get(eco->item_list));
}
static void
_e_configure_item_add(E_Configure_Category *cat, const char *label, const char *icon_file, const char *icon, const char *path)
{
E_Configure_Item *ci;
E_Configure_CB *cb;
if ((!cat) || (!label)) return;
ci = E_NEW(E_Configure_Item, 1);
cb = E_NEW(E_Configure_CB, 1);
cb->eco = cat->eco;
cb->path = eina_stringshare_add(path);
ci->cb = cb;
ci->label = eina_stringshare_add(label);
if (icon_file) ci->icon_file = eina_stringshare_add(icon_file);
if (icon) ci->icon = eina_stringshare_add(icon);
if ((!ci->icon_file) && (!ci->icon))
ci->icon = eina_stringshare_add("unknown");
cat->items = eina_list_append(cat->items, ci);
}
2012-06-14 03:07:33 -07:00
static void
_e_configure_item_cb(void *data)
{
E_Configure_Item *ci;
E_Configure_CB *cb;
if (!(ci = data)) return;
cb = ci->cb;
if (cb->path) e_configure_registry_call(cb->path, NULL, NULL);
}
2012-06-14 03:07:33 -07:00
static void
_e_configure_focus_cb(void *data, Evas_Object *obj)
{
E_Configure *eco = data;
2012-06-14 03:07:33 -07:00
if (obj == eco->close)
{
2012-06-14 03:07:33 -07:00
e_widget_focused_object_clear(eco->item_list);
e_widget_focused_object_clear(eco->cat_list);
}
2012-06-14 03:07:33 -07:00
else if (obj == eco->item_list)
{
2012-06-14 03:07:33 -07:00
e_widget_focused_object_clear(eco->cat_list);
e_widget_focused_object_clear(eco->close);
}
2012-06-14 03:07:33 -07:00
else if (obj == eco->cat_list)
{
2012-06-14 03:07:33 -07:00
e_widget_focused_object_clear(eco->item_list);
e_widget_focused_object_clear(eco->close);
}
}
static void
_e_configure_keydown_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
{
Evas_Event_Key_Down *ev;
E_Configure *eco = data;
ev = event;
if (!strcmp(ev->key, "Tab"))
{
if (evas_key_modifier_is_set(evas_key_modifier_get(evas_object_evas_get(eco->win)), "Shift"))
2012-06-14 03:07:33 -07:00
{
if (e_widget_focus_get(eco->close))
e_widget_focus_set(eco->item_list, 0);
else if (e_widget_focus_get(eco->item_list))
e_widget_focus_set(eco->cat_list, 1);
else if (e_widget_focus_get(eco->cat_list))
e_widget_focus_set(eco->close, 0);
}
else
{
if (e_widget_focus_get(eco->close))
e_widget_focus_set(eco->cat_list, 1);
else if (e_widget_focus_get(eco->item_list))
e_widget_focus_set(eco->close, 0);
else if (e_widget_focus_get(eco->cat_list))
e_widget_focus_set(eco->item_list, 0);
}
}
else if (((!strcmp(ev->key, "Return")) ||
(!strcmp(ev->key, "KP_Enter")) ||
(!strcmp(ev->key, "space"))))
{
2012-06-14 03:07:33 -07:00
Evas_Object *o = NULL;
if (e_widget_focus_get(eco->cat_list))
o = eco->cat_list;
else if (e_widget_focus_get(eco->item_list))
o = eco->item_list;
else if (e_widget_focus_get(eco->close))
o = eco->close;
if (o)
{
if (!(o = e_widget_focused_object_get(o))) return;
e_widget_activate(o);
}
}
else if (!strcmp(ev->key, "Escape"))
e_widget_activate(eco->close);
}
2012-06-14 03:07:33 -07:00
static void
_e_configure_fill_cat_list(void *data, const char *sel)
{
E_Configure *eco;
Evas_Coord mw, mh;
E_Configure_Category *cat;
Eina_List *l, *ll;
E_Configure_Cat *ecat;
int num = -1;
if (!(eco = data)) return;
if (eco->cat_list) evas_object_del(eco->cat_list);
if (eco->item_list) evas_object_del(eco->item_list);
eco->cat_list = NULL;
eco->item_list = NULL;
2012-06-14 03:07:33 -07:00
/* Category List */
eco->cat_list = e_widget_toolbar_add(eco->evas, 32 * e_scale, 32 * e_scale);
e_widget_toolbar_scrollable_set(eco->cat_list, 1);
/***--- fill ---***/
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
{
2012-06-14 03:07:33 -07:00
if ((ecat->pri >= 0) && (ecat->items))
{
E_Configure_It *eci;
2012-06-14 03:07:33 -07:00
cat = _e_configure_category_add(eco, _(ecat->label),
ecat->icon_file, ecat->icon);
EINA_LIST_FOREACH(ecat->items, ll, eci)
2012-06-14 03:07:33 -07:00
{
char buf[1024];
if (eci->pri >= 0)
{
snprintf(buf, sizeof(buf), "%s/%s", ecat->cat,
eci->item);
2012-06-14 03:07:33 -07:00
_e_configure_item_add(cat, _(eci->label),
eci->icon_file, eci->icon, buf);
2012-06-14 03:07:33 -07:00
}
}
if (sel && (ecat->cat == sel))
num = e_widget_toolbar_items_count(eco->cat_list) - 1;
2012-06-14 03:07:33 -07:00
}
}
e_widget_on_focus_hook_set(eco->cat_list, _e_configure_focus_cb, eco);
e_widget_list_object_append(eco->o_list, eco->cat_list, 1, 0, 0.5);
/* Item List */
eco->item_list = e_widget_ilist_add(eco->evas, 32 * e_scale, 32 * e_scale, NULL);
e_widget_ilist_selector_set(eco->item_list, 1);
e_widget_ilist_go(eco->item_list);
e_widget_on_focus_hook_set(eco->item_list, _e_configure_focus_cb, eco);
e_widget_size_min_get(eco->item_list, &mw, &mh);
if (mw < (200 * e_scale)) mw = 200 * e_scale;
if (mh < (120 * e_scale)) mh = 120 * e_scale;
e_widget_size_min_set(eco->item_list, mw, mh);
e_widget_list_object_append(eco->o_list, eco->item_list, 1, 1, 0.5);
if (num != -1) e_widget_toolbar_item_select(eco->cat_list, num);
}
static Eina_Bool
_e_configure_module_update_cb(void *data, int type __UNUSED__, void *event __UNUSED__)
{
E_Configure *eco;
int sel = 0;
if (!(eco = data)) return ECORE_CALLBACK_PASS_ON;
if (!eco->cat_list) return ECORE_CALLBACK_PASS_ON;
sel = e_widget_toolbar_item_selected_get(eco->cat_list);
_e_configure_fill_cat_list(eco, NULL);
e_widget_toolbar_item_select(eco->cat_list, sel);
return ECORE_CALLBACK_PASS_ON;
}
2012-06-14 03:07:33 -07:00