summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-10-24 11:13:51 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-10-24 11:57:27 +0900
commit1e83dd84c6d41dbb977eb6820f5ba26dc8b11e07 (patch)
tree3ca5ae6abac267342ad7930269d910caebb0b040
parentd26759555737681f454dbf80653a72dc506d355f (diff)
nstate: Remove some legacy code
This uses constructor/destructor instead of group_add/group_del. Note: finalize can't be used for theme loading as any action done inside efl_add(...) would be lost (eg. part text set).
-rw-r--r--src/lib/elementary/efl_ui_check.c58
-rw-r--r--src/lib/elementary/efl_ui_nstate.c72
2 files changed, 46 insertions, 84 deletions
diff --git a/src/lib/elementary/efl_ui_check.c b/src/lib/elementary/efl_ui_check.c
index 26341ec756..bb25ea400b 100644
--- a/src/lib/elementary/efl_ui_check.c
+++ b/src/lib/elementary/efl_ui_check.c
@@ -274,39 +274,6 @@ _on_check_toggle(void *data,
274 _activate(data); 274 _activate(data);
275} 275}
276 276
277EOLIAN static void
278_efl_ui_check_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Check_Data *_pd EINA_UNUSED)
279{
280 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
281
282 efl_canvas_group_add(efl_super(obj, MY_CLASS));
283 elm_widget_sub_object_parent_add(obj);
284
285 if (!elm_layout_theme_set(obj, "check", "base", elm_widget_style_get(obj)))
286 CRI("Failed to set layout!");
287
288 edje_object_signal_callback_add
289 (wd->resize_obj, "elm,action,check,on", "*",
290 _on_check_on, obj);
291 edje_object_signal_callback_add
292 (wd->resize_obj, "elm,action,check,off", "*",
293 _on_check_off, obj);
294 edje_object_signal_callback_add
295 (wd->resize_obj, "elm,action,check,toggle", "*",
296 _on_check_toggle, obj);
297
298 _elm_access_object_register(obj, wd->resize_obj);
299 _elm_access_text_set
300 (_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("Check"));
301 _elm_access_callback_set
302 (_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, obj);
303 _elm_access_callback_set
304 (_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, obj);
305
306 elm_widget_can_focus_set(obj, EINA_TRUE);
307 elm_layout_sizing_eval(obj);
308}
309
310EOLIAN static Eina_Bool 277EOLIAN static Eina_Bool
311_efl_ui_check_selected_get(Eo *obj, Efl_Ui_Check_Data *pd EINA_UNUSED) 278_efl_ui_check_selected_get(Eo *obj, Efl_Ui_Check_Data *pd EINA_UNUSED)
312{ 279{
@@ -351,12 +318,34 @@ elm_check_add(Evas_Object *parent)
351} 318}
352 319
353EOLIAN static Eo * 320EOLIAN static Eo *
354_efl_ui_check_efl_object_constructor(Eo *obj, Efl_Ui_Check_Data *_pd EINA_UNUSED) 321_efl_ui_check_efl_object_constructor(Eo *obj, Efl_Ui_Check_Data *pd EINA_UNUSED)
355{ 322{
356 obj = efl_constructor(efl_super(obj, MY_CLASS)); 323 obj = efl_constructor(efl_super(obj, MY_CLASS));
357 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); 324 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
358 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); 325 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
326 elm_widget_sub_object_parent_add(obj);
327
328 if (!elm_layout_theme_set(obj, "check", "base", elm_widget_style_get(obj)))
329 CRI("Failed to set layout!");
330
331 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
332 efl_canvas_layout_signal_callback_add
333 (wd->resize_obj, "elm,action,check,on", "*", _on_check_on, obj);
334 efl_canvas_layout_signal_callback_add
335 (wd->resize_obj, "elm,action,check,off", "*", _on_check_off, obj);
336 efl_canvas_layout_signal_callback_add
337 (wd->resize_obj, "elm,action,check,toggle", "*", _on_check_toggle, obj);
338
359 efl_access_role_set(obj, EFL_ACCESS_ROLE_CHECK_BOX); 339 efl_access_role_set(obj, EFL_ACCESS_ROLE_CHECK_BOX);
340 _elm_access_object_register(obj, wd->resize_obj);
341 _elm_access_text_set
342 (_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("Check"));
343 _elm_access_callback_set
344 (_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, obj);
345 _elm_access_callback_set
346 (_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, obj);
347
348 elm_widget_can_focus_set(obj, EINA_TRUE);
360 349
361 return obj; 350 return obj;
362} 351}
@@ -419,7 +408,6 @@ ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_check, Efl_Ui_Check_Data)
419ELM_LAYOUT_TEXT_ALIASES_IMPLEMENT(MY_CLASS_PFX) 408ELM_LAYOUT_TEXT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
420 409
421#define EFL_UI_CHECK_EXTRA_OPS \ 410#define EFL_UI_CHECK_EXTRA_OPS \
422 EFL_CANVAS_GROUP_ADD_OPS(efl_ui_check), \
423 ELM_LAYOUT_TEXT_ALIASES_OPS(MY_CLASS_PFX) 411 ELM_LAYOUT_TEXT_ALIASES_OPS(MY_CLASS_PFX)
424 412
425#include "efl_ui_check.eo.c" 413#include "efl_ui_check.eo.c"
diff --git a/src/lib/elementary/efl_ui_nstate.c b/src/lib/elementary/efl_ui_nstate.c
index 25a1264357..3d0a5b42fe 100644
--- a/src/lib/elementary/efl_ui_nstate.c
+++ b/src/lib/elementary/efl_ui_nstate.c
@@ -18,10 +18,6 @@ typedef struct
18 int state; 18 int state;
19} Efl_Ui_Nstate_Data; 19} Efl_Ui_Nstate_Data;
20 20
21static const Evas_Smart_Cb_Description _smart_callbacks[] = {
22 {NULL, NULL}
23};
24
25static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params); 21static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
26static void _state_active(Evas_Object *obj, Efl_Ui_Nstate_Data *sd); 22static void _state_active(Evas_Object *obj, Efl_Ui_Nstate_Data *sd);
27 23
@@ -30,12 +26,33 @@ static const Elm_Action key_actions[] = {
30 {NULL, NULL} 26 {NULL, NULL}
31}; 27};
32 28
29static void
30_on_state_changed(void *data,
31 Evas_Object *o EINA_UNUSED,
32 const char *emission EINA_UNUSED,
33 const char *source EINA_UNUSED)
34{
35 efl_ui_nstate_activate(data);
36}
37
33EOLIAN static Efl_Object * 38EOLIAN static Efl_Object *
34_efl_ui_nstate_efl_object_constructor(Eo *obj, Efl_Ui_Nstate_Data *pd EINA_UNUSED) 39_efl_ui_nstate_efl_object_constructor(Eo *obj, Efl_Ui_Nstate_Data *pd)
35{ 40{
36 obj = efl_constructor(efl_super(obj, MY_CLASS)); 41 obj = efl_constructor(efl_super(obj, MY_CLASS));
37 efl_canvas_object_type_set(obj, MY_CLASS_NAME); 42 efl_canvas_object_type_set(obj, MY_CLASS_NAME);
38 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); 43 elm_widget_sub_object_parent_add(obj);
44
45 pd->state = 0;
46 // Default: 2 states
47 pd->nstate = 2;
48
49 if (!elm_layout_theme_set(obj, "nstate", "base", elm_widget_style_get(obj)))
50 CRI("Failed to set layout!");
51
52 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
53 efl_canvas_layout_signal_callback_add
54 (wd->resize_obj, "elm,action,state,changed", "*", _on_state_changed, obj);
55
39 //TODO: Add ATSPI call here 56 //TODO: Add ATSPI call here
40 57
41 return obj; 58 return obj;
@@ -60,44 +77,6 @@ _state_active(Evas_Object *obj, Efl_Ui_Nstate_Data *sd)
60 efl_event_callback_legacy_call(obj, EFL_UI_NSTATE_EVENT_STATE_CHANGED, NULL); 77 efl_event_callback_legacy_call(obj, EFL_UI_NSTATE_EVENT_STATE_CHANGED, NULL);
61} 78}
62 79
63static void
64_on_state_changed(void *data,
65 Evas_Object *o EINA_UNUSED,
66 const char *emission EINA_UNUSED,
67 const char *source EINA_UNUSED)
68{
69 efl_ui_nstate_activate(data);
70}
71
72EOLIAN static void
73_efl_ui_nstate_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Nstate_Data *pd)
74{
75 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
76
77 efl_canvas_group_add(efl_super(obj, MY_CLASS));
78 elm_widget_sub_object_parent_add(obj);
79
80 pd->state = 0;
81 // Default: 2 states
82 pd->nstate = 2;
83
84 if (!elm_layout_theme_set(obj, "nstate", "base", elm_widget_style_get(obj)))
85 CRI("Failed to set layout!");
86
87 edje_object_signal_callback_add(wd->resize_obj, "elm,action,state,changed",
88 "*", _on_state_changed, obj);
89}
90
91EOLIAN static void
92_efl_ui_nstate_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Nstate_Data *pd EINA_UNUSED)
93{
94 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
95
96 edje_object_signal_callback_del_full(wd->resize_obj, "elm,action,state,changed",
97 "*", _on_state_changed, obj);
98 efl_canvas_group_del(efl_super(obj, MY_CLASS));
99}
100
101EOLIAN static int 80EOLIAN static int
102_efl_ui_nstate_count_get(Eo *obj EINA_UNUSED, Efl_Ui_Nstate_Data *pd) 81_efl_ui_nstate_count_get(Eo *obj EINA_UNUSED, Efl_Ui_Nstate_Data *pd)
103{ 82{
@@ -174,9 +153,4 @@ _efl_ui_nstate_class_constructor(Efl_Class *klass)
174 153
175ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_nstate, Efl_Ui_Nstate_Data) 154ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_nstate, Efl_Ui_Nstate_Data)
176 155
177/* Internal EO APIs and hidden overrides */
178
179#define EFL_UI_NSTATE_EXTRA_OPS \
180 EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_nstate)
181
182#include "efl_ui_nstate.eo.c" 156#include "efl_ui_nstate.eo.c"