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.
17 #include <app_service.h>
18 #include "ge-ext-ug-load.h"
20 #include "ge-ui-util.h"
22 #include "ge-albums.h"
23 #include "ge-gridview.h"
25 #define GE_IV_UG_NAME "image-viewer-efl"
27 static bool ge_destroy_me = false;
29 static void _ge_ext_destroy_me(ge_ugdata *ugd)
33 GE_CHECK(ugd->ug_called_by_me);
35 GE_CHECK(ugd->bundle);
36 bool send_result = false;
43 if(ge_destroy_me == false)
45 ug_destroy(ugd->ug_called_by_me);
46 ugd->ug_called_by_me = NULL;
48 if(ugd->file_select_mode == GE_File_Select_Setas)
50 if(ugd->file_setas_image_path)
52 ge_dbg("GE_SETAS_IMAGE_PATH:%s", ugd->file_setas_image_path);
53 bundle_add(ugd->bundle, GE_SETAS_IMAGE_PATH, ugd->file_setas_image_path);
55 free(ugd->file_setas_image_path);
56 ugd->file_setas_image_path = NULL;
60 if(ugd->file_setas_crop_image_path &&
61 ugd->file_select_setas_mode == GE_File_Select_Setas_CallerID)
63 ge_dbg("GE_SETAS_CALLERID_CROP_IMAGE_PATH:%s", ugd->file_setas_crop_image_path);
64 bundle_add(ugd->bundle, GE_SETAS_CALLERID_CROP_IMAGE_PATH, ugd->file_setas_crop_image_path);
66 free(ugd->file_setas_crop_image_path);
67 ugd->file_setas_crop_image_path = NULL;
73 ge_dbg("Call ug_send_result() to send result.");
74 ug_send_result(ugd->ug, ugd->bundle);
80 ge_dbg("Seting is appllied, destroy gallery UG.");
81 ge_destroy_me = false;
82 ug_destroy_me(ugd->ug);//close selection ug
83 ugd->ug_called_by_me = NULL;
87 ge_dbg("Cancel button tapped, back to thumbnails view.");
91 static void _ge_ext_iv_layout_cb(struct ui_gadget *ug, enum ug_mode mode, void* priv)
97 Evas_Object *base = (Evas_Object *) ug_get_layout(ug);
104 ge_ugdata *ugd = (ge_ugdata *)priv;
106 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
107 elm_win_resize_object_add(ugd->win, base);
108 evas_object_show(base);
111 static void _ge_ext_iv_result_cb(struct ui_gadget *ug, bundle *result, void *priv)
116 ge_ugdata *ugd = (ge_ugdata *)priv;
117 const char* path = NULL;
119 if(ugd->file_select_mode == GE_File_Select_Setas)
121 path = bundle_get_val(result, GE_IMAGEVIEWER_IMAGE_PATH);
122 ge_dbg("SETAS_IMAGE_PATH");
123 ge_destroy_me = true;
127 ugd->file_setas_image_path = strdup(path);
130 if(ugd->file_select_setas_mode == GE_File_Select_Setas_CallerID)
132 path = bundle_get_val(result, GE_IMAGEVIEWER_CROP_IMAGE_PATH);
133 ge_dbg("CALLERID_CROP_IMAGE_PATH");
137 ugd->file_setas_crop_image_path = strdup(path);
142 const char *error_state = bundle_get_val(result, GE_IMAGEVIEWER_RETURN_ERROR);
145 ge_dbg("error string : %s", error_state);
147 if (!g_strcmp0(error_state, "not_supported_file_type")) {
148 ge_destroy_me = FALSE;
149 ge_item* cur_item = _ge_get_current_item();
150 if(cur_item == NULL || cur_item->item == NULL ||
151 cur_item->item->file_url == NULL) {
152 ge_dbgE("current item is NULL");
156 service_create(&service);
158 service_set_operation(service, SERVICE_OPERATION_VIEW);
159 service_set_uri(service, cur_item->item->file_url);
160 service_send_launch_request(service, NULL, NULL);
161 service_destroy(service);
166 static void _ge_ext_iv_destroy_cb(struct ui_gadget *ug, void *priv)
170 ge_ugdata *ad = (ge_ugdata *) priv;
172 _ge_ext_destroy_me(ad);
175 int ge_ext_load_iv_ug(ge_ugdata* ugd)
178 GE_CHECK_VAL(ugd, -1);
181 struct ui_gadget* ug = NULL;
182 bundle* param = NULL;
184 if(ugd->ug_called_by_me)
186 ge_dbg("Already exits some UG called by me");
190 ge_item* cur_item = _ge_get_current_item();
191 if(cur_item == NULL || cur_item->item == NULL)
193 ge_dbg("current item is NULL");
196 memset(&cbs,0x00,sizeof(struct ug_cbs));
197 cbs.layout_cb = _ge_ext_iv_layout_cb;
198 cbs.result_cb = _ge_ext_iv_result_cb;
199 cbs.destroy_cb = _ge_ext_iv_destroy_cb;
202 param = bundle_create();
203 GE_CHECK_VAL(param, -1);
207 bundle_add(param, "View Mode", "SETAS" );
208 bundle_add(param, "Path", cur_item->item->file_url);
210 if(ugd->file_select_setas_mode == GE_File_Select_Setas_Wallpaper)
212 bundle_add(param, "Setas type", "Wallpaper");
214 if(ugd->file_setas_homescreen_path)
216 ge_dbg("homescreen_path:%s", ugd->file_setas_homescreen_path);
217 bundle_add(param, GE_IMAGEVIEWER_HOMESCREEN_PATH, ugd->file_setas_homescreen_path);
218 free(ugd->file_setas_homescreen_path);
219 ugd->file_setas_homescreen_path = NULL;
222 if(ugd->file_setas_lockscreen_path)
224 ge_dbg("lockscreen_path:%s", ugd->file_setas_lockscreen_path);
225 bundle_add(param, GE_IMAGEVIEWER_LOCKSCREEN_PATH, ugd->file_setas_lockscreen_path);
226 free(ugd->file_setas_lockscreen_path);
227 ugd->file_setas_lockscreen_path = NULL;
230 else if(ugd->file_select_setas_mode == GE_File_Select_Setas_CallerID)
232 bundle_add(param, "Setas type", "CallerID");
233 if(ugd->file_setas_callid_size)
235 ge_dbg("callerid_size:%s", ugd->file_setas_callid_size);
236 bundle_add(param, GE_IMAGEVIEWER_CALLERID_SIZE, ugd->file_setas_callid_size);
237 free(ugd->file_setas_callid_size);
238 ugd->file_setas_callid_size = NULL;
241 if(ugd->file_setas_callid_path)
243 ge_dbg("callerid_path:%s", ugd->file_setas_callid_path);
244 bundle_add(param, GE_IMAGEVIEWER_CALLERID_PATH, ugd->file_setas_callid_path);
245 free(ugd->file_setas_callid_path);
246 ugd->file_setas_callid_path = NULL;
249 ug = ug_create(ugd->ug, GE_IV_UG_NAME, UG_MODE_FULLVIEW, param, &cbs);
250 ugd->ug_called_by_me = ug;