Changes in uspace/app/launcher/launcher.c [552b69f:d8ddf7a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/launcher/launcher.c
r552b69f rd8ddf7a 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2020 Jiri Svoboda 3 3 * Copyright (c) 2012 Petr Koupy 4 4 * All rights reserved. … … 56 56 #define NAME "launcher" 57 57 58 static c onst char *display_spec = UI_DISPLAY_DEFAULT;58 static 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 l(const char *, ...);72 static int app_launch(const char *, const char *); 73 73 74 74 /** Window close button was clicked. … … 94 94 95 95 if (pbutton == launcher->pb1) { 96 app_launch l("/app/terminal", "-c", "/app/nav", NULL);96 app_launch("/app/terminal", NULL); 97 97 } else if (pbutton == launcher->pb2) { 98 app_launch l("/app/terminal", "-c", "/app/edit", NULL);98 app_launch("/app/calculator", NULL); 99 99 } else if (pbutton == launcher->pb3) { 100 app_launch l("/app/terminal", NULL);100 app_launch("/app/uidemo", NULL); 101 101 } else if (pbutton == launcher->pb4) { 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); 107 } 108 } 109 110 static int app_launchl(const char *app, ...) 102 app_launch("/app/gfxdemo", "ui"); 103 } 104 } 105 106 static int app_launch(const char *app, const char *arg) 111 107 { 112 108 errno_t rc; 113 109 task_id_t id; 114 110 task_wait_t wait; 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) 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)); 131 125 return -1; 126 } 132 127 133 128 task_exit_t texit; 134 129 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 165 130 rc = task_wait(&wait, &texit, &retval); 166 131 if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) { … … 224 189 params.rect.p0.y = 0; 225 190 params.rect.p1.x = 210; 226 params.rect.p1.y = 3 45;191 params.rect.p1.y = 300; 227 192 228 193 memset((void *) &launcher, 0, sizeof(launcher)); … … 298 263 } 299 264 300 /* Navigator */ 301 302 rc = ui_pbutton_create(ui_res, "Navigator", &launcher.pb1); 265 rc = ui_pbutton_create(ui_res, "Terminal", &launcher.pb1); 303 266 if (rc != EOK) { 304 267 printf("Error creating button.\n"); … … 311 274 rect.p0.y = 130; 312 275 rect.p1.x = 190; 313 rect.p1.y = rect.p0.y + 28;276 rect.p1.y = 158; 314 277 ui_pbutton_set_rect(launcher.pb1, &rect); 315 278 … … 320 283 } 321 284 322 /* Text Editor */ 323 324 rc = ui_pbutton_create(ui_res, "Text Editor", &launcher.pb2); 285 rc = ui_pbutton_create(ui_res, "Calculator", &launcher.pb2); 325 286 if (rc != EOK) { 326 287 printf("Error creating button.\n"); … … 331 292 332 293 rect.p0.x = 15; 333 rect.p0.y = 1 30 + 35;294 rect.p0.y = 170; 334 295 rect.p1.x = 190; 335 rect.p1.y = rect.p0.y + 28;296 rect.p1.y = 198; 336 297 ui_pbutton_set_rect(launcher.pb2, &rect); 337 298 … … 342 303 } 343 304 344 /* Terminal */ 345 346 rc = ui_pbutton_create(ui_res, "Terminal", &launcher.pb3); 305 rc = ui_pbutton_create(ui_res, "UI Demo", &launcher.pb3); 347 306 if (rc != EOK) { 348 307 printf("Error creating button.\n"); … … 353 312 354 313 rect.p0.x = 15; 355 rect.p0.y = 130 + 2 * 35;314 rect.p0.y = 210; 356 315 rect.p1.x = 190; 357 rect.p1.y = rect.p0.y + 28;316 rect.p1.y = 238; 358 317 ui_pbutton_set_rect(launcher.pb3, &rect); 359 318 … … 364 323 } 365 324 366 /* Calculator */ 367 368 rc = ui_pbutton_create(ui_res, "Calculator", &launcher.pb4); 325 rc = ui_pbutton_create(ui_res, "GFX Demo", &launcher.pb4); 369 326 if (rc != EOK) { 370 327 printf("Error creating button.\n"); … … 375 332 376 333 rect.p0.x = 15; 377 rect.p0.y = 130 + 3 * 35;334 rect.p0.y = 250; 378 335 rect.p1.x = 190; 379 rect.p1.y = rect.p0.y + 28;336 rect.p1.y = 278; 380 337 ui_pbutton_set_rect(launcher.pb4, &rect); 381 338 … … 386 343 } 387 344 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 432 345 ui_window_add(window, ui_fixed_ctl(launcher.fixed)); 346 347 (void) ui_res; 348 (void) app_launch; 433 349 434 350 rc = ui_window_paint(window);
Note:
See TracChangeset
for help on using the changeset viewer.