Fix activation of selected entry
[qi-bootmenu.git] / gui.c
blob88fbe47fd48bd7d5ddae96b78c78260773a3bf91
1 static void gui_show_error(const char *errstr, ...) {
2 va_list ap;
4 va_start(ap, errstr);
6 if (gui->error)
7 gui->error(errstr, ap);
9 vfprintf(stderr, errstr, ap);
10 fprintf(stderr, "\n");
11 va_end(ap);
12 }
14 static void gui_item_clicked(void *data, Evas *evas, Evas_Object *item, void *event) {
15 MenuItem *menu = data;
16 if (gui->select) {
17 gui->select(item);
18 /* flush all changes of the whole canvas to the screen.
19 * normally this would be done once the event handler
20 * returns, however in our case this might never happen
21 * because the menu callback could kexec a kernel.
22 */
23 evas_render(evas);
24 }
25 menu->callback(menu->data);
26 if (gui->deselect)
27 gui->deselect(item);
28 }
30 static void poweroff(void *data) {
31 umount_all();
32 system("poweroff");
33 }
35 static void boot_nand(void *data) {
36 BootItem *nand = scan_partition((const char *)data);
37 if (!nand) {
38 gui_show_error("No kernel found in NAND Flash");
39 return;
40 }
42 boot_kernel(nand);
43 }
45 static void gui_bootitem_clicked(void *data) {
46 boot_kernel((BootItem*)data);
47 }
49 static bool gui_init(){
50 if (!ecore_init() || !ecore_evas_init())
51 return false;
53 /* XXX: fixed dimensions */
54 ee = ecore_evas_new(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
56 if (!ee)
57 return false;
59 ecore_evas_title_set(ee, APPNAME);
60 ecore_evas_borderless_set(ee, 0);
61 ecore_evas_show(ee);
63 evas = ecore_evas_get(ee);
64 if (!evas)
65 return false;
67 evas_font_path_append(evas, FONT_PATH);
69 return true;
70 }