Eolian: Integration of Prefs

This commit is contained in:
Daniel Zaoui 2014-03-25 14:27:37 +02:00
parent 6b3cc41354
commit 1f5c92fec0
5 changed files with 504 additions and 538 deletions

View File

@ -630,7 +630,9 @@ BUILT_SOURCES = \
elm_plug.eo.c \
elm_plug.eo.h \
elc_popup.eo.c \
elc_popup.eo.h
elc_popup.eo.h \
elm_prefs.eo.c \
elm_prefs.eo.h
EXTRA_DIST += \
elm_widget.eo \
@ -685,7 +687,8 @@ EXTRA_DIST += \
elm_photo.eo \
elc_player.eo \
elm_plug.eo \
elc_popup.eo
elc_popup.eo \
elm_prefs.eo
nodist_includesunstable_HEADERS = \
elm_widget.eo.h \
@ -740,5 +743,6 @@ nodist_includesunstable_HEADERS = \
elm_photo.eo.h \
elc_player.eo.h \
elm_plug.eo.h \
elc_popup.eo.h
elc_popup.eo.h \
elm_prefs.eo.h

View File

@ -10,8 +10,6 @@
#include "Eo.h"
EAPI Eo_Op ELM_OBJ_PREFS_BASE_ID = EO_NOOP;
#define MY_CLASS ELM_OBJ_PREFS_CLASS
#define MY_CLASS_NAME "Elm_Prefs"
@ -45,8 +43,8 @@ static void _elm_prefs_values_get_default(Elm_Prefs_Page_Node *,
static Eina_Bool _prefs_item_widget_value_from_self(Elm_Prefs_Item_Node *,
Eina_Bool);
static void
_elm_prefs_smart_add(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
EOLIAN static void
_elm_prefs_evas_smart_add(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED)
{
eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
elm_widget_sub_object_parent_add(obj);
@ -148,7 +146,7 @@ end:
}
static void
_root_node_free(Elm_Prefs_Smart_Data *sd)
_root_node_free(Elm_Prefs_Data *sd)
{
_page_free(sd->root);
}
@ -224,7 +222,7 @@ _prefs_data_type_fix(Elm_Prefs_Item_Node *it,
}
static Eina_Bool
_prefs_item_widget_value_from_data(Elm_Prefs_Smart_Data *sd,
_prefs_item_widget_value_from_data(Elm_Prefs_Data *sd,
Elm_Prefs_Item_Node *it,
Eina_Value *value)
{
@ -328,7 +326,7 @@ _elm_prefs_page_item_by_name(Elm_Prefs_Page_Node *p,
}
static Elm_Prefs_Item_Node *
_elm_prefs_item_node_by_name(Elm_Prefs_Smart_Data *sd,
_elm_prefs_item_node_by_name(Elm_Prefs_Data *sd,
const char *name)
{
char buf[PATH_MAX];
@ -347,7 +345,7 @@ _elm_prefs_item_node_by_name(Elm_Prefs_Smart_Data *sd,
}
static Eina_List *
_elm_prefs_item_list_node_by_name(Elm_Prefs_Smart_Data *sd,
_elm_prefs_item_list_node_by_name(Elm_Prefs_Data *sd,
const char *name)
{
Elm_Prefs_Item_Node *it;
@ -446,11 +444,9 @@ _elm_prefs_data_cbs_del(Eo *obj)
"prefs data handle");
}
static void
_elm_prefs_smart_del(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
EOLIAN static void
_elm_prefs_evas_smart_del(Eo *obj, Elm_Prefs_Data *sd)
{
Elm_Prefs_Smart_Data *sd = _pd;
sd->delete_me = EINA_TRUE;
if (sd->saving_poller) ecore_poller_del(sd->saving_poller);
@ -474,39 +470,28 @@ _elm_prefs_smart_del(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
}
static void
_elm_prefs_smart_focus_next(Eo *obj, void *_pd, va_list *list)
EOLIAN static Eina_Bool
_elm_prefs_elm_widget_focus_next(Eo *obj, Elm_Prefs_Data *sd, Elm_Focus_Direction dir, Evas_Object **next)
{
Elm_Prefs_Smart_Data *sd = _pd;
Elm_Focus_Direction dir = va_arg(*list, Elm_Focus_Direction);
Evas_Object **next = va_arg(*list, Evas_Object **);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
Eina_Bool mret;
const Eina_List *items;
ELM_PREFS_CHECK(obj);
ELM_PREFS_CHECK(obj) EINA_FALSE;
items = elm_widget_focus_custom_chain_get(obj);
if (items)
{
mret = elm_widget_focus_list_next_get
return elm_widget_focus_list_next_get
(obj, items, eina_list_data_get, dir, next);
if (ret) *ret = mret;
return;
}
if (sd->root && sd->root->w_obj)
{
mret = elm_widget_focus_next_get(sd->root->w_obj, dir, next);
if (ret) *ret = mret;
return;
return elm_widget_focus_next_get(sd->root->w_obj, dir, next);
}
if (next) *next = NULL;
if (ret) *ret = EINA_FALSE;
return EINA_FALSE;
}
EAPI Evas_Object *
@ -526,8 +511,8 @@ elm_prefs_add(Evas_Object *parent)
return obj;
}
static void
_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
EOLIAN static void
_elm_prefs_eo_base_constructor(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED)
{
eo_do_super(obj, MY_CLASS, eo_constructor());
eo_do(obj,
@ -1061,7 +1046,7 @@ _elm_prefs_values_get_default(Elm_Prefs_Page_Node *page,
}
static void
_elm_prefs_values_get_user(Elm_Prefs_Smart_Data *sd,
_elm_prefs_values_get_user(Elm_Prefs_Data *sd,
Elm_Prefs_Page_Node *p)
{
char buf[PATH_MAX];
@ -1137,33 +1122,16 @@ _elm_prefs_values_get_user(Elm_Prefs_Smart_Data *sd,
}
}
EAPI Eina_Bool
elm_prefs_file_set(Evas_Object *obj,
const char *file,
const char *page)
{
ELM_PREFS_CHECK(obj) EINA_FALSE;
Eina_Bool ret;
eo_do(obj, elm_obj_prefs_file_set(file, page, &ret));
return ret;
}
static void
_elm_prefs_file_set(Eo *obj, void *_pd, va_list *list)
EOLIAN static Eina_Bool
_elm_prefs_file_set(Eo *obj, Elm_Prefs_Data *sd, const char *file, const char *page)
{
const char *prefix;
const char *file = va_arg(*list, const char *);
const char *page = va_arg(*list, const char *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
Elm_Prefs_Smart_Data *sd = _pd;
if (!_elm_prefs_init_count)
{
CRI("prefs_iface module is not loaded! you can't"
" create prefs widgets");
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
prefix = elm_app_data_dir_get();
if (!strlen(prefix))
@ -1186,19 +1154,14 @@ _elm_prefs_file_set(Eo *obj, void *_pd, va_list *list)
sd->page = eina_stringshare_add(page ? page : "main");
sd->root = _elm_prefs_page_load(obj, sd->page);
if (!sd->root)
{
*ret = EINA_FALSE;
return;
}
if (!sd->root) return EINA_FALSE;
if (!_elm_prefs_page_populate(sd->root, obj))
{
_root_node_free(sd);
sd->root = NULL;
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
elm_widget_resize_object_set(obj, sd->root->w_obj, EINA_TRUE);
@ -1208,62 +1171,25 @@ _elm_prefs_file_set(Eo *obj, void *_pd, va_list *list)
evas_object_smart_callback_call
(obj, SIG_PAGE_LOADED, (char *)sd->root->name);
*ret = EINA_TRUE;
return EINA_TRUE;
}
EAPI Eina_Bool
elm_prefs_file_get(const Evas_Object *obj,
const char **file,
const char **page)
EOLIAN static Eina_Bool
_elm_prefs_file_get(Eo *obj EINA_UNUSED, Elm_Prefs_Data *sd, const char **file, const char **page)
{
ELM_PREFS_CHECK(obj) EINA_FALSE;
Eina_Bool ret;
eo_do((Eo *) obj, elm_obj_prefs_file_get(file, page, &ret));
return ret;
}
static void
_elm_prefs_file_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
{
const char **file = va_arg(*list, const char **);
const char **page = va_arg(*list, const char **);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
Elm_Prefs_Smart_Data *sd = _pd;
if (file) *file = sd->file;
if (page) *page = sd->page;
*ret = EINA_TRUE;
return EINA_TRUE;
}
EAPI Eina_Bool
elm_prefs_data_set(Evas_Object *obj,
Elm_Prefs_Data *prefs_data)
EOLIAN static Eina_Bool
_elm_prefs_data_set(Eo *obj, Elm_Prefs_Data *sd, Elm_Prefs_Data *prefs_data)
{
ELM_PREFS_CHECK(obj) EINA_FALSE;
Eina_Bool ret;
eo_do(obj, elm_obj_prefs_data_set(prefs_data, &ret));
return ret;
}
static void
_elm_prefs_data_set(Eo *obj, void *_pd, va_list *list)
{
Elm_Prefs_Smart_Data *sd = _pd;
Elm_Prefs_Data *prefs_data = va_arg(*list, Elm_Prefs_Data *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
if (!sd->root)
{
*ret = EINA_FALSE;
return;
}
if (!sd->root) return EINA_FALSE;
if (prefs_data && !_elm_prefs_data_cbs_add(obj, prefs_data))
{
*ret = EINA_FALSE;
return;
}
return EINA_FALSE;
if (sd->prefs_data)
{
@ -1292,41 +1218,20 @@ end:
evas_object_smart_callback_call
(obj, SIG_PAGE_CHANGED, (char *)sd->root->name);
*ret = EINA_TRUE;
return EINA_TRUE;
}
EAPI Elm_Prefs_Data *
elm_prefs_data_get(const Evas_Object *obj)
EOLIAN static Elm_Prefs_Data*
_elm_prefs_data_get(Eo *obj EINA_UNUSED, Elm_Prefs_Data *sd)
{
ELM_PREFS_CHECK(obj) NULL;
Elm_Prefs_Data *ret;
eo_do((Eo *) obj, elm_obj_prefs_data_get(&ret));
return ret;
if (!sd->root) return NULL;
else return sd->prefs_data;
}
static void
_elm_prefs_data_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
{
Elm_Prefs_Smart_Data *sd = _pd;
Elm_Prefs_Data **ret = va_arg(*list, Elm_Prefs_Data **);
if (!sd->root) *ret = NULL;
else *ret = sd->prefs_data;
}
EAPI void
elm_prefs_autosave_set(Evas_Object *obj,
Eina_Bool autosave)
{
ELM_PREFS_CHECK(obj);
eo_do(obj, elm_obj_prefs_autosave_set(autosave));
}
static void
_elm_prefs_autosave_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
EOLIAN static void
_elm_prefs_autosave_set(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, Eina_Bool autosave)
{
ELM_PREFS_DATA_GET(obj, sd);
Eina_Bool autosave = va_arg(*list, int);
autosave = !!autosave;
@ -1351,38 +1256,15 @@ _elm_prefs_autosave_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
}
}
EAPI Eina_Bool
elm_prefs_autosave_get(const Evas_Object *obj)
EOLIAN static Eina_Bool
_elm_prefs_autosave_get(Eo *obj EINA_UNUSED, Elm_Prefs_Data *sd)
{
ELM_PREFS_CHECK(obj) EINA_FALSE;
Eina_Bool ret;
eo_do((Eo *) obj, elm_obj_prefs_autosave_get(&ret));
return ret;
return sd->autosave;
}
static void
_elm_prefs_autosave_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
EOLIAN static void
_elm_prefs_reset(Eo *obj EINA_UNUSED, Elm_Prefs_Data *sd, Elm_Prefs_Reset_Mode mode)
{
Elm_Prefs_Smart_Data *sd = _pd;
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
*ret = sd->autosave;
}
EAPI void
elm_prefs_reset(Evas_Object *obj,
Elm_Prefs_Reset_Mode mode)
{
ELM_PREFS_CHECK(obj);
eo_do(obj, elm_obj_prefs_reset(mode));
}
static void
_elm_prefs_reset(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
{
Elm_Prefs_Smart_Data *sd = _pd;
Elm_Prefs_Reset_Mode mode = va_arg(*list, Elm_Prefs_Reset_Mode);
EINA_SAFETY_ON_NULL_RETURN(sd->root);
if (mode == ELM_PREFS_RESET_DEFAULTS)
@ -1412,57 +1294,32 @@ _elm_prefs_item_api_entry_common(const Evas_Object *obj,
return ret;
}
EAPI Eina_Bool
elm_prefs_item_value_set(Evas_Object *obj,
const char *name,
const Eina_Value *value)
{
ELM_PREFS_CHECK(obj) EINA_FALSE;
Eina_Bool ret;
eo_do(obj, elm_obj_prefs_item_value_set(name, value, &ret));
return ret;
}
static void
_elm_prefs_item_value_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
EOLIAN static Eina_Bool
_elm_prefs_item_value_set(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, const char *name, const Eina_Value *value)
{
const Eina_Value_Type *t, *def_t;
Elm_Prefs_Item_Node *it;
Eina_Value it_val;
const char *name = va_arg(*list, const char *);
const Eina_Value *value = va_arg(*list, const Eina_Value *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
it = _elm_prefs_item_api_entry_common(obj, name);
if (!it)
{
*ret = EINA_FALSE;
return;
}
if (!it) return EINA_FALSE;
if (!_elm_prefs_item_has_value(it))
{
ERR("item %s has no underlying value, you can't operate on it",
it->name);
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
EINA_SAFETY_ON_NULL_RETURN(value);
EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
t = eina_value_type_get(value);
if (!t)
{
*ret = EINA_FALSE;
return;
}
if (!t) return EINA_FALSE;
if (!it->available)
{
ERR("widget of item %s has been deleted, we can't set values on it",
it->name);
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
if (!it->w_impl->value_get(it->w_obj, &it_val))
@ -1487,114 +1344,62 @@ _elm_prefs_item_value_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
}
eina_value_flush(&it_val);
*ret = EINA_TRUE;
return;
return EINA_TRUE;
err:
*ret = EINA_FALSE;
return EINA_FALSE;
}
EAPI Eina_Bool
elm_prefs_item_value_get(const Evas_Object *obj,
const char *name,
Eina_Value *value)
{
ELM_PREFS_CHECK(obj) EINA_FALSE;
Eina_Bool ret;
eo_do((Eo *) obj, elm_obj_prefs_item_value_get(name, value, &ret));
return ret;
}
static void
_elm_prefs_item_value_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
EOLIAN static Eina_Bool
_elm_prefs_item_value_get(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, const char *name, Eina_Value *value)
{
Elm_Prefs_Item_Node *it;
const char *name = va_arg(*list, const char *);
Eina_Value *value = va_arg(*list, Eina_Value *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
it = _elm_prefs_item_api_entry_common(obj, name);
if (!it)
{
*ret = EINA_FALSE;
return;
}
if (!it) return EINA_FALSE;
if (!_elm_prefs_item_has_value(it))
{
ERR("item %s has no underlying value, you can't operate on it",
it->name);
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
if (!value)
{
*ret = EINA_FALSE;
return;
}
if (!value) return EINA_FALSE;
if (!it->available)
{
ERR("widget of item %s has been deleted, we can't set values on it",
it->name);
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
if (!it->w_impl->value_get(it->w_obj, value))
{
ERR("failed to fetch value from widget of item %s", it->name);
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
*ret = EINA_TRUE;
return EINA_TRUE;
}
EAPI const Evas_Object *
elm_prefs_item_object_get(Evas_Object *obj,
const char *name)
{
ELM_PREFS_CHECK(obj) NULL;
const Evas_Object *ret;
eo_do(obj, elm_obj_prefs_item_object_get(name, &ret));
return ret;
}
static void
_elm_prefs_item_object_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
EOLIAN static const Evas_Object*
_elm_prefs_item_object_get(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, const char *name)
{
Elm_Prefs_Item_Node *it;
const char *name = va_arg(*list, const char *);
const Evas_Object **ret = va_arg(*list, const Evas_Object **);
it = _elm_prefs_item_api_entry_common(obj, name);
if (!it) *ret = NULL;
else *ret = it->w_obj;
if (!it) return NULL;
else return it->w_obj;
}
EAPI void
elm_prefs_item_visible_set(Evas_Object *obj,
const char *name,
Eina_Bool visible)
{
ELM_PREFS_CHECK(obj);
eo_do(obj, elm_obj_prefs_item_visible_set(name, visible));
}
static void
_elm_prefs_item_visible_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
EOLIAN static void
_elm_prefs_item_visible_set(Eo *obj EINA_UNUSED, Elm_Prefs_Data *sd, const char *name, Eina_Bool visible)
{
Elm_Prefs_Item_Node *it;
Eina_List *l;
Evas_Object *lbl, *icon;
Elm_Prefs_Smart_Data *sd = _pd;
const char *name = va_arg(*list, const char *);
Eina_Bool visible = va_arg(*list, int);
EINA_SAFETY_ON_NULL_RETURN(name);
EINA_SAFETY_ON_NULL_RETURN(sd->root);
@ -1670,55 +1475,27 @@ _elm_prefs_item_visible_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
}
}
EAPI Eina_Bool
elm_prefs_item_visible_get(const Evas_Object *obj,
const char *name)
EOLIAN static Eina_Bool
_elm_prefs_item_visible_get(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, const char *name)
{
ELM_PREFS_CHECK(obj) EINA_FALSE;
Eina_Bool ret;
eo_do((Eo *) obj, elm_obj_prefs_item_visible_get(name, &ret));
return ret;
}
static void
_elm_prefs_item_visible_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
{
const char *name = va_arg(*list, const char *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
Elm_Prefs_Item_Node *it;
it = _elm_prefs_item_api_entry_common(obj, name);
if (!it)
{
*ret = EINA_FALSE;
return;
}
if (!it) return EINA_FALSE;
if (!it->available)
{
ERR("widget of item %s has been deleted, we can't act on it",
it->name);
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
*ret = it->visible;
return it->visible;
}
EAPI void
elm_prefs_item_disabled_set(Evas_Object *obj,
const char *name,
Eina_Bool disabled)
EOLIAN static void
_elm_prefs_item_disabled_set(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, const char *name, Eina_Bool disabled)
{
ELM_PREFS_CHECK(obj);
eo_do(obj, elm_obj_prefs_item_disabled_set(name, disabled));
}
static void
_elm_prefs_item_disabled_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
{
const char *name = va_arg(*list, const char *);
Eina_Bool disabled = va_arg(*list, int);
Elm_Prefs_Item_Node *it;
it = _elm_prefs_item_api_entry_common(obj, name);
@ -1734,55 +1511,27 @@ _elm_prefs_item_disabled_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
elm_object_disabled_set(it->w_obj, disabled);
}
EAPI Eina_Bool
elm_prefs_item_disabled_get(const Evas_Object *obj,
const char *name)
EOLIAN static Eina_Bool
_elm_prefs_item_disabled_get(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, const char *name)
{
ELM_PREFS_CHECK(obj) EINA_FALSE;
Eina_Bool ret;
eo_do((Eo *) obj, elm_obj_prefs_item_disabled_get(name, &ret));
return ret;
}
static void
_elm_prefs_item_disabled_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
{
const char *name = va_arg(*list, const char *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
Elm_Prefs_Item_Node *it;
it = _elm_prefs_item_api_entry_common(obj, name);
if (!it)
{
*ret = EINA_FALSE;
return;
}
if (!it) return EINA_FALSE;
if (!it->available)
{
ERR("widget of item %s has been deleted, we can't act on it",
it->name);
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
*ret = elm_object_disabled_get(it->w_obj);
return elm_object_disabled_get(it->w_obj);
}
EAPI void
elm_prefs_item_editable_set(Evas_Object *obj,
const char *name,
Eina_Bool editable)
EOLIAN static void
_elm_prefs_item_editable_set(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, const char *name, Eina_Bool editable)
{
ELM_PREFS_CHECK(obj);
eo_do(obj, elm_obj_prefs_item_editable_set(name, editable));
}
static void
_elm_prefs_item_editable_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
{
const char *name = va_arg(*list, const char *);
Eina_Bool editable = va_arg(*list, int);
Elm_Prefs_Item_Node *it;
it = _elm_prefs_item_api_entry_common(obj, name);
@ -1798,136 +1547,79 @@ _elm_prefs_item_editable_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
it->w_impl->editable_set(it->w_obj, editable);
}
EAPI Eina_Bool
elm_prefs_item_editable_get(const Evas_Object *obj,
const char *name)
EOLIAN static Eina_Bool
_elm_prefs_item_editable_get(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, const char *name)
{
ELM_PREFS_CHECK(obj) EINA_FALSE;
Eina_Bool ret;
eo_do((Eo *) obj, elm_obj_prefs_item_editable_get(name, &ret));
return ret;
}
static void
_elm_prefs_item_editable_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
{
const char *name = va_arg(*list, const char *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
Elm_Prefs_Item_Node *it;
it = _elm_prefs_item_api_entry_common(obj, name);
if (!it)
{
*ret = EINA_FALSE;
return;
}
if (!it) return EINA_FALSE;
if (!it->w_impl->editable_get)
{
ERR("the item %s does not implement the 'editable' "
"property (using widget %s)", it->name, it->widget);
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
*ret = it->w_impl->editable_get(it->w_obj);
return it->w_impl->editable_get(it->w_obj);
}
EAPI Eina_Bool
elm_prefs_item_swallow(Evas_Object *obj,
const char *name,
Evas_Object *child)
{
ELM_PREFS_CHECK(obj) EINA_FALSE;
Eina_Bool ret;
eo_do(obj, elm_obj_prefs_item_swallow(name, child, &ret));
return ret;
}
static void
_elm_prefs_item_swallow(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
EOLIAN static Eina_Bool
_elm_prefs_item_swallow(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, const char *name, Evas_Object *child)
{
Eina_Value v;
const char *name = va_arg(*list, const char *);
Evas_Object *child = va_arg(*list, Evas_Object *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
Eina_Bool ret = EINA_FALSE;
Elm_Prefs_Item_Node *it = _elm_prefs_item_api_entry_common(obj, name);
if (!it)
{
*ret = EINA_FALSE;
return;
}
if (!it) return EINA_FALSE;
if (it->type != ELM_PREFS_TYPE_SWALLOW)
{
ERR("item %s does not match a SWALLOW item", name);
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
if (!eina_value_setup(&v, EINA_VALUE_TYPE_UINT64))
{
*ret = EINA_FALSE;
return;
}
if (!eina_value_setup(&v, EINA_VALUE_TYPE_UINT64)) return EINA_FALSE;
if (!eina_value_set(&v, child))
{
eina_value_flush(&v);
*ret = EINA_FALSE;
return;
return EINA_FALSE;
}
*ret = it->w_impl->value_set(it->w_obj, &v);
ret = it->w_impl->value_set(it->w_obj, &v);
eina_value_flush(&v);
}
EAPI Evas_Object *
elm_prefs_item_unswallow(Evas_Object *obj,
const char *name)
{
ELM_PREFS_CHECK(obj) NULL;
Evas_Object *ret;
eo_do(obj, elm_obj_prefs_item_unswallow(name, &ret));
return ret;
}
static void
_elm_prefs_item_unswallow(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
EOLIAN static Evas_Object*
_elm_prefs_item_unswallow(Eo *obj, Elm_Prefs_Data *_pd EINA_UNUSED, const char *name)
{
Eina_Value v;
const char *name = va_arg(*list, const char *);
Evas_Object **ret = va_arg(*list, Evas_Object **);
Evas_Object *ret = NULL;
Elm_Prefs_Item_Node *it = _elm_prefs_item_api_entry_common(obj, name);
if (!it)
{
*ret = NULL;
return;
}
if (!it) return NULL;
if (it->type != ELM_PREFS_TYPE_SWALLOW)
{
ERR("item %s does not match a SWALLOW item", name);
*ret = NULL;
return;
return NULL;
}
if (!(it->w_impl->value_get(it->w_obj, &v)))
{
*ret = NULL;
return;
}
if (!(it->w_impl->value_get(it->w_obj, &v))) return NULL;
if (eina_value_type_get(&v) != EINA_VALUE_TYPE_UINT64 ||
!eina_value_get(&v, ret))
{
eina_value_flush(&v);
*ret = NULL;
return;
return NULL;
}
eina_value_flush(&v);
return ret;
}
static unsigned int
@ -2173,130 +1865,9 @@ _elm_prefs_shutdown(void)
}
static void
_class_constructor(Eo_Class *klass)
_elm_prefs_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_ADD),
_elm_prefs_smart_add),
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_DEL),
_elm_prefs_smart_del),
EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_NEXT),
_elm_prefs_smart_focus_next),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_FILE_SET),
_elm_prefs_file_set),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_FILE_GET),
_elm_prefs_file_get),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_DATA_SET),
_elm_prefs_data_set),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_DATA_GET),
_elm_prefs_data_get),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_AUTOSAVE_SET),
_elm_prefs_autosave_set),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_AUTOSAVE_GET),
_elm_prefs_autosave_get),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_RESET),
_elm_prefs_reset),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_VALUE_SET),
_elm_prefs_item_value_set),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_VALUE_GET),
_elm_prefs_item_value_get),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_OBJECT_GET),
_elm_prefs_item_object_get),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_VISIBLE_SET),
_elm_prefs_item_visible_set),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_VISIBLE_GET),
_elm_prefs_item_visible_get),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_DISABLED_SET),
_elm_prefs_item_disabled_set),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_DISABLED_GET),
_elm_prefs_item_disabled_get),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_EDITABLE_SET),
_elm_prefs_item_editable_set),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_EDITABLE_GET),
_elm_prefs_item_editable_get),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_SWALLOW),
_elm_prefs_item_swallow),
EO_OP_FUNC(ELM_OBJ_PREFS_ID(ELM_OBJ_PREFS_SUB_ID_ITEM_UNSWALLOW),
_elm_prefs_item_unswallow),
EO_OP_FUNC_SENTINEL
};
eo_class_funcs_set(klass, func_desc);
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
}
static const Eo_Op_Description op_desc[] = {
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_FILE_SET, "Set file and page to populate a given "
"prefs widget's interface."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_FILE_GET, "Retrieve file and page bound to a given "
"prefs widget."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_DATA_SET, "Set user data for a given prefs widget."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_DATA_GET, "Retrieve user data for a given prefs "
"widget."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_AUTOSAVE_SET, "Set whether a given prefs widget "
"should save its values back (on the user data file, if set) "
"automatically on every UI element changes."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_AUTOSAVE_GET, "Get whether a given prefs widget is "
"saving its values back automatically on changes."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_RESET, "Reset the values of a given prefs widget to "
"a previous state."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_VALUE_SET, "Set the value on a given prefs "
"widget's item."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_VALUE_GET, "Retrieve the value of a given prefs"
" widget's item."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_OBJECT_GET, "Retrieve the Elementary widget "
"bound to a given prefs widget's item."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_VISIBLE_SET, "Set whether the widget bound to "
"given prefs widget's item should be visible or not."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_VISIBLE_GET, "Retrieve whether the widget bound"
" to a given prefs widget's item is visible or not."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_DISABLED_SET, "Set whether the widget bound to "
"a given prefs widget's item is disabled or not."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_DISABLED_GET, "Retrieve whether the widget "
"bound to a given prefs widget's item is disabled or not."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_EDITABLE_SET, "Set whether the widget bound to "
"a given prefs widget's item is editable or not."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_EDITABLE_GET, "Retrieve whether the widget "
"bound to a given prefs widget's item is editable or not."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_SWALLOW, "\"Swallows\" an object into a SWALLOW"
" item of a prefs widget."),
EO_OP_DESCRIPTION
(ELM_OBJ_PREFS_SUB_ID_ITEM_UNSWALLOW, "Unswallow an object from a SWALLOW"
" item of a prefs widget."),
EO_OP_DESCRIPTION_SENTINEL
};
static const Eo_Class_Description class_desc = {
EO_VERSION,
MY_CLASS_NAME,
EO_CLASS_TYPE_REGULAR,
EO_CLASS_DESCRIPTION_OPS
(&ELM_OBJ_PREFS_BASE_ID, op_desc, ELM_OBJ_PREFS_SUB_ID_LAST),
NULL,
sizeof(Elm_Prefs_Smart_Data),
_class_constructor,
NULL
};
EO_DEFINE_CLASS(elm_obj_prefs_class_get, &class_desc, ELM_OBJ_WIDGET_CLASS, NULL);
#include "elm_prefs.eo.c"

View File

@ -0,0 +1,388 @@
class Elm_Prefs (Elm_Widget)
{
eo_prefix: elm_obj_prefs;
properties {
data {
set {
/*@
Set user data for a given prefs widget
@return @c EINA_TRUE, on success, @c EINA_FALSE otherwise
Once a prefs widget is created, after elm_prefs_file_set() is
issued on it, all of its UI elements will get default values, when
declared on that file. To fetch an user's own, personal set of
those values, one gets to pair a <b>prefs data</b> handle to the
prefs widget. This is what this call is intended for.
Prefs data values from @a prefs_data with keys matching the ones
present on the file passed on elm_prefs_file_set() to @a obj will
have their values applied to the respective UI elements of the
widget.
When @a obj dies, the values of the elements declared on its @b
.epb file (the one set on elm_prefs_file_set()) marked as permanent
<b>will be written back</b> to @a prefs_data, if it is writable.
One is also able to make this writing event to take place
automatically after each UI element modification by using
elm_prefs_autosave_set().
@note @a obj will keep a reference of its own for @a prefs_data,
but you should still unreference it by yourself, after the widget
is gone.
@see elm_prefs_data_get()
@since 1.8 */
return Eina_Bool;
}
get {
/*@
Retrieve user data for a given prefs widget
@return A pointer to the user data of a given prefs widget on success.
@c NULL otherwise.
@see elm_prefs_data_set() for more details
@since 1.8 */
}
values {
Elm_Prefs_Data *data; /*@ A valid prefs_data handle */
}
}
file {
set {
/*@
Set file and page to populate a given prefs widget's interface.
@return @c EINA_TRUE, on success, @c EINA_FALSE otherwise
Elm prefs widgets start blank, with no child widgets. It's meant to
have its viewport populated with child elements coming from a
declaration file. That file (usually with @b .epb extension), is a
binary format (Eet) one, coming from a human-readable textual
declaration. This textual form (usually with @b .epc extension) is
translated to the binary form by means of the @b prefs_cc compiler.
With this function, one thus populates a prefs widget with UI
elements.
If @a file is @c NULL, "elm_app_data_dir_get()/preferences.epb"
will be used, by default. If @a file is a @b relative path, the
prefix "elm_app_data_dir_get()/" will be implicitly used with it.
If @a page is @c NULL, it is considered "main", as default.
@warning If your binary is not properly installed and
elm_app_data_dir_get() can't be figured out, a fallback value of
"." will be tryed, instead.
@see elm_prefs_file_get()
@since 1.8 */
return Eina_Bool;
}
get {
/*@
Retrieve file and page bound to a given prefs widget.
@return @c EINA_TRUE, on success, @c EINA_FALSE otherwise
@note Use @c NULL pointers on the components you're not
interested in: they'll be ignored by the function.
@see elm_prefs_file_set() for more information
@since 1.8 */
return Eina_Bool;
}
values {
const char *file; /*@ The @b .epb (binary) file to get contents from */
const char *page; /*@ The page, inside @a file, where to get item contents from */
}
}
autosave {
set {
/*@
Set whether a given prefs widget should save its values back (on
the user data file, if set) automatically on every UI element
changes.
If @a autosave is @c EINA_TRUE, every call to
elm_prefs_item_value_set(), every
Elm_Prefs_Data_Event_Type::ELM_PREFS_DATA_EVENT_ITEM_CHANGED event
coming for its prefs data and every UI element direct value
changing will implicitly make the prefs values to be flushed back
to it prefs data. If a prefs data handle with no writing
permissions or no prefs data is set on @a prefs, naturally nothing
will happen.
@see elm_prefs_autosave_get()
@since 1.8 */
}
get {
/*@
Get whether a given prefs widget is saving its values back
automatically on changes.
@return @c EINA_TRUE if @a prefs is saving automatically,
@c EINA_FALSE otherwise.
@see elm_prefs_autosave_set(), for more details
@since 1.8 */
}
values {
Eina_Bool autosave; /*@ @c EINA_TRUE to save automatically, @c EINA_FALSE
otherwise. */
}
}
}
methods {
reset {
/*@
Reset the values of a given prefs widget to a previous state.
As can be seen on #Elm_Prefs_Reset_Mode, there are two possible
actions to be taken by this call -- either to reset @a prefs'
values to the defaults (declared on the @c .epb file it is bound
to) or to reset to the state they were before the last modification
it got.
@since 1.8 */
params {
@in Elm_Prefs_Reset_Mode mode; /*@ The reset mode to apply on @a prefs */
}
}
item_value_set {
/*@
Set the value on a given prefs widget's item.
@return @c EINA_TRUE, on success, @c EINA_FALSE otherwise
This will change the value of item named @a name programatically.
@see elm_prefs_item_value_get()
@since 1.8 */
return Eina_Bool;
params {
@in const char *name; /*@ The name of the item (as declared in the prefs
collection) */
@in const Eina_Value *value; /*@ The value to set on the item. It should be typed as
the item expects, preferably, or a conversion will
take place */
}
}
item_value_get {
/*@
Retrieve the value of a given prefs widget's item.
@return @c EINA_TRUE, on success, @c EINA_FALSE otherwise
This will retrieve the value of item named @a name.
@see elm_prefs_item_value_set()
@since 1.8 */
const;
return Eina_Bool;
params {
@in const char *name; /*@ The name of the item (as declared in the prefs
collection) to get value from */
@out Eina_Value value; /*@ Where to store the value of the item. It will be
overwritten and setup with the type the item
is bound to */
}
}
item_object_get {
/*@
Retrieve the Elementary widget bound to a given prefs widget's
item.
@return A valid widget handle, on success, or @c NULL, otherwise
This will retrieve a handle to the real widget implementing a given
item of @a prefs, <b>for read-only</b> actions.
@warning You should @b never modify the state of the returned
widget, because it's meant to be managed by @a prefs, solely.
@see elm_prefs_item_value_set()
@since 1.8 */
return const Evas_Object *;
params {
@in const char *name; /*@ The name of the item (as declared in the prefs
collection) to get object from */
}
}
item_disabled_set {
/*@
Set whether the widget bound to a given prefs widget's item is
disabled or not.
@see elm_prefs_item_disabled_get()
@since 1.8 */
params {
@in const char *name; /*@ The name of the item (as declared in the prefs
collection) to act on */
@in Eina_Bool disabled; /*@ @c EINA_TRUE, to make it disabled, @c EINA_FALSE
otherwise */
}
}
item_disabled_get {
/*@
Retrieve whether the widget bound to a given prefs widget's item is
disabled or not.
@return @c EINA_TRUE, if it is disabled, @c EINA_FALSE
otherwise
@see elm_prefs_item_disabled_set()
@since 1.8 */
const;
return Eina_Bool;
params {
@in const char *name; /*@ The name of the item (as declared in the prefs
collection) to get disabled state from */
}
}
item_swallow {
/*@
"Swallows" an object into a SWALLOW item of a prefs widget.
@return @c EINA_TRUE, on success, @c EINA_FALSE otherwise
@see elm_prefs_item_swallow() for more details
@since 1.8 */
return Eina_Bool;
params {
@in const char *name; /*@ the name of the SWALLOW item (as declared in the prefs
collection) */
@in Evas_Object *child; /*@ The object to occupy the item */
}
}
item_editable_set {
/*@
Set whether the widget bound to a given prefs widget's item is
editable or not.
@note Only @c TEXT or @c TEXTAREA items' default widgets implement
the 'editable' property. Custom registered widgets may as well
implement them.
@see elm_prefs_item_editable_get()
@since 1.8 */
params {
@in const char *name; /*@ The name of the item (as declared in the prefs
collection) to act on */
@in Eina_Bool editable; /*@ @c EINA_TRUE, to make it editable, @c EINA_FALSE
otherwise */
}
}
item_editable_get {
/*@
Retrieve whether the widget bound to a given prefs widget's item is
editable or not.
@return @c EINA_TRUE, if it is editable, @c EINA_FALSE
otherwise
@see elm_prefs_item_editable_set() for more details
@since 1.8 */
const;
return Eina_Bool;
params {
@in const char *name; /*@ The name of the item (as declared in the prefs
collection) to get editable state from */
}
}
item_unswallow {
/*@
Unswallow an object from a SWALLOW item of a prefs widget.
@return The unswallowed object, or NULL on errors
@see elm_prefs_item_unswallow() for more details
@since 1.8 */
return Evas_Object *;
params {
@in const char *name; /*@ the name of the SWALLOW item (as declared in the prefs
collection) */
}
}
item_visible_set {
/*@
Set whether the widget bound to given prefs widget's item should be
visible or not.
Each prefs item may have a default visibility state, declared on
the @c .epb @a prefs it was loaded with. By this call one may alter
that state, programatically.
@see elm_prefs_item_visible_get()
@since 1.8 */
params {
@in const char *name; /*@ The name of the item (as declared in the prefs
collection) to change visibility of */
@in Eina_Bool visible; /*@ @c EINA_TRUE, to make it visible, @c EINA_FALSE
otherwise */
}
}
item_visible_get {
/*@
Retrieve whether the widget bound to a given prefs widget's item is
visible or not.
@return @c EINA_TRUE, if it is visible, @c EINA_FALSE
otherwise
@see elm_prefs_item_visible_set() for more details
@since 1.8 */
const;
return Eina_Bool;
params {
@in const char *name; /*@ The name of the item (as declared in the prefs
collection) to get visibility state from */
}
}
}
implements {
class::constructor;
Eo_Base::constructor;
Evas_Smart::del;
Evas_Smart::add;
Elm_Widget::focus_next;
}
events {
page,changed; /*@ s */
page,saved; /*@ s */
page,reset; /*@ s */
page,loaded; /*@ s */
item,changed; /*@ s */
action; /*@ ss */
}
}

View File

@ -3,6 +3,8 @@
*
* @{
*/
#include "elm_prefs.eo.h"
#if 0
#define ELM_OBJ_PREFS_CLASS elm_obj_prefs_class_get()
const Eo_Class *elm_obj_prefs_class_get(void) EINA_CONST;
@ -352,6 +354,7 @@ enum
EO_TYPECHECK(const char *,name), \
EO_TYPECHECK(Evas_Object **, ret)
//FIXME: ret == EObject?
#endif
/**
* @}
*/

View File

@ -64,8 +64,8 @@ typedef struct _Elm_Prefs_Item_Node
/**
* Base widget smart data extended with prefs instance data.
*/
typedef struct _Elm_Prefs_Smart_Data Elm_Prefs_Smart_Data;
struct _Elm_Prefs_Smart_Data
typedef struct _Elm_Prefs_Data Elm_Prefs_Data;
struct _Elm_Prefs_Data
{
Elm_Prefs_Page_Node *root;
@ -91,7 +91,7 @@ extern const Eina_Hash *elm_prefs_item_type_widgets_map;
extern const Elm_Prefs_Item_Iface *elm_prefs_item_default_widget;
#define ELM_PREFS_DATA_GET(o, sd) \
Elm_Prefs_Smart_Data * sd = eo_data_scope_get(o, ELM_OBJ_PREFS_CLASS)
Elm_Prefs_Data * sd = eo_data_scope_get(o, ELM_OBJ_PREFS_CLASS)
#define ELM_PREFS_ENTRY(o, sd) \
if (EINA_UNLIKELY(!sd->data_file || !sd->page)) \