5 #include <Ecore_Evas.h>
10 /* XXX: replace hardcoded values with runtime information */
11 #define SCREEN_WIDTH 480
12 #define SCREEN_HEIGHT 640
14 /* drawing related stuff */
15 static Ecore_Evas
*ee
;
18 void poweroff(void *data
, Evas
*evas
, Evas_Object
*obj
, void *event
);
19 static void draw_item_border(Evas_Object
*item
);
24 void(*callback
)(void*, Evas
*, Evas_Object
*, void *);
28 { "Power Off", POWEROFF_LOGO
, poweroff
},
31 void poweroff(void *data
, Evas
*evas
, Evas_Object
*item
, void *event
) {
32 draw_item_border(item
);
36 static void bootitem_clicked(void *data
, Evas
*evas
, Evas_Object
*item
, void *event
) {
37 draw_item_border(item
);
38 boot_kernel((BootItem
*)data
);
39 /* XXX: shouldn't be reached, display an error message? */
42 static bool canvas_init(){
43 if (!ecore_init() || !ecore_evas_init())
46 /* XXX: fixed dimensions */
47 if (getenv("DISPLAY"))
48 ee
= ecore_evas_software_x11_new(NULL
, 0, 0, 0, SCREEN_WIDTH
, SCREEN_HEIGHT
);
50 ee
= ecore_evas_fb_new(NULL
, 0, SCREEN_WIDTH
, SCREEN_HEIGHT
);
55 ecore_evas_title_set(ee
, APPNAME
);
56 ecore_evas_borderless_set(ee
, 0);
59 evas
= ecore_evas_get(ee
);
60 evas_font_path_append(evas
, FONT_PATH
);
65 static void draw_item(const char *text
, const char *logo
, void(*callback
)(void*, Evas
*, Evas_Object
*, void *),
66 void *data
, int x
, int y
) {
68 Evas_Object
*ebox
, *elogo
, *etext
;
70 elogo
= evas_object_image_add(evas
);
71 evas_object_image_file_set(elogo
, logo
, NULL
);
72 evas_object_image_fill_set(elogo
, 0, 0, LOGO_WIDTH
, LOGO_HEIGHT
);
73 evas_object_resize(elogo
, LOGO_WIDTH
, LOGO_HEIGHT
);
74 evas_object_show(elogo
);
76 etext
= evas_object_text_add(evas
);
77 evas_object_text_font_set(etext
, FONT
, FONT_SIZE
);
78 evas_object_text_text_set(etext
, text
);
79 evas_object_show(etext
);
81 ebox
= evas_object_box_add(evas
);
82 evas_object_box_align_set(ebox
, 0, 0.5);
83 evas_object_box_padding_set(ebox
, 10, 10);
84 evas_object_move(ebox
, x
, y
);
85 evas_object_resize(ebox
, SCREEN_WIDTH
, LOGO_HEIGHT
);
86 evas_object_box_append(ebox
, elogo
);
87 evas_object_box_append(ebox
, etext
);
88 evas_object_event_callback_add(ebox
, EVAS_CALLBACK_MOUSE_UP
, callback
, data
);
90 evas_object_show(ebox
);
93 static void draw_item_border(Evas_Object
*item
) {
95 Evas_Coord x
, y
, w
, h
;
96 evas_object_geometry_get(item
, &x
, &y
, &w
, &h
);
97 eline
= evas_object_line_add(evas
);
98 evas_object_line_xy_set(eline
, x
, y
, x
+w
, y
);
99 evas_object_show(eline
);
100 eline
= evas_object_line_add(evas
);
101 evas_object_line_xy_set(eline
, x
, y
, x
, y
+h
);
102 evas_object_show(eline
);
103 eline
= evas_object_line_add(evas
);
104 evas_object_line_xy_set(eline
, x
+w
, y
, x
+w
, y
+h
);
105 evas_object_show(eline
);
106 eline
= evas_object_line_add(evas
);
107 evas_object_line_xy_set(eline
, x
, y
+h
, x
+w
, y
+h
);
108 evas_object_show(eline
);
111 int gui(int argc
, char **argv
) {
113 if (!canvas_init()) {
114 eprint("Couldn't init GUI\n");
118 /* search for system images to boot and display them in a list */
119 Eina_List
*l
, *systems
= scan_system();
123 EINA_LIST_FOREACH(systems
, l
, s
) {
124 draw_item(s
->dev
, s
->logo
, bootitem_clicked
, s
, 0, y
);
128 /* add pre defined menu entries */
129 for (i
= 0; i
< countof(menu
); i
++) {
130 draw_item(menu
[i
].text
, menu
[i
].logo
, menu
[i
].callback
, NULL
, 0, y
);
134 ecore_main_loop_begin();