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

SVN revision: 67989
This commit is contained in:
Tom Hacohen 2012-02-15 16:27:34 +00:00
parent aebbc146dd
commit c9f55529ad
2 changed files with 63 additions and 13 deletions

View File

@ -13,6 +13,7 @@ struct _Widget_Data
Eina_Bool preserve: 1; Eina_Bool preserve: 1;
Eina_Bool auto_pushed: 1; Eina_Bool auto_pushed: 1;
Eina_Bool freeze_events: 1; Eina_Bool freeze_events: 1;
Eina_Stringshare *item_style;
}; };
struct _Elm_Naviframe_Content_Item_Pair struct _Elm_Naviframe_Content_Item_Pair
@ -180,6 +181,7 @@ _del_hook(Evas_Object *obj)
if (!wd->stack) break; if (!wd->stack) break;
} }
} }
eina_stringshare_del(wd->item_style);
free(wd); 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_Content_Item_Pair *content_pair;
Elm_Naviframe_Text_Item_Pair *text_pair; Elm_Naviframe_Text_Item_Pair *text_pair;
Widget_Data *wd; Widget_Data *wd;
wd = elm_widget_data_get(WIDGET(navi_it));
if (!wd) return;
char buf[256]; char buf[256];
if (!item_style) if (!item_style)
{ {
strcpy(buf, "item/basic"); snprintf(buf, sizeof(buf), "item/%s", wd->item_style);
eina_stringshare_replace(&navi_it->style, "basic");
} }
else else
{ {
@ -950,9 +953,6 @@ _item_style_set(Elm_Naviframe_Item *navi_it, const char *item_style)
navi_it->title_visible = EINA_TRUE; navi_it->title_visible = EINA_TRUE;
_sizing_eval(WIDGET(navi_it)); _sizing_eval(WIDGET(navi_it));
wd = elm_widget_data_get(WIDGET(navi_it));
if (!wd) return;
if (wd->freeze_events) if (wd->freeze_events)
evas_object_freeze_events_set(VIEW(navi_it), EINA_FALSE); 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->auto_pushed = EINA_TRUE;
wd->freeze_events = EINA_TRUE; wd->freeze_events = EINA_TRUE;
wd->item_style = eina_stringshare_add("basic");
return obj; 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; Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
//Return if new style is exsiting one. //Return if new style is exsiting one.
if (item_style) if ((item_style && navi_it->style) && (!strcmp(item_style, navi_it->style)))
if (!strcmp(item_style, navi_it->style)) return; return;
if (!item_style) if ((!item_style) && (!navi_it->style))
if (!strcmp("basic", navi_it->style)) return; return;
_item_style_set(navi_it, item_style); _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; return wd->auto_pushed;
} }
EAPI Eina_Inlist * EAPI Eina_List *
elm_naviframe_items_get(const Evas_Object *obj) elm_naviframe_items_get(const Evas_Object *obj)
{ {
ELM_CHECK_WIDTYPE(obj, widtype) NULL; ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj); Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL; 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 EAPI void
@ -1413,3 +1420,22 @@ elm_naviframe_event_enabled_get(const Evas_Object *obj)
if (!wd) return EINA_FALSE; if (!wd) return EINA_FALSE;
return !wd->freeze_events; 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;
}

View File

@ -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. * @brief Get a list of all the naviframe items.
* *
* @param obj The naviframe object * @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. * or @c NULL on failure.
* *
* @ingroup Naviframe * @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 * @brief Set the event enabled when pushing/popping items
@ -360,6 +360,30 @@ EAPI void elm_naviframe_event_enabled_set(Evas_Object *obj, Eina_Boo
*/ */
EAPI Eina_Bool elm_naviframe_event_enabled_get(const Evas_Object *obj); 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);
/** /**
* @} * @}
*/ */