summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2016-03-03 11:58:21 +0530
committerAmitesh Singh <amitesh.sh@samsung.com>2016-03-03 11:59:36 +0530
commitb9c912f7213dc4026e41d3f99e2f4a5fc78269db (patch)
tree870c05e3f768957526c000be3560eca6dcca1881
parentb6ecb5084a3b265cfac661ba3f1dbc10e4adc08b (diff)
radio: inherit from elm check
Summary: Radio inherits from Check now and remove the duplicate codes Reviewers: yashu21985, cedric, tasn, raster Reviewed By: raster Subscribers: seoz Differential Revision: https://phab.enlightenment.org/D3747
-rw-r--r--src/lib/elm_radio.c109
-rw-r--r--src/lib/elm_radio.eo8
2 files changed, 20 insertions, 97 deletions
diff --git a/src/lib/elm_radio.c b/src/lib/elm_radio.c
index 4c6f5fa3a..3d4099064 100644
--- a/src/lib/elm_radio.c
+++ b/src/lib/elm_radio.c
@@ -16,12 +16,6 @@
16#define MY_CLASS_NAME "Elm_Radio" 16#define MY_CLASS_NAME "Elm_Radio"
17#define MY_CLASS_NAME_LEGACY "elm_radio" 17#define MY_CLASS_NAME_LEGACY "elm_radio"
18 18
19static const Elm_Layout_Part_Alias_Description _content_aliases[] =
20{
21 {"icon", "elm.swallow.content"},
22 {NULL, NULL}
23};
24
25static const Elm_Layout_Part_Alias_Description _text_aliases[] = 19static const Elm_Layout_Part_Alias_Description _text_aliases[] =
26{ 20{
27 {"default", "elm.text"}, 21 {"default", "elm.text"},
@@ -129,56 +123,6 @@ _activate(Evas_Object *obj)
129 } 123 }
130} 124}
131 125
132/* FIXME: replicated from elm_layout just because radio's icon spot
133 * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
134 * can changed the theme API */
135static void
136_icon_signal_emit(Evas_Object *obj)
137{
138 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
139 char buf[64];
140
141 snprintf(buf, sizeof(buf), "elm,state,icon,%s",
142 elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
143
144 elm_layout_signal_emit(obj, buf, "elm");
145 edje_object_message_signal_process(wd->resize_obj);
146}
147
148/* FIXME: replicated from elm_layout just because radio's icon spot
149 * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
150 * can changed the theme API */
151EOLIAN static Eina_Bool
152_elm_radio_elm_widget_sub_object_del(Eo *obj, Elm_Radio_Data *_pd EINA_UNUSED, Evas_Object *sobj)
153{
154 Eina_Bool int_ret = EINA_FALSE;
155 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_sub_object_del(sobj));
156 if (!int_ret) return EINA_FALSE;
157
158 _icon_signal_emit(obj);
159
160 eo_do(obj, elm_obj_layout_sizing_eval());
161
162 return EINA_TRUE;
163}
164
165/* FIXME: replicated from elm_layout just because radio's icon spot
166 * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
167 * can changed the theme API */
168EOLIAN static Eina_Bool
169_elm_radio_elm_container_content_set(Eo *obj, Elm_Radio_Data *_pd EINA_UNUSED, const char *part, Evas_Object *content)
170{
171 Eina_Bool int_ret = EINA_FALSE;
172 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_container_content_set(part, content));
173 if (!int_ret) return EINA_FALSE;
174
175 _icon_signal_emit(obj);
176
177 eo_do(obj, elm_obj_layout_sizing_eval());
178
179 return EINA_TRUE;
180}
181
182static Eina_Bool 126static Eina_Bool
183_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED) 127_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
184{ 128{
@@ -202,12 +146,28 @@ _elm_radio_elm_widget_event(Eo *obj, Elm_Radio_Data *_pd EINA_UNUSED, Evas_Objec
202 return EINA_TRUE; 146 return EINA_TRUE;
203} 147}
204 148
149/* FIXME: replicated from elm_layout just because radio's icon spot
150 * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
151 * can changed the theme API */
152static void
153_icon_signal_emit(Evas_Object *obj)
154{
155 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
156 char buf[64];
157
158 snprintf(buf, sizeof(buf), "elm,state,icon,%s",
159 elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
160
161 elm_layout_signal_emit(obj, buf, "elm");
162 edje_object_message_signal_process(wd->resize_obj);
163}
164
205EOLIAN static Eina_Bool 165EOLIAN static Eina_Bool
206_elm_radio_elm_widget_theme_apply(Eo *obj, Elm_Radio_Data *sd) 166_elm_radio_elm_widget_theme_apply(Eo *obj, Elm_Radio_Data *sd)
207{ 167{
208 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); 168 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
209 Eina_Bool int_ret = EINA_FALSE; 169 Eina_Bool int_ret = EINA_FALSE;
210 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply()); 170 eo_do_super(obj, ELM_CHECK_CLASS, int_ret = elm_obj_widget_theme_apply());
211 if (!int_ret) return EINA_FALSE; 171 if (!int_ret) return EINA_FALSE;
212 172
213 if (sd->state) elm_layout_signal_emit(obj, "elm,state,radio,on", "elm"); 173 if (sd->state) elm_layout_signal_emit(obj, "elm,state,radio,on", "elm");
@@ -227,19 +187,6 @@ _elm_radio_elm_widget_theme_apply(Eo *obj, Elm_Radio_Data *sd)
227 return EINA_TRUE; 187 return EINA_TRUE;
228} 188}
229 189
230EOLIAN static void
231_elm_radio_elm_layout_sizing_eval(Eo *obj, Elm_Radio_Data *_pd EINA_UNUSED)
232{
233 Evas_Coord minw = -1, minh = -1;
234 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
235
236 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
237 edje_object_size_min_restricted_calc
238 (wd->resize_obj, &minw, &minh, minw, minh);
239 evas_object_size_hint_min_set(obj, minw, minh);
240 evas_object_size_hint_max_set(obj, -1, -1);
241}
242
243static void 190static void
244_radio_on_cb(void *data, 191_radio_on_cb(void *data,
245 Evas_Object *obj EINA_UNUSED, 192 Evas_Object *obj EINA_UNUSED,
@@ -276,7 +223,7 @@ _elm_radio_evas_object_smart_add(Eo *obj, Elm_Radio_Data *priv)
276{ 223{
277 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 224 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
278 225
279 eo_do_super(obj, MY_CLASS, evas_obj_smart_add()); 226 eo_do_super(obj, ELM_CHECK_CLASS, evas_obj_smart_add());
280 elm_widget_sub_object_parent_add(obj); 227 elm_widget_sub_object_parent_add(obj);
281 228
282 if (!elm_layout_theme_set(obj, "radio", "base", elm_widget_style_get(obj))) 229 if (!elm_layout_theme_set(obj, "radio", "base", elm_widget_style_get(obj)))
@@ -307,7 +254,7 @@ _elm_radio_evas_object_smart_del(Eo *obj, Elm_Radio_Data *sd)
307 sd->group->radios = eina_list_remove(sd->group->radios, obj); 254 sd->group->radios = eina_list_remove(sd->group->radios, obj);
308 if (!sd->group->radios) free(sd->group); 255 if (!sd->group->radios) free(sd->group);
309 256
310 eo_do_super(obj, MY_CLASS, evas_obj_smart_del()); 257 eo_do_super(obj, ELM_CHECK_CLASS, evas_obj_smart_del());
311} 258}
312 259
313EOLIAN static const Elm_Layout_Part_Alias_Description* 260EOLIAN static const Elm_Layout_Part_Alias_Description*
@@ -316,12 +263,6 @@ _elm_radio_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Radio_Data *_pd
316 return _text_aliases; 263 return _text_aliases;
317} 264}
318 265
319EOLIAN static const Elm_Layout_Part_Alias_Description*
320_elm_radio_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Elm_Radio_Data *_pd EINA_UNUSED)
321{
322 return _content_aliases;
323}
324
325EAPI Evas_Object * 266EAPI Evas_Object *
326elm_radio_add(Evas_Object *parent) 267elm_radio_add(Evas_Object *parent)
327{ 268{
@@ -428,18 +369,6 @@ _elm_radio_selected_object_get(Eo *obj EINA_UNUSED, Elm_Radio_Data *sd)
428} 369}
429 370
430EOLIAN static Eina_Bool 371EOLIAN static Eina_Bool
431_elm_radio_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Radio_Data *_pd EINA_UNUSED)
432{
433 return EINA_FALSE;
434}
435
436EOLIAN static Eina_Bool
437_elm_radio_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Radio_Data *_pd EINA_UNUSED)
438{
439 return EINA_FALSE;
440}
441
442EOLIAN static Eina_Bool
443_elm_radio_elm_widget_activate(Eo *obj, Elm_Radio_Data *_pd EINA_UNUSED, Elm_Activate act) 372_elm_radio_elm_widget_activate(Eo *obj, Elm_Radio_Data *_pd EINA_UNUSED, Elm_Activate act)
444{ 373{
445 if (elm_widget_disabled_get(obj)) return EINA_FALSE; 374 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
diff --git a/src/lib/elm_radio.eo b/src/lib/elm_radio.eo
index fe4396809..64c6527d0 100644
--- a/src/lib/elm_radio.eo
+++ b/src/lib/elm_radio.eo
@@ -1,4 +1,4 @@
1class Elm.Radio (Elm.Layout, Elm.Interface_Atspi_Widget_Action) 1class Elm.Radio (Elm.Check, Elm.Interface_Atspi_Widget_Action)
2{ 2{
3 eo_prefix: elm_obj_radio; 3 eo_prefix: elm_obj_radio;
4 methods { 4 methods {
@@ -80,14 +80,8 @@ class Elm.Radio (Elm.Layout, Elm.Interface_Atspi_Widget_Action)
80 Evas.Object_Smart.del; 80 Evas.Object_Smart.del;
81 Elm.Widget.theme_apply; 81 Elm.Widget.theme_apply;
82 Elm.Widget.activate; 82 Elm.Widget.activate;
83 Elm.Widget.focus_next_manager_is;
84 Elm.Widget.focus_direction_manager_is;
85 Elm.Widget.sub_object_del;
86 Elm.Widget.event; 83 Elm.Widget.event;
87 Elm.Container.content_set;
88 Elm.Layout.text_aliases.get; 84 Elm.Layout.text_aliases.get;
89 Elm.Layout.content_aliases.get;
90 Elm.Layout.sizing_eval;
91 Elm.Interface_Atspi_Accessible.state_set.get; 85 Elm.Interface_Atspi_Accessible.state_set.get;
92 Elm.Interface_Atspi_Widget_Action.elm_actions.get; 86 Elm.Interface_Atspi_Widget_Action.elm_actions.get;
93 } 87 }