jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9c9278cd458422b73a3016ba056c0267d3d65bfb

commit 9c9278cd458422b73a3016ba056c0267d3d65bfb
Author: Jean-Philippe Andre <[email protected]>
Date:   Wed Nov 1 22:42:04 2017 +0900

    cxx: Fix a few examples
    
     - Calendar: Some examples can't be ported. Not good.
     - Toolbar: Needs the new API to be completed.
     - Clock: Crashes at runtime.
    
    Ping @felipealmeida
---
 src/examples/elementary/calendar_cxx_example_01.cc | 27 ++++-------
 src/examples/elementary/calendar_cxx_example_02.cc | 51 +++++++++++----------
 src/examples/elementary/calendar_cxx_example_03.cc | 34 ++++++--------
 src/examples/elementary/calendar_cxx_example_04.cc | 35 ++++++--------
 src/examples/elementary/calendar_cxx_example_05.cc | 15 +++---
 src/examples/elementary/clock_cxx_example.cc       | 53 +++++++---------------
 src/examples/elementary/toolbar_cxx_example_01.cc  |  7 ++-
 src/lib/elementary/efl_ui_calendar.eo              |  2 -
 8 files changed, 94 insertions(+), 130 deletions(-)

diff --git a/src/examples/elementary/calendar_cxx_example_01.cc 
b/src/examples/elementary/calendar_cxx_example_01.cc
index 89e0de873e..4e24fff699 100644
--- a/src/examples/elementary/calendar_cxx_example_01.cc
+++ b/src/examples/elementary/calendar_cxx_example_01.cc
@@ -5,27 +5,20 @@
 
 #include <Elementary.hh>
 
-EAPI_MAIN int
-elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
+using efl::eo::instantiate;
+
+static void
+efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
 {
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
 
-   using efl::eo::instantiate;
-
-   efl::ui::Win win(instantiate);
-   //win.title_set("Calendar Creation Example");
+   auto win = efl::ui::Win(instantiate);
+   win.text_set("Calendar Creation Example");
    win.autohide_set(true);
 
-   ::elm::Calendar cal(instantiate, win);
-   //cal.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   cal.eo_cxx::efl::Gfx::size_set({134,134});
-   //win.resize_object_add(cal);
-   cal.visible_set(true);
-
-   win.eo_cxx::efl::Gfx::size_set({134,134});
-   win.visible_set(true);
+   auto cal = efl::ui::Calendar(instantiate, win);
+   win.content_set(cal);
 
-   elm_run();
-   return 0;
+   win.size_set({320,320});
 }
-ELM_MAIN()
+EFL_MAIN()
diff --git a/src/examples/elementary/calendar_cxx_example_02.cc 
b/src/examples/elementary/calendar_cxx_example_02.cc
index ebc095de2a..6027b1658d 100644
--- a/src/examples/elementary/calendar_cxx_example_02.cc
+++ b/src/examples/elementary/calendar_cxx_example_02.cc
@@ -6,38 +6,41 @@
 #include <Efl.hh>
 #include <Elementary.hh>
 
-static char *
-_format_month_year(struct tm *format_time)
+using efl::eo::instantiate;
+
+// FIXME: Function callbacks need a lot of love in C++
+static void
+_format_cb(void *data EINA_UNUSED, Eina_Strbuf *str, const Eina_Value value)
 {
-   char buf[32];
-   if (!strftime(buf, sizeof(buf), "%b %y", format_time)) return NULL;
-   return strdup(buf);
+   if (::eina_value_type_get(&value) != ::EINA_VALUE_TYPE_TM)
+     {
+        // FIXME: val.to_string()
+        char *convert = ::eina_value_to_string(&value);
+        eina_strbuf_append(str, convert);
+        free(convert);
+     }
+   else
+     {
+        struct tm time;
+        eina_value_get(&value, &time);
+        eina_strbuf_append_strftime(str, "%b. %y", &time);
+     }
 }
 
-EAPI_MAIN int
-elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
+static void
+efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
 {
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
 
-   using efl::eo::instantiate;
-
    efl::ui::Win win(instantiate);
-   //win.title_set("Calendar Layout Formatting Example");
+   win.text_set("Calendar Layout Formatting Example");
    win.autohide_set(true);
 
-   ::elm::Calendar cal(instantiate, win);
-   //cal.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   //win.resize_object_add(cal);
-
-   cal.format_function_set(_format_month_year);
-   // cal.weekdays_names_set(weekdays);
-
-   cal.eo_cxx::efl::Gfx::size_set({125,134});
-   win.eo_cxx::efl::Gfx::size_set({125,134});
-   cal.visible_set(true);
-   win.visible_set(true);
+   auto cal = efl::ui::Calendar(instantiate, win);
+   win.content_set(cal);
 
-   elm_run();
-   return 0;
+   // FIXME: Function cb doesn't work (C++ variant)
+   cal.format_cb_set(_format_cb);
+   ::efl_ui_format_cb_set(cal._eo_ptr(), NULL, _format_cb, NULL);
 }
-ELM_MAIN()
+EFL_MAIN()
diff --git a/src/examples/elementary/calendar_cxx_example_03.cc 
b/src/examples/elementary/calendar_cxx_example_03.cc
index 672e6319f9..c780987f48 100644
--- a/src/examples/elementary/calendar_cxx_example_03.cc
+++ b/src/examples/elementary/calendar_cxx_example_03.cc
@@ -5,35 +5,27 @@
 
 #include <Elementary.hh>
 
-EAPI_MAIN int
-elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
+using efl::eo::instantiate;
+
+static void
+efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
 {
-   Efl_Time min, max;
+   Efl_Time min = {}, max = {};
 
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
 
-   using efl::eo::instantiate;
-
-   efl::ui::Win win(instantiate);
-   //win.title_set("Calendar Min/Max Year Example");
-   win.autohide_set(true);
-
-   elm::Calendar cal(instantiate, win);
-
    min.tm_year = 2020 - 1900;
    max.tm_year = 2022 - 1900;
 
-   //cal.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   //win.resize_object_add(cal);
+   auto win = efl::ui::Win(instantiate);
+   win.text_set("Calendar Min/Max Year Example");
+   win.autohide_set(true);
+
+   auto cal = efl::ui::Calendar(instantiate, win);
+   win.content_set(cal);
    cal.date_min_set(min);
    cal.date_max_set(max);
-   cal.visible_set(true);
-
-   cal.eo_cxx::efl::Gfx::size_set({140,140});
-   win.eo_cxx::efl::Gfx::size_set({140,140});
-   win.visible_set(true);
 
-   elm_run();
-   return 0;
+   win.size_set({320,320});
 }
-ELM_MAIN()
+EFL_MAIN()
diff --git a/src/examples/elementary/calendar_cxx_example_04.cc 
b/src/examples/elementary/calendar_cxx_example_04.cc
index 0b6b21a35f..e0983268f8 100644
--- a/src/examples/elementary/calendar_cxx_example_04.cc
+++ b/src/examples/elementary/calendar_cxx_example_04.cc
@@ -3,36 +3,34 @@
 #include "elementary_config.h"
 #endif
 
+#warning This example can't be implemented with EO APIs... FIXME
+
 #include <Elementary.hh>
 
+using efl::eo::instantiate;
+
 #define SECS_DAY 86400
 
-EAPI_MAIN int
-elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
+static void
+efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
 {
    struct tm selected_time;
    time_t current_time;
 
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
 
-   using efl::eo::instantiate;
-
    efl::ui::Win win(instantiate);
-   //win.title_set("Calendar Day Selection Example");
+   win.text_set("Calendar Day Selection Example");
    win.autohide_set(true);
 
    ::efl::ui::Box bx(instantiate, win);
-   //bx.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   //win.resize_object_add(bx);
-   bx.eo_cxx::efl::Gfx::size_set({700,700});
-   bx.visible_set(true);
-
-   ::elm::Calendar cal(instantiate, win);
-   // cal.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   // cal.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
+   win.content_set(bx);
+
+#if 0
+
+   ::efl::ui::Calendar cal(instantiate, win);
    cal.select_mode_set(ELM_CALENDAR_SELECT_MODE_NONE);
    cal.eo_cxx::efl::Gfx::size_set({125,135});
-   cal.visible_set(true);
    //bx.pack_end(cal); no matching function for call to 
‘efl::ui::Box::pack_end(elm::Calendar&)’
    //candidate: bool eo_cxx::efl::pack::Linear::pack_end(Efl_Gfx*) const 
    //  inline bool eo_cxx::efl::pack::Linear::pack_end(Efl_Gfx * subobj_) const
@@ -44,13 +42,10 @@ elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
    localtime_r(&current_time, &selected_time);
    // cal2.selected_time_set(&selected_time);
    cal2.eo_cxx::efl::Gfx::size_set({125,135});
-   cal2.visible_set(true);
    //bx.pack_end(cal2);
 
-   win.eo_cxx::efl::Gfx::size_set({500,560});
-   win.visible_set(true);
+#endif
 
-   elm_run();
-   return 0;
+   win.size_set({500,560});
 }
-ELM_MAIN()
+EFL_MAIN()
diff --git a/src/examples/elementary/calendar_cxx_example_05.cc 
b/src/examples/elementary/calendar_cxx_example_05.cc
index 3f6332e530..f5185eff45 100644
--- a/src/examples/elementary/calendar_cxx_example_05.cc
+++ b/src/examples/elementary/calendar_cxx_example_05.cc
@@ -3,6 +3,8 @@
 #include "elementary_config.h"
 #endif
 
+#warning This example can't be implemented with EO APIs... FIXME
+
 #include <Elementary.hh>
 
 EAPI_MAIN int
@@ -13,13 +15,12 @@ elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
    using efl::eo::instantiate;
 
    efl::ui::Win win(instantiate);
-   //win.title_set("Calendar Getters Example");
+   win.text_set("Calendar Getters Example");
    win.autohide_set(true);
 
-   elm::Calendar cal(instantiate, win);
-   //cal.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   //win.resize_object_add(cal);
-   cal.eo_cxx::efl::Gfx::size_set({135,135});
+   efl::ui::Calendar cal(instantiate, win);
+   win.content_set(cal);
+   cal.size_set({135,135});
 
    // auto print_cal_info = std::bind([] (::elm::Calendar obj)
    //                       {
@@ -48,10 +49,8 @@ elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
    //                       } , std::placeholders::_1 );
 
    // cal.callback_changed_add(print_cal_info);
-   cal.visible_set(true);
 
-   win.eo_cxx::efl::Gfx::size_set({135,135});
-   win.visible_set(true);
+   win.size_set({135,135});
 
    elm_run();
    return 0;
diff --git a/src/examples/elementary/clock_cxx_example.cc 
b/src/examples/elementary/clock_cxx_example.cc
index bb8be2b39a..9939746468 100644
--- a/src/examples/elementary/clock_cxx_example.cc
+++ b/src/examples/elementary/clock_cxx_example.cc
@@ -5,58 +5,37 @@
 
 #include <Elementary.hh>
 
-EAPI_MAIN int
-elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
+using efl::eo::instantiate;
+
+static void
+efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
 {
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
 
-   using efl::eo::instantiate;
-
    efl::ui::Win win(instantiate);
-   //win.title_set("Clock Example");
+   win.text_set("Clock Example");
    win.autohide_set(true);
 
    efl::ui::Box bx(instantiate, win);
-   //bx.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   //win.resize_object_add(bx);
-   bx.eo_cxx::efl::Gfx::size_set({300,300});
-   bx.visible_set(true);
+   win.content_set(bx);
 
-   ::elm::Clock ck(instantiate, win);
+   efl::ui::Clock ck(instantiate, win);
    bx.pack_end(ck);
-   ck.visible_set(true);
 
-   ::elm::Clock ck2(instantiate, win);
-   ck2.show_am_pm_set(true);
+   efl::ui::Clock ck2(instantiate, win);
+   ck2.format_set("%I:%M %p");
    bx.pack_end(ck2);
-   ck2.visible_set(true);
 
-   ::elm::Clock ck3(instantiate, win);
-   ck3.show_seconds_set(true);
-   ck3.time_set(10, 11, 12);
+   efl::ui::Clock ck3(instantiate, win);
+   ck2.format_set("%H:%M:%S");
+   ck3.time_set(Efl_Time({.tm_hour = 12, .tm_min = 42, .tm_sec = 59}));
    bx.pack_end(ck3);
-   ck3.visible_set(true);
-
-   ::elm::Clock ck4(instantiate, win);
-   ck4.edit_set(true);
-   ck4.show_seconds_set(true);
-   ck4.show_am_pm_set(true);
-   ck4.time_set(10, 11, 12);
-   bx.pack_end(ck4);
-   ck4.visible_set(true);
-
-   ::elm::Clock ck5(instantiate, win);
-   ck5.show_seconds_set(true);
-   ck5.edit_set(true);
+
+   efl::ui::Clock ck5(instantiate, win);
    int digedit = ELM_CLOCK_EDIT_HOUR_UNIT | ELM_CLOCK_EDIT_MIN_UNIT | 
ELM_CLOCK_EDIT_SEC_UNIT;
    ck5.edit_mode_set(static_cast<Elm_Clock_Edit_Mode>(digedit));
    bx.pack_end(ck5);
-   ck5.visible_set(true);
-
-   win.eo_cxx::efl::Gfx::size_set({500,500});
-   win.visible_set(true);
 
-   elm_run();
-   return 0;
+   win.size_set({500,500});
 }
-ELM_MAIN()
+EFL_MAIN()
diff --git a/src/examples/elementary/toolbar_cxx_example_01.cc 
b/src/examples/elementary/toolbar_cxx_example_01.cc
index f194221d19..12548e046d 100644
--- a/src/examples/elementary/toolbar_cxx_example_01.cc
+++ b/src/examples/elementary/toolbar_cxx_example_01.cc
@@ -5,8 +5,9 @@
 #include "config.h"
 #endif
 
+#warning This example requires yet unfinished EO APIs
+
 #include <Elementary.hh>
-#include <Evas.hh>
 
 EAPI int
 elm_main(int argc, char* argv[])
@@ -25,6 +26,8 @@ elm_main(int argc, char* argv[])
       });
 
    win_1.autodel_set(true);
+
+#if 0
    win_1.eo_cxx::efl::Gfx::size_set({320, 300});
 
    efl::ui::Box box_1(instantiate, win_1);
@@ -128,6 +131,8 @@ elm_main(int argc, char* argv[])
      });
 
    efl::eolian::event_add(efl::ui::Selectable::selected_event, item_5, 
_item_5_selected_cb);
+
+#endif
    
    elm_run();
    return 0;
diff --git a/src/lib/elementary/efl_ui_calendar.eo 
b/src/lib/elementary/efl_ui_calendar.eo
index f1afa05f04..43d4508516 100644
--- a/src/lib/elementary/efl_ui_calendar.eo
+++ b/src/lib/elementary/efl_ui_calendar.eo
@@ -1,7 +1,5 @@
 import efl_types;
 
-type Efl_Ui_Calendar_Format_Cb: __undefined_type; [[Elementary calendar format 
callback type]]
-
 enum Efl.Ui.Calendar.Weekday
 {
    [[A weekday

-- 


Reply via email to