Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/vlaunch/vlaunch.c

    rbdfdc51c r9e7898e  
    3737#include <stdio.h>
    3838#include <malloc.h>
     39#include <io/pixel.h>
    3940#include <task.h>
     41#include <str.h>
    4042#include <str_error.h>
    4143
     
    6264static int app_launch(const char *app)
    6365{
     66        int rc;
    6467        printf("%s: Spawning %s %s \n", NAME, app, winreg);
    65        
     68
    6669        task_id_t id;
    67         task_wait_t wait;
    68         int rc = task_spawnl(&id, &wait, app, app, winreg, NULL);
     70        task_exit_t texit;
     71        int retval;
     72        rc = task_spawnl(&id, app, app, winreg, NULL);
    6973        if (rc != EOK) {
    7074                printf("%s: Error spawning %s %s (%s)\n", NAME, app,
     
    7276                return -1;
    7377        }
    74        
    75         task_exit_t texit;
    76         int retval;
    77         rc = task_wait(&wait, &texit, &retval);
    78         if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {
     78        rc = task_wait(id, &texit, &retval);
     79        if (rc != EOK || texit != TASK_EXIT_NORMAL) {
    7980                printf("%s: Error retrieving retval from %s (%s)\n", NAME,
    8081                    app, str_error(rc));
    8182                return -1;
    8283        }
    83        
     84
    8485        return retval;
    8586}
    8687
    87 static void on_btn_click(widget_t *widget, void *data)
     88static void on_vterm(widget_t *widget, void *data)
    8889{
    89         const char *app = (const char *) widget_get_data(widget);
    90         app_launch(app);
     90        app_launch("/app/vterm");
     91}
     92
     93static void on_vdemo(widget_t *widget, void *data)
     94{
     95        app_launch("/app/vdemo");
     96}
     97
     98static void on_vlaunch(widget_t *widget, void *data)
     99{
     100        app_launch("/app/vlaunch");
    91101}
    92102
     
    105115       
    106116        winreg = argv[1];
    107         window_t *main_window = window_open(argv[1], NULL,
    108             WINDOW_MAIN | WINDOW_DECORATED | WINDOW_RESIZEABLE, "vlaunch");
     117        window_t *main_window = window_open(argv[1], true, true, "vlaunch", 0, 0);
    109118        if (!main_window) {
    110119                printf("Cannot open main window.\n");
     
    113122       
    114123        pixel_t grd_bg = PIXEL(255, 255, 255, 255);
     124        pixel_t btn_bg = PIXEL(255, 0, 0, 0);
     125        pixel_t btn_fg = PIXEL(255, 240, 240, 240);
     126        pixel_t lbl_bg = PIXEL(255, 255, 255, 255);
     127        pixel_t lbl_fg = PIXEL(255, 0, 0, 0);
    115128       
    116         pixel_t btn_bg = PIXEL(255, 255, 255, 255);
    117         pixel_t btn_fg = PIXEL(255, 186, 186, 186);
    118         pixel_t btn_text = PIXEL(255, 0, 0, 0);
    119        
    120         pixel_t lbl_bg = PIXEL(255, 255, 255, 255);
    121         pixel_t lbl_text = PIXEL(255, 0, 0, 0);
    122        
    123         canvas_t *logo_canvas = create_canvas(NULL, NULL, LOGO_WIDTH, LOGO_HEIGHT,
     129        canvas_t *logo_canvas = create_canvas(NULL, LOGO_WIDTH, LOGO_HEIGHT,
    124130            logo);
    125         label_t *lbl_caption = create_label(NULL, NULL, "Launch application:",
    126             16, lbl_bg, lbl_text);
    127         button_t *btn_vterm = create_button(NULL, "/app/vterm", "vterm",
    128             16, btn_bg, btn_fg, btn_text);
    129         button_t *btn_vcalc = create_button(NULL, "/app/vcalc", "vcalc",
    130             16, btn_bg, btn_fg, btn_text);
    131         button_t *btn_vdemo = create_button(NULL, "/app/vdemo", "vdemo",
    132             16, btn_bg, btn_fg, btn_text);
    133         button_t *btn_vlaunch = create_button(NULL, "/app/vlaunch", "vlaunch",
    134             16, btn_bg, btn_fg, btn_text);
    135         grid_t *grid = create_grid(window_root(main_window), NULL, 1, 6, grd_bg);
     131        label_t *lbl_caption = create_label(NULL, "Launch application:", 16,
     132            lbl_bg, lbl_fg);
     133        button_t *btn_vterm = create_button(NULL, "vterm", 16, btn_bg,
     134            btn_fg);
     135        button_t *btn_vdemo = create_button(NULL, "vdemo", 16, btn_bg,
     136            btn_fg);
     137        button_t *btn_vlaunch = create_button(NULL, "vlaunch", 16, btn_bg,
     138            btn_fg);
     139        grid_t *grid = create_grid(window_root(main_window), 1, 5, grd_bg);
    136140       
    137141        if ((!logo_canvas) || (!lbl_caption) || (!btn_vterm) ||
    138             (!btn_vcalc) || (!btn_vdemo) || (!btn_vlaunch) || (!grid)) {
     142            (!btn_vdemo) || (!btn_vlaunch) || (!grid)) {
    139143                window_close(main_window);
    140144                printf("Cannot create widgets.\n");
     
    142146        }
    143147       
    144         sig_connect(&btn_vterm->clicked, &btn_vterm->widget, on_btn_click);
    145         sig_connect(&btn_vcalc->clicked, &btn_vcalc->widget, on_btn_click);
    146         sig_connect(&btn_vdemo->clicked, &btn_vdemo->widget, on_btn_click);
    147         sig_connect(&btn_vlaunch->clicked, &btn_vlaunch->widget, on_btn_click);
     148        sig_connect(&btn_vterm->clicked, NULL, on_vterm);
     149        sig_connect(&btn_vdemo->clicked, NULL, on_vdemo);
     150        sig_connect(&btn_vlaunch->clicked, NULL, on_vlaunch);
    148151       
    149152        grid->add(grid, &logo_canvas->widget, 0, 0, 1, 1);
    150153        grid->add(grid, &lbl_caption->widget, 0, 1, 1, 1);
    151154        grid->add(grid, &btn_vterm->widget, 0, 2, 1, 1);
    152         grid->add(grid, &btn_vcalc->widget, 0, 3, 1, 1);
    153         grid->add(grid, &btn_vdemo->widget, 0, 4, 1, 1);
    154         grid->add(grid, &btn_vlaunch->widget, 0, 5, 1, 1);
     155        grid->add(grid, &btn_vdemo->widget, 0, 3, 1, 1);
     156        grid->add(grid, &btn_vlaunch->widget, 0, 4, 1, 1);
    155157       
    156         window_resize(main_window, 0, 0, 210, 164 + LOGO_HEIGHT,
    157             WINDOW_PLACEMENT_RIGHT | WINDOW_PLACEMENT_TOP);
     158        window_resize(main_window, 210, 130 + LOGO_HEIGHT);
    158159        window_exec(main_window);
    159160       
Note: See TracChangeset for help on using the changeset viewer.