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 #include <Elementary.h>
19 #include <ui-gadget-module.h>
20 #include <Ecore_X.h> /*EFL*/
22 #include "ivug-common.h" //common
23 #include "ivug-util.h"
24 #include "ivug-main.h"
25 #include "ivug-main-view.h"
26 #include "ivug-setas-view.h"
27 #include "ivug-details-view.h"
28 #include "ivug-slider.h"
30 #include "ug-image-viewer.h"
32 #include "ivug-data.h"
33 #include "ivug-parameter.h"
35 static Evas_Object *create_fullview(Evas_Object *win, struct ug_data *ugd)
39 /* Create Full view */
40 base = elm_layout_add(win);
44 ret = elm_layout_file_set(base , EDJ_PATH"/ivug-base.edj", "ivug_base" );
46 if ( ret == EINA_FALSE)
48 MSG_IMAGEVIEW_HIGH("Cannot set layout. EDJ=%s Group=%s", EDJ_PATH"/ivug-base.edj", "ivug_base");
49 evas_object_del(base);
54 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
55 evas_object_size_hint_align_set(base, EVAS_HINT_FILL, EVAS_HINT_FILL);
57 elm_win_resize_object_add(win, base);
62 static Evas_Object *create_frameview(Evas_Object *parent, struct ug_data *ugd)
66 /* Create Frame view */
67 base = elm_layout_add(parent);
68 elm_layout_theme_set(base, "layout", "application", "default");
73 static void *on_create(struct ui_gadget *ug, enum ug_mode mode, bundle *data, void *priv)
77 PERF_CHECK_BEGIN("On Create");
79 MSG_IMAGEVIEW_HIGH("Image Viewer : %s ug=0x%08x", __func__, ug);
83 MSG_IMAGEVIEW_ERROR("Error. ug=0x%08x priv=0x%08x", ug, priv);
89 If application call this US, ug_get_parent_layout() returns window ID not layout.
92 ugd->parent_layout = ug_get_parent_layout(ug); //parent's layout
93 if (!ugd->parent_layout)
95 MSG_IMAGEVIEW_ERROR("Cannot get parent's layout. parent=0x%08x", ugd->parent_layout);
99 PERF_CHECK_BEGIN(LVL1 "main_init");
101 if (!ivug_main_init(ug))
103 MSG_IMAGEVIEW_ERROR("ivug_main_init error");
106 PERF_CHECK_END(LVL1 "main_init");
108 PERF_CHECK_BEGIN(LVL1 "parse bundle");
110 ugd->ivug_param = ivug_param_create_from_bundle(data);
111 if ( ugd->ivug_param == NULL )
113 MSG_IMAGEVIEW_ERROR("Cannot parse parameter");
114 ivug_main_deinit(ug);
117 PERF_CHECK_END(LVL1 "parse bundle");
120 if (mode == UG_MODE_FULLVIEW)
122 MSG_IMAGEVIEW_MED("create base layout for FullView");
123 ugd->base = create_fullview(ug_get_window(), ugd);
127 MSG_IMAGEVIEW_MED("create base layout for FrameView");
128 ugd->base = create_frameview(ug_get_window(), ugd);
131 if ( ugd->base == NULL )
133 MSG_IMAGEVIEW_ERROR("Cannot create base view");
137 if(ugd->ivug_param->mode == IVUG_MODE_SETAS)
139 MSG_IMAGEVIEW_HIGH("UG types=%d", ugd->ivug_param->setas_type);
141 if(ugd->ivug_param->setas_type == IVUG_SET_AS_UG_TYPE_WALLPAPER)
143 // From Wall paper in Setting
144 ugd->setas_view = ivug_setas_view_screen_ug_create(ugd->base, ugd->ivug_param->filepath);
148 MSG_IMAGEVIEW_ERROR("Invalid SetAS UG Type:%d", ugd->ivug_param->setas_type);
152 if(ugd->setas_view == NULL)
154 MSG_IMAGEVIEW_ERROR("SetAS UG creation failed Type:%d", ugd->ivug_param->setas_type);
155 ivug_main_deinit(ug);
158 evas_object_del(ugd->base);
164 Evas_Object *layout = ivug_setas_view_object_get(ugd->setas_view);
166 elm_object_part_content_set(ugd->base, "elm.swallow.content", layout); //swallow
167 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
169 evas_object_show(layout);
173 PERF_CHECK_BEGIN(LVL1 "main_view_create");
175 ugd->main_view = ivug_main_view_create(ugd->base, ugd->ivug_param->mode, ugd->ivug_param->view_by);
177 if (ugd->main_view == NULL) //set main view.
179 MSG_IMAGEVIEW_ERROR("Main View Layout Lading Fail");
180 ivug_main_deinit(ug);
183 evas_object_del(ugd->base);
189 PERF_CHECK_END(LVL1 "main_view_create");
192 if ( ivug_main_view_load_list(ugd->main_view, ugd->ivug_param) == false)
194 MSG_IMAGEVIEW_ERROR("Cannot load media list.");
196 ivug_main_deinit(ug);
199 evas_object_del(ugd->base);
206 Evas_Object *layout = ivug_main_view_object_get(ugd->main_view);
208 elm_object_part_content_set(ugd->base, "elm.swallow.content", layout); //swallow
209 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
211 evas_object_show(layout);
215 PERF_CHECK_END("On Create");
220 static void on_start(struct ui_gadget *ug, bundle *data, void *priv)
222 MSG_IMAGEVIEW_HIGH("Image Viewer : %s", __func__);
225 static void on_pause(struct ui_gadget *ug, bundle *data, void *priv)
227 MSG_IMAGEVIEW_HIGH("Image Viewer : %s", __func__);
231 MSG_IMAGEVIEW_ERROR("Invalid UG. UG=0x%08x Priv=0x%08x", ug, priv);
235 struct ug_data *ugd = (struct ug_data *)priv;
237 if ( ugd->main_view )
239 ivug_slider_stop_slide_show(ugd->main_view->slider);
244 static void on_resume(struct ui_gadget *ug, bundle *data, void *priv)
246 MSG_IMAGEVIEW_HIGH("Image Viewer : %s", __func__);
250 IVUG_DEBUG_MSG("Invalid UG. UG=0x%08x Priv=0x%08x", ug, priv);
254 struct ug_data *ugd = (struct ug_data *)priv;
256 if ( ugd->main_view )
258 ivug_main_view_update(ugd->main_view);
260 // ivug_slider_resume_slide_show(ugd->main_view->slider);
265 static void on_destroy(struct ui_gadget *ug, bundle *data, void *priv)
267 MSG_IMAGEVIEW_HIGH("Image Viewer : %s UG=0x%08x", __func__, ug);
269 PERF_CHECK_BEGIN("On Destroy");
273 MSG_IMAGEVIEW_ERROR("Invalid UG. UG=0x%08x Priv=0x%08x", ug, priv);
277 struct ug_data *ugd = (struct ug_data *)priv;
279 MSG_IMAGEVIEW_HIGH("On Destroy : ug=0x%08x", ug);
281 if ( ugd->main_view )
283 ivug_main_view_destroy(ugd->main_view);
284 ugd->main_view = NULL;
289 ivug_setas_view_destroy(ugd->setas_view);
290 ugd->setas_view = NULL;
296 ivug_param_delete(ugd->ivug_param);
297 ugd->ivug_param = NULL;
301 if ( !ivug_main_deinit(ug))
303 MSG_IMAGEVIEW_ERROR("ivug_main_deinit failed");
308 evas_object_del(ugd->base);
312 MSG_IMAGEVIEW_HIGH("Destroyed all ug");
314 PERF_CHECK_END("On Destroy");
319 static void on_message(struct ui_gadget *ug, bundle *msg, bundle *data, void *priv)
321 MSG_IMAGEVIEW_HIGH("Image Viewer : %s UG=0x%08x", __func__, ug); //on message
324 static void on_event(struct ui_gadget *ug, enum ug_event event, bundle *data, void *priv)
328 MSG_IMAGEVIEW_ERROR("Invalid UG. UG=0x%08x Priv=0x%08x", ug, priv);
331 MSG_IMAGEVIEW_HIGH("Image Viewer : %s UG=0x%08x", __func__, ug); //on message
333 //struct ug_data *ugd = (struct ug_data *)priv;
336 case UG_EVENT_LOW_MEMORY:
337 MSG_IMAGEVIEW_HIGH("Get Event : Low Memory");
339 case UG_EVENT_LOW_BATTERY:
340 MSG_IMAGEVIEW_HIGH("Get Event : Low battery");
342 case UG_EVENT_LANG_CHANGE:
343 MSG_IMAGEVIEW_HIGH("Get Event : Language changed");
346 MSG_IMAGEVIEW_ERROR("Unknown event type : %d", event);
351 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
355 MSG_IMAGEVIEW_HIGH("UG_MODULE_INIT");
359 MSG_IMAGEVIEW_ERROR("OPS Pointer is NULL");
363 ugd = calloc(1, sizeof(struct ug_data)); //alloc ug_data memory
366 MSG_IMAGEVIEW_ERROR("Cannot allocate memory.");
372 ops->create = on_create;
373 ops->start = on_start;
374 ops->pause = on_pause;
375 ops->resume = on_resume;
376 ops->destroy = on_destroy;
377 ops->message = on_message;
378 ops->event = on_event;
380 ops->opt = UG_OPT_INDICATOR_ENABLE;
385 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
390 MSG_IMAGEVIEW_ERROR("OPS Pointer is NULL");
401 MSG_IMAGEVIEW_HIGH("UG_MODULE_EXIT");
403 PERF_SHOW_RESULT(stdout);
410 #define _CONSTRUCTOR __attribute__ ((constructor))
411 #define _DESTRUCTOR __attribute__ ((destructor))
413 void _CONSTRUCTOR _DLLInit(void)
415 printf("Image Viewer - Called constructor\n");
418 void _DESTRUCTOR _DLLExit(void)
420 printf("Image Viewer - Called destructor\n");
427 /* For detecting undefined symbol */