From a5007dd56eabab4b8434d409ea0354571cb53c50 Mon Sep 17 00:00:00 2001 From: tasn Date: Wed, 15 Feb 2012 16:27:34 +0000 Subject: [PATCH] Elm naviframe: Fix naviframe a little and add item default style set/get 1. items_get is no longer completely broken 2. default style set/get is used as a replacement for the style NULL git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@67989 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/elc_naviframe.c | 48 +++++++++++++++++++++++++++++++++++++----------- src/lib/elc_naviframe.h | 28 ++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/src/lib/elc_naviframe.c b/src/lib/elc_naviframe.c index 55adf04..6cf96dd 100644 --- a/src/lib/elc_naviframe.c +++ b/src/lib/elc_naviframe.c @@ -13,6 +13,7 @@ struct _Widget_Data Eina_Bool preserve: 1; Eina_Bool auto_pushed: 1; Eina_Bool freeze_events: 1; + Eina_Stringshare *item_style; }; struct _Elm_Naviframe_Content_Item_Pair @@ -180,6 +181,7 @@ _del_hook(Evas_Object *obj) if (!wd->stack) break; } } + eina_stringshare_del(wd->item_style); free(wd); } @@ -906,13 +908,14 @@ _item_style_set(Elm_Naviframe_Item *navi_it, const char *item_style) Elm_Naviframe_Content_Item_Pair *content_pair; Elm_Naviframe_Text_Item_Pair *text_pair; Widget_Data *wd; + wd = elm_widget_data_get(WIDGET(navi_it)); + if (!wd) return; char buf[256]; if (!item_style) { - strcpy(buf, "item/basic"); - eina_stringshare_replace(&navi_it->style, "basic"); + snprintf(buf, sizeof(buf), "item/%s", wd->item_style); } else { @@ -950,9 +953,6 @@ _item_style_set(Elm_Naviframe_Item *navi_it, const char *item_style) navi_it->title_visible = EINA_TRUE; _sizing_eval(WIDGET(navi_it)); - wd = elm_widget_data_get(WIDGET(navi_it)); - if (!wd) return; - if (wd->freeze_events) evas_object_freeze_events_set(VIEW(navi_it), EINA_FALSE); } @@ -1070,6 +1070,7 @@ elm_naviframe_add(Evas_Object *parent) wd->auto_pushed = EINA_TRUE; wd->freeze_events = EINA_TRUE; + wd->item_style = eina_stringshare_add("basic"); return obj; } @@ -1329,11 +1330,11 @@ elm_naviframe_item_style_set(Elm_Object_Item *it, const char *item_style) Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it; //Return if new style is exsiting one. - if (item_style) - if (!strcmp(item_style, navi_it->style)) return; + if ((item_style && navi_it->style) && (!strcmp(item_style, navi_it->style))) + return; - if (!item_style) - if (!strcmp("basic", navi_it->style)) return; + if ((!item_style) && (!navi_it->style)) + return; _item_style_set(navi_it, item_style); } @@ -1385,13 +1386,19 @@ elm_naviframe_prev_btn_auto_pushed_get(const Evas_Object *obj) return wd->auto_pushed; } -EAPI Eina_Inlist * +EAPI Eina_List * elm_naviframe_items_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return NULL; - return wd->stack; + Eina_List *ret = NULL; + Elm_Naviframe_Item *itr; + EINA_INLIST_FOREACH(wd->stack, itr) + { + ret = eina_list_append(ret, itr); + } + return ret; } EAPI void @@ -1413,3 +1420,22 @@ elm_naviframe_event_enabled_get(const Evas_Object *obj) if (!wd) return EINA_FALSE; return !wd->freeze_events; } + +EAPI void +elm_naviframe_item_style_default_set(Evas_Object *obj, const char *style) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + eina_stringshare_replace(&wd->item_style, style); + _theme_hook(obj); +} + +EAPI const char * +elm_naviframe_item_style_default_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; + return wd->item_style; +} diff --git a/src/lib/elc_naviframe.h b/src/lib/elc_naviframe.h index 348cabe..43147b8 100644 --- a/src/lib/elc_naviframe.h +++ b/src/lib/elc_naviframe.h @@ -320,12 +320,12 @@ EAPI Eina_Bool elm_naviframe_prev_btn_auto_pushed_get(const Evas_Object * * @brief Get a list of all the naviframe items. * * @param obj The naviframe object - * @return An Eina_Inlist* of naviframe items, #Elm_Object_Item, + * @return An Eina_List of naviframe items, #Elm_Object_Item, * or @c NULL on failure. * * @ingroup Naviframe */ -EAPI Eina_Inlist *elm_naviframe_items_get(const Evas_Object *obj); +EAPI Eina_List *elm_naviframe_items_get(const Evas_Object *obj) EINA_MALLOC EINA_WARN_UNUSED_RESULT; /** * @brief Set the event enabled when pushing/popping items @@ -361,5 +361,29 @@ EAPI void elm_naviframe_event_enabled_set(Evas_Object *obj, Eina_Boo EAPI Eina_Bool elm_naviframe_event_enabled_get(const Evas_Object *obj); /** + * @brief Set the default item style. + * + * Default item style will be used with items who's style is NULL + * + * @param obj The naviframe object + * @param style The style + * + * @ingroup Naviframe + */ +EAPI void elm_naviframe_item_style_default_set(Evas_Object *obj, const char *style); + +/** + * @brief Get the default item style + * + * @param obj The naviframe object + * @return the default item style + * + * @see elm_naviframe_item_style_default_set() + * + * @ingroup Naviframe + */ +EAPI const char *elm_naviframe_item_style_default_get(const Evas_Object *obj); + +/** * @} */ -- 2.7.4