Version : 0807
authorJin Yoon <jinny.yoon@samsung.com>
Fri, 7 Aug 2015 01:23:22 +0000 (10:23 +0900)
committerJin Yoon <jinny.yoon@samsung.com>
Fri, 7 Aug 2015 01:23:22 +0000 (10:23 +0900)
inc/city.h [changed mode: 0755->0644]
inc/db.h
inc/main.h
inc/main_view.h
inc/map.h
inc/result_view.h
res/edje/main_view.edc
src/city.c [changed mode: 0755->0644]
src/main_view.c
src/map.c
src/result_view.c

old mode 100755 (executable)
new mode 100644 (file)
index 30eb9ce..10a39cf 100644 (file)
--- a/inc/db.h
+++ b/inc/db.h
@@ -52,9 +52,4 @@ extern int db_remove_version(sqlite3 *db, int version);
 extern int db_update_version(sqlite3 *db, int version);
 extern int db_count_version(sqlite3 *db);
 
-extern int db_insert_login(sqlite3 *db, const char *id, const char *passwd);
-extern int db_update_login(sqlite3 *db, const char *id, const char *passwd);
-extern int db_remove_login(sqlite3 *db, const char *id, const char *passwd);
-extern int db_count_login(sqlite3 *db, const char *id, const char *passwd);
-
 #endif // __ADVENTURE_DB_H__
index ad9d92c..f00c816 100644 (file)
@@ -1,53 +1,53 @@
-/*\r
- * Samsung API\r
- * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/license/\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __MOMENT_H__\r
-#define __MOMENT_H__\r
-\r
-#include <app.h>\r
-#include <Elementary.h>\r
-#include <system_settings.h>\r
-#include <efl_extension.h>\r
-#include <dlog.h>\r
-\r
-#ifdef  LOG_TAG\r
-#undef  LOG_TAG\r
-#endif\r
-#define LOG_TAG "MOMENT"\r
-\r
-#if !defined(PACKAGE)\r
-#define PACKAGE "org.tizen.moment"\r
-#endif\r
-\r
-#define PATH_LEN 1024\r
-\r
-struct _moment_info_s {\r
-       Evas_Object *win;\r
-       Evas_Object *conform;\r
-       Evas_Object *ui_manager;\r
-       Evas_Object *main_view;\r
-       Evas_Object *result_view;\r
-       Evas_Object *scroller;\r
-\r
-       Evas *e;\r
-\r
-       int width;\r
-       int height;\r
-};\r
-typedef struct _moment_info_s moment_info_s;\r
-\r
-#endif /* __MOMENT_H__ */\r
+/*
+ * Samsung API
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MOMENT_H__
+#define __MOMENT_H__
+
+#include <app.h>
+#include <Elementary.h>
+#include <system_settings.h>
+#include <efl_extension.h>
+#include <dlog.h>
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "MOMENT"
+
+#if !defined(PACKAGE)
+#define PACKAGE "org.tizen.moment"
+#endif
+
+#define PATH_LEN 1024
+#define DATA_KEY_INFO "__info__"
+
+struct _moment_info_s {
+       Evas_Object *win;
+       Evas_Object *conform;
+       Evas_Object *ui_manager;
+       Evas_Object *main_view;
+       Evas_Object *result_view;
+
+       Evas *e;
+
+       int width;
+       int height;
+};
+typedef struct _moment_info_s moment_info_s;
+
+#endif /* __MOMENT_H__ */
index 073352e..378b4cc 100644 (file)
@@ -1,10 +1,22 @@
-#ifndef __MAIN_VIEW_H__\r
-#define __MAIN_VIEW_H__\r
-\r
-#include <Elementary.h>\r
-#include "main.h"\r
-\r
-extern Evas_Object *main_view_create(Evas_Object *parent, moment_info_s *moment_info);\r
-extern void *main_view_destroy(Evas_Object *main_view);\r
-\r
-#endif /* __MAIN_VIEW_H__ */\r
+#ifndef __MAIN_VIEW_H__
+#define __MAIN_VIEW_H__
+
+#include <Elementary.h>
+#include "main.h"
+
+struct _main_view_s {
+       Evas_Object *main_view;
+       Evas_Object *entry;
+       Evas_Object *map;
+       Evas_Object *result_button;
+       Evas_Object *selected_scroller;
+       Evas_Object *plus_button;
+
+       Evas_Object *predict_scroller;
+};
+typedef struct _main_view_s main_view_s;
+
+extern Evas_Object *main_view_create(Evas_Object *parent, moment_info_s *moment_info);
+extern void *main_view_destroy(Evas_Object *main_view);
+
+#endif /* __MAIN_VIEW_H__ */
index a5b4878..835c8c2 100644 (file)
--- a/inc/map.h
+++ b/inc/map.h
@@ -52,7 +52,7 @@ enum {
        CITY_SEOUL,
        CITY_TOKYO,
        CITY_SYDNEY,
-}
+};
 
 struct _city_info_s {
        int id;
index 073352e..a33f5e3 100644 (file)
@@ -1,10 +1,10 @@
-#ifndef __MAIN_VIEW_H__\r
-#define __MAIN_VIEW_H__\r
-\r
-#include <Elementary.h>\r
-#include "main.h"\r
-\r
-extern Evas_Object *main_view_create(Evas_Object *parent, moment_info_s *moment_info);\r
-extern void *main_view_destroy(Evas_Object *main_view);\r
-\r
-#endif /* __MAIN_VIEW_H__ */\r
+#ifndef __RESULT_VIEW_H__
+#define __RESULT_VIEW_H__
+
+#include <Elementary.h>
+#include "main.h"
+
+extern Evas_Object *result_view_create(Evas_Object *parent, moment_info_s *moment_info);
+extern void *result_view_destroy(Evas_Object *result_view);
+
+#endif /* __RESULT_VIEW_H__ */
index 98a2913..853395d 100755 (executable)
@@ -57,6 +57,22 @@ collections {
                                }
                        }
                        part {
+                               name: "result_button";
+                               type: SWALLOW;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0      .5 1.0; to: "map"; }
+                                       rel2 { relative: 0.5 1.0; to: "map"; }
+                                       align: 0.5 0.0;
+                                       visible: 1;
+                               }
+                               description {
+                                       state: "hide" 0.0;
+                                       inherit: "default" 0.0;
+                                       visible: 0;
+                               }
+                       }
+                       part {
                                name: "title";
                                type: TEXT;
                                scale: 1;
@@ -106,23 +122,7 @@ collections {
                                }
                        }
                        part {
-                               name: "button";
-                               type: SWALLOW;
-                               description {
-                                       state: "default" 0.0;
-                                       rel1 { relative: 0.5 1.0; to: "bg"; }
-                                       rel2 { relative: 0.5 1.0; to: "bg"; }
-                                       align: 0.5 1.0;
-                                       visible: 1;
-                               }
-                               description {
-                                       state: "hide" 0.0;
-                                       inherit: "default" 0.0;
-                                       visible: 0;
-                               }
-                       }
-                       part {
-                               name: "content";
+                               name: "selected_scroller";
                                type: SWALLOW;
                                scale: 1;
                                mouse_events: 0;
@@ -202,17 +202,15 @@ collections {
 
                        program {
                                signal: "hide";
-                               source: "content";
+                               source: "selected_scroller";
                                action: STATE_SET "hide" 0.0;
-                               target: "search";
-                               target: "content";
+                               target: "selected_scroller";
                        }
                        program {
                                signal: "show";
-                               source: "content";
+                               source: "selected_scroller";
                                action: STATE_SET "default" 0.0;
-                               target: "search";
-                               target: "content";
+                               target: "selected_scroller";
                        }
 
                        program {
old mode 100755 (executable)
new mode 100644 (file)
index ae62b50..2633222 100644 (file)
-#include <Elementary.h>\r
-#include "main.h"\r
-#include "log.h"\r
-#include "scroller"\r
-\r
-const char *const MAIN_VIEW_EDJE = "main_view.edj";\r
-\r
-static void _change_entry_cb(void *data, Evas_Object *obj, void *event_info)\r
-{\r
-       moment_info_s *moment_info = data;\r
-\r
-       ret_if(!moment_info);\r
-}\r
-\r
-static Evas_Object *_create_search_entry(Evas_Object *parent, moment_info_s *moment_info)\r
-{\r
-       Evas_Object *entry = NULL;\r
-\r
-       retv_if(!parent, NULL);\r
-\r
-       entry = elm_entry_add(parent);\r
-       retv_if(!entry, NULL);\r
-\r
-       elm_entry_single_line_set(entry, EINA_TRUE);\r
-       elm_entry_scrollable_set(entry, EINA_TRUE);\r
-       elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);\r
-       elm_object_part_text_set(entry, "elm.guide", "City");\r
-\r
-       evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
-       evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
-\r
-       evas_object_smart_callback_add(entry, "changed", _change_entry_cb, moment_info);\r
-       evas_object_smart_callback_add(entry, "focused", _focus_entry_cb, moment_info);\r
-       evas_object_smart_callback_add(entry, "unfocused", _focus_entry_cb, moment_info);\r
-\r
-       evas_object_show(entry);\r
-\r
-       return entry;\r
-}\r
-\r
-void _destroy_search_entry(Evas_Object *entry)\r
-{\r
-       ret_if(!entry);\r
-       evas_object_del(entry);\r
-}\r
-\r
-static _clicked_cb(void *data, Evas_Object *obj, void *event_info)\r
-{\r
-       moment_info_s *moment_info = data;\r
-\r
-       _D("Add button is clicked");\r
-\r
-       ret_if(!moment_info);\r
-\r
-       elm_object_signal_emit(moment_info->main_view\r
-\r
-       moment_info->scroller = scroller_create(moment_info->ui_manager);\r
-       ret_if(!moment_info->scroller);\r
-}\r
-\r
-Evas_Object *main_view_create(Evas_Object *parent, moment_info_s *moment_info)\r
-{\r
-       Evas_Object *main_view = NULL;\r
-       Evas_Object *button = NULL;\r
-       char *path = NULL;\r
-       char full_path[] = {0, };\r
-\r
-       retv_if(!parent, NULL);\r
-\r
-       path = app_get_resource_path();\r
-       retv_if(!path, NULL);\r
-\r
-       snprintf(full_path, sizeof(full_path), "%s/edje/%s", path, MAIN_VIEW_EDJE);\r
-       free(path);\r
-\r
-       main_view = elm_layout_add(parent);\r
-       retv_if(!main_view, NULL);\r
-       elm_layout_file_set(main_view, full_path, "main");\r
-       evas_object_size_hint_weight_set(main_view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
-       evas_object_size_hint_align_set(main_view, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
-       evas_object_show(main_view);\r
-\r
-       elm_object_part_text_set(main_view, "title", "No cities");\r
-       elm_object_part_text_set(main_view, "description", "After you add cities, they will be shown here.");\r
-\r
-       button = elm_button_add(parent);\r
-       if (button) {\r
-               elm_object_text_set(button, "+ Add");\r
-               elm_object_part_content_set(main_view, "button", button);\r
-               evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
-               evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
-               evas_object_smart_callback_add(button, "clicked", _clicked_cb, moment_info);\r
-       }\r
-\r
-       return main_view;\r
-}\r
-\r
-void main_view_destroy(Evas_Object *main_view)\r
-{\r
-       Evas_Object *button = NULL;\r
-\r
-       ret_if(!main_view);\r
-\r
-       button = elm_object_part_content_unset(main_view, "button");\r
-       if (button) {\r
-               evas_object_del(button);\r
-       }\r
-\r
-       evas_object_del(main_view);\r
-}\r
+#include <Elementary.h>
+#include "main.h"
+#include "log.h"
+#include "scroller.h"
+#include "city.h"
+
+const char *const MAIN_VIEW_EDJE = "main_view.edj";
+const char *const PREDICT_ITEM_EDJE = "predict_item.edj";
+
+static void _change_entry_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       main_view_s *main_view_info = data;
+       Evas_Object *entry = obj;
+       const char *str = NULL;
+
+       ret_if(!moment_info);
+
+       str = elm_entry_entry_get(obj);
+       if (!str)
+               return;
+
+       _update_predict_scroller(main_view_info->predict_scroller, str);
+}
+
+static void _focus_entry_cb(void *data, Evas_Object *obj, void *event_info)
+{
+}
+
+static void _unfocus_entry_cb(void *data, Evas_Object *obj, void *event_info)
+{
+}
+
+static Evas_Object *_create_search_entry(Evas_Object *parent, moment_info_s *moment_info)
+{
+       Evas_Object *entry = NULL;
+
+       retv_if(!parent, NULL);
+
+       entry = elm_entry_add(parent);
+       retv_if(!entry, NULL);
+
+       elm_entry_single_line_set(entry, EINA_TRUE);
+       elm_entry_scrollable_set(entry, EINA_TRUE);
+       elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
+       elm_object_part_text_set(entry, "elm.guide", "Search");
+
+       evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+       evas_object_smart_callback_add(entry, "changed", _change_entry_cb, main_view_info);
+       evas_object_smart_callback_add(entry, "focused", _focus_entry_cb, main_view_info);
+       evas_object_smart_callback_add(entry, "unfocused", _unfocus_entry_cb, main_view_info);
+
+       evas_object_show(entry);
+
+       return entry;
+}
+
+static void _destroy_search_entry(Evas_Object *entry)
+{
+       ret_if(!entry);
+       evas_object_del(entry);
+}
+
+static Evas_Object *_create_map(Evas_Object *parent)
+{
+       Evas_Object *map = NULL;
+       Evas *e = NULL;
+
+       retv_if(!parent, NULL);
+
+       e = evas_object_evas_get(parent);
+       retv_if(!e, NULL);
+
+       map = evas_object_rectangle_add(e);
+       retv_if(!map, NULL);
+
+       evas_object_color_set(map, 200, 200, 0, 255);
+       evas_object_size_hint_min_set(map, 480, 400);
+       evas_object_show(map);
+
+       return map;
+}
+
+static void _destroy_map(Evas_Object *map)
+{
+       ret_if(!map);
+
+       evas_object_del(map);
+}
+
+static _click_result_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       moment_info_s *moment_info = data;
+
+       _D("Add button is clicked");
+
+       ret_if(!moment_info);
+
+       moment_info->result_view = result_view_create(moment_info->ui_manager);
+       ret_if(!moment_info->result_view);
+}
+
+static Evas_Object *_create_result_button(Evas_Object *parent, main_view_s *main_view_info)
+{
+       Evas_Object *result_button = NULL;
+
+       result_button = elm_button_add(parent);
+       retv_if(!result_button, NULL);
+
+       elm_object_part_text_set(result_button, "Result");
+       evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_smart_callback_add(button, "clicked", _click_result_button_cb, moment_info);
+
+       return result_button;
+}
+
+static void _destroy_result_button(Evas_Object *result_button)
+{
+       ret_if(!result_button);
+       evas_object_del(result_button);
+}
+
+static Evas_Object *_create_selected_scroller(Evas_Object *parent)
+{
+       Evas_Object *selected_scroller = NULL;
+
+       retv_if(!parent, NULL);
+
+       selected_scroller = scroller_create(parent);
+       retv_if(!selected_scroller, NULL);
+
+       return selected_scroller;
+}
+
+static void _destroy_selected_scroller(Evas_Object *selected_scroller)
+{
+       ret_if(!selected_scroller);
+
+       evas_object_del(selected_scroller);
+}
+
+static _click_plus_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       moment_info_s *moment_info = data;
+
+       _D("Add button is clicked");
+
+       ret_if(!moment_info);
+
+       /* Show the entry */
+}
+
+static Evas_Object *_create_plus_button(Evas_Object *parent, main_view_s *main_view_info)
+{
+       Evas_Object *plus_button = NULL;
+
+       retv_if(!parent, NULL);
+
+       plus_button = elm_button_add(parent);
+       retv_if(!plus_button, NULL);
+
+       elm_object_part_text_set(plus_button, "+Add");
+       evas_object_size_hint_weight_set(plus_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(plus_button, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_smart_callback_add(plus_button, "clicked", _click_plus_button_cb, main_view_info);
+
+       return plus_button;
+}
+
+static void _destroy_plus_button(Evas_Object *plus_button)
+{
+       ret_if(!plus_button);
+       evas_object_del(plus_button);
+}
+
+static Evas_Object *_create_predict_item(Evas_Object *parent, const char *city, const char *nation)
+{
+       Evas_Object *predict_item = NULL;
+
+       char *path = NULL;
+       char full_path[PATH_LEN] = {0, };
+       char city_name[PATH_LEN] = {0, };
+
+       retv_if(!parent, NULL);
+
+       path = app_get_resource_path();
+       retv_if(!path, NULL);
+
+       snprintf(full_path, sizeof(full_path), "%s/edje/%s", path, PREDICT_ITEM_EDJE);
+       free(path);
+
+       predict_item = elm_layout_add(parent);
+       retv_if(!predict_item, NULL);
+
+       elm_layout_file_set(predict_item, full_path, "main");
+       evas_object_size_hint_weight_set(predict_item, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(predict_item, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_show(predict_item);
+
+       snprintf(city_name, sizeof(city_name), "%s, %s", city, nation);
+       elm_object_part_text_set(predict_item, "city", city_name);
+
+       return predict_item;
+}
+
+static void _destroy_predict_item(Evas_Object *predict_item)
+{
+       ret_if(!predict_item);
+       evas_object_del(predict_item);
+}
+
+static Evas_Object *_create_predict_scroller(Evas_Object *parent)
+{
+       Evas_Object *predict_scroller = NULL;
+
+       retv_if(!parent, NULL);
+
+       predict_scroller = scroller_create(parent);
+       retv_if(!predict_scroller, NULL);
+
+       return predict_scroller;
+}
+
+static void _destroy_predict_scroller(Evas_Object *predict_scroller)
+{
+       ret_if(!predict_scroller);
+
+       evas_object_del(predict_scroller);
+}
+
+static void _clean_predict_scroller(Evas_Object *predict_scroller)
+{
+       Evas_Object *box = NULL;
+       Evas_Object *predict_item = NULL;
+       Eina_List *list = NULL;
+
+       ret_if(!predict_scroller);
+
+       box = elm_object_content_get(predict_scroller);
+       ret_if(!box);
+
+       list = elm_box_children_get(box);
+       ret_if(!list);
+
+       EINA_LIST_FREE(list, predict_item) {
+               _destroy_predict_item(predict_item);
+       }
+}
+
+static void _append_item_to_predict_scroller(Evas_Object *predict_scroller, Evas_Object *item)
+{
+       Evas_Object *box = NULL;
+
+       ret_if(!predict_scroller);
+       ret_if(!item);
+
+       box = elm_object_content_get(predict_scroller);
+       ret_if(!box);
+
+       elm_box_pack_end(box, item);
+}
+
+static void _remove_item_in_predict_scroller(Evas_Object *predict_scroller, Evas_Object *item)
+{
+       Evas_Object *box = NULL;
+       Evas_Object *item = NULL;
+
+       ret_if(!predict_scroller);
+       ret_if(!item);
+
+       box = elm_object_content_get(predict_scroller);
+       ret_if(!box);
+
+       elm_box_unpack(box, item);
+}
+
+static void _update_predict_scroller(Evas_Object *predict_scroller, const char *str)
+{
+       city_s *city_info = NULL;
+       register int i = 0;
+
+       ret_if(!predict_scroller);
+
+       if (!str)
+               _clean_predict_scroller(predict_scroller);
+
+       city_info = city_get();
+       ret_if(!city_info);
+
+       for (; i < CITY_MAX; i++) {
+               int matched = 0;
+               if (city_info[i]->name && strstr(city_info[i]->name, str))
+                       matched = 1;
+               else if (city_info[i]->nation && strstr(city_info[i]->nation, str))
+                       matched = 1;
+
+               if (matched) {
+                       Evas_Object *predict_item = NULL;
+                       predict_item = _create_predict_item(predict_scroller, city_info[i]->name, city_info[i]->nation);
+                       if (predict_item)
+                               _append_item_to_predict_scroller(predict_scroller);
+               }
+       }
+}
+
+Evas_Object *main_view_create(Evas_Object *parent, moment_info_s *moment_info)
+{
+       Evas_Object *button = NULL;
+       main_view_s *main_view_info = NULL;
+       char *path = NULL;
+       char full_path[] = {0, };
+
+       retv_if(!parent, NULL);
+
+       path = app_get_resource_path();
+       retv_if(!path, NULL);
+
+       snprintf(full_path, sizeof(full_path), "%s/edje/%s", path, MAIN_VIEW_EDJE);
+       free(path);
+
+       main_view_info = calloc(1, sizeof(main_view_s));
+       retv_if(!main_view_info, NULL);
+
+       main_view_info->main_view = elm_layout_add(parent);
+       if (!main_view_info->main_view) {
+               free(main_view_info);
+               return NULL;
+       }
+
+       elm_layout_file_set(main_view_info->main_view, full_path, "main");
+       evas_object_size_hint_weight_set(main_view_info->main_view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(main_view_info->main_view, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_show(main_view);
+       evas_object_data_set(main_view_info->main_view, DATA_KEY_INFO, main_view_info);
+
+       elm_object_part_text_set(main_view_info->main_view, "title", "No cities");
+       elm_object_part_text_set(main_view_info->main_view, "description", "After you add cities, they will be shown here.");
+
+       main_view_info->entry = _create_search_entry(main_view_info->main_view, moment_info);
+       if (main_view_info->entry)
+               elm_object_part_content_set(main_view_info->main_view, "entry", main_view_info->entry);
+
+       main_view_info->map = _create_map(main_view_info->main_view);
+       if (main_view_info->map)
+               elm_object_part_content_set(main_view_info->main_view, "map", main_view_info->map);
+
+       main_view_info->result_button = _create_result_button(main_view_info->main_view, main_view_info);
+       if (main_view_info->result_button)
+               elm_object_part_content_set(main_view_info->main_view, "result_button", main_view_info->result_button);
+
+       main_view_info->selected_scroller = _create_selected_scroller(main_view_info->main_view);
+       if (main_view_info->selected_scroller)
+               elm_object_part_content_set(main_view_info->main_view, "selected_scroller", main_view_info->selected_scroller);
+
+       main_view_info->plus_button = _create_plus_button(main_view_info->main_view, main_view_info);
+       if (main_view_info->plus_button)
+               elm_object_part_content_set(main_view_info->main_view, "plus_button", main_view_info->plus_button);
+
+       main_view_info->predict_scroller = _create_predict_scroller(main_view_info->main_view);
+       if (main_view_info->predict_scroller)
+               elm_object_part_content_set(main_view_info->main_view, "predict_scroller", main_view_info->predict_scroller);
+
+       return main_view;
+}
+
+void main_view_destroy(Evas_Object *main_view)
+{
+       Evas_Object *button = NULL;
+       main_view_s *main_view_info = NULL;
+
+       ret_if(!main_view);
+
+       main_view_info = evas_object_data_del(main_view_info->main_view, DATA_KEY_INFO);
+       ret_if(!main_view_info);
+
+       if (main_view_info->predict_scroller)
+               _destroy_predict_scroller(main_view_info->predict_scroller);
+
+       if (main_view_info->plus_button)
+               _destroy_plus_button(main_view_info->plus_button);
+
+       if (main_view_info->selected_scroller)
+               _destroy_selected_scroller(main_view_info->selected_scroller);
+
+       if (main_view_info->result_button)
+               _destroy_result_button(button);
+
+       if (main_view_info->map)
+               _destroy_map(main_view_info->map);
+
+       if (main_view_info->entry)
+               _destroy_search_entry(main_view_info->entry);
+
+       free(main_view_info);
+
+       evas_object_del(main_view);
+}
index e5da519..daf9ac2 100644 (file)
--- a/src/map.c
+++ b/src/map.c
 #include <Elementary.h>
 #include "main.h"
 #include "log.h"
+#include "map.h"
 
 const char *const MAP_EDJE = "map.edj";
 
-
-static city_info_s cities[] = {
-       {
-               .id = CITY_HONOLULU,
-               .timezone = -10.0,
-               .name = "Honolulu",
-               .nation = "USA",
-       },
-       {
-               .id = CITY_LOS_ANGELES,
-               .timezone = -8.0,
-               .name = "Los Angeles",
-               .nation = "USA",
-       },
-       {
-               .id = CITY_SAN_FRANCISCO,
-               .timezone = -8.0,
-               .name = "San Francisco",
-               .nation = "USA",
-       },
-       {
-               .id = CITY_VANCOUVER,
-               .timezone = -8.0,
-               .name = "Vancouver",
-               .nation = "Canada",
-       },
-       {
-               .id = CITY_CHICAGO,
-               .timezone = -6.0,
-               .name = "Chicago",
-               .nation = "USA",
-       },
-       {
-               .id = CITY_MEICO_CITY,
-               .timezone = -6.0,
-               .name = "Mexico City",
-               .nation = "Mexico",
-       },
-       {
-               .id = CITY_SAN_JOSE,
-               .timezone = -6.0,
-               .name = "San Jose",
-               .nation = "Costa Rica",
-       },
-       {
-               .id = CITY_NEW_YORK_CITY,
-               .timezone = -5.0,
-               .name = "New York City",
-               .nation = "USA",
-       },
-       {
-               .id = CITY_TORONTO,
-               .timezone = -5.0,
-               .name = "Toronto",
-               .nation = "Canada",
-       },
-       {
-               .id = CITY_WASHINGTON_DC,
-               .timezone = -5.0,
-               .name = "Washington DC",
-               .nation = "USA",
-       },
-       {
-               .id = CITY_BRASILIA,
-               .timezone = -3.0,
-               .name = "Brasilia",
-               .nation = "Brazil",
-       },
-       {
-               .id = CITY_BUENOS_AIRES,
-               .timezone = -3.0,
-               .name = "Buenos Aires",
-               .nation = "Argentina",
-       },
-       {
-               .id = CITY_SAO_PAULO,
-               .timezone = -3.0,
-               .name = "Sao Paulo",
-               .nation = "Brazil",
-       },
-       {
-               .id = CITY_DUBLIN,
-               .timezone = 0.0,
-               .name = "Dublin",
-               .nation = "Ireland",
-       },
-       {
-               .id = CITY_LISBON,
-               .timezone = 0.0,
-               .name = "Lisbon",
-               .nation = "Portugal",
-       },
-       {
-               .id = CITY_LONDON,
-               .timezone = 0.0,
-               .name = "London",
-               .nation = "England",
-       },
-       {
-               .id = CITY_AMSTERDAM,
-               .timezone = 1.0,
-               .name = "Amsterdam",
-               .nation = "Netherlands",
-       },
-       {
-               .id = CITY_BARCELONA,
-               .timezone = 1.0,
-               .name = "Barcelona",
-               .nation = "Spain",
-       },
-       {
-               .id = CITY_BERLIN,
-               .timezone = 1.0,
-               .name = "Berlin",
-               .nation = "Germany",
-       },
-       {
-               .id = CITY_BRUSSELS,
-               .timezone = 1.0,
-               .name = "Brussels",
-               .nation = "Belgium",
-       },
-       {
-               .id = CITY_CAPE_TOWN,
-               .timezone = 1.0,
-               .name = "Cape Town",
-               .nation = "South Africa",
-       },
-       {
-               .id = CITY_GENEVA,
-               .timezone = 1.0,
-               .name = "Geneva",
-               .nation = "Switzerland",
-       },
-       {
-               .id = CITY_MADRID,
-               .timezone = 1.0,
-               .name = "Madrid",
-               .nation = "Spain",
-       },
-       {
-               .id = CITY_PARIS,
-               .timezone = 1.0,
-               .name = "Paris",
-               .nation = "France",
-       },
-       {
-               .id = CITY_ROME,
-               .timezone = 1.0,
-               .name = "Rome",
-               .nation = "Italy",
-       },
-       {
-               .id = CITY_STOCKHOLM,
-               .timezone = 1.0,
-               .name = "Stockholm",
-               .nation = "Sweden",
-       },
-       {
-               .id = CITY_WARSAW,
-               .timezone = 1.0,
-               .name = "Warsaw",
-               .nation = "Poland",
-       },
-       {
-               .id = CITY_ANKARA,
-               .timezone = 2.0,
-               .name = "Ankara",
-               .nation = "Turkey",
-       },
-       {
-               .id = CITY_ATHENS,
-               .timezone = 2.0,
-               .name = "Athens",
-               .nation = "Greece",
-       },
-       {
-               .id = CITY_HELSINKI,
-               .timezone = 2.0,
-               .name = "Helsinki",
-               .nation = "Finland",
-       },
-       {
-               .id = CITY_ISTANBUL,
-               .timezone = 2.0,
-               .name = "Istanbul",
-               .nation = "Turkey",
-       },
-       {
-               .id = CITY_JERUSALEM,
-               .timezone = 2.0,
-               .name = "Jerusalem",
-               .nation = "Israel",
-       },
-       {
-               .id = CITY_KAHIRA,
-               .timezone = 2.0,
-               .name = "Jerusalem",
-               .nation = "Egypt",
-       },
-       {
-               .id = CITY_BAGHDAD,
-               .timezone = 3.0,
-               .name = "Baghdad",
-               .nation = "Iraq",
-       },
-       {
-               .id = CITY_DUBAI,
-               .timezone = 3.0,
-               .name = "Dubai",
-               .nation = "United Arab Emirates",
-       },
-       {
-               .id = CITY_MOSCOW,
-               .timezone = 3.0,
-               .name = "Moscow",
-               .nation = "Russia",
-       },
-       {
-               .id = CITY_ISLAMABAD,
-               .timezone = 5.0,
-               .name = "Islamabad",
-               .nation = "Pakistan",
-       },
-       {
-               .id = CITY_DELHI,
-               .timezone = 5.5,
-               .name = "Delhi",
-               .nation = "India",
-       },
-       {
-               .id = CITY_MUMBAI,
-               .timezone = 5.5,
-               .name = "Mumbai",
-               .nation = "India",
-       },
-       {
-               .id = CITY_BOMBAY,
-               .timezone = 6.0,
-               .name = "Bombay",
-               .nation = "India",
-       },
-       {
-               .id = CITY_CALCUTTA,
-               .timezone = 6.0,
-               .name = "Calcutta",
-               .nation = "India",
-       },
-       {
-               .id = CITY_BANGKOK,
-               .timezone = 7.0,
-               .name = "Bangkok",
-               .nation = "Thailand",
-       },
-       {
-               .id = CITY_JAKARTA,
-               .timezone = 7.0,
-               .name = "Jakarta",
-               .nation = "Indonesia",
-       },
-       {
-               .id = CITY_BEIJING,
-               .timezone = 8.0,
-               .name = "Beijing",
-               .nation = "China",
-       },
-       {
-               .id = CITY_HONG_KONG,
-               .timezone = 8.0,
-               .name = "Hong Kong",
-               .nation = "China",
-       },
-       {
-               .id = CITY_SINGAPORE,
-               .timezone = 8.0,
-               .name = "Singapore",
-               .nation = "Singapore",
-       },
-       {
-               .id = CITY_TAIPEI,
-               .timezone = 8.0,
-               .name = "Taipei",
-               .nation = "Thaiwan",
-       },
-       {
-               .id = CITY_SEOUL,
-               .timezone = 9.0,
-               .name = "Seoul",
-               .nation = "Korea",
-       },
-       {
-               .id = CITY_TOKYO,
-               .timezone = 9.0,
-               .name = "Tokyo",
-               .nation = "Japan",
-       },
-       {
-               .id = CITY_SYDNEY,
-               .timezone = 10.0,
-               .name = "Sydney",
-               .nation = "Australia",
-       },
-};
-
 Evas_Object *map_create(Evas_Object *parent)
 {
        Evas_Object *map = NULL;
index a702fd2..5cbea82 100644 (file)
@@ -1,71 +1,69 @@
-#include <Elementary.h>\r
-#include "main.h"\r
-#include "log.h"\r
-#include "scroller"\r
-\r
-const char *const MAIN_VIEW_EDJE = "result_view.edj";\r
-\r
-static _clicked_cb(void *data, Evas_Object *obj, void *event_info)\r
-{\r
-       moment_info_s *moment_info = data;\r
-\r
-       _D("Add button is clicked");\r
-\r
-       ret_if(!moment_info);\r
-\r
-       elm_object_signal_emit(moment_info->result_view\r
-\r
-       moment_info->scroller = scroller_create(moment_info->ui_manager);\r
-       ret_if(!moment_info->scroller);\r
-}\r
-\r
-Evas_Object *result_view_create(Evas_Object *parent, moment_info_s *moment_info)\r
-{\r
-       Evas_Object *result_view = NULL;\r
-       Evas_Object *button = NULL;\r
-       char *path = NULL;\r
-       char full_path[] = {0, };\r
-\r
-       retv_if(!parent, NULL);\r
-\r
-       path = app_get_resource_path();\r
-       retv_if(!path, NULL);\r
-\r
-       snprintf(full_path, sizeof(full_path), "%s/edje/%s", path, MAIN_VIEW_EDJE);\r
-       free(path);\r
-\r
-       result_view = elm_layout_add(parent);\r
-       retv_if(!result_view, NULL);\r
-       elm_layout_file_set(result_view, full_path, "main");\r
-       evas_object_size_hint_weight_set(result_view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
-       evas_object_size_hint_align_set(result_view, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
-       evas_object_show(result_view);\r
-\r
-       elm_object_part_text_set(result_view, "title", "No cities");\r
-       elm_object_part_text_set(result_view, "description", "After you add cities, they will be shown here.");\r
-\r
-       button = elm_button_add(parent);\r
-       if (button) {\r
-               elm_object_text_set(button, "+ Add");\r
-               elm_object_part_content_set(result_view, "button", button);\r
-               evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
-               evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
-               evas_object_smart_callback_add(button, "clicked", _clicked_cb, moment_info);\r
-       }\r
-\r
-       return result_view;\r
-}\r
-\r
-void result_view_destroy(Evas_Object *result_view)\r
-{\r
-       Evas_Object *button = NULL;\r
-\r
-       ret_if(!result_view);\r
-\r
-       button = elm_object_part_content_unset(result_view, "button");\r
-       if (button) {\r
-               evas_object_del(button);\r
-       }\r
-\r
-       evas_object_del(result_view);\r
-}\r
+#include <Elementary.h>
+#include "main.h"
+#include "log.h"
+#include "scroller.h"
+
+const char *const MAIN_VIEW_EDJE = "result_view.edj";
+
+static _clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       moment_info_s *moment_info = data;
+
+       _D("Add button is clicked");
+
+       ret_if(!moment_info);
+
+       moment_info->scroller = scroller_create(moment_info->ui_manager);
+       ret_if(!moment_info->scroller);
+}
+
+Evas_Object *result_view_create(Evas_Object *parent, moment_info_s *moment_info)
+{
+       Evas_Object *result_view = NULL;
+       Evas_Object *button = NULL;
+       char *path = NULL;
+       char full_path[] = {0, };
+
+       retv_if(!parent, NULL);
+
+       path = app_get_resource_path();
+       retv_if(!path, NULL);
+
+       snprintf(full_path, sizeof(full_path), "%s/edje/%s", path, MAIN_VIEW_EDJE);
+       free(path);
+
+       result_view = elm_layout_add(parent);
+       retv_if(!result_view, NULL);
+       elm_layout_file_set(result_view, full_path, "main");
+       evas_object_size_hint_weight_set(result_view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(result_view, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_show(result_view);
+
+       elm_object_part_text_set(result_view, "title", "No cities");
+       elm_object_part_text_set(result_view, "description", "After you add cities, they will be shown here.");
+
+       button = elm_button_add(parent);
+       if (button) {
+               elm_object_part_text_set(button, "+ Add");
+               elm_object_part_content_set(result_view, "button", button);
+               evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_smart_callback_add(button, "clicked", _clicked_cb, moment_info);
+       }
+
+       return result_view;
+}
+
+void result_view_destroy(Evas_Object *result_view)
+{
+       Evas_Object *button = NULL;
+
+       ret_if(!result_view);
+
+       button = elm_object_part_content_unset(result_view, "button");
+       if (button) {
+               evas_object_del(button);
+       }
+
+       evas_object_del(result_view);
+}