4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.1 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://floralicense.org/license/
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include <ui-gadget.h>
21 #include "pts_common.h"
22 #include "pts_main_view.h"
23 #include "image_editor_conn.h"
25 #define IMAGE_EDITOR_STR_MAX_LEN 64
27 extern int size_index;
29 void image_editor_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
35 base = (Evas_Object *) ug_get_layout(ug);
36 win = ug_get_window();
37 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
38 elm_win_resize_object_add(win, base);
40 /* Disable effect to avoid BS caused by ui-gadget to
41 unset ug layout after deleting it */
42 ug_disable_effect(ug);
43 evas_object_show(base);
48 void image_editor_result_cb(ui_gadget_h ug, service_h result, void *priv)
51 pts_appdata_t *ad = (pts_appdata_t *)priv;
52 PTS_RET_IF(ad == NULL, "ad is NULL");
56 ret = service_get_extra_data(result, "crop_image_path", &path);
57 PTS_RET_IF(ret != SERVICE_ERROR_NONE, "Failed to get crop_image_path(%d)", ret);
58 PTS_RET_IF(path == NULL, "path is NULL");
61 PTS_IF_FREE_MEM(ad->printing_data.request_files[0]);
62 ad->printing_data.request_files[0] = strdup(path);
63 PTS_DEBUG("crop_image_path: %s", path);
64 pts_main_view_rotate_image(ad, app_get_device_orientation());
65 size_index = ad->size_popup_info.image_size; // When crop is done, then save the index.
71 void image_editor_destroy_cb(ui_gadget_h ug, void *priv)
74 pts_appdata_t *ad = (pts_appdata_t *)priv;
75 PTS_RET_IF(ad == NULL || ug == NULL, "Invalid argument");
81 int load_image_editor_ug(pts_appdata_t *ad)
84 PTS_RETV_IF(ad == NULL, -1, "ad is NULL");
86 struct ug_cbs image_editor_cbs;
87 ui_gadget_h ug = NULL;
88 service_h service = NULL;
89 char reso_str[IMAGE_EDITOR_STR_MAX_LEN + 1];
93 switch (ad->size_popup_info.image_size) {
94 case PTS_SIZE_FIT_TO_PAPER:
105 case PTS_SIZE_WALLET:
108 case PTS_SIZE_CUSTOM:
109 w = w * (ad->size_popup_info.custom_width / ad->size_popup_info.custom_height);
110 PTS_DEBUG("Passed custom ratio : %dx%d", w, h);
116 memset(&image_editor_cbs,0x00,sizeof(struct ug_cbs));
117 image_editor_cbs.layout_cb = image_editor_layout_cb;
118 image_editor_cbs.result_cb = image_editor_result_cb;
119 image_editor_cbs.destroy_cb = image_editor_destroy_cb;
120 image_editor_cbs.priv = ad;
122 service_create(&service);
123 service_add_extra_data(service, "View Mode", "SETAS");
124 service_add_extra_data(service, "Path", ad->printing_data.input_file);
125 service_add_extra_data(service, "Setas type", "Crop");
126 service_add_extra_data(service, "Fixed ratio", "TRUE");
128 snprintf(reso_str, IMAGE_EDITOR_STR_MAX_LEN, "%dx%d", w, h);
129 service_add_extra_data(service, "Resolution", reso_str);
130 PTS_DEBUG("Passed resolution : %s", reso_str);
132 ug_create(ug, "image-viewer-efl", UG_MODE_FULLVIEW, service, &image_editor_cbs);
133 service_destroy(service);