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);
91 ErrPrint("Failed to create a list\n");
95 evas_object_resize(list, 720, 1280);
96 evas_object_show(list);
98 DbgPrint("Get Package list\n");
99 livebox_service_get_pkglist(append_livebox_cb, list);
102 scroller_append(s_info.scroller, list);
105 static bool app_create(void *data)
111 s_info.window = elm_win_add(NULL, "Box viewer", ELM_WIN_BASIC);
112 if (!s_info.window) {
113 ErrPrint("Failed to create a window\n");
116 elm_win_autodel_set(s_info.window, EINA_TRUE);
118 evas_object_resize(s_info.window, 720, 1280);
119 evas_object_show(s_info.window);
121 bg = elm_bg_add(s_info.window);
122 elm_win_resize_object_add(s_info.window, bg);
123 elm_bg_color_set(bg, 0, 0, 255);
124 evas_object_show(bg);
126 s_info.scroller = scroller_create(s_info.window);
127 if (!s_info.scroller) {
128 evas_object_del(s_info.window);
129 s_info.window = NULL;
130 ErrPrint("Failed to create a scroller\n");
134 evas_object_resize(s_info.scroller, 720, 1280);
135 evas_object_show(s_info.scroller);
137 livebox_list_create();
142 static void app_terminate(void *data)
144 DbgPrint("terminate");
148 * Delete all objects from the scroller.
151 scroller_destroy(s_info.scroller);
152 evas_object_del(s_info.window);
153 s_info.window = NULL;
156 static void app_pause(void *data)
161 static void app_resume(void *data)
166 static void app_reset(service_h service, void *data)
171 int main(int argc, char *argv[])
173 app_event_callback_s event_callback;
175 setenv("ELM_ENGINE", "gl", 0);
176 event_callback.create = app_create;
177 event_callback.terminate = app_terminate;
178 event_callback.pause = app_pause;
179 event_callback.resume = app_resume;
180 event_callback.service = app_reset;
181 event_callback.low_memory = NULL;
182 event_callback.low_battery = NULL;
183 event_callback.device_orientation = NULL;
184 event_callback.language_changed = NULL;
186 return app_efl_main(&argc, &argv, &event_callback, NULL);