4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include <setting-applications-defaultapp.h>
23 #include <dbus/dbus.h>
24 #include <dbus/dbus-glib-lowlevel.h>
27 static int setting_applications_defaultapp_create(void *cb);
28 static int setting_applications_defaultapp_destroy(void *cb);
29 static int setting_applications_defaultapp_update(void *cb);
30 static int setting_applications_defaultapp_cleanup(void *cb);
32 static void setting_applications_defaultapp_click_softkey_cancel_cb(void *data, Evas_Object *obj, void *event_info);
33 static void setting_applications_defaultapp_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info);
35 static gboolean setting_applications_create_homescreen_setting_ug(void *data);
37 setting_view setting_view_applications_defaultapp = {
38 .create = setting_applications_defaultapp_create,
39 .destroy = setting_applications_defaultapp_destroy,
40 .update = setting_applications_defaultapp_update,
41 .cleanup = setting_applications_defaultapp_cleanup,
43 /* ***************************************************
47 ***************************************************/
48 static void _indicator_free(char *str)
53 void construct_defaultapp(void *data, Evas_Object *genlist)
57 SettingApplicationsUG *ad = (SettingApplicationsUG *) data;
60 setting_create_Gendial_field_def(genlist, &(ad->itc_2text_2),
61 setting_applications_defaultapp_mouse_up_Gendial_list_cb,
62 ad, SWALLOW_Type_INVALID, NULL,
66 ad->data_home->userdata = ad;
67 ad->data_home->group_style = SETTING_GROUP_STYLE_TOP;
68 __BACK_POINTER_SET(ad->data_home);
70 SETTING_TRACE_ERROR("ad->data_home is NULL");
75 setting_create_Gendial_field_def(genlist, &(ad->itc_2text_2),
76 setting_applications_defaultapp_mouse_up_Gendial_list_cb,
77 ad, SWALLOW_Type_INVALID, NULL,
80 if (ad->data_message) {
81 ad->data_message->userdata = ad;
82 ad->data_message->group_style = SETTING_GROUP_STYLE_TOP;
83 __BACK_POINTER_SET(ad->data_message);
85 SETTING_TRACE_ERROR("ad->data_message is NULL");
91 void destruct_defaultapp(void *data)
96 SettingApplicationsUG *ad = (SettingApplicationsUG *) data;
98 evas_object_del(ad->popup);
104 static int setting_applications_defaultapp_create(void *cb)
107 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
109 SettingApplicationsUG *ad = (SettingApplicationsUG *) cb;
110 Evas_Object *genlist = elm_genlist_add(ad->win_main_layout);
111 retvm_if(genlist == NULL, SETTING_RETURN_FAIL, "Cannot set scroller object as contento of layout");
112 /*elm_object_style_set(genlist, "dialogue"); */
113 elm_genlist_realization_mode_set(genlist, EINA_TRUE);
114 elm_genlist_clear(genlist); /* first to clear list */
116 setting_push_layout_navi_bar("Default Applications",
117 _("IDS_ST_BUTTON_BACK"), NULL, NULL,
118 setting_applications_defaultapp_click_softkey_cancel_cb,
120 NULL, ad, genlist, ad->navi_bar, NULL);
122 /*ad->genlist = genlist; */
123 evas_object_smart_callback_add(genlist, "realized", __gl_realized_cb, ad);
125 construct_defaultapp(ad, genlist);/*------- */
128 setting_view_applications_defaultapp.is_create = 1;
129 return SETTING_RETURN_SUCCESS;
132 static int setting_applications_defaultapp_destroy(void *cb)
137 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
138 retv_if(!(setting_view_applications_defaultapp.is_create), SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
140 destruct_defaultapp(cb);/*------- */
142 SettingApplicationsUG *ad = (SettingApplicationsUG *) cb;
144 setting_view_applications_defaultapp.is_create = 0;
145 elm_naviframe_item_pop(ad->navi_bar);
147 return SETTING_RETURN_SUCCESS;
150 static int setting_applications_defaultapp_update(void *cb)
153 return SETTING_RETURN_SUCCESS;
157 static int setting_applications_defaultapp_cleanup(void *cb)
161 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
162 setting_applications_defaultapp_destroy(cb);
164 return SETTING_RETURN_SUCCESS;
167 /* ***************************************************
171 ***************************************************/
173 /* ***************************************************
177 ***************************************************/
180 setting_applications_defaultapp_click_softkey_cancel_cb(void *data,
186 retm_if(data == NULL, "Data parameter is NULL");
187 SettingApplicationsUG *ad = (SettingApplicationsUG *) data;
189 setting_view_change(&setting_view_applications_defaultapp,
190 &setting_view_applications_main, ad);
193 void setting_applications_defaultapp_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
197 setting_retm_if(data == NULL, "Data parameter is NULL");
199 SettingApplicationsUG *ad = (SettingApplicationsUG *) data;
200 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
201 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
202 elm_genlist_item_selected_set(item, 0);
203 Setting_GenGroupItem_Data *list_item =
204 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
206 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
207 /*SETTING_TRACE("chk_status[%d]", list_item->chk_status); */
208 if (!strcmp(_(list_item->keyStr), "Home")) {
209 SETTING_TRACE("click Home and run UG");
210 setting_applications_create_homescreen_setting_ug(ad);
211 } else if (!strcmp(_(list_item->keyStr), "Messages")) {
212 SETTING_TRACE("click Home and run Message logic - do nothing now.");
216 static void setting_applications_destroy_homescreen_setting_ug_cb(ui_gadget_h ug, void *priv)
219 ret_if(priv == NULL);
220 SettingApplicationsUG *ad = (SettingApplicationsUG *) priv;
222 setting_ug_destroy(ug);
223 ad->ug_homescreen = NULL;
225 elm_genlist_realized_items_update(ad->genlist);
228 static gboolean setting_applications_create_homescreen_setting_ug(void *data)
232 retv_if(data == NULL, FALSE);
234 SettingApplicationsUG *ad = (SettingApplicationsUG *) data; /* ad is point to data */
236 if (ad->ug_homescreen) {
237 SETTING_TRACE("Font UG is already loaded.");
240 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
245 cbs->layout_cb = setting_applications_layout_ug_cb;
246 cbs->result_cb = NULL;
247 cbs->destroy_cb = setting_applications_destroy_homescreen_setting_ug_cb;
248 cbs->priv = (void *)ad;
250 elm_object_tree_focus_allow_set(ad->ly_main, EINA_FALSE);
252 ad->ug_homescreen = setting_ug_create(ad->ug, "setting-homescreen-efl", UG_MODE_FULLVIEW, NULL, cbs);
253 if (NULL == ad->ug_homescreen) { /* error handling */
254 SETTING_TRACE_ERROR("NULL == ad->ug_homescreen");
255 evas_object_show(ad->ly_main);