2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #define UG_MODULE_API __attribute__ ((visibility("default")))
21 #include <Elementary.h>
22 #include <ui-gadget-module.h>
23 #include <supplement.h>
27 static Evas_Object *create_fullview(Evas_Object *parent, struct ug_data *ugd)
31 base = elm_layout_add(parent);
34 elm_layout_theme_set(base, "layout", "application", "default");
37 Evas_Object *bg = elm_bg_add(base);
38 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
39 elm_object_part_content_set(base, "elm.swallow.bg", bg);
44 static Evas_Object *create_frameview(Evas_Object *parent, struct ug_data *ugd)
48 base = elm_layout_add(parent);
51 elm_layout_theme_set(base, "layout", "application", "default");
56 static Evas_Object *create_error_popup_layout(Evas_Object *parent, bool is_fullview)
60 base = elm_layout_add(parent);
65 elm_layout_theme_set(base, "layout", "application", "default");
67 elm_layout_theme_set(base, "layout", "application", "noindicator");
69 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
74 void memo_ug_hide_cb(void *data, Evas_Object *obj, void *event_info)
79 static void *on_create(struct ui_gadget *ug, enum ug_mode mode, bundle *data, void *priv)
83 const char *index = NULL;
94 ugd->th = elm_theme_new();
95 elm_theme_ref_set(ugd->th, NULL);
96 elm_theme_extension_add(ugd->th, EDJ_FILE);
102 bindtextdomain("memo", "/opt/ug/res/locale");
104 parent = ug_get_parent_layout(ug);
108 index = bundle_get_val(data, "index");
109 if (index != NULL) {/* legitimacy check of memo record */
110 memo_data_t *md = memo_get_data(atoi(index));
112 if (mode == UG_MODE_FULLVIEW)
113 ugd->base = create_error_popup_layout(parent, TRUE);
115 ugd->base = create_error_popup_layout(parent, FALSE);
118 popup = elm_popup_add(ugd->base);
119 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
120 elm_object_text_set(popup, dgettext("sys_string", "IDS_COM_POP_FILE_NOT_FOUND"));
121 elm_popup_timeout_set(popup, 1.5);
122 evas_object_show(popup);
124 evas_object_smart_callback_add(popup, "timeout", memo_ug_hide_cb, ugd->ug);
132 if (mode == UG_MODE_FULLVIEW)
133 ugd->base = create_fullview(parent, ugd);
135 ugd->base = create_frameview(parent, ugd);
138 if (bundle_key_check(data, "type", "select")) {
139 memo_load_select_view(ugd, data);
140 } else if (index != NULL) {
141 memo_load_detail_view(ugd, data);
143 memo_load_select_view(ugd, data);
150 static void on_start(struct ui_gadget *ug, bundle *data, void *priv)
154 static void on_pause(struct ui_gadget *ug, bundle *data, void *priv)
159 static void on_resume(struct ui_gadget *ug, bundle *data, void *priv)
164 static void on_destroy(struct ui_gadget *ug, bundle *data, void *priv)
177 elm_theme_extension_del(ugd->th, EDJ_FILE);
178 elm_theme_free(ugd->th);
181 evas_object_del(ugd->base);
185 static void on_message(struct ui_gadget *ug, bundle *msg, bundle *data, void *priv)
189 static void on_event(struct ui_gadget *ug, enum ug_event event, bundle *data, void *priv)
192 case UG_EVENT_LOW_MEMORY:
194 case UG_EVENT_LOW_BATTERY:
196 case UG_EVENT_LANG_CHANGE:
198 case UG_EVENT_ROTATE_PORTRAIT:
200 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
202 case UG_EVENT_ROTATE_LANDSCAPE:
204 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
211 static void on_key_event(struct ui_gadget *ug, enum ug_key_event event, bundle *data, void *priv)
217 case UG_KEY_EVENT_END:
225 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
232 ugd = calloc(1, sizeof(struct ug_data));
236 ops->create = on_create;
237 ops->start = on_start;
238 ops->pause = on_pause;
239 ops->resume = on_resume;
240 ops->destroy = on_destroy;
241 ops->message = on_message;
242 ops->event = on_event;
243 ops->key_event = on_key_event;
245 ops->opt = UG_OPT_INDICATOR_ENABLE;
250 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)