jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3136500fbeba47538ebdf95ead9ef49a4579db3d

commit 3136500fbeba47538ebdf95ead9ef49a4579db3d
Author: Jean-Philippe Andre <[email protected]>
Date:   Tue Dec 12 15:55:43 2017 +0900

    elm: Uniform change event for nstate,radio,check
    
    I added convenience macros for check and radio, easing discoverability
    in C.
    
    This will avoid C# issues such as:
    
    lib/elementary/elm_pan.eo.cs(14,23): warning CS0108: `elm.Pan.CHANGED'
    hides inherited member `efl.Gfx.CHANGED'. Use the new keyword if hiding
    was intended
    lib/efl/interfaces/efl_gfx.eo.cs(24,23): (Location of the symbol related
    to previous warning)
    
    Since nstate is not a legacy widget, I can safely change the event name
    and the test case.
---
 src/bin/elementary/test_nstate.c    | 34 +++++++++++++---------------------
 src/lib/elementary/efl_ui_check.eo  |  4 ----
 src/lib/elementary/efl_ui_nstate.c  |  2 +-
 src/lib/elementary/efl_ui_nstate.eo |  2 +-
 src/lib/elementary/efl_ui_radio.eo  |  3 ---
 src/lib/elementary/elm_check.h      |  1 +
 src/lib/elementary/elm_radio.h      |  1 +
 7 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/src/bin/elementary/test_nstate.c b/src/bin/elementary/test_nstate.c
index 98dcfd4269..ebc97d4f3c 100644
--- a/src/bin/elementary/test_nstate.c
+++ b/src/bin/elementary/test_nstate.c
@@ -4,16 +4,10 @@
 #include <Elementary.h>
 
 static void
-_state_changed_cb(void *d EINA_UNUSED, Evas_Object *o, void *ei EINA_UNUSED)
+_state_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
 {
-   char buf[100];
-   int val;
-
-   val = efl_ui_nstate_value_get(o);
-
-   printf("nstate widget state: %d\n", val);
-   sprintf(buf, "nstate = %d", val);
-   elm_object_text_set(o, buf);
+   int val = efl_ui_nstate_value_get(ev->object);
+   efl_text_set(ev->object, eina_slstr_printf("nstate = %d", val));
 }
 
 void
@@ -21,21 +15,19 @@ test_nstate(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, void *event_in
 {
    Evas_Object *win, *bx, *nstate;
 
-   win = elm_win_util_standard_add("nstate", "nstate");
-   elm_win_autodel_set(win, EINA_TRUE);
+   win = efl_add(EFL_UI_WIN_CLASS, NULL,
+                 efl_text_set(efl_added, "N-state widget"),
+                 elm_win_autodel_set(efl_added, EINA_TRUE));
 
-   bx = elm_box_add(win);
-   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   elm_win_resize_object_add(win, bx);
-   evas_object_show(bx);
+   bx = efl_add(EFL_UI_BOX_CLASS, win);
+   efl_content_set(win, bx);
 
    nstate = efl_add(EFL_UI_NSTATE_CLASS, win);
+   efl_event_callback_add(nstate, EFL_UI_NSTATE_EVENT_CHANGED,
+                          _state_changed_cb, NULL);
    efl_ui_nstate_count_set(nstate, 5);
-   elm_object_text_set(nstate, "nstate = 0");
-   elm_box_pack_end(bx, nstate);
-   evas_object_smart_callback_add(nstate, "state,changed",
-                                  _state_changed_cb, NULL);
+   efl_text_set(nstate, "nstate = 0");
+   efl_pack(bx, nstate);
 
-   evas_object_resize(win, 100, 100);
-   evas_object_show(win);
+   efl_gfx_size_set(win, EINA_SIZE2D(120, 80));
 }
diff --git a/src/lib/elementary/efl_ui_check.eo 
b/src/lib/elementary/efl_ui_check.eo
index 441227776d..44d79d9272 100644
--- a/src/lib/elementary/efl_ui_check.eo
+++ b/src/lib/elementary/efl_ui_check.eo
@@ -32,8 +32,4 @@ class Efl.Ui.Check (Efl.Ui.Nstate, Efl.Access.Widget.Action)
       Efl.Access.state_set { get; }
       Efl.Access.Widget.Action.elm_actions { get; }
    }
-   events {
-      changed; [[This is called whenever the user changes the state of the 
check
-                  objects (event_info is always NULL).]]
-   }
 }
diff --git a/src/lib/elementary/efl_ui_nstate.c 
b/src/lib/elementary/efl_ui_nstate.c
index 99c3a766d5..14313763ef 100644
--- a/src/lib/elementary/efl_ui_nstate.c
+++ b/src/lib/elementary/efl_ui_nstate.c
@@ -73,7 +73,7 @@ _state_active(Evas_Object *obj, Efl_Ui_Nstate_Data *sd)
    elm_layout_signal_emit(obj, buf, "elm");
    edje_object_message_signal_process(elm_layout_edje_get(obj));
    elm_layout_sizing_eval(obj);
-   efl_event_callback_legacy_call(obj, EFL_UI_NSTATE_EVENT_STATE_CHANGED, 
NULL);
+   efl_event_callback_legacy_call(obj, EFL_UI_NSTATE_EVENT_CHANGED, NULL);
 }
 
 EOLIAN static int
diff --git a/src/lib/elementary/efl_ui_nstate.eo 
b/src/lib/elementary/efl_ui_nstate.eo
index 7f8bb978f6..bdf5da9e9d 100644
--- a/src/lib/elementary/efl_ui_nstate.eo
+++ b/src/lib/elementary/efl_ui_nstate.eo
@@ -34,6 +34,6 @@ class Efl.Ui.Nstate(Efl.Ui.Button)
       Elm.Widget.widget_event;
    }
    events {
-      state,changed; [[Called when nstate widget changed]]
+      changed; [[Called when the value changed.]]
    }
 }
diff --git a/src/lib/elementary/efl_ui_radio.eo 
b/src/lib/elementary/efl_ui_radio.eo
index ff6d0acb21..e4e5b9e368 100644
--- a/src/lib/elementary/efl_ui_radio.eo
+++ b/src/lib/elementary/efl_ui_radio.eo
@@ -71,7 +71,4 @@ class Efl.Ui.Radio (Efl.Ui.Check, Efl.Access.Widget.Action, 
Efl.Content)
       Efl.Content.content_unset;
       Efl.Ui.Nstate.value { set; get; }
    }
-   events {
-      changed; [[Called when radio changed]]
-   }
 }
diff --git a/src/lib/elementary/elm_check.h b/src/lib/elementary/elm_check.h
index 0cf6b821c7..b0e404e8bc 100644
--- a/src/lib/elementary/elm_check.h
+++ b/src/lib/elementary/elm_check.h
@@ -61,6 +61,7 @@
 
 #ifdef EFL_EO_API_SUPPORT
 #include "efl_ui_check_eo.h"
+#define EFL_UI_CHECK_EVENT_CHANGED EFL_UI_NSTATE_EVENT_CHANGED
 #endif
 #ifndef EFL_NOLEGACY_API_SUPPORT
 #include "elm_check_legacy.h"
diff --git a/src/lib/elementary/elm_radio.h b/src/lib/elementary/elm_radio.h
index 03c266dc80..4a58cac81d 100644
--- a/src/lib/elementary/elm_radio.h
+++ b/src/lib/elementary/elm_radio.h
@@ -66,6 +66,7 @@
 
 #ifdef EFL_EO_API_SUPPORT
 #include "efl_ui_radio_eo.h"
+#define EFL_UI_RADIO_EVENT_CHANGED EFL_UI_NSTATE_EVENT_CHANGED
 #endif
 #ifndef EFL_NOLEGACY_API_SUPPORT
 #include "elm_radio_legacy.h"

-- 


Reply via email to