Changeset 24c452b3 in mainline
- Timestamp:
- 2021-11-02T00:24:50Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce862ac
- Parents:
- 7b11315
- Location:
- uspace/app/launcher
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/launcher/launcher.c
r7b11315 r24c452b3 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * Copyright (c) 2012 Petr Koupy 4 4 * All rights reserved. … … 70 70 }; 71 71 72 static int app_launch (const char *, const char *);72 static int app_launchl(const char *, ...); 73 73 74 74 /** Window close button was clicked. … … 94 94 95 95 if (pbutton == launcher->pb1) { 96 app_launch ("/app/terminal", NULL);96 app_launchl("/app/terminal", "-c", "/app/nav", NULL); 97 97 } else if (pbutton == launcher->pb2) { 98 app_launch ("/app/calculator", NULL);98 app_launchl("/app/terminal", NULL); 99 99 } else if (pbutton == launcher->pb3) { 100 app_launch ("/app/uidemo", NULL);100 app_launchl("/app/calculator", NULL); 101 101 } 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); 103 105 } 104 106 } 105 107 106 static int app_launch (const char *app, const char *arg)108 static int app_launchl(const char *app, ...) 107 109 { 108 110 errno_t rc; 109 111 task_id_t id; 110 112 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) 125 129 return -1; 126 }127 130 128 131 task_exit_t texit; 129 132 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 130 163 rc = task_wait(&wait, &texit, &retval); 131 164 if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) { … … 189 222 params.rect.p0.y = 0; 190 223 params.rect.p1.x = 210; 191 params.rect.p1.y = 3 00;224 params.rect.p1.y = 310; 192 225 193 226 memset((void *) &launcher, 0, sizeof(launcher)); … … 263 296 } 264 297 265 rc = ui_pbutton_create(ui_res, "Terminal", &launcher.pb1); 298 /* Navigator */ 299 300 rc = ui_pbutton_create(ui_res, "Navigator", &launcher.pb1); 266 301 if (rc != EOK) { 267 302 printf("Error creating button.\n"); … … 274 309 rect.p0.y = 130; 275 310 rect.p1.x = 190; 276 rect.p1.y = 158;311 rect.p1.y = rect.p0.y + 28; 277 312 ui_pbutton_set_rect(launcher.pb1, &rect); 278 313 … … 283 318 } 284 319 285 rc = ui_pbutton_create(ui_res, "Calculator", &launcher.pb2); 320 /* Terminal */ 321 322 rc = ui_pbutton_create(ui_res, "Terminal", &launcher.pb2); 286 323 if (rc != EOK) { 287 324 printf("Error creating button.\n"); … … 292 329 293 330 rect.p0.x = 15; 294 rect.p0.y = 1 70;331 rect.p0.y = 130 + 35; 295 332 rect.p1.x = 190; 296 rect.p1.y = 198;333 rect.p1.y = rect.p0.y + 28; 297 334 ui_pbutton_set_rect(launcher.pb2, &rect); 298 335 … … 303 340 } 304 341 305 rc = ui_pbutton_create(ui_res, "UI Demo", &launcher.pb3); 342 /* Calculator */ 343 344 rc = ui_pbutton_create(ui_res, "Calculator", &launcher.pb3); 306 345 if (rc != EOK) { 307 346 printf("Error creating button.\n"); … … 312 351 313 352 rect.p0.x = 15; 314 rect.p0.y = 210;353 rect.p0.y = 130 + 2 * 35; 315 354 rect.p1.x = 190; 316 rect.p1.y = 238;355 rect.p1.y = rect.p0.y + 28; 317 356 ui_pbutton_set_rect(launcher.pb3, &rect); 318 357 … … 323 362 } 324 363 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); 326 367 if (rc != EOK) { 327 368 printf("Error creating button.\n"); … … 332 373 333 374 rect.p0.x = 15; 334 rect.p0.y = 250;375 rect.p0.y = 130 + 3 * 35; 335 376 rect.p1.x = 190; 336 rect.p1.y = 278;377 rect.p1.y = rect.p0.y + 28; 337 378 ui_pbutton_set_rect(launcher.pb4, &rect); 338 379 … … 343 384 } 344 385 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 345 408 ui_window_add(window, ui_fixed_ctl(launcher.fixed)); 346 347 (void) ui_res;348 (void) app_launch;349 409 350 410 rc = ui_window_paint(window); -
uspace/app/launcher/launcher.h
r7b11315 r24c452b3 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 56 56 ui_pbutton_t *pb3; 57 57 ui_pbutton_t *pb4; 58 ui_pbutton_t *pb5; 58 59 } launcher_t; 59 60
Note:
See TracChangeset
for help on using the changeset viewer.