if (item->icon == icon) return;
if (item->icon)
{
- elm_widget_sub_object_del(WIDGET(item), item->icon);
evas_object_data_del(item->icon, "_popup_content_item");
evas_object_del(item->icon);
}
_item_icon_set(Elm_Diskselector_Item *it, Evas_Object *icon)
{
if (it->icon == icon) return;
- if (it->icon)
- evas_object_del(it->icon);
+ if (it->icon) evas_object_del(it->icon);
it->icon = icon;
if (VIEW(it))
{
static void
_item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content)
{
+ Evas_Object *prev_obj;
+
if (content && part)
{
+ if (eina_list_data_find(it->content_objs, content)) return;
+ prev_obj = edje_object_part_swallow_get(VIEW(it), part);
+ if (prev_obj) evas_object_del(prev_obj);
it->content_objs = eina_list_append(it->content_objs, content);
edje_object_part_swallow(VIEW(it), part, content);
}
}
static void
-_item_content_set(Elm_Object_Item *it, const char *part, Evas_Object *content)
+_item_content_set_hook(Elm_Object_Item *it, const char *part, Evas_Object *content)
{
Elm_List_Item *item = (Elm_List_Item *)it;
Evas_Object **icon_p = NULL;
}
static Evas_Object *
-_item_content_get(const Elm_Object_Item *it, const char *part)
+_item_content_get_hook(const Elm_Object_Item *it, const char *part)
{
Elm_List_Item *item = (Elm_List_Item *)it;
}
static Evas_Object *
-_item_content_unset(const Elm_Object_Item *it, const char *part)
+_item_content_unset_hook(const Elm_Object_Item *it, const char *part)
{
Elm_List_Item *item = (Elm_List_Item *)it;
if ((!part) || (!strcmp(part, "start")))
{
Evas_Object *obj = item->icon;
- _item_content_set((Elm_Object_Item *)it, part, NULL);
+ _item_content_set_hook((Elm_Object_Item *)it, part, NULL);
return obj;
}
else if (!strcmp(part, "end"))
{
Evas_Object *obj = item->end;
- _item_content_set((Elm_Object_Item *)it, part, NULL);
+ _item_content_set_hook((Elm_Object_Item *)it, part, NULL);
return obj;
}
return NULL;
_changed_size_hints, obj);
}
elm_widget_item_disable_hook_set(it, _item_disable);
- elm_widget_item_content_set_hook_set(it, _item_content_set);
- elm_widget_item_content_get_hook_set(it, _item_content_get);
- elm_widget_item_content_unset_hook_set(it, _item_content_unset);
+ elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
+ elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
+ elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
elm_widget_item_text_set_hook_set(it, _item_text_set);
elm_widget_item_text_get_hook_set(it, _item_text_get);
elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
Evas_Object *content)
{
Elm_Menu_Item *item;
-
if (part && strcmp(part, "default")) return;
item = (Elm_Menu_Item *)it;
+ if (content == item->content) return;
- if (item->content)
- {
- elm_widget_sub_object_del(WIDGET(item), item->content);
- evas_object_del(item->content);
- }
+ if (item->content) evas_object_del(item->content);
item->content = content;
-
elm_widget_sub_object_add(WIDGET(item), item->content);
- edje_object_part_swallow(VIEW(item), "elm.swallow.content", item->content);
+ if (item->content)
+ edje_object_part_swallow(VIEW(item), "elm.swallow.content", item->content);
_sizing_eval(WIDGET(item));
}
* @param part The content part name to set (NULL for the default content)
* @param content The new content of the object item
*
+ * This sets a new object to an item as a content object. If any object was
+ * already set as a content object in the same part, previous object will be
+ * deleted automatically.
+ *
* @note Elementary object items may have many contents
*
* @ingroup General
Evas_Object *content)
{
Elm_Segment_Item *item;
-
if (part && strcmp(part, "icon")) return;
item = (Elm_Segment_Item *)it;
+ if (content == item->icon) return;
//Remove the existing icon
- if (item->icon)
- {
- edje_object_part_unswallow(VIEW(item), item->icon);
- evas_object_del(item->icon);
- item->icon = NULL;
- }
+ if (item->icon) evas_object_del(item->icon);
item->icon = content;
if (item->icon)
{
Evas_Object *content)
{
double scale;
-
if (part && strcmp(part, "object")) return;
Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
Evas_Object *obj = WIDGET(item);
Widget_Data *wd = elm_widget_data_get(obj);
-
+ if (!wd || !obj) return;
if (item->object == content) return;
+
+ if (item->object) evas_object_del(item->object);
+
item->object = content;
- elm_widget_sub_object_add(obj, item->object);
+ if (item->object)
+ elm_widget_sub_object_add(obj, item->object);
scale = (elm_widget_scale_get(obj) * _elm_config->scale);
_theme_hook_item(obj, item, scale, wd->icon_size);
}