Changeset 24c452b3 in mainline


Ignore:
Timestamp:
2021-11-02T00:24:50Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ce862ac
Parents:
7b11315
Message:

Start Navigator from launcher

Location:
uspace/app/launcher
Files:
2 edited

Legend:

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

    r7b11315 r24c452b3  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * Copyright (c) 2012 Petr Koupy
    44 * All rights reserved.
     
    7070};
    7171
    72 static int app_launch(const char *, const char *);
     72static int app_launchl(const char *, ...);
    7373
    7474/** Window close button was clicked.
     
    9494
    9595        if (pbutton == launcher->pb1) {
    96                 app_launch("/app/terminal", NULL);
     96                app_launchl("/app/terminal", "-c", "/app/nav", NULL);
    9797        } else if (pbutton == launcher->pb2) {
    98                 app_launch("/app/calculator", NULL);
     98                app_launchl("/app/terminal", NULL);
    9999        } else if (pbutton == launcher->pb3) {
    100                 app_launch("/app/uidemo", NULL);
     100                app_launchl("/app/calculator", NULL);
    101101        } else if (pbutton == launcher->pb4) {
    102                 app_launch("/app/gfxdemo", "ui");
     102                app_launchl("/app/uidemo", NULL);
     103        } else if (pbutton == launcher->pb5) {
     104                app_launchl("/app/gfxdemo", "ui", NULL);
    103105        }
    104106}
    105107
    106 static int app_launch(const char *app, const char *arg)
     108static int app_launchl(const char *app, ...)
    107109{
    108110        errno_t rc;
    109111        task_id_t id;
    110112        task_wait_t wait;
    111 
    112         if (display_spec != UI_DISPLAY_DEFAULT) {
    113                 printf("%s: Spawning %s -d %s\n", NAME, app, display_spec);
    114                 rc = task_spawnl(&id, &wait, app, app, "-d", display_spec,
    115                     arg, NULL);
    116         } else {
    117                 printf("%s: Spawning %s\n", NAME, app);
    118                 rc = task_spawnl(&id, &wait, app, app, arg, NULL);
    119         }
    120 
    121         if (rc != EOK) {
    122                 printf("%s: Error spawning %s %s (%s)\n", NAME, app,
    123                     display_spec != DISPLAY_DEFAULT ? display_spec :
    124                     "<default>", str_error(rc));
     113        va_list ap;
     114        const char *arg;
     115        const char **argv;
     116        const char **argp;
     117        int cnt = 0;
     118        int i;
     119
     120        va_start(ap, app);
     121        do {
     122                arg = va_arg(ap, const char *);
     123                cnt++;
     124        } while (arg != NULL);
     125        va_end(ap);
     126
     127        argv = calloc(cnt + 4, sizeof(const char *));
     128        if (argv == NULL)
    125129                return -1;
    126         }
    127130
    128131        task_exit_t texit;
    129132        int retval;
     133
     134        argp = argv;
     135        *argp++ = app;
     136
     137        if (display_spec != UI_DISPLAY_DEFAULT) {
     138                *argp++ = "-d";
     139                *argp++ = display_spec;
     140        }
     141
     142        va_start(ap, app);
     143        do {
     144                arg = va_arg(ap, const char *);
     145                *argp++ = arg;
     146        } while (arg != NULL);
     147        va_end(ap);
     148
     149        *argp++ = NULL;
     150
     151        printf("%s: Spawning %s", NAME, app);
     152        for (i = 0; argv[i] != NULL; i++) {
     153                printf(" %s", argv[i]);
     154        }
     155        printf("\n");
     156
     157        rc = task_spawnv(&id, &wait, app, argv);
     158        if (rc != EOK) {
     159                printf("%s: Error spawning %s (%s)\n", NAME, app, str_error(rc));
     160                return -1;
     161        }
     162
    130163        rc = task_wait(&wait, &texit, &retval);
    131164        if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {
     
    189222        params.rect.p0.y = 0;
    190223        params.rect.p1.x = 210;
    191         params.rect.p1.y = 300;
     224        params.rect.p1.y = 310;
    192225
    193226        memset((void *) &launcher, 0, sizeof(launcher));
     
    263296        }
    264297
    265         rc = ui_pbutton_create(ui_res, "Terminal", &launcher.pb1);
     298        /* Navigator */
     299
     300        rc = ui_pbutton_create(ui_res, "Navigator", &launcher.pb1);
    266301        if (rc != EOK) {
    267302                printf("Error creating button.\n");
     
    274309        rect.p0.y = 130;
    275310        rect.p1.x = 190;
    276         rect.p1.y = 158;
     311        rect.p1.y = rect.p0.y + 28;
    277312        ui_pbutton_set_rect(launcher.pb1, &rect);
    278313
     
    283318        }
    284319
    285         rc = ui_pbutton_create(ui_res, "Calculator", &launcher.pb2);
     320        /* Terminal */
     321
     322        rc = ui_pbutton_create(ui_res, "Terminal", &launcher.pb2);
    286323        if (rc != EOK) {
    287324                printf("Error creating button.\n");
     
    292329
    293330        rect.p0.x = 15;
    294         rect.p0.y = 170;
     331        rect.p0.y = 130 + 35;
    295332        rect.p1.x = 190;
    296         rect.p1.y = 198;
     333        rect.p1.y = rect.p0.y + 28;
    297334        ui_pbutton_set_rect(launcher.pb2, &rect);
    298335
     
    303340        }
    304341
    305         rc = ui_pbutton_create(ui_res, "UI Demo", &launcher.pb3);
     342        /* Calculator */
     343
     344        rc = ui_pbutton_create(ui_res, "Calculator", &launcher.pb3);
    306345        if (rc != EOK) {
    307346                printf("Error creating button.\n");
     
    312351
    313352        rect.p0.x = 15;
    314         rect.p0.y = 210;
     353        rect.p0.y = 130 + 2 * 35;
    315354        rect.p1.x = 190;
    316         rect.p1.y = 238;
     355        rect.p1.y = rect.p0.y + 28;
    317356        ui_pbutton_set_rect(launcher.pb3, &rect);
    318357
     
    323362        }
    324363
    325         rc = ui_pbutton_create(ui_res, "GFX Demo", &launcher.pb4);
     364        /* UI Demo */
     365
     366        rc = ui_pbutton_create(ui_res, "UI Demo", &launcher.pb4);
    326367        if (rc != EOK) {
    327368                printf("Error creating button.\n");
     
    332373
    333374        rect.p0.x = 15;
    334         rect.p0.y = 250;
     375        rect.p0.y = 130 + 3 * 35;
    335376        rect.p1.x = 190;
    336         rect.p1.y = 278;
     377        rect.p1.y = rect.p0.y + 28;
    337378        ui_pbutton_set_rect(launcher.pb4, &rect);
    338379
     
    343384        }
    344385
     386        /* GFX Demo */
     387
     388        rc = ui_pbutton_create(ui_res, "GFX Demo", &launcher.pb5);
     389        if (rc != EOK) {
     390                printf("Error creating button.\n");
     391                return rc;
     392        }
     393
     394        ui_pbutton_set_cb(launcher.pb5, &pbutton_cb, (void *) &launcher);
     395
     396        rect.p0.x = 15;
     397        rect.p0.y = 130 + 4 * 35;
     398        rect.p1.x = 190;
     399        rect.p1.y = rect.p0.y + 28;
     400        ui_pbutton_set_rect(launcher.pb5, &rect);
     401
     402        rc = ui_fixed_add(launcher.fixed, ui_pbutton_ctl(launcher.pb5));
     403        if (rc != EOK) {
     404                printf("Error adding control to layout.\n");
     405                return rc;
     406        }
     407
    345408        ui_window_add(window, ui_fixed_ctl(launcher.fixed));
    346 
    347         (void) ui_res;
    348         (void) app_launch;
    349409
    350410        rc = ui_window_paint(window);
  • uspace/app/launcher/launcher.h

    r7b11315 r24c452b3  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5656        ui_pbutton_t *pb3;
    5757        ui_pbutton_t *pb4;
     58        ui_pbutton_t *pb5;
    5859} launcher_t;
    5960
Note: See TracChangeset for help on using the changeset viewer.