3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.1 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #define UG_MODULE_API __attribute__ ((visibility("default")))
22 #include <Elementary.h>
23 #include <ui-gadget-module.h>
24 #include <supplement.h>
30 static Evas_Object *create_fullview(Evas_Object *parent, struct ug_data *ugd)
34 base = elm_layout_add(parent);
37 elm_layout_theme_set(base, "layout", "application", "default");
40 Evas_Object *bg = elm_bg_add(base);
41 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
42 elm_object_part_content_set(base, "elm.swallow.bg", bg);
47 static Evas_Object *create_frameview(Evas_Object *parent, struct ug_data *ugd)
51 base = elm_layout_add(parent);
54 elm_layout_theme_set(base, "layout", "application", "default");
59 static Evas_Object *create_error_popup_layout(Evas_Object *parent, bool is_fullview)
63 base = elm_layout_add(parent);
68 elm_layout_theme_set(base, "layout", "application", "default");
70 elm_layout_theme_set(base, "layout", "application", "noindicator");
72 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
77 void memo_ug_hide_cb(void *data, Evas_Object *obj, void *event_info)
82 static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
94 service_dump(service);
97 ugd->th = elm_theme_new();
98 elm_theme_ref_set(ugd->th, NULL);
99 elm_theme_extension_add(ugd->th, EDJ_FILE);
105 bindtextdomain("memo", LOCALEDIR);
107 parent = ug_get_parent_layout(ug);
111 service_get_extra_data(service, "index", &index);
112 if (index != NULL) {/* legitimacy check of memo record */
113 memo_data_t *md = memo_get_data(atoi(index));
115 if (mode == UG_MODE_FULLVIEW)
116 ugd->base = create_error_popup_layout(parent, TRUE);
118 ugd->base = create_error_popup_layout(parent, FALSE);
121 popup = elm_popup_add(ugd->base);
122 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
123 elm_object_text_set(popup, dgettext("sys_string", "IDS_COM_POP_FILE_NOT_FOUND"));
124 elm_popup_timeout_set(popup, 1.5);
125 evas_object_show(popup);
127 evas_object_smart_callback_add(popup, "timeout", memo_ug_hide_cb, ugd->ug);
135 if (mode == UG_MODE_FULLVIEW)
136 ugd->base = create_fullview(parent, ugd);
138 ugd->base = create_frameview(parent, ugd);
141 if (edit_view_pre_condition_check(service)) {
142 ugd->h_ug = memo_load_edit_view(ugd, service);
143 } else if (service_key_check(service, "type", "select")) {
144 memo_load_select_view(ugd, service);
145 } else if (index != NULL) {
147 memo_load_detail_view(ugd, service);
149 memo_load_select_view(ugd, service);
156 static void on_start(ui_gadget_h ug, service_h service, void *priv)
160 static void on_pause(ui_gadget_h ug, service_h service, void *priv)
165 static void on_resume(ui_gadget_h ug, service_h service, void *priv)
170 static void on_destroy(ui_gadget_h ug, service_h service, void *priv)
183 elm_theme_extension_del(ugd->th, EDJ_FILE);
184 elm_theme_free(ugd->th);
187 if (ugd->h_ug != NULL) {
188 memo_del_edit_view(ugd->h_ug);
191 evas_object_del(ugd->base);
195 static void on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv)
199 static void on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv)
202 case UG_EVENT_LOW_MEMORY:
204 case UG_EVENT_LOW_BATTERY:
206 case UG_EVENT_LANG_CHANGE:
208 case UG_EVENT_ROTATE_PORTRAIT:
210 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
212 case UG_EVENT_ROTATE_LANDSCAPE:
214 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
221 static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv)
227 case UG_KEY_EVENT_END:
235 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
242 ugd = calloc(1, sizeof(struct ug_data));
246 ops->create = on_create;
247 ops->start = on_start;
248 ops->pause = on_pause;
249 ops->resume = on_resume;
250 ops->destroy = on_destroy;
251 ops->message = on_message;
252 ops->event = on_event;
253 ops->key_event = on_key_event;
255 ops->opt = UG_OPT_INDICATOR_ENABLE;
260 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)