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 <Elementary.h>
25 #include <livebox-service.h>
35 Evas_Object *scroller;
41 Evas_Object *main_get_window(void)
46 static void click_cb(void *data, Evas_Object *obj, void *event_info)
48 Elm_Object_Item *item;
51 item = elm_list_selected_item_get(obj);
55 label = elm_object_item_part_text_get(item, NULL);
59 DbgPrint("Label: %s (%s)\n", label, data);
60 if (lb_add(s_info.scroller, data) < 0)
61 ErrPrint("Failed to add a new livebox\n");
64 static int append_livebox_cb(const char *appid, const char *lbid, int is_prime, void *data)
68 DbgPrint("%s - %s\n", appid, lbid);
70 name = livebox_service_i18n_name(lbid, NULL);
74 ErrPrint("Heap: %s\n", strerror(errno));
79 DbgPrint("Name: %s\n", name);
80 elm_list_item_append(data, name, NULL, NULL, click_cb, strdup(lbid));
85 static inline void livebox_list_create(void)
89 list = elm_list_add(s_info.window);
90 evas_object_resize(list, 720, 1000);
91 evas_object_show(list);
93 DbgPrint("Get Package list\n");
94 livebox_service_get_pkglist(append_livebox_cb, list);
95 scroller_append(s_info.scroller, list);
99 static bool app_create(void *data)
102 Evas_Object *conformant;
107 s_info.window = elm_win_add(NULL, "Box viewer", ELM_WIN_BASIC);
108 if (!s_info.window) {
109 ErrPrint("Failed to create a window\n");
112 elm_win_autodel_set(s_info.window, EINA_TRUE);
114 bg = elm_bg_add(s_info.window);
115 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
116 elm_win_resize_object_add(s_info.window, bg);
117 evas_object_show(bg);
119 evas_object_resize(s_info.window, 720, 1280);
120 evas_object_show(s_info.window);
122 conformant = elm_conformant_add(s_info.window);
123 evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
124 elm_win_resize_object_add(s_info.window, conformant);
125 evas_object_show(conformant);
127 box = elm_box_add(s_info.window);
128 s_info.scroller = scroller_create(s_info.window);
129 if (!s_info.scroller) {
130 evas_object_del(s_info.window);
131 s_info.window = NULL;
132 ErrPrint("Failed to create a scroller\n");
135 livebox_list_create();
136 evas_object_size_hint_min_set(s_info.scroller, 720, 1000);
137 evas_object_resize(s_info.scroller, 720, 1000);
138 evas_object_show(s_info.scroller);
140 elm_box_pack_end(box, s_info.scroller);
141 evas_object_size_hint_min_set(box, 720, 1000);
142 evas_object_resize(box, 720, 1000);
143 evas_object_show(box);
145 elm_object_content_set(conformant, box);
146 elm_win_indicator_mode_set(s_info.window, ELM_WIN_INDICATOR_SHOW);
151 static void app_terminate(void *data)
153 DbgPrint("terminate");
157 * Delete all objects from the scroller.
160 scroller_destroy(s_info.scroller);
161 evas_object_del(s_info.window);
162 s_info.window = NULL;
165 static void app_pause(void *data)
170 static void app_resume(void *data)
175 static void app_reset(service_h service, void *data)
180 int main(int argc, char *argv[])
182 app_event_callback_s event_callback;
184 setenv("ELM_ENGINE", "gl", 0);
185 event_callback.create = app_create;
186 event_callback.terminate = app_terminate;
187 event_callback.pause = app_pause;
188 event_callback.resume = app_resume;
189 event_callback.service = app_reset;
190 event_callback.low_memory = NULL;
191 event_callback.low_battery = NULL;
192 event_callback.device_orientation = NULL;
193 event_callback.language_changed = NULL;
195 return app_efl_main(&argc, &argv, &event_callback, NULL);