Standardizing elm_<widget>_{icon,content}_set API

elm_<widget>_icon_set was changed to the better form and the signals
was passed to hidden icons when one icon is changed/removed.
Moreover, when changed by {icon,content}_set the old {icon,content}
will be deleted.

By: Fabiano Fidencio <fidencio@profusion.mobi>



SVN revision: 49706
This commit is contained in:
Iván Briano 2010-06-16 20:58:09 +00:00
parent a03476375e
commit 99ff1921a9
20 changed files with 492 additions and 148 deletions

View File

@ -367,6 +367,7 @@ extern "C" {
EAPI Evas_Object *elm_win_inwin_add(Evas_Object *obj);
EAPI void elm_win_inwin_activate(Evas_Object *obj);
EAPI void elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content);
EAPI Evas_Object *elm_win_inwin_content_unset(Evas_Object *obj);
/* available styles:
* default
* minimal
@ -491,6 +492,7 @@ extern "C" {
EAPI Evas_Object *elm_scroller_add(Evas_Object *parent);
EAPI void elm_scroller_content_set(Evas_Object *obj, Evas_Object *child);
EAPI Evas_Object *elm_scroller_content_unset(Evas_Object *obj);
EAPI void elm_scroller_custom_widget_base_theme_set(Evas_Object *obj, const char *widget, const char *base);
EAPI void elm_scroller_content_min_limit(Evas_Object *obj, Eina_Bool w, Eina_Bool h);
EAPI void elm_scroller_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
@ -546,6 +548,7 @@ extern "C" {
EAPI void elm_frame_label_set(Evas_Object *obj, const char *label);
EAPI const char *elm_frame_label_get(const Evas_Object *obj);
EAPI void elm_frame_content_set(Evas_Object *obj, Evas_Object *content);
EAPI Evas_Object *elm_frame_content_unset(Evas_Object *obj);
/* available styles:
* default
* pad_small
@ -644,6 +647,7 @@ extern "C" {
EAPI Eina_Bool elm_layout_file_set(Evas_Object *obj, const char *file, const char *group);
EAPI Eina_Bool elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style);
EAPI void elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content);
EAPI Evas_Object *elm_layout_content_unset(Evas_Object *obj, const char *swallow);
EAPI Evas_Object *elm_layout_edje_get(const Evas_Object *obj);
EAPI void elm_layout_sizing_eval(Evas_Object *obj);
/* smart callbacks called:
@ -663,6 +667,7 @@ extern "C" {
} Elm_Notify_Orient;
EAPI Evas_Object *elm_notify_add(Evas_Object *parent);
EAPI void elm_notify_content_set(Evas_Object *obj, Evas_Object *content);
EAPI Evas_Object *elm_notify_content_unset(Evas_Object *obj);
EAPI void elm_notify_parent_set(Evas_Object *obj, Evas_Object *parent);
EAPI void elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient);
EAPI void elm_notify_timeout_set(Evas_Object *obj, int timeout);
@ -684,6 +689,7 @@ extern "C" {
EAPI void elm_hover_parent_set(Evas_Object *obj, Evas_Object *parent);
EAPI Evas_Object *elm_hover_parent_get(Evas_Object *obj);
EAPI void elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content);
EAPI Evas_Object *elm_hover_content_unset(Evas_Object *obj, const char *swallow);
EAPI const char *elm_hover_best_content_location_get(const Evas_Object *obj, Elm_Hover_Axis pref_axis);
/* available styles:
* default
@ -846,6 +852,7 @@ extern "C" {
EAPI const char *elm_bubble_info_get(const Evas_Object *obj);
EAPI void elm_bubble_content_set(Evas_Object *obj, Evas_Object *content);
EAPI Evas_Object *elm_bubble_content_unset(Evas_Object *obj);
EAPI void elm_bubble_icon_set(Evas_Object *obj, Evas_Object *icon);
EAPI Evas_Object *elm_bubble_icon_get(const Evas_Object *obj);
EAPI void elm_bubble_corner_set(Evas_Object *obj, const char *corner);
@ -1455,6 +1462,7 @@ extern "C" {
EAPI void elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient);
EAPI Elm_Panel_Orient elm_panel_orient_get(Evas_Object *obj);
EAPI void elm_panel_content_set(Evas_Object *obj, Evas_Object *content);
EAPI Evas_Object *elm_panel_content_unset(Evas_Object *obj);
EAPI void elm_panel_hidden_set(Evas_Object *obj, Eina_Bool hidden);
EAPI Eina_Bool elm_panel_hidden_get(Evas_Object *obj);
EAPI void elm_panel_toggle(Evas_Object *obj);
@ -1519,9 +1527,12 @@ extern "C" {
EAPI Evas_Object *elm_conformant_add(Evas_Object *parent);
EAPI void elm_conformant_content_set(Evas_Object *obj, Evas_Object *content);
EAPI Evas_Object *elm_conformant_content_unset(Evas_Object *obj);
EAPI Evas_Object *elm_mapbuf_add(Evas_Object *parent);
EAPI void elm_mapbuf_content_set(Evas_Object *obj, Evas_Object *content);
EAPI Evas_Object *elm_mapbuf_content_unset(Evas_Object *obj);
EAPI void elm_mapbuf_enabled_set(Evas_Object *obj, Eina_Bool enabled);
EAPI Eina_Bool elm_mapbuf_enabled_get(const Evas_Object *obj);
EAPI void elm_mapbuf_smooth_set(Evas_Object *obj, Eina_Bool smooth);

View File

@ -695,6 +695,8 @@ elm_fileselector_button_inwin_mode_get(const Evas_Object *obj)
/**
* Set the icon used for the button
*
* Once the icon object is set, a previously set one will be deleted.
*
* @param obj The button object
* @param icon The image for the button
*
@ -706,21 +708,19 @@ elm_fileselector_button_icon_set(Evas_Object *obj, Evas_Object *icon)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->icon != icon) && (wd->icon))
elm_widget_sub_object_del(obj, wd->icon);
if ((icon) && (wd->icon != icon))
if (wd->icon == icon) return;
if (wd->icon) evas_object_del(wd->icon);
wd->icon = icon;
if (icon)
{
wd->icon = icon;
elm_widget_sub_object_add(obj, icon);
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
edje_object_part_swallow(wd->btn, "elm.swallow.content", icon);
edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
edje_object_message_signal_process(wd->btn);
_sizing_eval(obj);
}
else
wd->icon = icon;
_sizing_eval(obj);
}
/**

View File

@ -209,13 +209,17 @@ elm_bubble_info_get(const Evas_Object *obj)
}
/**
* Set the text to be showed in the bubble
* Set the content to be shown in the bubble
*
* Once the content object is set, a previously set one will be deleted.
* If you want to keep the old content object, use the
* elm_bubble_content_unset() function.
*
* @param obj The bubble object
* @param content The given info about the bubble
* @param content The given content of the bubble
*
* This function sets the text shown on the top right of bubble. In
* the Anchorblock example of the Elementary tests application it
* This function sets the content shown on the middle of the bubble.
* In the Anchorblock example of the Elementary tests application it
* shows time.
*
* @ingroup Bubble
@ -226,28 +230,52 @@ elm_bubble_content_set(Evas_Object *obj, Evas_Object *content)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->content != content) && (wd->content))
elm_widget_sub_object_del(obj, wd->content);
if (wd->content == content) return;
if (wd->content) evas_object_del(wd->content);
wd->content = content;
if (content)
{
elm_widget_sub_object_add(obj, content);
evas_object_event_callback_add(content,
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
edje_object_part_swallow(wd->bbl, "elm.swallow.content", content);
}
_sizing_eval(obj);
}
/**
* Unset the content shown in the bubble
*
* Unparent and return the content object which was set for this widget.
*
* @param obj The bubble object
* @return The content that was being used
*
* @ingroup Bubble
*/
EAPI Evas_Object *
elm_bubble_content_unset(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *content;
if (!wd) return NULL;
if (!wd->content) return NULL;
content = wd->content;
elm_widget_sub_object_del(obj, wd->content);
edje_object_part_unswallow(wd->bbl, wd->content);
wd->content = NULL;
return content;
}
/**
* Set the icon of the bubble
*
* Once the icon object is set, a previously set one will be deleted.
*
* @param obj The bubble object
* @param icon The given icon for the bubble
*
* This function sets the icon shown on the top left of bubble.
*
* @ingroup Bubble
*/
EAPI void
@ -256,8 +284,8 @@ elm_bubble_icon_set(Evas_Object *obj, Evas_Object *icon)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->icon != icon) && (wd->icon))
elm_widget_sub_object_del(obj, wd->icon);
if (wd->icon == icon) return;
if (wd->icon) evas_object_del(wd->icon);
wd->icon = icon;
if (icon)
{
@ -267,8 +295,8 @@ elm_bubble_icon_set(Evas_Object *obj, Evas_Object *icon)
_changed_size_hints, obj);
edje_object_signal_emit(wd->bbl, "elm,state,icon,visible", "elm");
edje_object_message_signal_process(wd->bbl);
_sizing_eval(obj);
}
_sizing_eval(obj);
}
/**

View File

@ -18,7 +18,6 @@ struct _Widget_Data
{
Evas_Object *btn, *icon;
const char *label;
Eina_Bool autorepeat;
Eina_Bool repeating;
double ar_threshold;
@ -305,8 +304,10 @@ elm_button_label_get(const Evas_Object *obj)
/**
* Set the icon used for the button
*
* Once the icon object is set, a previously set one will be deleted
*
* @param obj The button object
* @param icon The image for the button
* @param icon The image for the button
*
* @ingroup Button
*/
@ -316,21 +317,19 @@ elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->icon != icon) && (wd->icon))
elm_widget_sub_object_del(obj, wd->icon);
if ((icon) && (wd->icon != icon))
if (wd->icon == icon) return;
if (wd->icon) evas_object_del(wd->icon);
wd->icon = icon;
if (icon)
{
wd->icon = icon;
elm_widget_sub_object_add(obj, icon);
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
edje_object_part_swallow(wd->btn, "elm.swallow.content", icon);
edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
edje_object_message_signal_process(wd->btn);
_sizing_eval(obj);
}
else
wd->icon = icon;
_sizing_eval(obj);
}
/**

View File

@ -127,6 +127,7 @@ _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
_changed_size_hints, obj);
wd->icon = NULL;
_sizing_eval(obj);
edje_object_message_signal_process(wd->chk);
}
}
@ -256,10 +257,7 @@ elm_check_label_get(const Evas_Object *obj)
/**
* Set the icon object of the check object
*
* Once the icon object is set, it will become a child of the check object and
* be deleted when the check object is deleted. If another icon object is set
* then the previous one becomes orophaned and will no longer be deleted along
* with the check.
* Once the icon object is set, a previously set one will be deleted.
*
* @param obj The check object
* @param icon The icon object
@ -272,8 +270,8 @@ elm_check_icon_set(Evas_Object *obj, Evas_Object *icon)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->icon != icon) && (wd->icon))
elm_widget_sub_object_del(obj, wd->icon);
if (wd->icon == icon) return;
if (wd->icon) evas_object_del(wd->icon);
wd->icon = icon;
if (icon)
{
@ -282,8 +280,9 @@ elm_check_icon_set(Evas_Object *obj, Evas_Object *icon)
_changed_size_hints, obj);
edje_object_part_swallow(wd->chk, "elm.swallow.content", icon);
edje_object_signal_emit(wd->chk, "elm,state,icon,visible", "elm");
_sizing_eval(obj);
edje_object_message_signal_process(wd->chk);
}
_sizing_eval(obj);
}
/**

View File

@ -268,28 +268,56 @@ elm_conformant_add(Evas_Object *parent)
/**
* Set the content of the conformant widget
*
*
* Once the content object is set, a previously set one will be deleted.
* If you want to keep that old content object, use the
* elm_conformat_content_unset() function.
*
* @param obj The conformant object
* @param content The content that will be used inside this conformant object
*
* @return The content that was being used
*
* @ingroup Conformant
*/
EAPI void
elm_conformant_content_set(Evas_Object *obj, Evas_Object *content)
EAPI void
elm_conformant_content_set(Evas_Object *obj, Evas_Object *content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->content != content) && (wd->content))
elm_widget_sub_object_del(obj, wd->content);
if (wd->content == content) return;
if (wd->content) evas_object_del(wd->content);
wd->content = content;
if (content)
if (content)
{
elm_widget_sub_object_add(obj, content);
evas_object_event_callback_add(content,
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
edje_object_part_swallow(wd->base, "elm.swallow.content", content);
_sizing_eval(obj);
elm_widget_sub_object_add(obj, content);
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
edje_object_part_swallow(wd->base, "elm.swallow.content", content);
}
_sizing_eval(obj);
}
/**
* Unset the content of the conformant widget
*
* Unparent and return the content object which was set for this widget;
*
* @param obj The conformant object
* @return The content that was being used
*
* @ingroup Conformant
*/
EAPI Evas_Object *
elm_conformant_content_unset(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *content;
if (!wd) return NULL;
if (!wd->content) return NULL;
content = wd->content;
elm_widget_sub_object_del(obj, wd->content);
edje_object_part_unswallow(wd->base, wd->content);
wd->content = NULL;
return content;
}

View File

@ -152,7 +152,11 @@ elm_frame_label_get(const Evas_Object *obj)
}
/**
* Set the frame content
* Set the content of the frame widget
*
* Once the content object is set, a previously set one will be deleted.
* If you want to keep that old content object, use the
* elm_frame_content_unset() function.
*
* @param obj The frame object
* @param content The content will be filled in this frame object
@ -165,16 +169,40 @@ elm_frame_content_set(Evas_Object *obj, Evas_Object *content)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->content != content) && (wd->content))
elm_widget_sub_object_del(obj, wd->content);
if (wd->content == content) return;
if (wd->content) evas_object_del(wd->content);
wd->content = content;
if (content)
{
elm_widget_sub_object_add(obj, content);
evas_object_event_callback_add(content,
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
_sizing_eval(obj);
}
_sizing_eval(obj);
}
/**
* Unset the content of the frame widget
*
* Unparent and return the content object which was set for this widget
*
* @param obj The frame object
* @return The content that was being used
*
* @ingroup Frame
*/
EAPI Evas_Object *
elm_frame_content_unset(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *content;
if (!wd) return NULL;
if (!wd->content) NULL;
content = wd->content;
elm_widget_sub_object_del(obj, wd->content);
edje_object_part_unswallow(wd->frm, wd->content);
wd->content = NULL;
return content;
}

View File

@ -426,6 +426,10 @@ elm_hover_parent_get(Evas_Object *obj)
* Sets the content of the hover object and the direction in which
* it will pop out.
*
* Once the content object is set, a previously set one will be deleted.
* If you want to keep that old content object, use the
* elm_hover_content_unset() function.
*
* @param obj The hover object
* @param swallow The direction that the object will display in. Multiple
* objects can have the same swallow location. Objects placed in the same
@ -451,7 +455,8 @@ elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *conten
if (!strcmp(buf, si->swallow))
{
if (content == si->obj) return;
elm_widget_sub_object_del(obj, si->obj);
evas_object_del(si->obj);
si->obj = NULL;
break;
}
}
@ -463,8 +468,49 @@ elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *conten
si->swallow = eina_stringshare_add(buf);
si->obj = content;
wd->subs = eina_list_append(wd->subs, si);
_sizing_eval(obj);
}
_sizing_eval(obj);
}
/**
* Unset the content of the hover object
*
* Unparent and return the content object which was set for this widget
*
* @param obj The hover object
* @param swallow The direction that the object will display in. Multiple
* objects can have the same swallow location. Objects placed in the same
* swallow will be placed starting at the middle of the hover and ending
* farther from the middle.
* Accepted values are "left" "right" "top" "bottom" "middle"
* @return The content that was being used
*
* @ingroup Hover
*/
EAPI Evas_Object *
elm_hover_content_unset(Evas_Object *obj, const char *swallow)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
Subinfo *si;
Evas_Object *content;
const Eina_List *l;
char buf[1024];
if (!wd) return NULL;
snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", swallow);
EINA_LIST_FOREACH(wd->subs, l, si)
{
if (!strcmp(buf, si->swallow))
{
if (!si->obj) return NULL;
content = si->obj;
elm_widget_sub_object_del(obj, si->obj);
edje_object_part_unswallow(wd->cov, si->obj);
si->obj = NULL;
break;
}
}
return content;
}
/**

View File

@ -211,6 +211,10 @@ elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, cons
/**
* Set the layout content
*
* Once the content object is set, a previously set one will be deleted.
* If you want to keep that old content object, use the
* elm_layout_content_unset() function.
*
* @param obj The layout object
* @param swallow The swallow group name in the edje file
* @param content The content will be filled in this layout object
@ -230,7 +234,8 @@ elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *conte
if (!strcmp(swallow, si->swallow))
{
if (content == si->obj) return;
elm_widget_sub_object_del(obj, si->obj);
evas_object_del(si->obj);
si->obj = NULL;
break;
}
}
@ -245,8 +250,43 @@ elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *conte
si->swallow = eina_stringshare_add(swallow);
si->obj = content;
wd->subs = eina_list_append(wd->subs, si);
_request_sizing_eval(obj);
}
_request_sizing_eval(obj);
}
/**
* Unset the layout content
*
* Unparent and return the content object which was set for this widget
*
* @param obj The layout object
* @param swallow The swallow group name in the edje file
* @return The content that was being used
*
* @ingroup Layout
*/
EAPI Evas_Object *
elm_layout_content_unset(Evas_Object *obj, const char *swallow)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Subinfo *si;
Evas_Object *content;
const Eina_List *l;
if (!wd) return NULL;
EINA_LIST_FOREACH(wd->subs, l, si)
{
if (!strcmp(swallow, si->swallow))
{
if (!si->obj) return NULL;
content == si->obj;
elm_widget_sub_object_del(obj, si->obj);
edje_object_part_unswallow(wd->lay, si->obj);
si->obj = NULL;
break;
}
}
return content;
}
/**

View File

@ -1296,6 +1296,10 @@ elm_list_item_icon_get(const Elm_List_Item *it)
/**
* Sets the left side icon associated with the item.
*
* Once the icon object is set, a previously set one will be deleted.
* You probably don't want, then, to have the <b>same</b> icon object set
* for more than one item of the list.
*
* @param it The list item
* @param icon The left side icon object to associate with @p it
*
@ -1307,13 +1311,22 @@ elm_list_item_icon_set(Elm_List_Item *it, Evas_Object *icon)
ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
if (it->icon == icon) return;
if (it->dummy_icon && !icon) return;
if (it->dummy_icon) evas_object_del(it->icon);
if (it->dummy_icon)
{
evas_object_del(it->icon);
it->dummy_icon = EINA_FALSE;
}
if (!icon)
{
icon = evas_object_rectangle_add(evas_object_evas_get(it->obj));
evas_object_color_set(icon, 0, 0, 0, 0);
it->dummy_icon = EINA_TRUE;
}
if (it->icon)
{
evas_object_del(it->icon);
it->icon = NULL;
}
it->icon = icon;
if (it->base)
edje_object_part_swallow(it->base, "elm.swallow.icon", icon);
@ -1336,7 +1349,11 @@ elm_list_item_end_get(const Elm_List_Item *it)
}
/**
* Gets the right side icon associated with the item.
* Sets the right side icon associated with the item.
*
* Once the icon object is set, a previously set one will be deleted.
* You probably don't want, then, to have the <b>same</b> icon object set
* for more than one item of the list.
*
* @param it The list item
* @param icon The right side icon object to associate with @p it
@ -1349,13 +1366,22 @@ elm_list_item_end_set(Elm_List_Item *it, Evas_Object *end)
ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
if (it->end == end) return;
if (it->dummy_end && !end) return;
if (it->dummy_end) evas_object_del(it->end);
if (it->dummy_end)
{
evas_object_del(it->end);
it->dummy_icon = EINA_FALSE;
}
if (!end)
{
end = evas_object_rectangle_add(evas_object_evas_get(it->obj));
evas_object_color_set(end, 0, 0, 0, 0);
it->dummy_end = EINA_TRUE;
}
if (it->end)
{
evas_object_del(it->end);
it->end = NULL;
}
it->end = end;
if (it->base)
edje_object_part_swallow(it->base, "elm.swallow.end", end);

View File

@ -175,6 +175,10 @@ elm_mapbuf_add(Evas_Object *parent)
/**
* Set the mapbuf front content
*
* Once the content object is set, a previously set one will be deleted.
* If you want to keep that old content object, use the
* elm_mapbuf_content_unset() function.
*
* @param obj The mapbuf object
* @param content The content will be filled in this mapbuf object
*
@ -187,24 +191,44 @@ elm_mapbuf_content_set(Evas_Object *obj, Evas_Object *content)
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->content == content) return;
if ((wd->content != content) && (wd->content))
{
elm_widget_sub_object_del(obj, wd->content);
evas_object_smart_member_del(wd->content);
}
if (wd->content) evas_object_del(wd->content);
wd->content = content;
if (content)
{
elm_widget_sub_object_add(content, obj);
evas_object_smart_member_add(content, obj);
evas_object_event_callback_add(content,
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
evas_object_smart_member_add(content, obj);
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
_sizing_eval(obj);
}
_sizing_eval(obj);
_configure(obj);
}
/**
* Unset the mapbuf front content
*
* Unparent and return the content object which was set for this widget.
*
* @param obj The mapbuf object
* @return The content that was being used
*
* @ingroup Mapbuf
*/
EAPI Evas_Object *
elm_mapbuf_content_unset(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *content;
if (!wd) return NULL;
if (!wd->content) return NULL;
content = wd->content;
elm_widget_sub_object_del(obj, wd->content);
evas_object_smart_member_del(wd->content);
wd->content = NULL;
return content;
}
/**
* Set the mapbuf enabled state
*

View File

@ -80,7 +80,6 @@ _del_hook(Evas_Object *obj)
ll = eina_list_append(ll, item->items);
if (item->del_cb) item->del_cb((void*)item->data, item->o, item);
if (item->label) eina_stringshare_del(item->label);
if (item->icon) evas_object_del(item->icon);
if (item->hv) evas_object_del(item->hv);
if (item->location) evas_object_del(item->location);
free(item);
@ -597,6 +596,8 @@ elm_menu_item_label_get(Elm_Menu_Item *item)
/**
* Set the icon of a menu item
*
* Once the icon object is set, a previously set one will be deleted.
*
* @param it The menu item object.
* @param icon The icon object to set for @p item
*
@ -605,24 +606,21 @@ elm_menu_item_label_get(Elm_Menu_Item *item)
EAPI void
elm_menu_item_icon_set(Elm_Menu_Item *item, Evas_Object *icon)
{
if ((item->icon != icon) && (item->icon))
elm_widget_sub_object_del(item->menu, item->icon);
if ((icon) && (item->icon != icon))
if(item->icon == icon) return;
if (item->icon) evas_object_del(item->icon);
item->icon = icon;
if (icon)
{
item->icon = icon;
elm_widget_sub_object_add(item->menu, icon);
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, item->menu);
_changed_size_hints, item->menu);
edje_object_part_swallow(item->o, "elm.swallow.content", icon);
edje_object_signal_emit(item->o, "elm,state,icon,visible", "elm");
edje_object_message_signal_process(item->o);
_sizing_eval(item->menu);
}
else
item->icon = icon;
_sizing_eval(item->menu);
}
/**
* Set the disabled state of @p item.
*

View File

@ -54,7 +54,6 @@ _del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_notify_content_set(obj, NULL);
elm_notify_parent_set(obj, NULL);
elm_notify_repeat_events_set(obj, EINA_TRUE);
if (wd->timer)
@ -100,8 +99,16 @@ static void
_sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *sub = event_info;
if (!wd) return;
if (event_info == wd->content) wd->content = NULL;
if (sub == wd->content)
{
evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
evas_object_event_callback_del_full(sub, EVAS_CALLBACK_RESIZE,
_content_resize, obj);
wd->content = NULL;
}
}
static void
@ -279,7 +286,11 @@ elm_notify_add(Evas_Object *parent)
}
/**
* Set the notify content
* Set the content of the notify widget
*
* Once the content object is set, a previously set one will be deleted.
* If you want to keep that old content object, use the
* elm_notify_content_unset() function.
*
* @param obj The notify object
* @param content The content will be filled in this notify object
@ -292,33 +303,47 @@ elm_notify_content_set(Evas_Object *obj, Evas_Object *content)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->content)
{
evas_object_event_callback_del_full(wd->content,
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
evas_object_event_callback_del_full(wd->content, EVAS_CALLBACK_RESIZE,
_content_resize, obj);
evas_object_del(wd->content);
wd->content = NULL;
}
if (wd->content == content) return;
if (wd->content) evas_object_del(wd->content);
wd->content = content;
if (content)
{
elm_widget_sub_object_add(obj, content);
wd->content = content;
evas_object_event_callback_add(content,
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
evas_object_event_callback_add(content, EVAS_CALLBACK_RESIZE,
_content_resize, obj);
_content_resize, obj);
edje_object_part_swallow(wd->notify, "elm.swallow.content", content);
_sizing_eval(obj);
}
_sizing_eval(obj);
_calc(obj);
}
/**
* Unset the content of the notify widget
*
* Unparent and return the content object which was set for this widget
*
* @param obj The notify object
* @return The content that was being used
*
* @ingroup Notify
*/
EAPI Evas_Object *
elm_notify_content_unset(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *content;
if (!wd) return NULL;
if (!wd->content) return NULL;
content = wd->content;
elm_widget_sub_object_del(obj, wd->content);
edje_object_part_unswallow(wd->notify, wd->content);
wd->content = NULL;
return content;
}
/**
* Set the notify parent
*

View File

@ -20,7 +20,7 @@
typedef struct _Widget_Data Widget_Data;
struct _Widget_Data
{
Evas_Object *scr, *bx;
Evas_Object *scr, *bx, *content;
Elm_Panel_Orient orient;
Eina_Bool hidden : 1;
};
@ -235,24 +235,57 @@ elm_panel_orient_get(Evas_Object *obj)
/**
* Set the content of the panel.
*
* Once the content object is set, a previously set one will be deleted.
* If you want to keep that old content object, use the
* elm_panel_content_unset() function.
*
* @param obj The panel object
* @param content The panel content
*
* @ingroup Panel
*/
EAPI void
elm_panel_content_set(Evas_Object *obj, Evas_Object *content)
EAPI void
elm_panel_content_set(Evas_Object *obj, Evas_Object *content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_box_remove_all(wd->bx, EINA_TRUE);
if (!content) return;
evas_object_box_append(wd->bx, content);
evas_object_show(content);
if (wd->content == content) return;
if (wd->content)
evas_object_box_remove_all(wd->bx, EINA_TRUE);
wd->content = content;
if (content)
{
evas_object_box_append(wd->bx, wd->content);
evas_object_show(wd->content);
}
_sizing_eval(obj);
}
/**
* Unset the content of the panel.
*
* Unparent and return the content object which was set for this widget.
*
* @param obj The panel object
* @return The content that was being used
*
* @ingroup Panel
*/
EAPI Evas_Object *
elm_panel_content_unset(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *content;
if (!wd) return NULL;
if (!wd->content) return NULL;
content = wd->content;
evas_object_box_remove_all(wd->bx, EINA_FALSE);
wd->content = NULL;
return content;
}
/**
* Set the state of the panel.
*

View File

@ -139,6 +139,7 @@ _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
evas_object_event_callback_del_full
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
wd->icon = NULL;
edje_object_message_signal_process(wd->progressbar);
_sizing_eval(obj);
}
}
@ -372,10 +373,7 @@ elm_progressbar_label_get(const Evas_Object *obj)
/**
* Set the icon object of the progressbar object
*
* Once the icon object is set, it will become a child of the progressbar object and
* be deleted when the progressbar object is deleted. If another icon object is set
* then the previous one becomes orophaned and will no longer be deleted along
* with the progressbar.
* Once the icon object is set, a previously set one will be deleted.
*
* @param obj The progressbar object
* @param icon The icon object
@ -388,8 +386,8 @@ elm_progressbar_icon_set(Evas_Object *obj, Evas_Object *icon)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->icon != icon) && (wd->icon))
elm_widget_sub_object_del(obj, wd->icon);
if (wd->icon == icon) return;
if (wd->icon) evas_object_del(wd->icon);
wd->icon = icon;
if (icon)
{
@ -398,8 +396,9 @@ elm_progressbar_icon_set(Evas_Object *obj, Evas_Object *icon)
_changed_size_hints, obj);
edje_object_part_swallow(wd->progressbar, "elm.swallow.content", icon);
edje_object_signal_emit(wd->progressbar, "elm,state,icon,visible", "elm");
_sizing_eval(obj);
edje_object_message_signal_process(wd->progressbar);
}
_sizing_eval(obj);
}
/**

View File

@ -296,10 +296,7 @@ elm_radio_label_get(const Evas_Object *obj)
/**
* Set the icon object of the radio object
*
* Once the icon object is set, it will become a child of the radio object and
* be deleted when the radio object is deleted. If another icon object is set
* then the previous one becomes orophaned and will no longer be deleted along
* with the radio.
* Once the icon object is set, a previously set one will be deleted.
*
* @param obj The radio object
* @param icon The icon object
@ -312,8 +309,8 @@ elm_radio_icon_set(Evas_Object *obj, Evas_Object *icon)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->icon != icon) && (wd->icon))
elm_widget_sub_object_del(obj, wd->icon);
if (wd->icon == icon) return;
if (wd->icon) evas_object_del(wd->icon);
wd->icon = icon;
if (icon)
{
@ -322,8 +319,9 @@ elm_radio_icon_set(Evas_Object *obj, Evas_Object *icon)
_changed_size_hints, obj);
edje_object_part_swallow(wd->radio, "elm.swallow.content", icon);
edje_object_signal_emit(wd->radio, "elm,state,icon,visible", "elm");
_sizing_eval(obj);
edje_object_message_signal_process(wd->radio);
}
_sizing_eval(obj);
}
/**

View File

@ -75,7 +75,6 @@ static const Evas_Smart_Cb_Description _signals[] = {
static void
_del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
free(wd);
@ -353,9 +352,11 @@ elm_scroller_add(Evas_Object *parent)
/**
* Set the content object
* Set the content of the scroller widget (the object to be scrolled around).
*
* Sets the content of the scroller (the object to be scrolled around)
* Once the content object is set, a previously set one will be deleted.
* If you want to keep that old content object, use the
* elm_scroller_content_unset() function.
*
* @param obj The scroller object
* @param content The new content object
@ -368,8 +369,8 @@ elm_scroller_content_set(Evas_Object *obj, Evas_Object *content)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->content != content) && (wd->content))
elm_widget_sub_object_del(obj, wd->content);
if (wd->content == content) return;
if (wd->content) evas_object_del(wd->content);
wd->content = content;
if (content)
{
@ -379,8 +380,33 @@ elm_scroller_content_set(Evas_Object *obj, Evas_Object *content)
elm_smart_scroller_child_set(wd->scr, content);
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
_sizing_eval(obj);
}
_sizing_eval(obj);
}
/**
* Unset the content of the scroller widget
*
* Unparent and return the content object which was set for this widget
*
* @param obj The slider objecet
* @return The content that was being used
*
* @ingroup Scroller
*/
EAPI Evas_Object *
elm_scroller_content_unset(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *content;
if (!wd) return NULL;
if (!wd->content) return NULL;
content = wd->content;
elm_widget_sub_object_del(obj, wd->content);
edje_object_part_unswallow(wd->scr, wd->content);
wd->content = NULL;
return content;
}
/**
@ -389,6 +415,8 @@ elm_scroller_content_set(Evas_Object *obj, Evas_Object *content)
* @param obj The scroller object
* @param widget The widget name to use (default is "scroller")
* @param base The base name to use (default is "base")
*
* @ingroup Scroller
*/
EAPI void
elm_scroller_custom_widget_base_theme_set(Evas_Object *obj, const char *widget, const char *base)

View File

@ -160,6 +160,7 @@ _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
evas_object_event_callback_del_full
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
wd->icon = NULL;
edje_object_message_signal_process(wd->slider);
_sizing_eval(obj);
}
}
@ -396,10 +397,7 @@ elm_slider_label_get(const Evas_Object *obj)
/**
* Set the icon object of the slider object
*
* Once the icon object is set, it will become a child of the slider object and
* be deleted when the slider object is deleted. If another icon object is set
* then the previous one becomes orophaned and will no longer be deleted along
* with the slider.
* Once the icon object is set, a previously set one will be deleted.
*
* @param obj The slider object
* @param icon The icon object
@ -412,8 +410,8 @@ elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->icon != icon) && (wd->icon))
elm_widget_sub_object_del(obj, wd->icon);
if (wd->icon == icon) return;
if (wd->icon) evas_object_del(wd->icon);
wd->icon = icon;
if (icon)
{
@ -422,8 +420,9 @@ elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
_changed_size_hints, obj);
edje_object_part_swallow(wd->slider, "elm.swallow.content", icon);
edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
_sizing_eval(obj);
edje_object_message_signal_process(wd->slider);
}
_sizing_eval(obj);
}
/**

View File

@ -125,6 +125,7 @@ _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
evas_object_event_callback_del_full
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
wd->icon = NULL;
edje_object_message_signal_process(wd->tgl);
_sizing_eval(obj);
}
}
@ -242,6 +243,8 @@ elm_toggle_label_get(const Evas_Object *obj)
/**
* Sets the icon to be displayed with the toggle.
*
* Once the icon object is set, a previously set one will be deleted.
*
* @param obj The toggle object
* @param icon The icon object to be displayed
*
@ -253,15 +256,18 @@ elm_toggle_icon_set(Evas_Object *obj, Evas_Object *icon)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->icon != icon) && (wd->icon))
elm_widget_sub_object_del(obj, wd->icon);
if (wd->icon == icon) return;
if (wd->icon) evas_object_del(wd->icon);
wd->icon = icon;
if (!icon) return;
elm_widget_sub_object_add(obj, icon);
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
edje_object_part_swallow(wd->tgl, "elm.swallow.content", icon);
edje_object_signal_emit(wd->tgl, "elm,state,icon,visible", "elm");
if (icon)
{
elm_widget_sub_object_add(obj, icon);
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
edje_object_part_swallow(wd->tgl, "elm.swallow.content", icon);
edje_object_signal_emit(wd->tgl, "elm,state,icon,visible", "elm");
edje_object_message_signal_process(wd->tgl);
}
_sizing_eval(obj);
}

View File

@ -1583,6 +1583,7 @@ static void
_del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
free(wd);
}
@ -1688,6 +1689,10 @@ elm_win_inwin_activate(Evas_Object *obj)
/**
* Set the content of an inwin object.
*
* Once the content object is set, a previously set one will be deleted.
* If you want to keep that old content object, use the
* elm_win_inwin_content_unset() function.
*
* @param obj The inwin object
* @param content The object to set as content
*
@ -1699,8 +1704,8 @@ elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
ELM_CHECK_WIDTYPE(obj, widtype2);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((wd->content) && (wd->content != content))
elm_widget_sub_object_del(obj, wd->content);
if (wd->content == content) return;
if (wd->content) evas_object_del(wd->content);
wd->content = content;
if (content)
{
@ -1708,8 +1713,32 @@ elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
_sizing_eval(obj);
}
_sizing_eval(obj);
}
/**
* Unset the content of an inwin object.
*
* Unparent and return the content object which was set for this widget.
*
* @param obj The inwin object
* @return The content that was being used
*
* @ingroup Inwin
*/
EAPI Evas_Object *
elm_win_inwin_content_unset(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
if (!wd->content) return NULL;
Evas_Object *content = wd->content;
elm_widget_sub_object_del(obj, wd->content);
edje_object_part_unswallow(wd->frm, wd->content);
wd->content = NULL;
return content;
}
/* windowing spcific calls - shall we do this differently? */