3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.0 (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.
17 #include <setting-fileview-main.h>
19 #define SETTING_FILEVIEW_LEN 20
21 static int setting_fileview_create(void *cb);
22 static int setting_fileview_destroy(void *cb);
23 static int setting_fileview_update(void *cb);
24 static int setting_fileview_cleanup(void *cb);
26 setting_view setting_view_fileview_main = {
27 .create = setting_fileview_create,
28 .destroy = setting_fileview_destroy,
29 .update = setting_fileview_update,
30 .cleanup = setting_fileview_cleanup,
33 /* ***************************************************
37 ***************************************************/
39 static Eina_Bool __web_on_idle(void *data)
42 SettingFileviewUG *ad = (SettingFileviewUG *) data;
43 if (ad->progress_bar) {
44 evas_object_del(ad->progress_bar);
45 ad->progress_bar = NULL;
50 static void __setting_fileview_policy_navigation_decide(void *data, Evas_Object *webview, void *event_info)
53 setting_retm_if(data == NULL, "data is NULL");
54 setting_retm_if(event_info == NULL, "event_info is NULL");
56 //SettingFileviewUG *ad = (SettingFileviewUG *)data;
58 // open url in local window
59 Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info;
61 char *url = (char *)ewk_policy_decision_url_get(policy_decision);
62 char *scheme = (char *)ewk_policy_decision_scheme_get(policy_decision);
63 SETTING_TRACE("url : %s", url);
64 SETTING_TRACE("scheme : %s", scheme);
66 /* if not launch broswer, do not call ewk_policy_decision_ignore */
67 //ewk_policy_decision_ignore(policy_decision);
70 static int setting_fileview_create(void *cb)
73 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
75 SettingFileviewUG *ad = (SettingFileviewUG *) cb;
77 Evas_Object *scroller;
78 //ad->progress_bar = setting_create_popup_with_progressbar(ad, ad->win_get, "pending_list", NULL, NULL, NULL, 0, TRUE, TRUE);
80 ad->ly_main = setting_create_layout_navi_bar_scroller(ad->win_main_layout,
82 _(ad->input_title),//_("IDS_ST_BODY_OPEN_SOURCE_LICENCES"),
83 _("IDS_COM_BODY_BACK"),
85 setting_fileview_click_back_cb,
89 Evas *evas = evas_object_evas_get(ad->win_get);
90 Evas_Object *webview = ewk_view_add(evas);
93 SETTING_TRACE("ad->input_file:%s", ad->input_file);
94 ewk_view_url_set(webview, ad->input_file);
96 elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE);
98 elm_object_content_set(scroller, webview);
99 evas_object_show(webview);
100 //ecore_idler_add(__web_on_idle, ad);
102 evas_object_smart_callback_add(webview, "policy,navigation,decide", __setting_fileview_policy_navigation_decide, ad);
105 if (service_create(&svc)) {
106 return SETTING_RETURN_FAIL;
109 setting_view_fileview_main.is_create = 1;
110 service_destroy(svc);
112 return SETTING_RETURN_SUCCESS;
115 static int setting_fileview_destroy(void *cb)
119 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
120 SettingFileviewUG *ad = (SettingFileviewUG *) cb;
121 evas_object_smart_callback_del(ad->webkit, "policy,navigation,decide", __setting_fileview_policy_navigation_decide);
124 evas_object_del(ad->webkit);
128 if (ad->progress_bar) {
129 evas_object_del(ad->progress_bar);
130 ad->progress_bar = NULL;
133 if (ad->ly_main != NULL) {
134 evas_object_del(ad->ly_main);
136 setting_view_fileview_main.is_create = 0;
139 return SETTING_RETURN_SUCCESS;
142 static int setting_fileview_update(void *cb)
145 SettingFileviewUG *ad = (SettingFileviewUG *) cb;
147 if (ad->ly_main != NULL) {
148 evas_object_show(ad->ly_main);
150 return SETTING_RETURN_SUCCESS;
154 static int setting_fileview_cleanup(void *cb)
157 SettingFileviewUG *ad = (SettingFileviewUG *) cb;
159 if (ad->ly_main != NULL) {
160 evas_object_hide(ad->ly_main);
162 return SETTING_RETURN_SUCCESS;
165 /* ***************************************************
169 ***************************************************/
172 setting_fileview_click_back_cb(void *data, Evas_Object *obj,
176 setting_retm_if(data == NULL, " Data parameter is NULL");
178 SettingFileviewUG *ad = (SettingFileviewUG *) data;
179 /* Send destroy request */
180 ug_destroy_me(ad->ug);