Changes in uspace/app/launcher/launcher.c [d8ddf7a:552b69f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/launcher/launcher.c
rd8ddf7a r552b69f 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. … … 56 56 #define NAME "launcher" 57 57 58 static c har *display_spec = UI_DISPLAY_DEFAULT;58 static const char *display_spec = UI_DISPLAY_DEFAULT; 59 59 60 60 static void wnd_close(ui_window_t *, void *); … … 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", "-c", "/app/edit", NULL); 99 99 } else if (pbutton == launcher->pb3) { 100 app_launch ("/app/uidemo", NULL);100 app_launchl("/app/terminal", NULL); 101 101 } else if (pbutton == launcher->pb4) { 102 app_launch("/app/gfxdemo", "ui"); 102 app_launchl("/app/calculator", NULL); 103 } else if (pbutton == launcher->pb5) { 104 app_launchl("/app/uidemo", NULL); 105 } else if (pbutton == launcher->pb6) { 106 app_launchl("/app/gfxdemo", "ui", NULL); 103 107 } 104 108 } 105 109 106 static int app_launch (const char *app, const char *arg)110 static int app_launchl(const char *app, ...) 107 111 { 108 112 errno_t rc; 109 113 task_id_t id; 110 114 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)); 115 va_list ap; 116 const char *arg; 117 const char **argv; 118 const char **argp; 119 int cnt = 0; 120 int i; 121 122 va_start(ap, app); 123 do { 124 arg = va_arg(ap, const char *); 125 cnt++; 126 } while (arg != NULL); 127 va_end(ap); 128 129 argv = calloc(cnt + 4, sizeof(const char *)); 130 if (argv == NULL) 125 131 return -1; 126 }127 132 128 133 task_exit_t texit; 129 134 int retval; 135 136 argp = argv; 137 *argp++ = app; 138 139 if (str_cmp(display_spec, UI_DISPLAY_DEFAULT) != 0) { 140 *argp++ = "-d"; 141 *argp++ = display_spec; 142 } 143 144 va_start(ap, app); 145 do { 146 arg = va_arg(ap, const char *); 147 *argp++ = arg; 148 } while (arg != NULL); 149 va_end(ap); 150 151 *argp++ = NULL; 152 153 printf("%s: Spawning %s", NAME, app); 154 for (i = 0; argv[i] != NULL; i++) { 155 printf(" %s", argv[i]); 156 } 157 printf("\n"); 158 159 rc = task_spawnv(&id, &wait, app, argv); 160 if (rc != EOK) { 161 printf("%s: Error spawning %s (%s)\n", NAME, app, str_error(rc)); 162 return -1; 163 } 164 130 165 rc = task_wait(&wait, &texit, &retval); 131 166 if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) { … … 189 224 params.rect.p0.y = 0; 190 225 params.rect.p1.x = 210; 191 params.rect.p1.y = 3 00;226 params.rect.p1.y = 345; 192 227 193 228 memset((void *) &launcher, 0, sizeof(launcher)); … … 263 298 } 264 299 265 rc = ui_pbutton_create(ui_res, "Terminal", &launcher.pb1); 300 /* Navigator */ 301 302 rc = ui_pbutton_create(ui_res, "Navigator", &launcher.pb1); 266 303 if (rc != EOK) { 267 304 printf("Error creating button.\n"); … … 274 311 rect.p0.y = 130; 275 312 rect.p1.x = 190; 276 rect.p1.y = 158;313 rect.p1.y = rect.p0.y + 28; 277 314 ui_pbutton_set_rect(launcher.pb1, &rect); 278 315 … … 283 320 } 284 321 285 rc = ui_pbutton_create(ui_res, "Calculator", &launcher.pb2); 322 /* Text Editor */ 323 324 rc = ui_pbutton_create(ui_res, "Text Editor", &launcher.pb2); 286 325 if (rc != EOK) { 287 326 printf("Error creating button.\n"); … … 292 331 293 332 rect.p0.x = 15; 294 rect.p0.y = 1 70;295 rect.p1.x = 190; 296 rect.p1.y = 198;333 rect.p0.y = 130 + 35; 334 rect.p1.x = 190; 335 rect.p1.y = rect.p0.y + 28; 297 336 ui_pbutton_set_rect(launcher.pb2, &rect); 298 337 … … 303 342 } 304 343 305 rc = ui_pbutton_create(ui_res, "UI Demo", &launcher.pb3); 344 /* Terminal */ 345 346 rc = ui_pbutton_create(ui_res, "Terminal", &launcher.pb3); 306 347 if (rc != EOK) { 307 348 printf("Error creating button.\n"); … … 312 353 313 354 rect.p0.x = 15; 314 rect.p0.y = 210;315 rect.p1.x = 190; 316 rect.p1.y = 238;355 rect.p0.y = 130 + 2 * 35; 356 rect.p1.x = 190; 357 rect.p1.y = rect.p0.y + 28; 317 358 ui_pbutton_set_rect(launcher.pb3, &rect); 318 359 … … 323 364 } 324 365 325 rc = ui_pbutton_create(ui_res, "GFX Demo", &launcher.pb4); 366 /* Calculator */ 367 368 rc = ui_pbutton_create(ui_res, "Calculator", &launcher.pb4); 326 369 if (rc != EOK) { 327 370 printf("Error creating button.\n"); … … 332 375 333 376 rect.p0.x = 15; 334 rect.p0.y = 250;335 rect.p1.x = 190; 336 rect.p1.y = 278;377 rect.p0.y = 130 + 3 * 35; 378 rect.p1.x = 190; 379 rect.p1.y = rect.p0.y + 28; 337 380 ui_pbutton_set_rect(launcher.pb4, &rect); 338 381 … … 343 386 } 344 387 388 /* UI Demo */ 389 390 rc = ui_pbutton_create(ui_res, "UI Demo", &launcher.pb5); 391 if (rc != EOK) { 392 printf("Error creating button.\n"); 393 return rc; 394 } 395 396 ui_pbutton_set_cb(launcher.pb5, &pbutton_cb, (void *) &launcher); 397 398 rect.p0.x = 15; 399 rect.p0.y = 130 + 4 * 35; 400 rect.p1.x = 190; 401 rect.p1.y = rect.p0.y + 28; 402 ui_pbutton_set_rect(launcher.pb5, &rect); 403 404 rc = ui_fixed_add(launcher.fixed, ui_pbutton_ctl(launcher.pb5)); 405 if (rc != EOK) { 406 printf("Error adding control to layout.\n"); 407 return rc; 408 } 409 410 /* GFX Demo */ 411 412 rc = ui_pbutton_create(ui_res, "GFX Demo", &launcher.pb6); 413 if (rc != EOK) { 414 printf("Error creating button.\n"); 415 return rc; 416 } 417 418 ui_pbutton_set_cb(launcher.pb6, &pbutton_cb, (void *) &launcher); 419 420 rect.p0.x = 15; 421 rect.p0.y = 130 + 5 * 35; 422 rect.p1.x = 190; 423 rect.p1.y = rect.p0.y + 28; 424 ui_pbutton_set_rect(launcher.pb6, &rect); 425 426 rc = ui_fixed_add(launcher.fixed, ui_pbutton_ctl(launcher.pb6)); 427 if (rc != EOK) { 428 printf("Error adding control to layout.\n"); 429 return rc; 430 } 431 345 432 ui_window_add(window, ui_fixed_ctl(launcher.fixed)); 346 347 (void) ui_res;348 (void) app_launch;349 433 350 434 rc = ui_window_paint(window);
Note:
See TracChangeset
for help on using the changeset viewer.