2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.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 <ui-gadget.h>
20 #include "homescreen-setting-main.h"
21 #include "homescreen-setting-data.h"
22 #include "homescreen-setting-type.h"
24 static Elm_Genlist_Item_Class itc_seperator, itc_type;
26 struct ug_data *g_ug_data = NULL;
36 MAIN_GROUP_HOMESCREEN = 0,
39 typedef struct _homescreen_setting_main homescreen_setting_main_t;
40 struct _homescreen_setting_main
48 static void _homescreen_setting_main_back_cb(void *data, Evas_Object * obj, void *event_info)
51 struct ug_data *ugd = (struct ug_data *) data;
56 ug_destroy_me(ugd->ug);
59 static char *_homescreen_setting_main_gl_text_get(void *data, Evas_Object *obj, const char *part)
61 homescreen_setting_main_t *main_data = (homescreen_setting_main_t *) data;
63 if (main_data == NULL)
65 HOMESET_ERR("invalid data");
69 if (!strcmp(part, "elm.text.1"))
71 if (main_data->index == MAIN_INDEX_TYPE && main_data->text1 != NULL)
73 return strdup(main_data->text1);
76 else if (!strcmp(part, "elm.text.2"))
78 if (main_data->index == MAIN_INDEX_TYPE)
82 free(main_data->text2);
85 char *homeapp = homescreen_setting_data_get_selected_homeapp();
88 if (!strcmp(homeapp, HOMESCREEN_SETTING_DEFAULT_PKGNAME))
90 main_data->text2 = strdup(HOMESET_TEXT("IDS_ST_BODY_DEFAULT_HOME_SCREEN"));
94 main_data->text2 = homescreen_setting_data_get_name(homeapp);
101 main_data->text2 = strdup(HOMESET_TEXT("IDS_ST_BODY_DEFAULT_HOME_SCREEN"));
104 return strdup(main_data->text2);
111 static void _homescreen_setting_main_gl_del(void *data, Evas_Object *obj)
114 homescreen_setting_main_t *main_data = (homescreen_setting_main_t *) data;
116 if (main_data == NULL)
118 HOMESET_ERR("invalid data");
123 if (main_data->text1 != NULL)
125 free(main_data->text1);
128 if (main_data->text2 != NULL)
130 free(main_data->text2);
136 static void _homescreen_setting_main_gl_sel(void *data, Evas_Object *obj, void *event_info)
138 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
141 HOMESET_ERR("invalid item data");
145 elm_genlist_item_selected_set(item, EINA_FALSE);
147 homescreen_setting_main_t *main_data = (homescreen_setting_main_t *) elm_object_item_data_get(item);
148 if (main_data == NULL)
150 HOMESET_ERR("invalid main data");
154 struct ug_data *ugd = (struct ug_data *) data;
157 HOMESET_ERR("invalid ug data");
161 if (main_data->index == MAIN_INDEX_TYPE)
163 /* change home screen type view */
164 homescreen_setting_type_create_view(ugd);
168 static Evas_Object* _homescreen_setting_main_add_genlist(struct ug_data *ugd)
170 Evas_Object *genlist;
173 genlist = elm_genlist_add(ugd->naviframe);
174 elm_object_style_set(genlist, "dialogue");
176 /* dialogue for seperator */
177 itc_seperator.item_style = "dialogue/separator";
178 itc_seperator.func.text_get = NULL;
179 itc_seperator.func.content_get = NULL;
180 itc_seperator.func.state_get = NULL;
181 itc_seperator.func.del = NULL;
183 it = elm_genlist_item_append(genlist, &itc_seperator, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
184 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
186 /* dialogue for type */
187 itc_type.item_style = "dialogue/2text.3";
188 itc_type.func.text_get = _homescreen_setting_main_gl_text_get;
189 itc_type.func.content_get = NULL;
190 itc_type.func.state_get = NULL;
191 itc_type.func.del = _homescreen_setting_main_gl_del;
193 homescreen_setting_main_t *main_data = (homescreen_setting_main_t *) malloc(sizeof(homescreen_setting_main_t));
194 if (main_data != NULL)
196 main_data->index = MAIN_INDEX_TYPE;
197 main_data->group = MAIN_GROUP_HOMESCREEN;
198 main_data->text1 = strdup(HOMESET_TEXT("IDS_ST_BODY_HOME_SCREEN_TYPE"));
199 main_data->text2 = strdup(HOMESET_TEXT("IDS_ST_BODY_DEFAULT_HOME_SCREEN"));
201 elm_genlist_item_append(genlist, &itc_type, (void *) main_data, NULL, ELM_GENLIST_ITEM_NONE, _homescreen_setting_main_gl_sel, ugd);
207 void homescreen_setting_main_create_view(void *data)
209 HOMESET_DBG("create main view");
210 struct ug_data *ugd = (struct ug_data *) data;
213 HOMESET_ERR("invalid ugd");
220 Evas_Object *genlist = _homescreen_setting_main_add_genlist(ugd);
221 g_ug_data->genlist_main = genlist;
224 Evas_Object *button = elm_button_add(ugd->naviframe);
225 elm_object_style_set(button, "naviframe/end_btn/default");
226 evas_object_smart_callback_add(button, "clicked", _homescreen_setting_main_back_cb, ugd);
228 /* Push to naviframe */
229 elm_naviframe_item_push(ugd->naviframe, HOMESET_TEXT("IDS_ST_HEADER_HOME_SCREEN"), button, NULL, genlist, NULL);