forked from enlightenment/efl
elementary/diskselector - deprecated APIs. Now let's use elm_object_item APIs
elm_diskselector_item_label_set() elm_diskselector_item_label_get() elm_diskselector_item_icon_set() elm_diskselector_item_icon_get() elm_diskselector_item_data_get() SVN revision: 66685
This commit is contained in:
parent
354e2a3b3a
commit
c19672a89f
|
@ -8,7 +8,7 @@ static void
|
|||
_disk_sel(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info)
|
||||
{
|
||||
Elm_Object_Item *ds_it = event_info;
|
||||
printf("Equinox: %s\n", elm_diskselector_item_label_get(ds_it));
|
||||
printf("Equinox: %s\n", elm_object_item_text_get(ds_it));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -17,16 +17,15 @@ _disk_next(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info
|
|||
Elm_Object_Item *next_ds_it, *prev_ds_it, *ds_it = event_info;
|
||||
prev_ds_it = elm_diskselector_item_prev_get(ds_it);
|
||||
next_ds_it = elm_diskselector_item_next_get(ds_it);
|
||||
printf("Prev: %s, Next: %s\n",
|
||||
elm_diskselector_item_label_get(prev_ds_it),
|
||||
elm_diskselector_item_label_get(next_ds_it));
|
||||
printf("Prev: %s, Next: %s\n", elm_object_item_text_get(prev_ds_it),
|
||||
elm_object_item_text_get(next_ds_it));
|
||||
}
|
||||
|
||||
static void
|
||||
_print_disk_info_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
||||
{
|
||||
Elm_Object_Item *ds_it = event_info;
|
||||
printf("Selected label: %s\n", elm_diskselector_item_label_get(ds_it));
|
||||
printf("Selected label: %s\n", elm_object_item_text_get(ds_it));
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
|
|
|
@ -57,7 +57,7 @@ static void
|
|||
_sel_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
||||
{
|
||||
Elm_Object_Item *ds_it = event_info;
|
||||
printf("Selected label: %s\n", elm_diskselector_item_label_get(ds_it));
|
||||
printf("Selected label: %s\n", elm_object_item_text_get(ds_it));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -78,7 +78,7 @@ _sel_data_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
|
|||
char *content = data;
|
||||
Elm_Object_Item *ds_it = event_info;
|
||||
printf("Selected label: %s with data: %s\n",
|
||||
elm_diskselector_item_label_get(ds_it), content);
|
||||
elm_object_item_text_get(ds_it), content);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -134,7 +134,7 @@ _print_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
|||
|
||||
items = elm_diskselector_items_get(ds);
|
||||
EINA_LIST_FOREACH(items, l, ds_it)
|
||||
printf("%s\n", elm_diskselector_item_label_get(ds_it));
|
||||
printf("%s\n", elm_object_item_text_get(ds_it));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1150,6 +1150,123 @@ EINA_DEPRECATED EAPI int elm_diskselector_side_label_lenght_get(const Evas_Ob
|
|||
*/
|
||||
EINA_DEPRECATED EAPI void elm_diskselector_side_label_lenght_set(Evas_Object *obj, int len);
|
||||
|
||||
/**
|
||||
* Get the data associated to the item.
|
||||
*
|
||||
* @param it The diskselector item
|
||||
* @return The data associated to @p it
|
||||
*
|
||||
* The return value is a pointer to data associated to @p item when it was
|
||||
* created, with function elm_diskselector_item_append(). If no data
|
||||
* was passed as argument, it will return @c NULL.
|
||||
*
|
||||
* @see elm_diskselector_item_append()
|
||||
* @deprecated Use elm_object_item_data_get()
|
||||
*
|
||||
* @ingroup Diskselector
|
||||
*/
|
||||
EINA_DEPRECATED EAPI void *elm_diskselector_item_data_get(const Elm_Object_Item *it);
|
||||
|
||||
/**
|
||||
* Set the icon associated to the item.
|
||||
*
|
||||
* @param it The diskselector item
|
||||
* @param icon The icon object to associate with @p it
|
||||
*
|
||||
* The icon object to use at left side of the item. An
|
||||
* icon can be any Evas object, but usually it is an icon created
|
||||
* with elm_icon_add().
|
||||
*
|
||||
* Once the icon object is set, a previously set one will be deleted.
|
||||
* @warning Setting the same icon for two items will cause the icon to
|
||||
* dissapear from the first item.
|
||||
*
|
||||
* If an icon was passed as argument on item creation, with function
|
||||
* elm_diskselector_item_append(), it will be already
|
||||
* associated to the item.
|
||||
*
|
||||
* @see elm_diskselector_item_append()
|
||||
* @see elm_diskselector_item_icon_get()
|
||||
*
|
||||
* @deprecated Use elm_object_item_part_content_set() instead
|
||||
* @ingroup Diskselector
|
||||
*/
|
||||
EINA_DEPRECATED EAPI void elm_diskselector_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
|
||||
|
||||
/**
|
||||
* Get the icon associated to the item.
|
||||
*
|
||||
* @param item The diskselector item
|
||||
* @return The icon associated to @p it
|
||||
*
|
||||
* The return value is a pointer to the icon associated to @p item when it was
|
||||
* created, with function elm_diskselector_item_append(), or later
|
||||
* with function elm_diskselector_item_icon_set. If no icon
|
||||
* was passed as argument, it will return @c NULL.
|
||||
*
|
||||
* @see elm_diskselector_item_append()
|
||||
* @see elm_diskselector_item_icon_set()
|
||||
*
|
||||
* @deprecated Use elm_object_item_part_content_set() instead
|
||||
* @ingroup Diskselector
|
||||
*/
|
||||
EAPI Evas_Object *elm_diskselector_item_icon_get(const Elm_Object_Item *it);
|
||||
|
||||
/**
|
||||
* Set the label of item.
|
||||
*
|
||||
* @param it The item of diskselector.
|
||||
* @param label The label of item.
|
||||
*
|
||||
* The label to be displayed by the item.
|
||||
*
|
||||
* If no icon is set, label will be centered on item position, otherwise
|
||||
* the icon will be placed at left of the label, that will be shifted
|
||||
* to the right.
|
||||
*
|
||||
* An item with label "January" would be displayed on side position as
|
||||
* "Jan" if max length is set to 3 with function
|
||||
* elm_diskselector_side_label_lenght_set(), or "Janu", if this property
|
||||
* is set to 4.
|
||||
*
|
||||
* When this @p item is selected, the entire label will be displayed,
|
||||
* except for width restrictions.
|
||||
* In this case label will be cropped and "..." will be concatenated,
|
||||
* but only for display purposes. It will keep the entire string, so
|
||||
* if diskselector is resized the remaining characters will be displayed.
|
||||
*
|
||||
* If a label was passed as argument on item creation, with function
|
||||
* elm_diskselector_item_append(), it will be already
|
||||
* displayed by the item.
|
||||
*
|
||||
* @see elm_diskselector_side_label_lenght_set()
|
||||
* @see elm_diskselector_item_label_get()
|
||||
* @see elm_diskselector_item_append()
|
||||
*
|
||||
* @deprecated Use elm_object_item_text_set() instead
|
||||
* @ingroup Diskselector
|
||||
*/
|
||||
EINA_DEPRECATED EAPI void elm_diskselector_item_label_set(Elm_Object_Item *it, const char *label);
|
||||
|
||||
/**
|
||||
* Get the label of item.
|
||||
*
|
||||
* @param it The item of diskselector.
|
||||
* @return The label of item.
|
||||
*
|
||||
* The return value is a pointer to the label associated to @p item when it was
|
||||
* created, with function elm_diskselector_item_append(), or later
|
||||
* with function elm_diskselector_item_label_set. If no label
|
||||
* was passed as argument, it will return @c NULL.
|
||||
*
|
||||
* @see elm_diskselector_item_label_set() for more details.
|
||||
* @see elm_diskselector_item_append()
|
||||
* @use elm_object_item_text_get()
|
||||
*
|
||||
* @ingroup Diskselector
|
||||
*/
|
||||
EINA_DEPRECATED EAPI const char *elm_diskselector_item_label_get(const Elm_Object_Item *it);
|
||||
|
||||
EINA_DEPRECATED EAPI void elm_factory_content_set(Evas_Object *obj, Evas_Object *content);
|
||||
EINA_DEPRECATED EAPI Evas_Object *elm_factory_content_get(const Evas_Object *obj);
|
||||
|
||||
|
|
|
@ -65,6 +65,16 @@ static void _item_click_cb(void *data, Evas_Object *obj __UNUSED__,
|
|||
const char *emission __UNUSED__,
|
||||
const char *source __UNUSED__);
|
||||
static void _selected_item_indicate(Elm_Diskselector_Item *it);
|
||||
static void _item_text_set_hook(Elm_Object_Item *it,
|
||||
const char *part,
|
||||
const char *label);
|
||||
static const char * _item_text_get_hook(const Elm_Object_Item *it,
|
||||
const char *part);
|
||||
static void _item_content_set_hook(Elm_Object_Item *it,
|
||||
const char *part,
|
||||
Evas_Object *content);
|
||||
static Evas_Object * _item_content_get_hook(const Elm_Object_Item *it,
|
||||
const char *part);
|
||||
|
||||
static const char SIG_SELECTED[] = "selected";
|
||||
static const Evas_Smart_Cb_Description _signals[] = {
|
||||
|
@ -111,6 +121,11 @@ _item_new(Evas_Object *obj, Evas_Object *icon, const char *label, Evas_Smart_Cb
|
|||
it = elm_widget_item_new(obj, Elm_Diskselector_Item);
|
||||
if (!it) return NULL;
|
||||
|
||||
elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
|
||||
elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
|
||||
elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
|
||||
elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
|
||||
|
||||
it->label = eina_stringshare_add(label);
|
||||
it->icon = icon;
|
||||
it->func = func;
|
||||
|
@ -570,8 +585,7 @@ _scroller_stop_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UN
|
|||
Evas_Coord x, w, ow;
|
||||
Eina_List *l, *list;
|
||||
|
||||
if (wd->idler)
|
||||
return;
|
||||
if (wd->idler) return;
|
||||
|
||||
if (!wd->round)
|
||||
list = wd->items;
|
||||
|
@ -582,13 +596,10 @@ _scroller_stop_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UN
|
|||
EINA_LIST_FOREACH(list, l, it)
|
||||
{
|
||||
evas_object_geometry_get(VIEW(it), &x, NULL, &w, NULL);
|
||||
if (abs((int)(ow / 2 - (int)(x + w / 2))) < 10)
|
||||
break;
|
||||
if (abs((int)(ow / 2 - (int)(x + w / 2))) < 10) break;
|
||||
}
|
||||
|
||||
if (!it)
|
||||
return;
|
||||
|
||||
if (!it) return;
|
||||
_select_item(it);
|
||||
}
|
||||
|
||||
|
@ -824,6 +835,44 @@ _check_identical_item(Elm_Diskselector_Item *it, Evas_Object *icon)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
||||
Elm_Diskselector_Item *item;
|
||||
if (part && strcmp(part, "default")) return;
|
||||
item = (Elm_Diskselector_Item *) it;
|
||||
eina_stringshare_replace(&item->label, label);
|
||||
edje_object_part_text_set(VIEW(item), "elm.text", item->label);
|
||||
}
|
||||
|
||||
static const char *
|
||||
_item_text_get_hook(const Elm_Object_Item *it, const char *part)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
if (part && strcmp(part, "default")) return NULL;
|
||||
return ((Elm_Diskselector_Item *) it)->label;
|
||||
}
|
||||
|
||||
static void
|
||||
_item_content_set_hook(Elm_Object_Item *it,
|
||||
const char *part,
|
||||
Evas_Object *content)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
||||
if (part && strcmp(part, "icon")) return;
|
||||
_item_icon_set((Elm_Diskselector_Item *) it, content);
|
||||
_check_identical_item((Elm_Diskselector_Item *) it, content);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_item_content_get_hook(const Elm_Object_Item *it, const char *part)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
if (part && strcmp(part, "icon")) return NULL;
|
||||
return ((Elm_Diskselector_Item *) it)->icon;
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_diskselector_add(Evas_Object *parent)
|
||||
{
|
||||
|
@ -1218,17 +1267,13 @@ elm_diskselector_item_del(Elm_Object_Item * it)
|
|||
EAPI const char *
|
||||
elm_diskselector_item_label_get(const Elm_Object_Item * it)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
return ((Elm_Diskselector_Item *) it)->label;
|
||||
return _item_text_get_hook(it, NULL);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_diskselector_item_label_set(Elm_Object_Item * it, const char *label)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
||||
Elm_Diskselector_Item *item = (Elm_Diskselector_Item *) it;
|
||||
eina_stringshare_replace(&item->label, label);
|
||||
edje_object_part_text_set(VIEW(item), "elm.text", item->label);
|
||||
_item_text_set_hook(it, NULL, label);
|
||||
}
|
||||
|
||||
EAPI Elm_Object_Item *
|
||||
|
@ -1283,23 +1328,19 @@ elm_diskselector_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
|
|||
EAPI void *
|
||||
elm_diskselector_item_data_get(const Elm_Object_Item *it)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
return elm_widget_item_data_get(it);
|
||||
return elm_object_item_data_get(it);
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_diskselector_item_icon_get(const Elm_Object_Item *it)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
return ((Elm_Diskselector_Item *) it)->icon;
|
||||
return _item_content_get_hook(it, NULL);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_diskselector_item_icon_set(Elm_Object_Item *it, Evas_Object *icon)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
||||
_item_icon_set((Elm_Diskselector_Item *) it, icon);
|
||||
_check_identical_item((Elm_Diskselector_Item *) it, icon);
|
||||
_item_content_set_hook(it, NULL, icon);
|
||||
}
|
||||
|
||||
EAPI Elm_Object_Item *
|
||||
|
|
|
@ -18,6 +18,12 @@
|
|||
* Available styles for it:
|
||||
* - @c "default"
|
||||
*
|
||||
* Default contents parts of the diskseletor items that you can use for are:
|
||||
* @li "icon" - An icon in the diskselector item
|
||||
*
|
||||
* Default text parts of the diskselector items that you can use for are:
|
||||
* @li "default" - Label of the diskselector item
|
||||
*
|
||||
* List of examples:
|
||||
* @li @ref diskselector_example_01
|
||||
* @li @ref diskselector_example_02
|
||||
|
@ -323,118 +329,6 @@ EAPI void elm_diskselector_item_del(Elm_Object_Item *it);
|
|||
*/
|
||||
EAPI void elm_diskselector_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func);
|
||||
|
||||
/**
|
||||
* Get the data associated to the item.
|
||||
*
|
||||
* @param it The diskselector item
|
||||
* @return The data associated to @p it
|
||||
*
|
||||
* The return value is a pointer to data associated to @p item when it was
|
||||
* created, with function elm_diskselector_item_append(). If no data
|
||||
* was passed as argument, it will return @c NULL.
|
||||
*
|
||||
* @see elm_diskselector_item_append()
|
||||
*
|
||||
* @ingroup Diskselector
|
||||
*/
|
||||
EAPI void *elm_diskselector_item_data_get(const Elm_Object_Item *it);
|
||||
|
||||
/**
|
||||
* Set the icon associated to the item.
|
||||
*
|
||||
* @param it The diskselector item
|
||||
* @param icon The icon object to associate with @p it
|
||||
*
|
||||
* The icon object to use at left side of the item. An
|
||||
* icon can be any Evas object, but usually it is an icon created
|
||||
* with elm_icon_add().
|
||||
*
|
||||
* Once the icon object is set, a previously set one will be deleted.
|
||||
* @warning Setting the same icon for two items will cause the icon to
|
||||
* dissapear from the first item.
|
||||
*
|
||||
* If an icon was passed as argument on item creation, with function
|
||||
* elm_diskselector_item_append(), it will be already
|
||||
* associated to the item.
|
||||
*
|
||||
* @see elm_diskselector_item_append()
|
||||
* @see elm_diskselector_item_icon_get()
|
||||
*
|
||||
* @ingroup Diskselector
|
||||
*/
|
||||
EAPI void elm_diskselector_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
|
||||
|
||||
/**
|
||||
* Get the icon associated to the item.
|
||||
*
|
||||
* @param item The diskselector item
|
||||
* @return The icon associated to @p it
|
||||
*
|
||||
* The return value is a pointer to the icon associated to @p item when it was
|
||||
* created, with function elm_diskselector_item_append(), or later
|
||||
* with function elm_diskselector_item_icon_set. If no icon
|
||||
* was passed as argument, it will return @c NULL.
|
||||
*
|
||||
* @see elm_diskselector_item_append()
|
||||
* @see elm_diskselector_item_icon_set()
|
||||
*
|
||||
* @ingroup Diskselector
|
||||
*/
|
||||
EAPI Evas_Object *elm_diskselector_item_icon_get(const Elm_Object_Item *it);
|
||||
|
||||
/**
|
||||
* Set the label of item.
|
||||
*
|
||||
* @param it The item of diskselector.
|
||||
* @param label The label of item.
|
||||
*
|
||||
* The label to be displayed by the item.
|
||||
*
|
||||
* If no icon is set, label will be centered on item position, otherwise
|
||||
* the icon will be placed at left of the label, that will be shifted
|
||||
* to the right.
|
||||
*
|
||||
* An item with label "January" would be displayed on side position as
|
||||
* "Jan" if max length is set to 3 with function
|
||||
* elm_diskselector_side_label_lenght_set(), or "Janu", if this property
|
||||
* is set to 4.
|
||||
*
|
||||
* When this @p item is selected, the entire label will be displayed,
|
||||
* except for width restrictions.
|
||||
* In this case label will be cropped and "..." will be concatenated,
|
||||
* but only for display purposes. It will keep the entire string, so
|
||||
* if diskselector is resized the remaining characters will be displayed.
|
||||
*
|
||||
* If a label was passed as argument on item creation, with function
|
||||
* elm_diskselector_item_append(), it will be already
|
||||
* displayed by the item.
|
||||
*
|
||||
* @see elm_diskselector_side_label_lenght_set()
|
||||
* @see elm_diskselector_item_label_get()
|
||||
* @see elm_diskselector_item_append()
|
||||
*
|
||||
* @ingroup Diskselector
|
||||
*/
|
||||
EAPI void elm_diskselector_item_label_set(Elm_Object_Item *it, const char *label);
|
||||
|
||||
/**
|
||||
* Get the label of item.
|
||||
*
|
||||
* @param it The item of diskselector.
|
||||
* @return The label of item.
|
||||
*
|
||||
* The return value is a pointer to the label associated to @p item when it was
|
||||
* created, with function elm_diskselector_item_append(), or later
|
||||
* with function elm_diskselector_item_label_set. If no label
|
||||
* was passed as argument, it will return @c NULL.
|
||||
*
|
||||
* @see elm_diskselector_item_label_set() for more details.
|
||||
* @see elm_diskselector_item_append()
|
||||
*
|
||||
* @ingroup Diskselector
|
||||
*/
|
||||
EAPI const char *elm_diskselector_item_label_get(const Elm_Object_Item *it);
|
||||
|
||||
/**
|
||||
* Get the selected item.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue