add e_widget_check_widget_disable_on_* api for automatically enabling/disabling widgets without needing to add more callbacks

SVN revision: 83661
This commit is contained in:
Mike Blumenkrantz 2013-02-06 08:44:52 +00:00
parent ea684db564
commit 72aa96c65b
4 changed files with 72 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2013-02-06 Mike Blumenkrantz
* added api to automatically disable widgets when checkboxes are checked or unchecked
2013-02-05 Mike Blumenkrantz 2013-02-05 Mike Blumenkrantz
* improve load time of apps dialogs * improve load time of apps dialogs

1
NEWS
View File

@ -23,6 +23,7 @@ Additions:
* added functions for freeing binding config structs * added functions for freeing binding config structs
* E_Config_DD structs are now tracked and retrievable through e_config_descriptor_find * E_Config_DD structs are now tracked and retrievable through e_config_descriptor_find
* add e_border_pointer_warp_to_center_now() * add e_border_pointer_warp_to_center_now()
* e_widget_check_widget_disable_on_*
Config: Config:
* Added option for disabling icons in menus * Added option for disabling icons in menus
* Added option for disabling pointer warping when performing directional focus changes using winlist * Added option for disabling pointer warping when performing directional focus changes using winlist

View File

@ -6,16 +6,37 @@ struct _E_Widget_Data
Evas_Object *o_check; Evas_Object *o_check;
Evas_Object *o_icon; Evas_Object *o_icon;
int *valptr; int *valptr;
Eina_List *widgets_enable;
Eina_List *widgets_disable;
}; };
/* local subsystem functions */ /* local subsystem functions */
static void
_extern_obj_enable_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
E_Widget_Data *wd = data;
wd->widgets_enable = eina_list_remove(wd->widgets_enable, obj);
}
static void
_extern_obj_disable_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
E_Widget_Data *wd = data;
wd->widgets_disable = eina_list_remove(wd->widgets_disable, obj);
}
static void static void
_e_wid_del_hook(Evas_Object *obj) _e_wid_del_hook(Evas_Object *obj)
{ {
E_Widget_Data *wd; E_Widget_Data *wd;
Evas_Object *o;
wd = e_widget_data_get(obj); wd = e_widget_data_get(obj);
EINA_LIST_FREE(wd->widgets_enable, o)
evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL, _extern_obj_enable_del, wd);
EINA_LIST_FREE(wd->widgets_disable, o)
evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL, _extern_obj_disable_del, wd);
free(wd); free(wd);
} }
@ -47,6 +68,9 @@ _e_wid_do(Evas_Object *obj)
wd = e_widget_data_get(obj); wd = e_widget_data_get(obj);
if (wd->valptr) if (wd->valptr)
{ {
Eina_List *l;
Evas_Object *o;
if (*(wd->valptr) == 0) if (*(wd->valptr) == 0)
{ {
*(wd->valptr) = 1; *(wd->valptr) = 1;
@ -57,6 +81,10 @@ _e_wid_do(Evas_Object *obj)
*(wd->valptr) = 0; *(wd->valptr) = 0;
edje_object_signal_emit(wd->o_check, "e,state,unchecked", "e"); edje_object_signal_emit(wd->o_check, "e,state,unchecked", "e");
} }
EINA_LIST_FOREACH(wd->widgets_enable, l, o)
e_widget_disabled_set(o, *wd->valptr);
EINA_LIST_FOREACH(wd->widgets_disable, l, o)
e_widget_disabled_set(o, !(*wd->valptr));
} }
evas_object_smart_callback_call(obj, "changed", NULL); evas_object_smart_callback_call(obj, "changed", NULL);
e_widget_change(obj); e_widget_change(obj);
@ -92,7 +120,6 @@ _e_wid_focus_steal(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
e_widget_focus_steal(data); e_widget_focus_steal(data);
} }
/* externally accessible functions */ /* externally accessible functions */
/** /**
@ -204,6 +231,43 @@ e_widget_check_checked_get(Evas_Object *check)
return ret; return ret;
} }
/**
* Add widget to disable when check object is checked
* @param check the check box widget
* @param obj the object to disable when @p check is checked
*/
EAPI void
e_widget_check_widget_disable_on_checked_add(Evas_Object *check, Evas_Object *obj)
{
E_Widget_Data *wd;
EINA_SAFETY_ON_NULL_RETURN(check);
EINA_SAFETY_ON_NULL_RETURN(obj);
wd = e_widget_data_get(check);
EINA_SAFETY_ON_NULL_RETURN(wd);
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _extern_obj_enable_del, wd);
wd->widgets_enable = eina_list_append(wd->widgets_enable, obj);
}
/**
* Add widget to disable when check object is unchecked
* @param check the check box widget
* @param obj the object to disable when @p check is not unchecked
*/
EAPI void
e_widget_check_widget_disable_on_unchecked_add(Evas_Object *check, Evas_Object *obj)
{
E_Widget_Data *wd;
EINA_SAFETY_ON_NULL_RETURN(check);
EINA_SAFETY_ON_NULL_RETURN(obj);
wd = e_widget_data_get(check);
EINA_SAFETY_ON_NULL_RETURN(wd);
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _extern_obj_disable_del, wd);
wd->widgets_disable = eina_list_append(wd->widgets_disable, obj);
}
/** /**
* Creates a check box widget with icon * Creates a check box widget with icon
* *

View File

@ -9,5 +9,7 @@ EAPI int e_widget_check_checked_get(Evas_Object *check);
EAPI void e_widget_check_valptr_set(Evas_Object *check, int *val); EAPI void e_widget_check_valptr_set(Evas_Object *check, int *val);
EAPI Evas_Object *e_widget_check_icon_add(Evas *evas, const char *label, const char *icon, int icon_w, int icon_h, int *val); EAPI Evas_Object *e_widget_check_icon_add(Evas *evas, const char *label, const char *icon, int icon_w, int icon_h, int *val);
EAPI void e_widget_check_widget_disable_on_checked_add(Evas_Object *check, Evas_Object *obj);
EAPI void e_widget_check_widget_disable_on_unchecked_add(Evas_Object *check, Evas_Object *obj);
#endif #endif
#endif #endif