From: raster Date: Fri, 1 Apr 2011 06:08:02 +0000 (+0000) Subject: make all widgets use a standard setup macro. cuts code down and X-Git-Tag: REL_F_I9500_20120323_1~17^2~2981 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cbed8ac9b3c1bd3df2946e90f9589e58d3636bea;p=framework%2Fuifw%2Felementary.git make all widgets use a standard setup macro. cuts code down and handles null parent errors, null wd alloc, null obj create errors etc. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@58242 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/elc_anchorblock.c b/src/lib/elc_anchorblock.c index a22a8a5..e32ae0a 100644 --- a/src/lib/elc_anchorblock.c +++ b/src/lib/elc_anchorblock.c @@ -210,12 +210,8 @@ elm_anchorblock_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "anchorblock"); elm_widget_type_set(obj, "anchorblock"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elc_anchorview.c b/src/lib/elc_anchorview.c index a35bc23..e89a2e0 100644 --- a/src/lib/elc_anchorview.c +++ b/src/lib/elc_anchorview.c @@ -201,12 +201,8 @@ elm_anchorview_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "anchorview"); elm_widget_type_set(obj, "anchorview"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elc_ctxpopup.c b/src/lib/elc_ctxpopup.c index 73fcd9e..27afd7f 100644 --- a/src/lib/elc_ctxpopup.c +++ b/src/lib/elc_ctxpopup.c @@ -926,12 +926,8 @@ elm_ctxpopup_add(Evas_Object *parent) Widget_Data *wd; Evas_Coord x, y, w, h; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "ctxpopup"); elm_widget_type_set(obj, "ctxpopup"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elc_fileselector.c b/src/lib/elc_fileselector.c index 03d18da..1bcd430 100644 --- a/src/lib/elc_fileselector.c +++ b/src/lib/elc_fileselector.c @@ -564,18 +564,13 @@ _populate(Evas_Object *obj, EAPI Evas_Object * elm_fileselector_add(Evas_Object *parent) { - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - Evas *e = evas_object_evas_get(parent); - if (!e) return NULL; + Evas *e; Evas_Object *obj, *ic, *bt, *li, *en, *grid; Widget_Data *wd; int s; - // Elementary Widget - wd = ELM_NEW(Widget_Data); - wd->expand = !!_elm_config->fileselector_expand_enable; - obj = elm_widget_add(evas_object_evas_get(parent)); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "fileselector"); elm_widget_type_set(obj, "fileselector"); elm_widget_sub_object_add(parent, obj); @@ -584,6 +579,8 @@ elm_fileselector_add(Evas_Object *parent) elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_can_focus_set(obj, EINA_FALSE); + wd->expand = !!_elm_config->fileselector_expand_enable; + wd->edje = edje_object_add(e); _elm_theme_object_set(obj, wd->edje, "fileselector", "base", "default"); elm_widget_resize_object_set(obj, wd->edje); diff --git a/src/lib/elc_fileselector_button.c b/src/lib/elc_fileselector_button.c index 1639dc3..f08a823 100644 --- a/src/lib/elc_fileselector_button.c +++ b/src/lib/elc_fileselector_button.c @@ -263,23 +263,11 @@ elm_fileselector_button_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - wd->window_title = eina_stringshare_add(DEFAULT_WINDOW_TITLE); - wd->fsd.path = eina_stringshare_add(getenv("HOME")); - wd->fsd.expandable = _elm_config->fileselector_expand_enable; - wd->inwin_mode = _elm_config->inwin_dialogs_enable; - wd->w = 400; - wd->h = 400; - - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "fileselector_button"); elm_widget_type_set(obj, "fileselector_button"); elm_widget_sub_object_add(parent, obj); - wd->self = obj; elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL); elm_widget_data_set(obj, wd); elm_widget_del_hook_set(obj, _del_hook); @@ -288,6 +276,15 @@ elm_fileselector_button_add(Evas_Object *parent) elm_widget_can_focus_set(obj, EINA_TRUE); elm_widget_activate_hook_set(obj, _activate_hook); + wd->self = obj; + wd->window_title = eina_stringshare_add(DEFAULT_WINDOW_TITLE); + if (getenv("HOME")) wd->fsd.path = eina_stringshare_add(getenv("HOME")); + else wd->fsd.path = eina_stringshare_add("/"); + wd->fsd.expandable = _elm_config->fileselector_expand_enable; + wd->inwin_mode = _elm_config->inwin_dialogs_enable; + wd->w = 400; + wd->h = 400; + wd->btn = elm_button_add(parent); elm_widget_mirrored_automatic_set(wd->btn, EINA_FALSE); elm_widget_resize_object_set(obj, wd->btn); diff --git a/src/lib/elc_fileselector_entry.c b/src/lib/elc_fileselector_entry.c index d86c953..b79ad63 100644 --- a/src/lib/elc_fileselector_entry.c +++ b/src/lib/elc_fileselector_entry.c @@ -224,15 +224,11 @@ EAPI Evas_Object * elm_fileselector_entry_add(Evas_Object *parent) { Evas_Object *obj; - Evas *e = evas_object_evas_get(parent); - if (!e) return NULL; + Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "fileselector_entry"); elm_widget_type_set(obj, "fileselector_entry"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c index 8f8f4f2..c4cb27e 100644 --- a/src/lib/elc_hoversel.c +++ b/src/lib/elc_hoversel.c @@ -274,12 +274,8 @@ elm_hoversel_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "hoversel"); elm_widget_type_set(obj, "hoversel"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elc_scrolled_entry.c b/src/lib/elc_scrolled_entry.c index f8bbc74..d6e5e05 100644 --- a/src/lib/elc_scrolled_entry.c +++ b/src/lib/elc_scrolled_entry.c @@ -363,12 +363,8 @@ elm_scrolled_entry_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "scrolled_entry"); elm_widget_type_set(obj, "scrolled_entry"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_actionslider.c b/src/lib/elm_actionslider.c index 8e77b95..65eaf18 100644 --- a/src/lib/elm_actionslider.c +++ b/src/lib/elm_actionslider.c @@ -341,12 +341,8 @@ elm_actionslider_add(Evas_Object *parent) Widget_Data *wd; Evas *e; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "actionslider"); elm_widget_type_set(obj, "actionslider"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_bg.c b/src/lib/elm_bg.c index b9a9454..d35f495 100644 --- a/src/lib/elm_bg.c +++ b/src/lib/elm_bg.c @@ -135,12 +135,8 @@ elm_bg_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "bg"); elm_widget_type_set(obj, "bg"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_box.c b/src/lib/elm_box.c index 789e096..ae2f61d 100644 --- a/src/lib/elm_box.c +++ b/src/lib/elm_box.c @@ -351,12 +351,8 @@ elm_box_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "box"); elm_widget_type_set(obj, "box"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_bubble.c b/src/lib/elm_bubble.c index 603c783..4564ffd 100644 --- a/src/lib/elm_bubble.c +++ b/src/lib/elm_bubble.c @@ -163,12 +163,8 @@ elm_bubble_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "bubble"); elm_widget_type_set(obj, "bubble"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_button.c b/src/lib/elm_button.c index 34e44a6..88ca7db 100644 --- a/src/lib/elm_button.c +++ b/src/lib/elm_button.c @@ -306,12 +306,8 @@ elm_button_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "button"); elm_widget_type_set(obj, "button"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_calendar.c b/src/lib/elm_calendar.c index b66ff80..79941bd 100644 --- a/src/lib/elm_calendar.c +++ b/src/lib/elm_calendar.c @@ -728,12 +728,8 @@ elm_calendar_add(Evas_Object *parent) int i, t; Evas *e; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "calendar"); elm_widget_type_set(obj, "calendar"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_check.c b/src/lib/elm_check.c index 1cc043b..bc57cac 100644 --- a/src/lib/elm_check.c +++ b/src/lib/elm_check.c @@ -246,12 +246,8 @@ elm_check_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "check"); elm_widget_type_set(obj, "check"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_clock.c b/src/lib/elm_clock.c index f00dfea..6331db7 100644 --- a/src/lib/elm_clock.c +++ b/src/lib/elm_clock.c @@ -530,12 +530,8 @@ elm_clock_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "clock"); elm_widget_type_set(obj, "clock"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_colorselector.c b/src/lib/elm_colorselector.c index da4d013..bd58cc4 100644 --- a/src/lib/elm_colorselector.c +++ b/src/lib/elm_colorselector.c @@ -804,12 +804,8 @@ elm_colorselector_add(Evas_Object *parent) Widget_Data *wd = NULL; Evas *e; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "colorselector"); elm_widget_type_set(obj, "colorselector"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_conform.c b/src/lib/elm_conform.c index 8705b30..c10763a 100644 --- a/src/lib/elm_conform.c +++ b/src/lib/elm_conform.c @@ -223,17 +223,11 @@ EAPI Evas_Object * elm_conformant_add(Evas_Object *parent) { Evas_Object *obj; - Evas *evas; + Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - - evas = evas_object_evas_get(parent); - if (!evas) return NULL; - - obj = elm_widget_add(evas); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "conformant"); elm_widget_type_set(obj, "conformant"); elm_widget_sub_object_add(parent, obj); @@ -242,7 +236,7 @@ elm_conformant_add(Evas_Object *parent) elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_can_focus_set(obj, EINA_FALSE); - wd->base = edje_object_add(evas); + wd->base = edje_object_add(e); _elm_theme_object_set(obj, wd->base, "conformant", "base", "default"); elm_widget_resize_object_set(obj, wd->base); @@ -255,7 +249,7 @@ elm_conformant_add(Evas_Object *parent) ecore_x_e_illume_indicator_geometry_get(zone, NULL, NULL, NULL, &sh); if (sh < 0) sh = 0; - wd->shelf = evas_object_rectangle_add(evas); + wd->shelf = evas_object_rectangle_add(e); evas_object_color_set(wd->shelf, 0, 0, 0, 0); evas_object_size_hint_min_set(wd->shelf, -1, sh); evas_object_size_hint_max_set(wd->shelf, -1, sh); @@ -264,7 +258,7 @@ elm_conformant_add(Evas_Object *parent) sh = -1; ecore_x_e_illume_softkey_geometry_get(zone, NULL, NULL, NULL, &sh); if (sh < 0) sh = 0; - wd->panel = evas_object_rectangle_add(evas); + wd->panel = evas_object_rectangle_add(e); evas_object_color_set(wd->panel, 0, 0, 0, 0); evas_object_size_hint_min_set(wd->panel, -1, sh); evas_object_size_hint_max_set(wd->panel, -1, sh); diff --git a/src/lib/elm_diskselector.c b/src/lib/elm_diskselector.c index e5300af..9de3a88 100644 --- a/src/lib/elm_diskselector.c +++ b/src/lib/elm_diskselector.c @@ -621,13 +621,12 @@ _round_items_add(Widget_Data *wd) EAPI Evas_Object * elm_diskselector_add(Evas_Object *parent) { + Evas *e; Evas_Object *obj; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - wd->self = obj = elm_widget_add(evas_object_evas_get(parent)); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "diskselector"); elm_widget_type_set(obj, "diskselector"); elm_widget_sub_object_add(parent, obj); @@ -639,12 +638,13 @@ elm_diskselector_add(Evas_Object *parent) elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL); elm_widget_event_hook_set(obj, _event_hook); + wd->self = obj; wd->item_count = 0; wd->round = EINA_FALSE; wd->init = EINA_FALSE; wd->len_side = 3; - wd->scroller = elm_smart_scroller_add(evas_object_evas_get(parent)); + wd->scroller = elm_smart_scroller_add(e); elm_smart_scroller_widget_set(wd->scroller, obj); _theme_hook(obj); elm_widget_resize_object_set(obj, wd->scroller); diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index 1eae79c..1520339 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -1489,12 +1489,8 @@ elm_entry_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "entry"); elm_widget_type_set(obj, "entry"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_flip.c b/src/lib/elm_flip.c index 7375984..9c3f2b8 100644 --- a/src/lib/elm_flip.c +++ b/src/lib/elm_flip.c @@ -405,12 +405,8 @@ elm_flip_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "flip"); elm_widget_type_set(obj, "flip"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_flipselector.c b/src/lib/elm_flipselector.c index 3b783e8..8dd3142 100644 --- a/src/lib/elm_flipselector.c +++ b/src/lib/elm_flipselector.c @@ -568,13 +568,8 @@ elm_flipselector_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); - wd->self = obj; + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "flipselector"); elm_widget_type_set(obj, "flipselector"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_frame.c b/src/lib/elm_frame.c index 13ee3e9..61cdb8c 100644 --- a/src/lib/elm_frame.c +++ b/src/lib/elm_frame.c @@ -124,12 +124,8 @@ elm_frame_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "frame"); elm_widget_type_set(obj, "frame"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c index 1c430b4..2a262be 100644 --- a/src/lib/elm_gengrid.c +++ b/src/lib/elm_gengrid.c @@ -1545,12 +1545,8 @@ elm_gengrid_add(Evas_Object *parent) static Evas_Smart *smart = NULL; Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "gengrid"); elm_widget_type_set(obj, "gengrid"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c index f7362bb..868aaf0 100644 --- a/src/lib/elm_genlist.c +++ b/src/lib/elm_genlist.c @@ -2608,8 +2608,6 @@ elm_genlist_add(Evas_Object *parent) Evas_Coord minw, minh; static Evas_Smart *smart = NULL; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - if (!smart) { static Evas_Smart_Class sc; @@ -2625,10 +2623,9 @@ elm_genlist_add(Evas_Object *parent) sc.calculate = _pan_calculate; if (!(smart = evas_smart_class_new(&sc))) return NULL; } - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "genlist"); elm_widget_type_set(obj, "genlist"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_hover.c b/src/lib/elm_hover.c index 70cb3bf..ec51c4c 100644 --- a/src/lib/elm_hover.c +++ b/src/lib/elm_hover.c @@ -493,16 +493,8 @@ elm_hover_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - - ELM_HOVER_PARTS_FOREACH - wd->subs[i].swallow = _directions[i]; - - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "hover"); elm_widget_type_set(obj, "hover"); elm_widget_sub_object_add(parent, obj); @@ -516,6 +508,9 @@ elm_hover_add(Evas_Object *parent) elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook); elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook); + ELM_HOVER_PARTS_FOREACH + wd->subs[i].swallow = _directions[i]; + wd->hov = evas_object_rectangle_add(e); evas_object_pass_events_set(wd->hov, EINA_TRUE); evas_object_color_set(wd->hov, 0, 0, 0, 0); diff --git a/src/lib/elm_icon.c b/src/lib/elm_icon.c index c0fad61..2b1c0d3 100644 --- a/src/lib/elm_icon.c +++ b/src/lib/elm_icon.c @@ -186,12 +186,8 @@ elm_icon_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "icon"); elm_widget_type_set(obj, "icon"); elm_widget_can_focus_set(obj, EINA_FALSE); diff --git a/src/lib/elm_image.c b/src/lib/elm_image.c index a71fe11..d3a05a8 100644 --- a/src/lib/elm_image.c +++ b/src/lib/elm_image.c @@ -114,12 +114,8 @@ elm_image_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "image"); elm_widget_type_set(obj, "image"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_index.c b/src/lib/elm_index.c index ac10417..90fec40 100644 --- a/src/lib/elm_index.c +++ b/src/lib/elm_index.c @@ -512,12 +512,8 @@ elm_index_add(Evas_Object *parent) Widget_Data *wd; Evas_Coord minw, minh; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "index"); elm_widget_type_set(obj, "index"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_label.c b/src/lib/elm_label.c index c8a9fe1..8a67969 100644 --- a/src/lib/elm_label.c +++ b/src/lib/elm_label.c @@ -653,15 +653,8 @@ elm_label_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - wd->bgcolor = EINA_FALSE; - wd->bg = evas_object_rectangle_add(e); - evas_object_color_set(wd->bg, 0, 0, 0, 0); - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "label"); elm_widget_type_set(obj, "label"); elm_widget_sub_object_add(parent, obj); @@ -670,6 +663,10 @@ elm_label_add(Evas_Object *parent) elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_can_focus_set(obj, EINA_FALSE); + wd->bgcolor = EINA_FALSE; + wd->bg = evas_object_rectangle_add(e); + evas_object_color_set(wd->bg, 0, 0, 0, 0); + wd->linewrap = EINA_FALSE; wd->ellipsis = EINA_FALSE; wd->slidingmode = EINA_FALSE; diff --git a/src/lib/elm_layout.c b/src/lib/elm_layout.c index 65b0dd4..1952bd5 100644 --- a/src/lib/elm_layout.c +++ b/src/lib/elm_layout.c @@ -321,12 +321,8 @@ elm_layout_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - wd->obj = obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "layout"); elm_widget_type_set(obj, "layout"); elm_widget_sub_object_add(parent, obj); @@ -340,6 +336,7 @@ elm_layout_add(Evas_Object *parent) elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook); elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook); + wd->obj = obj; wd->lay = edje_object_add(e); elm_widget_resize_object_set(obj, wd->lay); edje_object_signal_callback_add(wd->lay, "size,eval", "elm", diff --git a/src/lib/elm_list.c b/src/lib/elm_list.c index 72497eb..b4bb5fd 100644 --- a/src/lib/elm_list.c +++ b/src/lib/elm_list.c @@ -1272,12 +1272,8 @@ elm_list_add(Evas_Object *parent) Widget_Data *wd; Evas_Coord minw, minh; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - wd->self = obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "list"); elm_widget_type_set(obj, "list"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_map.c b/src/lib/elm_map.c index 5be6def..a8817c9 100644 --- a/src/lib/elm_map.c +++ b/src/lib/elm_map.c @@ -2100,18 +2100,8 @@ elm_map_add(Evas_Object *parent) static Evas_Smart *smart = NULL; Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - if (!ecore_file_download_protocol_available("http://")) - { - ERR("Ecore must be built with the support of HTTP for the widget map !"); - return NULL; - } - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "map"); elm_widget_type_set(obj, "map"); elm_widget_sub_object_add(parent, obj); @@ -2223,6 +2213,12 @@ elm_map_add(Evas_Object *parent) // TODO: convert Elementary to subclassing of Evas_Smart_Class // TODO: and save some bytes, making descriptions per-class and not instance! evas_object_smart_callbacks_descriptions_set(obj, _signals); + + if (!ecore_file_download_protocol_available("http://")) + { + ERR("Ecore must be built with curl support for the map widget!"); + } + return obj; } diff --git a/src/lib/elm_mapbuf.c b/src/lib/elm_mapbuf.c index fc4d6ac..1c52ba8 100644 --- a/src/lib/elm_mapbuf.c +++ b/src/lib/elm_mapbuf.c @@ -167,12 +167,8 @@ elm_mapbuf_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "mapbuf"); elm_widget_type_set(obj, "mapbuf"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_menu.c b/src/lib/elm_menu.c index c470ad4..7b271ef 100644 --- a/src/lib/elm_menu.c +++ b/src/lib/elm_menu.c @@ -444,12 +444,8 @@ elm_menu_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "menu"); elm_widget_type_set(obj, "menu"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_notify.c b/src/lib/elm_notify.c index 410ea9e..e310e01 100644 --- a/src/lib/elm_notify.c +++ b/src/lib/elm_notify.c @@ -427,12 +427,8 @@ elm_notify_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "notify"); elm_widget_type_set(obj, "notify"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_pager.c b/src/lib/elm_pager.c index 037bd22..788de5c 100644 --- a/src/lib/elm_pager.c +++ b/src/lib/elm_pager.c @@ -256,12 +256,8 @@ elm_pager_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "pager"); elm_widget_type_set(obj, "pager"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_panel.c b/src/lib/elm_panel.c index aacc250..4be2a92 100644 --- a/src/lib/elm_panel.c +++ b/src/lib/elm_panel.c @@ -252,15 +252,11 @@ EAPI Evas_Object * elm_panel_add(Evas_Object *parent) { Evas_Object *obj; - Evas *evas; + Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - evas = evas_object_evas_get(parent); - if (!evas) return NULL; - obj = elm_widget_add(evas); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "panel"); elm_widget_type_set(obj, "panel"); elm_widget_sub_object_add(parent, obj); @@ -275,7 +271,7 @@ elm_panel_add(Evas_Object *parent) elm_widget_can_focus_set(obj, EINA_TRUE); elm_widget_event_hook_set(obj, _event_hook); - wd->scr = elm_smart_scroller_add(evas); + wd->scr = elm_smart_scroller_add(e); elm_smart_scroller_widget_set(wd->scr, obj); _theme_hook(obj); elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_FALSE); @@ -286,7 +282,7 @@ elm_panel_add(Evas_Object *parent) wd->hidden = EINA_FALSE; wd->orient = ELM_PANEL_ORIENT_LEFT; - wd->bx = evas_object_box_add(evas); + wd->bx = evas_object_box_add(e); evas_object_size_hint_align_set(wd->bx, 0.5, 0.5); evas_object_box_layout_set(wd->bx, _layout, wd, NULL); elm_widget_sub_object_add(obj, wd->bx); diff --git a/src/lib/elm_panes.c b/src/lib/elm_panes.c index f000064..c9a504b 100644 --- a/src/lib/elm_panes.c +++ b/src/lib/elm_panes.c @@ -210,12 +210,8 @@ elm_panes_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "panes"); elm_widget_type_set(obj, "panes"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_photo.c b/src/lib/elm_photo.c index ffe57ba..4e27331 100644 --- a/src/lib/elm_photo.c +++ b/src/lib/elm_photo.c @@ -217,12 +217,8 @@ elm_photo_add(Evas_Object *parent) Widget_Data *wd; Evas_Object *icon; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "photo"); elm_widget_type_set(obj, "photo"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_photocam.c b/src/lib/elm_photocam.c index 15014e2..7bed1a8 100644 --- a/src/lib/elm_photocam.c +++ b/src/lib/elm_photocam.c @@ -1062,12 +1062,8 @@ elm_photocam_add(Evas_Object *parent) static Evas_Smart *smart = NULL; Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "photocam"); elm_widget_type_set(obj, "photocam"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_progressbar.c b/src/lib/elm_progressbar.c index a30a02c..50415bc 100644 --- a/src/lib/elm_progressbar.c +++ b/src/lib/elm_progressbar.c @@ -202,12 +202,8 @@ elm_progressbar_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "progressbar"); elm_widget_type_set(obj, "progressbar"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_radio.c b/src/lib/elm_radio.c index aa1c43f..4f98add 100644 --- a/src/lib/elm_radio.c +++ b/src/lib/elm_radio.c @@ -283,12 +283,8 @@ elm_radio_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "radio"); elm_widget_type_set(obj, "radio"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_scroller.c b/src/lib/elm_scroller.c index e4157f3..d3b5347 100644 --- a/src/lib/elm_scroller.c +++ b/src/lib/elm_scroller.c @@ -457,12 +457,8 @@ elm_scroller_add(Evas_Object *parent) Widget_Data *wd; Evas_Coord minw, minh; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "scroller"); elm_widget_type_set(obj, "scroller"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_separator.c b/src/lib/elm_separator.c index 36eca3a..58084a1 100644 --- a/src/lib/elm_separator.c +++ b/src/lib/elm_separator.c @@ -81,12 +81,8 @@ elm_separator_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "separator"); wd->horizontal = EINA_FALSE; elm_widget_type_set(obj, "separator"); diff --git a/src/lib/elm_slider.c b/src/lib/elm_slider.c index a36b4a7..3e2b975 100644 --- a/src/lib/elm_slider.c +++ b/src/lib/elm_slider.c @@ -498,12 +498,8 @@ elm_slider_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "slider"); elm_widget_type_set(obj, "slider"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_slideshow.c b/src/lib/elm_slideshow.c index 8d62850..8d32121 100644 --- a/src/lib/elm_slideshow.c +++ b/src/lib/elm_slideshow.c @@ -309,12 +309,8 @@ elm_slideshow_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "slideshow"); elm_widget_type_set(obj, "slideshow"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_spinner.c b/src/lib/elm_spinner.c index 1a3db09..d7e8def 100644 --- a/src/lib/elm_spinner.c +++ b/src/lib/elm_spinner.c @@ -575,12 +575,8 @@ elm_spinner_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "spinner"); elm_widget_type_set(obj, "spinner"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_table.c b/src/lib/elm_table.c index d3181ba..158a3ac 100644 --- a/src/lib/elm_table.c +++ b/src/lib/elm_table.c @@ -140,12 +140,8 @@ elm_table_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "table"); elm_widget_type_set(obj, "table"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_thumb.c b/src/lib/elm_thumb.c index ecda646..b702633 100644 --- a/src/lib/elm_thumb.c +++ b/src/lib/elm_thumb.c @@ -420,17 +420,13 @@ elm_need_ethumb(void) EAPI Evas_Object * elm_thumb_add(Evas_Object *parent) { - Evas *evas; + Evas *e; Widget_Data *wd; Evas_Object *obj; Evas_Coord minw, minh; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - evas = evas_object_evas_get(parent); - if (!evas) return NULL; - obj = elm_widget_add(evas); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "thumb"); elm_widget_type_set(obj, "thumb"); elm_widget_sub_object_add(parent, obj); @@ -439,7 +435,7 @@ elm_thumb_add(Evas_Object *parent) elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_can_focus_set(obj, EINA_FALSE); - wd->frame = edje_object_add(evas); + wd->frame = edje_object_add(e); _elm_theme_object_set(obj, wd->frame, "thumb", "base", "default"); elm_widget_resize_object_set(obj, wd->frame); diff --git a/src/lib/elm_toggle.c b/src/lib/elm_toggle.c index eb2d239..80b2fc1 100644 --- a/src/lib/elm_toggle.c +++ b/src/lib/elm_toggle.c @@ -217,12 +217,8 @@ elm_toggle_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "toggle"); elm_widget_type_set(obj, "toggle"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c index feb2f57..a50b4bc 100644 --- a/src/lib/elm_toolbar.c +++ b/src/lib/elm_toolbar.c @@ -701,12 +701,8 @@ elm_toolbar_add(Evas_Object *parent) Evas *e; Widget_Data *wd; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - wd = ELM_NEW(Widget_Data); - e = evas_object_evas_get(parent); - if (!e) return NULL; - obj = elm_widget_add(e); + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + ELM_SET_WIDTYPE(widtype, "toolbar"); elm_widget_type_set(obj, "toolbar"); elm_widget_sub_object_add(parent, obj); diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h index 4b7c477..47e428b 100644 --- a/src/lib/elm_widget.h +++ b/src/lib/elm_widget.h @@ -108,12 +108,10 @@ * // elementary and that the api hasn't broken. if it has this returns * // false and you need to handle this error gracefully * if (!elm_widget_api_check(ELM_INTERNAL_API_VERSION)) return NULL; + * + * // standard widget setup and allocate wd, create obj given parent etc. + * ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); * - * // basic - allocate data for widget and fill it - * wd = ELM_NEW(Widget_Data); - * e = evas_object_evas_get(parent); - * if (!e) return NULL; - * obj = elm_widget_add(e); * // give it a type name and set up a mywidget type string if needed * ELM_SET_WIDTYPE(widtype, "mywidget"); * elm_widget_type_set(obj, "mywidget"); @@ -497,6 +495,13 @@ EAPI void elm_widget_tree_dot_dump(const Evas_Object *top, FILE *out ELM_WIDGET_ITEM_CHECK_OR_GOTO((Elm_Widget_Item *)it, label); \ if (!elm_widget_type_check((it->base.widget), (widtype))) goto label; +#define ELM_WIDGET_STANDARD_SETUP(wdat, wdtype, par, evas, ob, ret) \ + do { \ + EINA_SAFETY_ON_NULL_RETURN_VAL((par), (ret)); \ + evas = evas_object_evas_get(par); if (!(evas)) return (ret); \ + wdat = ELM_NEW(wdtype); if (!(wdat)) return (ret); \ + ob = elm_widget_add(evas); if (!(ob)) { free(wdat); return (ret); } \ + } while (0); /** * The drag and drop API.