]> git.ozlabs.org Git - petitboot/blobdiff - petitboot.c
Allow twin cflags and libs to be explicitly defined
[petitboot] / petitboot.c
index e69353e6b4dbc0bd70300d6d70507a5fd87749f0..e7eff4c91fee02730173febe09c0794e3486cf78 100644 (file)
@@ -14,6 +14,7 @@
 #include <libtwin/twin_png.h>
 
 #include "petitboot.h"
+#include "petitboot-paths.h"
 
 #define _USE_X11
 
@@ -75,6 +76,7 @@ struct _pboot_option
        twin_pixmap_t   *badge;
        twin_pixmap_t   *cache;
        twin_rect_t     box;
+       void            *data;
 };
 
 struct _pboot_device
@@ -399,6 +401,17 @@ static void pboot_rpane_mousetrack(twin_coord_t x, twin_coord_t y)
        pboot_rpane->mouse_target = candidate;
 }
 
+static void pboot_choose_option(void)
+{
+       pboot_device_t *dev = pboot_devices[pboot_dev_sel];
+       pboot_option_t *opt = &dev->options[pboot_rpane->focus_curindex];
+
+       LOG("Selected device %s\n", opt->title);
+
+       /* Give user feedback, make sure errors and panics will be seen */
+       pboot_exec_option(opt->data);
+}
+
 static twin_bool_t pboot_rpane_event (twin_window_t        *window,
                                      twin_event_t          *event)
 {
@@ -411,6 +424,9 @@ static twin_bool_t pboot_rpane_event (twin_window_t     *window,
                pboot_rpane_mousetrack(event->u.pointer.x, event->u.pointer.y);
                return TWIN_TRUE;
        case TwinEventButtonDown:
+               pboot_select_rpane();
+               pboot_rpane_mousetrack(event->u.pointer.x, event->u.pointer.y);
+               pboot_choose_option();
        case TwinEventButtonUp:
                return TWIN_TRUE;
        case TwinEventKeyDown:
@@ -424,6 +440,8 @@ static twin_bool_t pboot_rpane_event (twin_window_t     *window,
                case KEY_LEFT:
                        pboot_select_lpane();
                        return TWIN_TRUE;
+               case KEY_ENTER:
+                       pboot_choose_option();
                default:
                        break;
                }
@@ -436,7 +454,7 @@ static twin_bool_t pboot_rpane_event (twin_window_t     *window,
 
 
 int pboot_add_option(int devindex, const char *title,
-                           const char *subtitle, twin_pixmap_t *badge)
+                    const char *subtitle, twin_pixmap_t *badge, void *data)
 {
        pboot_device_t  *dev;
        pboot_option_t  *opt;
@@ -473,6 +491,7 @@ int pboot_add_option(int devindex, const char *title,
                index * PBOOT_RIGHT_OPTION_STRIDE;
        opt->box.bottom = opt->box.top + PBOOT_RIGHT_OPTION_HEIGHT;
 
+       opt->data = data;
        return index;
 }
 
@@ -845,6 +864,7 @@ static void sigint(int sig)
 int main(int argc, char **argv)
 {
        twin_pixmap_t *pic;
+       const char *background_path;
 
        atexit(exitfunc);
        signal(SIGINT, sigint);
@@ -868,7 +888,8 @@ int main(int argc, char **argv)
 #endif
 
        if (pboot_fbdev != NULL) {
-               pboot_cursor = twin_load_X_cursor("artwork/cursor", 2,
+               char *cursor_path = artwork_pathname("cursor");
+               pboot_cursor = twin_load_X_cursor(cursor_path, 2,
                                                  &pboot_cursor_hx,
                                                  &pboot_cursor_hy);
                if (pboot_cursor == NULL)
@@ -878,8 +899,9 @@ int main(int argc, char **argv)
        }
 
        /* Set background pixmap */
-       LOG("loading background...");
-       pic = twin_png_to_pixmap("artwork/background.png", TWIN_ARGB32);
+       background_path = artwork_pathname("background.png");
+       LOG("loading background: %s...", background_path);
+       pic = twin_png_to_pixmap(background_path, TWIN_ARGB32);
        LOG("%s\n", pic ? "ok" : "failed");
        if (pic)
                twin_screen_set_background(pboot_screen, pic);