From 0cfe327483884454d5d4009543f9b0ab927614ee Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Sun, 14 Aug 2011 03:36:56 +0000 Subject: [PATCH] elementary/ctxpopup - updated to use elm_object_item SVN revision: 62429 --- src/bin/test_ctxpopup.c | 11 +++--- src/lib/Elementary.h.in | 30 ++++++++-------- src/lib/elc_ctxpopup.c | 91 ++++++++++++++++++++++++++----------------------- 3 files changed, 69 insertions(+), 63 deletions(-) diff --git a/src/bin/test_ctxpopup.c b/src/bin/test_ctxpopup.c index 766b4c7..4e7d2a1 100644 --- a/src/bin/test_ctxpopup.c +++ b/src/bin/test_ctxpopup.c @@ -8,7 +8,7 @@ static void _ctxpopup_item_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) { printf("ctxpopup item selected: %s\n", - elm_ctxpopup_item_label_get(event_info)); + elm_ctxpopup_item_label_get(event_info)); } #define ITEM_NEW(_hov, _label, _icon) \ @@ -26,7 +26,7 @@ static void _list_item_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *ctxpopup, *ic; - Elm_Ctxpopup_Item *it; + Elm_Object_Item *it; Evas_Coord x,y; ctxpopup = elm_ctxpopup_add(obj); @@ -50,7 +50,7 @@ static void _list_item_cb2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *ctxpopup, *ic; - Elm_Ctxpopup_Item *it; + Elm_Object_Item *it; Evas_Coord x,y; ctxpopup = elm_ctxpopup_add(obj); @@ -73,7 +73,7 @@ static void _list_item_cb3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *ctxpopup, *ic; - Elm_Ctxpopup_Item *it; + Elm_Object_Item *it; Evas_Coord x,y; ctxpopup = elm_ctxpopup_add(obj); @@ -95,7 +95,7 @@ static void _list_item_cb4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *ctxpopup, *ic; - Elm_Ctxpopup_Item *it; + Elm_Object_Item *it; Evas_Coord x,y; ctxpopup = elm_ctxpopup_add(obj); @@ -168,6 +168,7 @@ test_ctxpopup(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in list = elm_list_add(win); elm_win_resize_object_add(win, list); + evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_list_mode_set(list, ELM_LIST_COMPRESS); evas_object_smart_callback_add(list, "selected", _list_clicked, NULL); diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index ae7791c..6177077 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -24686,48 +24686,48 @@ extern "C" { * * @see elm_ctxpopup_content_set() */ - Elm_Ctxpopup_Item *elm_ctxpopup_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); + Elm_Object_Item *elm_ctxpopup_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); /** * @brief Delete the given item in a ctxpopup object. * - * @param item Ctxpopup item to be deleted + * @param it Ctxpopup item to be deleted * * @see elm_ctxpopup_item_append() */ - EAPI void elm_ctxpopup_item_del(Elm_Ctxpopup_Item *it) EINA_ARG_NONNULL(1); + EAPI void elm_ctxpopup_item_del(Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Set the ctxpopup item's state as disabled or enabled. * - * @param item Ctxpopup item to be enabled/disabled + * @param it Ctxpopup item to be enabled/disabled * @param disabled @c EINA_TRUE to disable it, @c EINA_FALSE to enable it * * When disabled the item is greyed out to indicate it's state. */ - EAPI void elm_ctxpopup_item_disabled_set(Elm_Ctxpopup_Item *item, Eina_Bool disabled) EINA_ARG_NONNULL(1); + EAPI void elm_ctxpopup_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled) EINA_ARG_NONNULL(1); /** * @brief Get the ctxpopup item's disabled/enabled state. * - * @param item Ctxpopup item to be enabled/disabled + * @param it Ctxpopup item to be enabled/disabled * @return disabled @c EINA_TRUE, if disabled, @c EINA_FALSE otherwise * * @see elm_ctxpopup_item_disabled_set() */ - EAPI Eina_Bool elm_ctxpopup_item_disabled_get(const Elm_Ctxpopup_Item *item) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_ctxpopup_item_disabled_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Get the icon object for the given ctxpopup item. * - * @param item Ctxpopup item + * @param it Ctxpopup item * @return icon object or @c NULL, if the item does not have icon or an error * occurred * * @see elm_ctxpopup_item_append() * @see elm_ctxpopup_item_icon_set() */ - EAPI Evas_Object *elm_ctxpopup_item_icon_get(const Elm_Ctxpopup_Item *item) EINA_ARG_NONNULL(1); + EAPI Evas_Object *elm_ctxpopup_item_icon_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Sets the side icon associated with the ctxpopup item * - * @param item Ctxpopup item + * @param it Ctxpopup item * @param icon Icon object to be set * * Once the icon object is set, a previously set one will be deleted. @@ -24736,25 +24736,25 @@ extern "C" { * * @see elm_ctxpopup_item_append() */ - EAPI void elm_ctxpopup_item_icon_set(Elm_Ctxpopup_Item *item, Evas_Object *icon) EINA_ARG_NONNULL(1); + EAPI void elm_ctxpopup_item_icon_set(Elm_Object_Item *it, Evas_Object *icon) EINA_ARG_NONNULL(1); /** * @brief Get the label for the given ctxpopup item. * - * @param item Ctxpopup item + * @param it Ctxpopup item * @return label string or @c NULL, if the item does not have label or an * error occured * * @see elm_ctxpopup_item_append() * @see elm_ctxpopup_item_label_set() */ - EAPI const char *elm_ctxpopup_item_label_get(const Elm_Ctxpopup_Item *item) EINA_ARG_NONNULL(1); + EAPI const char *elm_ctxpopup_item_label_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief (Re)set the label on the given ctxpopup item. * - * @param item Ctxpopup item + * @param it Ctxpopup item * @param label String to set as label */ - EAPI void elm_ctxpopup_item_label_set(Elm_Ctxpopup_Item *item, const char *label) EINA_ARG_NONNULL(1); + EAPI void elm_ctxpopup_item_label_set(Elm_Object_Item *it, const char *label) EINA_ARG_NONNULL(1); /** * @brief Set an elm widget as the content of the ctxpopup. * diff --git a/src/lib/elc_ctxpopup.c b/src/lib/elc_ctxpopup.c index ebc83ac..5a65614 100644 --- a/src/lib/elc_ctxpopup.c +++ b/src/lib/elc_ctxpopup.c @@ -110,10 +110,6 @@ static const Evas_Smart_Cb_Description _signals[] = { {NULL, NULL} }; -#define ELM_CTXPOPUP_ITEM_CHECK_RETURN(it, ...) \ - ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \ - ELM_CHECK_WIDTYPE(item->base.widget, widtype) __VA_ARGS__; - static void _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) @@ -1077,54 +1073,58 @@ elm_ctxpopup_add(Evas_Object *parent) } EAPI Evas_Object * -elm_ctxpopup_item_icon_get(const Elm_Ctxpopup_Item *item) +elm_ctxpopup_item_icon_get(const Elm_Object_Item *it) { - ELM_CTXPOPUP_ITEM_CHECK_RETURN(item, NULL); - return item->icon; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + Elm_Ctxpopup_Item *ctxpopup_it = ELM_CAST(it); + return ctxpopup_it->icon; } EAPI void -elm_ctxpopup_item_icon_set(Elm_Ctxpopup_Item *item, Evas_Object *icon) +elm_ctxpopup_item_icon_set(Elm_Object_Item *it, Evas_Object *icon) { - ELM_CTXPOPUP_ITEM_CHECK_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); Widget_Data *wd; + Elm_Ctxpopup_Item *ctxpopup_it = ELM_CAST(it); - wd = elm_widget_data_get(item->base.widget); + wd = elm_widget_data_get(ctxpopup_it->base.widget); if (!wd) return; - _item_icon_set(item, icon); + _item_icon_set(ctxpopup_it, icon); if (wd->visible) { _scroller_size_reset(wd); - _sizing_eval(item->base.widget); + _sizing_eval(ctxpopup_it->base.widget); } } EAPI const char * -elm_ctxpopup_item_label_get(const Elm_Ctxpopup_Item *item) +elm_ctxpopup_item_label_get(const Elm_Object_Item *it) { - ELM_CTXPOPUP_ITEM_CHECK_RETURN(item, NULL); - return item->label; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + Elm_Ctxpopup_Item *ctxpopup_it = ELM_CAST(it); + return ctxpopup_it->label; } EAPI void -elm_ctxpopup_item_label_set(Elm_Ctxpopup_Item *item, const char *label) +elm_ctxpopup_item_label_set(Elm_Object_Item *it, const char *label) { - ELM_CTXPOPUP_ITEM_CHECK_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); Widget_Data *wd; + Elm_Ctxpopup_Item *ctxpopup_it = ELM_CAST(it); - wd = elm_widget_data_get(item->base.widget); + wd = elm_widget_data_get(ctxpopup_it->base.widget); if (!wd) return; - _item_label_set(item, label); + _item_label_set(ctxpopup_it, label); if (wd->visible) { _scroller_size_reset(wd); - _sizing_eval(item->base.widget); + _sizing_eval(ctxpopup_it->base.widget); } } @@ -1221,7 +1221,7 @@ elm_ctxpopup_horizontal_get(const Evas_Object *obj) return wd->horizontal; } -EAPI Elm_Ctxpopup_Item * +EAPI Elm_Object_Item * elm_ctxpopup_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data) @@ -1265,63 +1265,68 @@ elm_ctxpopup_item_append(Evas_Object *obj, const char *label, _sizing_eval(obj); } - return item; + return ELM_CAST(item); } EAPI void -elm_ctxpopup_item_del(Elm_Ctxpopup_Item *item) +elm_ctxpopup_item_del(Elm_Object_Item *it) { - ELM_CTXPOPUP_ITEM_CHECK_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); Widget_Data *wd; + Elm_Ctxpopup_Item *ctxpopup_it = ELM_CAST(it); - wd = elm_widget_data_get(item->base.widget); + wd = elm_widget_data_get(ctxpopup_it->base.widget); if (!wd) return; - if (item->icon) - evas_object_del(item->icon); - if (item->base.view) - evas_object_del(item->base.view); + if (ctxpopup_it->icon) + evas_object_del(ctxpopup_it->icon); + if (ctxpopup_it->base.view) + evas_object_del(ctxpopup_it->base.view); - eina_stringshare_del(item->label); + eina_stringshare_del(ctxpopup_it->label); - wd->items = eina_list_remove(wd->items, item); + wd->items = eina_list_remove(wd->items, ctxpopup_it); if (eina_list_count(wd->items) < 1) wd->items = NULL; if (wd->visible) - _sizing_eval(item->base.widget); + _sizing_eval(ctxpopup_it->base.widget); - free(item); + free(ctxpopup_it); } EAPI void -elm_ctxpopup_item_disabled_set(Elm_Ctxpopup_Item *item, Eina_Bool disabled) +elm_ctxpopup_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled) { - ELM_CTXPOPUP_ITEM_CHECK_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); Widget_Data *wd; + Elm_Ctxpopup_Item *ctxpopup_it = ELM_CAST(it); - wd = elm_widget_data_get(item->base.widget); + wd = elm_widget_data_get(ctxpopup_it->base.widget); if (!wd) return; - if (disabled == item->disabled) + ctxpopup_it = ELM_CAST(it); + + if (disabled == ctxpopup_it->disabled) return; if (disabled) - edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm"); + edje_object_signal_emit(ctxpopup_it->base.view, "elm,state,disabled", "elm"); else - edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm"); + edje_object_signal_emit(ctxpopup_it->base.view, "elm,state,enabled", "elm"); - item->disabled = !!disabled; + ctxpopup_it->disabled = !!disabled; } EAPI Eina_Bool -elm_ctxpopup_item_disabled_get(const Elm_Ctxpopup_Item *item) +elm_ctxpopup_item_disabled_get(const Elm_Object_Item *it) { - ELM_CTXPOPUP_ITEM_CHECK_RETURN(item, EINA_FALSE); - return item->disabled; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + Elm_Ctxpopup_Item *ctxpopup_it = ELM_CAST(it); + return ctxpopup_it->disabled; } EAPI void -- 2.7.4