From: Hermet Park Date: Tue, 14 Jun 2016 10:24:09 +0000 (+0900) Subject: Still c implementation is unstable. X-Git-Tag: submit/tizen/20160617.075742~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=721806e34e0c99d05e6c744c57b1ddaf18b45bad;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git Still c implementation is unstable. We are still on building up its bodies here and there. Change-Id: I38f81dc82fde761b5578635836d305c90e1b760f --- diff --git a/src/examples/efl/c/main.cpp b/src/examples/efl/c/main.cpp index 5962062..838c1ae 100644 --- a/src/examples/efl/c/main.cpp +++ b/src/examples/efl/c/main.cpp @@ -11,22 +11,27 @@ app_create(void *data) int main(int argc, char *argv[]) { - appdata_s ad = {0,}; - int ret = 0; + ui_app_lifecycle_callback_s lifecycle_callback = {0, }; - ui_app_lifecycle_callback_s lifecycle_callback = {0,}; - - ret = ui_app_init(PACKAGE, LOCALE_DIR); - if (!ret) { + if (!ui_app_init(PACKAGE, LOCALE_DIR)) + { dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_init() is failed. err = %d", ret); + return ret; } lifecycle_callback.create = app_create; - ret = ui_app_run(argc, argv, &lifecycle_callback, NULL, &ad); - if (ret != APP_ERROR_NONE) { + if (!ui_app_run(argc, argv, &lifecycle_callback, NULL, NULL)) + { dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_run() is failed. err = %d", ret); + return ret; + } + + if (!ui_app_term()) + { + dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_term() is failed. err = %d", ret); + return ret; } - return ret; + return 0; } diff --git a/src/examples/efl/c/main.h b/src/examples/efl/c/main.h index 5406440..b865460 100644 --- a/src/examples/efl/c/main.h +++ b/src/examples/efl/c/main.h @@ -31,15 +31,6 @@ #define PACKAGE "ui-viewmgr" #endif -typedef struct appdata { - Evas_Object *win; - Evas_Object *conform; - Evas_Object *layout; - Evas_Object *nf; - Evas_Object *tabbar; -} appdata_s; - - Evas_Object* create_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb); Evas_Object* create_landscape_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb); Evas_Object* create_title_handle_content(Evas_Object *parent, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb, diff --git a/src/examples/efl/c/page1.cpp b/src/examples/efl/c/page1.cpp index f10f6c6..7f64291 100644 --- a/src/examples/efl/c/page1.cpp +++ b/src/examples/efl/c/page1.cpp @@ -37,7 +37,7 @@ view1_load_cb(ui_view *view, void *data) Evas_Object *content = create_content(base_layout, "ViewMgr Demo
Basic View", view1_prev_btn_clicked_cb, view1_next_btn_clicked_cb); - ui_standard_view_content_set(view, content, "Page1 C example", NULL, NULL, NULL); + ui_standard_view_content_set(view, content, "Page1", NULL, NULL, NULL); return true; } diff --git a/src/examples/efl/cpp/page1.h b/src/examples/efl/cpp/page1.h index b7b6046..37e4819 100644 --- a/src/examples/efl/cpp/page1.h +++ b/src/examples/efl/cpp/page1.h @@ -15,7 +15,7 @@ * */ -/** This example create a simple view which is inheritance ui_standard_view. +/** This example create a simple view which is inheritance of an ui_standard_view. * Then push in viewmgr. */ class page1: public ui_standard_view @@ -27,7 +27,7 @@ protected: ui_standard_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Basic View", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Basic View", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { @@ -38,7 +38,7 @@ protected: { UI_VIEWMGR->push_view(new page2()); }); - this->set_content(content, "Page1 C++ example"); + this->set_content(content, "Page1"); } public: diff --git a/src/examples/efl/cpp/page10.h b/src/examples/efl/cpp/page10.h index 8f7de8c..a4cce67 100644 --- a/src/examples/efl/cpp/page10.h +++ b/src/examples/efl/cpp/page10.h @@ -34,7 +34,7 @@ protected: //Portrait if (this->get_degree() == 0 || this->get_degree() == 180) { - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Rotation", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Rotation", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { @@ -52,7 +52,7 @@ protected: //Landscape else { - Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo
Rotation", + Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr++ Demo
Rotation", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page11.h b/src/examples/efl/cpp/page11.h index 34e14b7..b752d40 100644 --- a/src/examples/efl/cpp/page11.h +++ b/src/examples/efl/cpp/page11.h @@ -34,7 +34,7 @@ protected: ui_standard_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Menu Popup", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Menu Popup", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page12.h b/src/examples/efl/cpp/page12.h index fdfafcf..cbe11f1 100644 --- a/src/examples/efl/cpp/page12.h +++ b/src/examples/efl/cpp/page12.h @@ -37,7 +37,7 @@ protected: ui_standard_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Popup", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Popup", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page13.h b/src/examples/efl/cpp/page13.h index 1ca40a4..7f7d487 100644 --- a/src/examples/efl/cpp/page13.h +++ b/src/examples/efl/cpp/page13.h @@ -28,7 +28,7 @@ protected: ui_standard_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Fade Transition", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Fade Transition", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page14.h b/src/examples/efl/cpp/page14.h index 36080ef..f588ba8 100644 --- a/src/examples/efl/cpp/page14.h +++ b/src/examples/efl/cpp/page14.h @@ -28,7 +28,7 @@ protected: ui_standard_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
None Transition", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
None Transition", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page2.h b/src/examples/efl/cpp/page2.h index ae4b496..aaf1f31 100644 --- a/src/examples/efl/cpp/page2.h +++ b/src/examples/efl/cpp/page2.h @@ -26,7 +26,7 @@ protected: ui_standard_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Title Buttons", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Title Buttons", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page3.h b/src/examples/efl/cpp/page3.h index 9de47ea..d2d13d1 100644 --- a/src/examples/efl/cpp/page3.h +++ b/src/examples/efl/cpp/page3.h @@ -26,7 +26,7 @@ protected: ui_standard_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Subtitle", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Subtitle", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page4.h b/src/examples/efl/cpp/page4.h index 8bfc0a5..eda5a39 100644 --- a/src/examples/efl/cpp/page4.h +++ b/src/examples/efl/cpp/page4.h @@ -27,7 +27,7 @@ protected: ui_standard_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Title Badge", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Title Badge", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page5.h b/src/examples/efl/cpp/page5.h index 8ec8998..df8da24 100644 --- a/src/examples/efl/cpp/page5.h +++ b/src/examples/efl/cpp/page5.h @@ -26,7 +26,7 @@ protected: ui_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Full View", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Full View", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page6.h b/src/examples/efl/cpp/page6.h index 5f56952..633be3f 100644 --- a/src/examples/efl/cpp/page6.h +++ b/src/examples/efl/cpp/page6.h @@ -25,7 +25,7 @@ protected: ui_standard_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Toolbar", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Toolbar", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page7.h b/src/examples/efl/cpp/page7.h index 27f5df8..dd45edd 100644 --- a/src/examples/efl/cpp/page7.h +++ b/src/examples/efl/cpp/page7.h @@ -25,7 +25,7 @@ protected: ui_standard_view::on_load(); //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Navigationbar", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Navigationbar", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/examples/efl/cpp/page8.h b/src/examples/efl/cpp/page8.h index 723553b..078d856 100644 --- a/src/examples/efl/cpp/page8.h +++ b/src/examples/efl/cpp/page8.h @@ -23,7 +23,7 @@ public: page8() : ui_standard_view("page8") { //Create a main content. - Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Content Preloading", + Evas_Object *content = create_content(this->get_base(), "ViewMgr++ Demo
Content Preloading", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { diff --git a/src/include/efl/mobile/c/ui_app.h b/src/include/efl/mobile/c/ui_app.h index 9394d38..f180f13 100644 --- a/src/include/efl/mobile/c/ui_app.h +++ b/src/include/efl/mobile/c/ui_app.h @@ -1,12 +1,10 @@ #ifndef _UI_APP_C_H_ #define _UI_APP_C_H_ -namespace efl_viewmanager -{ - #ifdef __cplusplus extern "C" { #endif + typedef void (*ui_app_event_low_battery_cb) (app_event_info_h event_info, void *data); typedef void (*ui_app_event_low_memory_cb) (app_event_info_h event_info, void *data); typedef void (*ui_app_event_orient_changed_cb) (app_event_info_h event_info, void *data); @@ -23,16 +21,13 @@ extern "C" { } ui_app_event_callback_s; bool ui_app_init(const char *pkg, const char *locale_dir); - - int ui_app_run(int argc, char **argv, ui_app_lifecycle_callback_s *lifecycle_callback, - ui_app_event_callback_s *event_callback, void *data); - + int ui_app_run(int argc, char **argv, ui_app_lifecycle_callback_s *lifecycle_callback, ui_app_event_callback_s *event_callback, void *data); ui_viewmgr *ui_app_viewmgr_get(); + bool ui_app_term(void); + - ui_app *ui_app_app_get(); #ifdef __cplusplus } #endif -} #endif /* _UI_APP_C_H_ */ diff --git a/src/lib/efl/mobile/c/ui_app.cpp b/src/lib/efl/mobile/c/ui_app.cpp index 04ee5c3..20de888 100644 --- a/src/lib/efl/mobile/c/ui_app.cpp +++ b/src/lib/efl/mobile/c/ui_app.cpp @@ -118,30 +118,46 @@ public: } }; -extern "C" { - static ui_app_capi *app = NULL; - bool ui_app_init(const char *pkg, const char *locale_dir) - { - app = new ui_app_capi(pkg, locale_dir); +static ui_app_capi *g_app = NULL; - if (app) return true; - else return false; - } +bool ui_app_init(const char *pkg, const char *locale_dir) +{ + ui_app_capi *app = g_app; + if (app) return true; - int ui_app_run(int argc, char **argv, ui_app_lifecycle_callback_s *lifecycle_callback, - ui_app_event_callback_s *event_callback, void *data) + app = new ui_app_capi(pkg, locale_dir); + if (!app) { - return app->run(argc, argv, lifecycle_callback, event_callback, data); + LOGE("Failed to create new ui_app_capi()!"); + return false; } - ui_viewmgr *ui_app_viewmgr_get() - { - return app->get_viewmgr(); - } + g_app = app; - ui_app *ui_app_app_get() - { - return app; - } + return true; +} + +int ui_app_run(int argc, char **argv, ui_app_lifecycle_callback_s *lifecycle_callback, ui_app_event_callback_s *event_callback, void *data) +{ + ui_app_capi *app = g_app; + if (!app) return -1; + + return app->run(argc, argv, lifecycle_callback, event_callback, data); +} + +ui_viewmgr *ui_app_viewmgr_get() +{ + ui_app_capi *app = g_app; + if (!app) return NULL; + + return app->get_viewmgr(); +} + +bool ui_app_term(void) +{ + ui_app_capi *app = g_app; + if (app) delete (app); + + return true; }