Changeset 10cb47e in mainline for uspace/app/vlaunch/vlaunch.c


Ignore:
Timestamp:
2016-08-31T15:43:01Z (8 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bdfdc51c
Parents:
58563585
Message:

add support for custom client data into widgets

File:
1 edited

Legend:

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

    r58563585 r10cb47e  
    8585}
    8686
    87 static void on_vterm(widget_t *widget, void *data)
     87static void on_btn_click(widget_t *widget, void *data)
    8888{
    89         app_launch("/app/vterm");
    90 }
    91 
    92 static void on_vdemo(widget_t *widget, void *data)
    93 {
    94         app_launch("/app/vdemo");
    95 }
    96 
    97 static void on_vlaunch(widget_t *widget, void *data)
    98 {
    99         app_launch("/app/vlaunch");
     89        const char *app = (const char *) widget_get_data(widget);
     90        app_launch(app);
    10091}
    10192
     
    114105       
    115106        winreg = argv[1];
    116         window_t *main_window = window_open(argv[1],
     107        window_t *main_window = window_open(argv[1], NULL,
    117108            WINDOW_MAIN | WINDOW_DECORATED | WINDOW_RESIZEABLE, "vlaunch");
    118109        if (!main_window) {
     
    130121        pixel_t lbl_text = PIXEL(255, 0, 0, 0);
    131122       
    132         canvas_t *logo_canvas = create_canvas(NULL, LOGO_WIDTH, LOGO_HEIGHT,
     123        canvas_t *logo_canvas = create_canvas(NULL, NULL, LOGO_WIDTH, LOGO_HEIGHT,
    133124            logo);
    134         label_t *lbl_caption = create_label(NULL, "Launch application:", 16,
    135             lbl_bg, lbl_text);
    136         button_t *btn_vterm = create_button(NULL, "vterm", 16, btn_bg,
    137             btn_fg, btn_text);
    138         button_t *btn_vdemo = create_button(NULL, "vdemo", 16, btn_bg,
    139             btn_fg, btn_text);
    140         button_t *btn_vlaunch = create_button(NULL, "vlaunch", 16, btn_bg,
    141             btn_fg, btn_text);
    142         grid_t *grid = create_grid(window_root(main_window), 1, 5, grd_bg);
     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_vdemo = create_button(NULL, "/app/vdemo", "vdemo",
     130            16, btn_bg, btn_fg, btn_text);
     131        button_t *btn_vlaunch = create_button(NULL, "/app/vlaunch", "vlaunch",
     132            16, btn_bg, btn_fg, btn_text);
     133        grid_t *grid = create_grid(window_root(main_window), NULL, 1, 5, grd_bg);
    143134       
    144135        if ((!logo_canvas) || (!lbl_caption) || (!btn_vterm) ||
     
    149140        }
    150141       
    151         sig_connect(&btn_vterm->clicked, NULL, on_vterm);
    152         sig_connect(&btn_vdemo->clicked, NULL, on_vdemo);
    153         sig_connect(&btn_vlaunch->clicked, NULL, on_vlaunch);
     142        sig_connect(&btn_vterm->clicked, &btn_vterm->widget, on_btn_click);
     143        sig_connect(&btn_vdemo->clicked, &btn_vdemo->widget, on_btn_click);
     144        sig_connect(&btn_vlaunch->clicked, &btn_vlaunch->widget, on_btn_click);
    154145       
    155146        grid->add(grid, &logo_canvas->widget, 0, 0, 1, 1);
Note: See TracChangeset for help on using the changeset viewer.