elementary/button -> use elm_object_content_set/get/unset

SVN revision: 64370
This commit is contained in:
ChunEon Park 2011-10-25 01:23:25 +00:00
parent da7bf528c9
commit 8d85b136bf
19 changed files with 111 additions and 85 deletions

View File

@ -842,7 +842,7 @@
* callback, where we move the button doing some size hint magic. To
* understand how that works better, refer to the @ref Box documentation.
* Also, the first time the function is called, we change the icon in the
* middle button, using elm_button_icon_unset() first to keep the reference
* middle button, using elm_object_content_unset() first to keep the reference
* to the previous one, so we don't need to recreate it when we are done
* moving it.
* @skip static void

View File

@ -9,7 +9,7 @@ elm_object_text_set(o, "Button");
Evas_Object *o2 = elm_icon_add(win);
elm_icon_standard_set(o2, "home");
elm_button_icon_set(o, o2);
elm_object_content_set(o, o2);
evas_object_show(o2);
#include "widget_preview_tmpl_foot.c"

View File

@ -7,7 +7,7 @@ evas_object_show(o);
Evas_Object *o2 = elm_icon_add(win);
elm_icon_standard_set(o2, "home");
elm_button_icon_set(o, o2);
elm_object_content_set(o, o2);
evas_object_show(o2);
#include "widget_preview_tmpl_foot.c"

View File

@ -64,7 +64,7 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_text_set(bt, "Icon sized to button");
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)1);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)1);
elm_box_pack_end(bx, bt);
@ -77,7 +77,7 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
elm_icon_scale_set(ic, 0, 0);
bt = elm_button_add(win);
elm_object_text_set(bt, "Icon no scale");
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)2);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)2);
elm_box_pack_end(bx, bt);
@ -90,7 +90,7 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_text_set(bt, "Disabled Button");
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
elm_object_disabled_set(bt, 1);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)3);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)3);
@ -103,7 +103,7 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
elm_object_disabled_set(bt, 1);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)4);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)4);
@ -127,7 +127,7 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
bt = elm_button_add(win);
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)6);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)6);
elm_box_pack_end(bx, bt);
@ -148,7 +148,7 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_style_set(bt, "anchor");
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)8);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)8);
elm_box_pack_end(bx, bt);
@ -162,7 +162,7 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
bt = elm_button_add(win);
elm_object_access_info_set(bt, "This is some custom text describing this widget");
elm_object_style_set(bt, "anchor");
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
elm_object_disabled_set(bt, 1);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)9);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)9);

View File

@ -546,7 +546,7 @@ _marker_get(Evas_Object *obj, Elm_Map_Marker *marker __UNUSED__, void *data)
evas_object_show(icon);
Evas_Object *o = elm_button_add(obj);
elm_button_icon_set(o, icon);
elm_object_content_set(o, icon);
evas_object_show(o);
elm_box_pack_end(bx, o);
}

View File

@ -37,7 +37,7 @@ _page4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
bt2 = elm_button_add(nf);
evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
@ -115,7 +115,7 @@ _page2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
it = elm_naviframe_item_push(nf,
"Page 2",

View File

@ -255,7 +255,7 @@ test_transit(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf
bt = elm_button_add(win);
elm_object_text_set(bt, "ImageAnimation Effect");
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(ic);
@ -386,7 +386,7 @@ test_transit5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_size_hint_max_set(ic, 50, 50);
bt = elm_button_add(win);
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
elm_object_text_set(bt, "Before Button - Blend Effect");
evas_object_move(bt, 25, 125);
evas_object_resize(bt, 250, 50);
@ -398,7 +398,7 @@ test_transit5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_size_hint_max_set(ic, 50, 50);
bt2 = elm_button_add(win);
elm_button_icon_set(bt2, ic);
elm_object_content_set(bt2, ic);
elm_object_text_set(bt2, "After Button - Blend Effect");
evas_object_move(bt2, 25, 125);
evas_object_resize(bt2, 250, 50);
@ -432,7 +432,7 @@ test_transit6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_size_hint_max_set(ic, 50, 50);
bt = elm_button_add(win);
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
elm_object_text_set(bt, "Before Button - Fade Effect");
evas_object_move(bt, 25, 125);
evas_object_resize(bt, 250, 50);
@ -444,7 +444,7 @@ test_transit6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_size_hint_max_set(ic, 50, 50);
bt2 = elm_button_add(win);
elm_button_icon_set(bt2, ic);
elm_object_content_set(bt2, ic);
elm_object_text_set(bt2, "After Button - Fade Effect");
evas_object_move(bt2, 25, 125);
evas_object_resize(bt2, 250, 50);

View File

@ -19,7 +19,7 @@ external_button_state_set(void *data __UNUSED__, Evas_Object *obj, const void *f
if (p->label)
elm_object_text_set(obj, p->label);
if (p->icon)
elm_button_icon_set(obj, p->icon);
elm_object_content_set(obj, p->icon);
}
static Eina_Bool
@ -39,7 +39,7 @@ external_button_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_Ex
{
Evas_Object *icon = external_common_param_icon_get(obj, param);
if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
elm_button_icon_set(obj, icon);
elm_object_content_set(obj, icon);
return EINA_TRUE;
}
}

View File

@ -24,7 +24,7 @@ static void
_btn_cursors_release_cb(void *data, Evas_Object *btn __UNUSED__, void *ev __UNUSED__)
{
App_Data *app = data;
elm_button_icon_set(app->mid, app->icon_still);
elm_object_content_set(app->mid, app->icon_still);
app->icon_still = NULL;
}
@ -37,10 +37,10 @@ _btn_cursors_move_cb(void *data, Evas_Object *btn, void *ev __UNUSED__)
if (!app->icon_still)
{
Evas_Object *icon;
app->icon_still = elm_button_icon_unset(app->mid);
app->icon_still = elm_object_content_unset(app->mid);
icon = elm_icon_add(app->mid);
elm_icon_standard_set(icon, "chat");
elm_button_icon_set(app->mid, icon);
elm_object_content_set(app->mid, icon);
}
evas_object_size_hint_align_get(app->mid, &ax, &ay);
@ -185,7 +185,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
icon = elm_icon_add(win);
elm_icon_standard_set(icon, "arrow_up");
elm_button_icon_set(btn, icon);
elm_object_content_set(btn, icon);
data.cursors.up = btn;
@ -210,7 +210,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
icon = elm_icon_add(win);
elm_icon_standard_set(icon, "arrow_left");
elm_button_icon_set(btn, icon);
elm_object_content_set(btn, icon);
data.cursors.left = btn;
@ -221,7 +221,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
icon = elm_icon_add(win);
elm_icon_standard_set(icon, "close");
elm_button_icon_set(btn, icon);
elm_object_content_set(btn, icon);
data.mid = btn;
@ -239,7 +239,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
icon = elm_icon_add(win);
elm_icon_standard_set(icon, "arrow_right");
elm_button_icon_set(btn, icon);
elm_object_content_set(btn, icon);
data.cursors.right = btn;
@ -257,7 +257,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
icon = elm_icon_add(win);
elm_icon_standard_set(icon, "arrow_down");
elm_button_icon_set(btn, icon);
elm_object_content_set(btn, icon);
data.cursors.down = btn;

View File

@ -553,7 +553,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
icon = elm_layout_add(win);
elm_layout_theme_set(icon, "entry", "emoticon/haha", "default");
elm_button_icon_set(o, icon);
elm_object_content_set(o, icon);
evas_object_smart_callback_add(o, "clicked", _image_insert_cb, &app);

View File

@ -227,7 +227,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
icon = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_07.png", PACKAGE_DATA_DIR);
elm_icon_file_set(icon, buf, NULL);
elm_button_icon_set(obj, icon);
elm_object_content_set(obj, icon);
evas_object_move(obj, 160, 60);
evas_object_resize(obj, 250, 100);
evas_object_show(obj);

View File

@ -132,7 +132,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
icon = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_07.png", PACKAGE_DATA_DIR);
elm_icon_file_set(icon, buf, NULL);
elm_button_icon_set(obj, icon);
elm_object_content_set(obj, icon);
evas_object_move(obj, 160, 60);
evas_object_resize(obj, 250, 100);
evas_object_show(obj);
@ -145,7 +145,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
icon = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_08.png", PACKAGE_DATA_DIR);
elm_icon_file_set(icon, buf, NULL);
elm_button_icon_set(obj, icon);
elm_object_content_set(obj, icon);
evas_object_move(obj, 160, 60);
evas_object_resize(obj, 250, 100);

View File

@ -405,7 +405,7 @@ _win_search_trigger_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED
ic = elm_icon_add(ad->win);
elm_icon_standard_set(ic, "arrow_up");
elm_button_icon_set(btn, ic);
elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _search_prev_cb, ad);
@ -415,7 +415,7 @@ _win_search_trigger_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED
ic = elm_icon_add(ad->win);
elm_icon_standard_set(ic, "arrow_down");
elm_button_icon_set(btn, ic);
elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _search_next_cb, ad);
@ -425,7 +425,7 @@ _win_search_trigger_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED
ic = elm_icon_add(ad->win);
elm_icon_standard_set(ic, "close");
elm_button_icon_set(btn, ic);
elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _search_close_cb, ad);
@ -523,7 +523,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "arrow_left");
elm_button_icon_set(btn, ic);
elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _nav_back_cb, ad);
@ -535,7 +535,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "refresh");
elm_button_icon_set(btn, ic);
elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _nav_refresh_cb, ad);
@ -547,7 +547,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "arrow_right");
elm_button_icon_set(btn, ic);
elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _nav_fwd_cb, ad);
@ -564,7 +564,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "file");
elm_button_icon_set(btn, ic);
elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _add_tab_cb, ad);
@ -586,7 +586,7 @@ elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "close");
elm_button_icon_set(btn, ic);
elm_object_content_set(btn, ic);
pager = elm_pager_add(win);
evas_object_size_hint_weight_set(pager, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

View File

@ -6189,7 +6189,7 @@ extern "C" {
* @param obj The button object
* @param icon The icon object for the button
*/
EAPI void elm_button_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
EINA_DEPRECATED EAPI void elm_button_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
/**
* Get the icon used for the button
*
@ -6202,7 +6202,7 @@ extern "C" {
*
* @see elm_button_icon_unset()
*/
EAPI Evas_Object *elm_button_icon_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
EINA_DEPRECATED EAPI Evas_Object *elm_button_icon_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
/**
* Remove the icon set without deleting it and return the object
*
@ -6214,7 +6214,7 @@ extern "C" {
* @param obj The button object
* @return The icon object that was being used
*/
EAPI Evas_Object *elm_button_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
EINA_DEPRECATED EAPI Evas_Object *elm_button_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
/**
* Turn on/off the autorepeat event generated when the button is kept pressed
*
@ -14036,7 +14036,7 @@ extern "C" {
* deleted, if you want to keep that old content object, use the
* elm_hoversel_icon_unset() function.
*
* @see elm_button_icon_set()
* @see elm_object_content_set() for the button widget
*/
EAPI void elm_hoversel_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
/**
@ -14046,7 +14046,7 @@ extern "C" {
* @return The icon object
*
* Get the icon of the button that is always visible (before it is clicked
* and expanded). Also see elm_button_icon_get().
* and expanded). Also see elm_object_content_get() for the button widget.
*
* @see elm_hoversel_icon_set()
*/
@ -14061,7 +14061,7 @@ extern "C" {
* (before it is clicked and expanded).
*
* @see elm_hoversel_icon_set()
* @see elm_button_icon_unset()
* @see elm_object_content_unset() for the button widget
*/
EAPI Evas_Object *elm_hoversel_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
/**

View File

@ -839,7 +839,7 @@ elm_fileselector_add(Evas_Object *parent)
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(parent);
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Up"));
evas_object_size_hint_align_set(bt, 0.0, 0.0);
@ -854,7 +854,7 @@ elm_fileselector_add(Evas_Object *parent)
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(parent);
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Home"));
evas_object_size_hint_align_set(bt, 0.0, 0.0);

View File

@ -497,7 +497,7 @@ elm_fileselector_button_icon_set(Evas_Object *obj,
evas_object_del(icon);
return;
}
elm_button_icon_set(wd->btn, icon);
elm_object_content_set(wd->btn, icon);
}
EAPI Evas_Object *
@ -506,7 +506,7 @@ elm_fileselector_button_icon_get(const Evas_Object *obj)
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return elm_button_icon_get(wd->btn);
return elm_object_content_get(wd->btn);
}
EAPI Evas_Object *
@ -515,6 +515,6 @@ elm_fileselector_button_icon_unset(Evas_Object *obj)
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return elm_button_icon_unset(wd->btn);
return elm_object_content_unset(wd->btn);
}

View File

@ -204,7 +204,7 @@ _activate(Evas_Object *obj)
elm_icon_file_set(ic, item->icon_file, item->icon_group);
else if (item->icon_type == ELM_ICON_STANDARD)
elm_icon_standard_set(ic, item->icon_file);
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
evas_object_show(ic);
}
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
@ -372,7 +372,7 @@ elm_hoversel_icon_set(Evas_Object *obj, Evas_Object *icon)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_button_icon_set(wd->btn, icon);
elm_object_content_set(wd->btn, icon);
}
EAPI Evas_Object *
@ -381,7 +381,7 @@ elm_hoversel_icon_get(const Evas_Object *obj)
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (!wd->btn)) return NULL;
return elm_button_icon_get(wd->btn);
return elm_object_content_get(wd->btn);
}
EAPI Evas_Object *
@ -390,7 +390,7 @@ elm_hoversel_icon_unset(Evas_Object *obj)
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (!wd->btn)) return NULL;
return elm_button_icon_unset(wd->btn);
return elm_object_content_unset(wd->btn);
}
EAPI void

View File

@ -418,7 +418,7 @@ _player_button_add(Evas_Object *parent, Evas_Object *obj, Evas_Object *layout, c
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(parent);
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
elm_button_icon_set(bt, ic);
elm_object_content_set(bt, ic);
evas_object_size_hint_align_set(bt, 0.0, 0.0);
elm_object_style_set(bt, "anchor");
evas_object_smart_callback_add(bt, "clicked", func, obj);

View File

@ -20,6 +20,9 @@ static void _del_hook(Evas_Object *obj);
static void _del_pre_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _disable_hook(Evas_Object *obj);
static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
static void _sizing_eval(Evas_Object *obj);
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
@ -172,6 +175,51 @@ _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *so
data);
}
static void
_content_set_hook(Evas_Object *obj, const char *part __UNUSED__, Evas_Object *content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->icon == content) return;
if (wd->icon) evas_object_del(wd->icon);
wd->icon = 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->btn, "elm.swallow.content", content);
edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
edje_object_message_signal_process(wd->btn);
}
_sizing_eval(obj);
}
static Evas_Object *
_content_get_hook(const Evas_Object *obj, const char *part __UNUSED__)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return wd->icon;
}
static Evas_Object *
_content_unset_hook(Evas_Object *obj, const char *part __UNUSED__)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
if (!wd->icon) return NULL;
Evas_Object *icon = wd->icon;
elm_widget_sub_object_del(obj, wd->icon);
edje_object_part_unswallow(wd->btn, wd->icon);
wd->icon = NULL;
return icon;
}
static void
_sizing_eval(Evas_Object *obj)
{
@ -376,6 +424,9 @@ elm_button_add(Evas_Object *parent)
elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
elm_widget_text_set_hook_set(obj, _elm_button_label_set);
elm_widget_text_get_hook_set(obj, _elm_button_label_get);
elm_widget_content_set_hook_set(obj, _content_set_hook);
elm_widget_content_get_hook_set(obj, _content_get_hook);
elm_widget_content_unset_hook_set(obj, _content_unset_hook);
wd->btn = edje_object_add(e);
_elm_theme_object_set(obj, wd->btn, "button", "base", "default");
@ -417,48 +468,23 @@ elm_button_label_get(const Evas_Object *obj)
return _elm_button_label_get(obj, NULL);
}
EAPI void
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) return;
if (wd->icon) evas_object_del(wd->icon);
wd->icon = icon;
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->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);
_content_set_hook(obj, NULL, icon);
}
EAPI Evas_Object *
elm_button_icon_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->icon;
return _content_get_hook(obj, NULL);
}
EAPI Evas_Object *
elm_button_icon_unset(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
if (!wd->icon) return NULL;
Evas_Object *icon = wd->icon;
elm_widget_sub_object_del(obj, wd->icon);
edje_object_part_unswallow(wd->btn, wd->icon);
wd->icon = NULL;
return icon;
return _content_unset_hook(obj, NULL);
}
EAPI void