summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-10 09:29:46 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-10 09:29:46 +0300
commit168ded2245101126e7954887ddc04b80f211e917 (patch)
tree69aacb221ef8093031a06fdc9c25054aca929192 /src
parentb85471a5b84f0837611fb47be35ee713139f702f (diff)
Mobile: Revised more dialogs
Diffstat (limited to 'src')
-rw-r--r--src/app.c4
-rw-r--r--src/ui/labelwidget.c10
-rw-r--r--src/ui/mobile.c27
-rw-r--r--src/ui/mobile.h6
-rw-r--r--src/ui/translation.c13
-rw-r--r--src/ui/util.c184
-rw-r--r--src/ui/util.h2
7 files changed, 160 insertions, 86 deletions
diff --git a/src/app.c b/src/app.c
index 0d0f2ffd..a52552c0 100644
--- a/src/app.c
+++ b/src/app.c
@@ -248,7 +248,9 @@ static iString *serializePrefs_App_(const iApp *d) {
248 appendFormat_String(str, "proxy.gemini address:%s\n", cstr_String(&d->prefs.geminiProxy)); 248 appendFormat_String(str, "proxy.gemini address:%s\n", cstr_String(&d->prefs.geminiProxy));
249 appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy)); 249 appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy));
250 appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy)); 250 appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy));
251#if defined (LAGRANGE_ENABLE_DOWNLOAD_EDIT)
251 appendFormat_String(str, "downloads path:%s\n", cstr_String(&d->prefs.downloadDir)); 252 appendFormat_String(str, "downloads path:%s\n", cstr_String(&d->prefs.downloadDir));
253#endif
252 appendFormat_String(str, "searchurl address:%s\n", cstr_String(&d->prefs.searchUrl)); 254 appendFormat_String(str, "searchurl address:%s\n", cstr_String(&d->prefs.searchUrl));
253 appendFormat_String(str, "translation.languages from:%d to:%d\n", d->prefs.langFrom, d->prefs.langTo); 255 appendFormat_String(str, "translation.languages from:%d to:%d\n", d->prefs.langFrom, d->prefs.langTo);
254 return str; 256 return str;
@@ -2331,10 +2333,12 @@ iBool handleCommand_App(const char *cmd) {
2331 setCStr_String(&d->prefs.httpProxy, suffixPtr_Command(cmd, "address")); 2333 setCStr_String(&d->prefs.httpProxy, suffixPtr_Command(cmd, "address"));
2332 return iTrue; 2334 return iTrue;
2333 } 2335 }
2336#if defined (LAGRANGE_ENABLE_DOWNLOAD_EDIT)
2334 else if (equal_Command(cmd, "downloads")) { 2337 else if (equal_Command(cmd, "downloads")) {
2335 setCStr_String(&d->prefs.downloadDir, suffixPtr_Command(cmd, "path")); 2338 setCStr_String(&d->prefs.downloadDir, suffixPtr_Command(cmd, "path"));
2336 return iTrue; 2339 return iTrue;
2337 } 2340 }
2341#endif
2338 else if (equal_Command(cmd, "downloads.open")) { 2342 else if (equal_Command(cmd, "downloads.open")) {
2339 postCommandf_App("open url:%s", cstrCollect_String(makeFileUrl_String(downloadDir_App()))); 2343 postCommandf_App("open url:%s", cstrCollect_String(makeFileUrl_String(downloadDir_App())));
2340 return iTrue; 2344 return iTrue;
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index b84e17f4..03595d1a 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -551,10 +551,12 @@ void updateText_LabelWidget(iLabelWidget *d, const iString *text) {
551} 551}
552 552
553void updateTextCStr_LabelWidget(iLabelWidget *d, const char *text) { 553void updateTextCStr_LabelWidget(iLabelWidget *d, const char *text) {
554 setCStr_String(&d->label, text); 554 if (d) {
555 set_String(&d->srcLabel, &d->label); 555 setCStr_String(&d->label, text);
556 replaceVariables_LabelWidget_(d); 556 set_String(&d->srcLabel, &d->label);
557 refresh_Widget(&d->widget); 557 replaceVariables_LabelWidget_(d);
558 refresh_Widget(&d->widget);
559 }
558} 560}
559 561
560void updateTextAndResizeWidthCStr_LabelWidget(iLabelWidget *d, const char *text) { 562void updateTextAndResizeWidthCStr_LabelWidget(iLabelWidget *d, const char *text) {
diff --git a/src/ui/mobile.c b/src/ui/mobile.c
index f3e23e06..daa1fa1a 100644
--- a/src/ui/mobile.c
+++ b/src/ui/mobile.c
@@ -498,16 +498,18 @@ void makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {
498 } 498 }
499 else if (equal_Command(spec, "button")) { 499 else if (equal_Command(spec, "button")) {
500 widget = as_Widget(heading = makePanelButton_(label, item->command)); 500 widget = as_Widget(heading = makePanelButton_(label, item->command));
501 setFlags_Widget(widget, selected_WidgetFlag, argLabel_Command(spec, "selected") != 0);
501 } 502 }
502 else if (equal_Command(spec, "label")) { 503 else if (equal_Command(spec, "label")) {
503 iLabelWidget *lab = new_LabelWidget(label, NULL); 504 iLabelWidget *lab = new_LabelWidget(label, NULL);
504 widget = as_Widget(lab); 505 widget = as_Widget(lab);
505 setWrap_LabelWidget(lab, iTrue); 506 setWrap_LabelWidget(lab, iTrue);
506 setFlags_Widget(widget, frameless_WidgetFlag, iTrue); 507 setFlags_Widget(widget, fixedHeight_WidgetFlag | frameless_WidgetFlag, iTrue);
507 } 508 }
508 else if (equal_Command(spec, "padding")) { 509 else if (equal_Command(spec, "padding")) {
509 widget = makePadding_Widget(lineHeight_Text(labelFont_()) * 1.5f); 510 widget = makePadding_Widget(lineHeight_Text(labelFont_()) * 1.5f);
510 } 511 }
512 /* Apply common styling to the heading. */
511 if (heading) { 513 if (heading) {
512 setRemoveTrailingColon_LabelWidget(heading, iTrue); 514 setRemoveTrailingColon_LabelWidget(heading, iTrue);
513 const iChar icon = toInt_String(string_Command(item->label, "icon")); 515 const iChar icon = toInt_String(string_Command(item->label, "icon"));
@@ -536,7 +538,7 @@ static const iMenuItem *findDialogCancelAction_(const iMenuItem *items, size_t n
536 if (n <= 1) { 538 if (n <= 1) {
537 return NULL; 539 return NULL;
538 } 540 }
539 for (size_t i = 0; i < n - 1; i++) { 541 for (size_t i = 0; i < n; i++) {
540 if (!iCmpStr(items[i].label, "${cancel}")) { 542 if (!iCmpStr(items[i].label, "${cancel}")) {
541 return &items[i]; 543 return &items[i];
542 } 544 }
@@ -547,6 +549,13 @@ static const iMenuItem *findDialogCancelAction_(const iMenuItem *items, size_t n
547iWidget *makePanels_Mobile(const char *id, 549iWidget *makePanels_Mobile(const char *id,
548 const iMenuItem *itemsNullTerminated, 550 const iMenuItem *itemsNullTerminated,
549 const iMenuItem *actions, size_t numActions) { 551 const iMenuItem *actions, size_t numActions) {
552 return makePanelsParent_Mobile(get_Root()->widget, id, itemsNullTerminated, actions, numActions);
553}
554
555iWidget *makePanelsParent_Mobile(iWidget *parentWidget,
556 const char *id,
557 const iMenuItem *itemsNullTerminated,
558 const iMenuItem *actions, size_t numActions) {
550 /* A multipanel widget has a top panel and one or more detail panels. In a horizontal layout, 559 /* A multipanel widget has a top panel and one or more detail panels. In a horizontal layout,
551 the detail panels slide in from the right and cover the top panel. In a landscape layout, 560 the detail panels slide in from the right and cover the top panel. In a landscape layout,
552 the detail panels are always visible on the side. */ 561 the detail panels are always visible on the side. */
@@ -637,7 +646,7 @@ iWidget *makePanels_Mobile(const char *id,
637 const iMenuItem *cancelItem = findDialogCancelAction_(actions, numActions); 646 const iMenuItem *cancelItem = findDialogCancelAction_(actions, numActions);
638 const iMenuItem *defaultItem = &actions[numActions - 1]; 647 const iMenuItem *defaultItem = &actions[numActions - 1];
639 iAssert(defaultItem); 648 iAssert(defaultItem);
640 if (!cancelItem) { 649 if (defaultItem && !cancelItem) {
641 updateTextCStr_LabelWidget(naviBack, defaultItem->label); 650 updateTextCStr_LabelWidget(naviBack, defaultItem->label);
642 setCommand_LabelWidget(naviBack, collectNewCStr_String(defaultItem->command)); 651 setCommand_LabelWidget(naviBack, collectNewCStr_String(defaultItem->command));
643 setFlags_Widget(as_Widget(naviBack), alignLeft_WidgetFlag, iFalse); 652 setFlags_Widget(as_Widget(naviBack), alignLeft_WidgetFlag, iFalse);
@@ -645,7 +654,7 @@ iWidget *makePanels_Mobile(const char *id,
645 setIcon_LabelWidget(naviBack, 0); 654 setIcon_LabelWidget(naviBack, 0);
646 setFont_LabelWidget(naviBack, labelBoldFont_()); 655 setFont_LabelWidget(naviBack, labelBoldFont_());
647 } 656 }
648 else { 657 else if (defaultItem && defaultItem != cancelItem) {
649 updateTextCStr_LabelWidget(naviBack, cancelItem->label); 658 updateTextCStr_LabelWidget(naviBack, cancelItem->label);
650 setCommand_LabelWidget(naviBack, collectNewCStr_String(cancelItem->command 659 setCommand_LabelWidget(naviBack, collectNewCStr_String(cancelItem->command
651 ? cancelItem->command 660 ? cancelItem->command
@@ -667,8 +676,12 @@ iWidget *makePanels_Mobile(const char *id,
667 if (act == cancelItem || act == defaultItem) { 676 if (act == cancelItem || act == defaultItem) {
668 continue; 677 continue;
669 } 678 }
670 if (!iCmpStr(act->label, "---")) { 679 const char *label = act->label;
671 continue; 680 if (*label == '*' || *label == '&') {
681 continue; /* Special value selection items for a Question dialog. */
682 }
683 if (!iCmpStr(label, "---")) {
684 continue; /* Separator. */
672 } 685 }
673 if (needPadding) { 686 if (needPadding) {
674 makePanelItem_Mobile(topPanel, &(iMenuItem){ "padding" }); 687 makePanelItem_Mobile(topPanel, &(iMenuItem){ "padding" });
@@ -680,7 +693,7 @@ iWidget *makePanels_Mobile(const char *id,
680 } 693 }
681 } 694 }
682 /* Finalize the layout. */ 695 /* Finalize the layout. */
683 addChild_Widget(sheet->root->widget, iClob(sheet)); 696 addChild_Widget(parentWidget, iClob(sheet));
684 mainDetailSplitHandler_(mainDetailSplit, "window.resized"); /* make it resize the split */ 697 mainDetailSplitHandler_(mainDetailSplit, "window.resized"); /* make it resize the split */
685 updatePanelSheetMetrics_(sheet); 698 updatePanelSheetMetrics_(sheet);
686 arrange_Widget(sheet); 699 arrange_Widget(sheet);
diff --git a/src/ui/mobile.h b/src/ui/mobile.h
index 4d742a0a..30679c7c 100644
--- a/src/ui/mobile.h
+++ b/src/ui/mobile.h
@@ -31,7 +31,11 @@ iBool isUsingPanelLayout_Mobile (void);
31iWidget * makePanels_Mobile (const char *id, 31iWidget * makePanels_Mobile (const char *id,
32 const iMenuItem *itemsNullTerminated, 32 const iMenuItem *itemsNullTerminated,
33 const iMenuItem *actions, size_t numActions); 33 const iMenuItem *actions, size_t numActions);
34 34iWidget * makePanelsParent_Mobile (iWidget *parent,
35 const char *id,
36 const iMenuItem *itemsNullTerminated,
37 const iMenuItem *actions, size_t numActions);
38
35void setupMenuTransition_Mobile (iWidget *menu, iBool isIncoming); 39void setupMenuTransition_Mobile (iWidget *menu, iBool isIncoming);
36void setupSheetTransition_Mobile (iWidget *sheet, iBool isIncoming); 40void setupSheetTransition_Mobile (iWidget *sheet, iBool isIncoming);
37 41
diff --git a/src/ui/translation.c b/src/ui/translation.c
index 3ffa961b..cef68dce 100644
--- a/src/ui/translation.c
+++ b/src/ui/translation.c
@@ -424,19 +424,18 @@ static iBool processResult_Translation_(iTranslation *d) {
424} 424}
425 425
426static iLabelWidget *acceptButton_Translation_(const iTranslation *d) { 426static iLabelWidget *acceptButton_Translation_(const iTranslation *d) {
427 iWidget *buttonParent = findChild_Widget(d->dlg, "dialogbuttons"); 427 return dialogAcceptButton_Widget(d->dlg);
428// if (!buttonParent) {
429// buttonParent = findChild_Widget(d->dlg, "panel.back");
430// }
431 return (iLabelWidget *) lastChild_Widget(buttonParent);
432} 428}
433 429
434iBool handleCommand_Translation(iTranslation *d, const char *cmd) { 430iBool handleCommand_Translation(iTranslation *d, const char *cmd) {
435 iWidget *w = as_Widget(d->doc); 431 iWidget *w = as_Widget(d->doc);
436 if (equalWidget_Command(cmd, w, "translation.submit")) { 432 if (equalWidget_Command(cmd, w, "translation.submit")) {
437 if (status_TlsRequest(d->request) == initialized_TlsRequestStatus) { 433 if (status_TlsRequest(d->request) == initialized_TlsRequestStatus) {
438 iWidget *langs = findChild_Widget(d->dlg, "xlt.langs"); 434 iWidget *langs = findChild_Widget(d->dlg, "xlt.langs");
439 setFlags_Widget(langs, hidden_WidgetFlag, iTrue); 435// setFlags_Widget(langs, hidden_WidgetFlag, iTrue);
436 setFlags_Widget(findChild_Widget(d->dlg, "xlt.from"), hidden_WidgetFlag, iTrue);
437 setFlags_Widget(findChild_Widget(d->dlg, "xlt.to"), hidden_WidgetFlag, iTrue);
438 if (!langs) langs = d->dlg;
440 iLabelWidget *acceptButton = acceptButton_Translation_(d); 439 iLabelWidget *acceptButton = acceptButton_Translation_(d);
441 updateTextCStr_LabelWidget(acceptButton, "00:00"); 440 updateTextCStr_LabelWidget(acceptButton, "00:00");
442 setFlags_Widget(as_Widget(acceptButton), disabled_WidgetFlag, iTrue); 441 setFlags_Widget(as_Widget(acceptButton), disabled_WidgetFlag, iTrue);
diff --git a/src/ui/util.c b/src/ui/util.c
index abe6f22e..6df4e980 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1394,6 +1394,28 @@ iWidget *makeMessage_Widget(const char *title, const char *msg, const iMenuItem
1394iWidget *makeQuestion_Widget(const char *title, const char *msg, 1394iWidget *makeQuestion_Widget(const char *title, const char *msg,
1395 const iMenuItem *items, size_t numItems) { 1395 const iMenuItem *items, size_t numItems) {
1396 processEvents_App(postedEventsOnly_AppEventMode); 1396 processEvents_App(postedEventsOnly_AppEventMode);
1397 if (isUsingPanelLayout_Mobile()) {
1398 iArray *panelItems = collectNew_Array(sizeof(iMenuItem));
1399 pushBackN_Array(panelItems, (iMenuItem[]){
1400 { format_CStr("title text:%s", title) },
1401 { format_CStr("label text:%s", msg) },
1402 { NULL }
1403 }, 3);
1404 for (size_t i = 0; i < numItems; i++) {
1405 const iMenuItem *item = &items[i];
1406 const char first = item->label[0];
1407 if (first == '*' || first == '&') {
1408 insert_Array(panelItems, size_Array(panelItems) - 1,
1409 &(iMenuItem){ format_CStr("button selected:%d text:%s",
1410 first == '&' ? 1 : 0, item->label + 1),
1411 0, 0, item->command });
1412 }
1413 }
1414 iWidget *dlg = makePanels_Mobile("", data_Array(panelItems), items, numItems);
1415 setCommandHandler_Widget(dlg, messageHandler_);
1416 setupSheetTransition_Mobile(dlg, iTrue);
1417 return dlg;
1418 }
1397 iWidget *dlg = makeSheet_Widget(""); 1419 iWidget *dlg = makeSheet_Widget("");
1398 setCommandHandler_Widget(dlg, messageHandler_); 1420 setCommandHandler_Widget(dlg, messageHandler_);
1399 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag); 1421 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag);
@@ -1485,6 +1507,15 @@ iWidget *makeTwoColumns_Widget(iWidget **headings, iWidget **values) {
1485 return page; 1507 return page;
1486} 1508}
1487 1509
1510iLabelWidget *dialogAcceptButton_Widget(const iWidget *d) {
1511 iWidget *buttonParent = findChild_Widget(d, "dialogbuttons");
1512 if (!buttonParent) {
1513 iAssert(isUsingPanelLayout_Mobile());
1514 buttonParent = findChild_Widget(d, "panel.back");
1515 }
1516 return (iLabelWidget *) lastChild_Widget(buttonParent);
1517}
1518
1488iWidget *appendTwoColumnTabPage_Widget(iWidget *tabs, const char *title, int shortcut, iWidget **headings, 1519iWidget *appendTwoColumnTabPage_Widget(iWidget *tabs, const char *title, int shortcut, iWidget **headings,
1489 iWidget **values) { 1520 iWidget **values) {
1490 /* TODO: Use `makeTwoColumnWidget_()`, see above. */ 1521 /* TODO: Use `makeTwoColumnWidget_()`, see above. */
@@ -2408,25 +2439,25 @@ iWidget *makeIdentityCreation_Widget(void) {
2408 }; 2439 };
2409 iWidget *dlg; 2440 iWidget *dlg;
2410 if (isUsingPanelLayout_Mobile()) { 2441 if (isUsingPanelLayout_Mobile()) {
2411 dlg = makePanels_Mobile("ident", 2442 dlg = makePanels_Mobile("ident", (iMenuItem[]){
2412 (iMenuItem[]){ { "title id:ident.heading text:${heading.newident}" }, 2443 { "title id:ident.heading text:${heading.newident}" },
2413 { "label text:${dlg.newident.rsa.selfsign}" }, 2444 { "label text:${dlg.newident.rsa.selfsign}" },
2414 { "dropdown id:ident.scope text:${dlg.newident.scope}", 0, 0, 2445 { "dropdown id:ident.scope text:${dlg.newident.scope}", 0, 0,
2415 (const void *) scopeItems }, 2446 (const void *) scopeItems },
2416 { "input id:ident.until hint:hint.newident.date maxlen:19 text:${dlg.newident.until}" }, 2447 { "input id:ident.until hint:hint.newident.date maxlen:19 text:${dlg.newident.until}" },
2417 //{ "padding" }, 2448 //{ "padding" },
2418 //{ "toggle id:ident.temp text:${dlg.newident.temp}" }, 2449 //{ "toggle id:ident.temp text:${dlg.newident.temp}" },
2419 //{ "label text:${help.ident.temp}" }, 2450 //{ "label text:${help.ident.temp}" },
2420 { "heading id:dlg.newident.commonname" }, 2451 { "heading id:dlg.newident.commonname" },
2421 { "input id:ident.common noheading:1" }, 2452 { "input id:ident.common noheading:1" },
2422 { "padding collapse:1" }, 2453 { "padding collapse:1" },
2423 { "input collapse:1 id:ident.email hint:hint.newident.optional text:${dlg.newident.email}" }, 2454 { "input collapse:1 id:ident.email hint:hint.newident.optional text:${dlg.newident.email}" },
2424 { "input collapse:1 id:ident.userid hint:hint.newident.optional text:${dlg.newident.userid}" }, 2455 { "input collapse:1 id:ident.userid hint:hint.newident.optional text:${dlg.newident.userid}" },
2425 { "input collapse:1 id:ident.domain hint:hint.newident.optional text:${dlg.newident.domain}" }, 2456 { "input collapse:1 id:ident.domain hint:hint.newident.optional text:${dlg.newident.domain}" },
2426 { "input collapse:1 id:ident.org hint:hint.newident.optional text:${dlg.newident.org}" }, 2457 { "input collapse:1 id:ident.org hint:hint.newident.optional text:${dlg.newident.org}" },
2427 { "input collapse:1 id:ident.country hint:hint.newident.optional text:${dlg.newident.country}" }, 2458 { "input collapse:1 id:ident.country hint:hint.newident.optional text:${dlg.newident.country}" },
2428 { NULL } 2459 { NULL }
2429 }, actions, iElemCount(actions)); 2460 }, actions, iElemCount(actions));
2430 setupSheetTransition_Mobile(dlg, iTrue); 2461 setupSheetTransition_Mobile(dlg, iTrue);
2431 } 2462 }
2432 else { 2463 else {
@@ -2513,6 +2544,7 @@ static const iMenuItem languages[] = {
2513 { "${lang.pt}", 0, 0, "xlt.lang id:pt" }, 2544 { "${lang.pt}", 0, 0, "xlt.lang id:pt" },
2514 { "${lang.ru}", 0, 0, "xlt.lang id:ru" }, 2545 { "${lang.ru}", 0, 0, "xlt.lang id:ru" },
2515 { "${lang.es}", 0, 0, "xlt.lang id:es" }, 2546 { "${lang.es}", 0, 0, "xlt.lang id:es" },
2547 { NULL }
2516}; 2548};
2517 2549
2518static iBool translationHandler_(iWidget *dlg, const char *cmd) { 2550static iBool translationHandler_(iWidget *dlg, const char *cmd) {
@@ -2529,6 +2561,7 @@ static iBool translationHandler_(iWidget *dlg, const char *cmd) {
2529 2561
2530const char *languageId_String(const iString *menuItemLabel) { 2562const char *languageId_String(const iString *menuItemLabel) {
2531 iForIndices(i, languages) { 2563 iForIndices(i, languages) {
2564 if (!languages[i].label) break;
2532 if (!cmp_String(menuItemLabel, translateCStr_Lang(languages[i].label))) { 2565 if (!cmp_String(menuItemLabel, translateCStr_Lang(languages[i].label))) {
2533 return cstr_Rangecc(range_Command(languages[i].command, "id")); 2566 return cstr_Rangecc(range_Command(languages[i].command, "id"));
2534 } 2567 }
@@ -2538,6 +2571,7 @@ const char *languageId_String(const iString *menuItemLabel) {
2538 2571
2539int languageIndex_CStr(const char *langId) { 2572int languageIndex_CStr(const char *langId) {
2540 iForIndices(i, languages) { 2573 iForIndices(i, languages) {
2574 if (!languages[i].label) break;
2541 if (equal_Rangecc(range_Command(languages[i].command, "id"), langId)) { 2575 if (equal_Rangecc(range_Command(languages[i].command, "id"), langId)) {
2542 return (int) i; 2576 return (int) i;
2543 } 2577 }
@@ -2546,54 +2580,70 @@ int languageIndex_CStr(const char *langId) {
2546} 2580}
2547 2581
2548iWidget *makeTranslation_Widget(iWidget *parent) { 2582iWidget *makeTranslation_Widget(iWidget *parent) {
2549 iWidget *dlg = makeSheet_Widget("xlt"); 2583 const iMenuItem actions[] = {
2550 setFlags_Widget(dlg, keepOnTop_WidgetFlag, iFalse); 2584 { "${cancel}", SDLK_ESCAPE, 0, "translation.cancel" },
2551 dlg->minSize.x = 70 * gap_UI; 2585 { uiTextAction_ColorEscape "${dlg.translate}", SDLK_RETURN, 0, "translation.submit" }
2586 };
2587 iWidget *dlg;
2588 if (isUsingPanelLayout_Mobile()) {
2589 dlg = makePanelsParent_Mobile(parent, "xlt", (iMenuItem[]){
2590 { "title id:heading.translate" },
2591 { "dropdown id:xlt.from text:${dlg.translate.from}", 0, 0, (const void *) languages },
2592 { "dropdown id:xlt.to text:${dlg.translate.to}", 0, 0, (const void *) languages },
2593 { NULL }
2594 }, actions, iElemCount(actions));
2595 }
2596 else {
2597 dlg = makeSheet_Widget("xlt");
2598 setFlags_Widget(dlg, keepOnTop_WidgetFlag, iFalse);
2599 dlg->minSize.x = 70 * gap_UI;
2600 addChildFlags_Widget(
2601 dlg,
2602 iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.translate}", NULL)),
2603 frameless_WidgetFlag);
2604 addChild_Widget(dlg, iClob(makePadding_Widget(lineHeight_Text(uiLabel_FontId))));
2605 iWidget *headings, *values;
2606 iWidget *page;
2607 addChild_Widget(dlg, iClob(page = makeTwoColumns_Widget(&headings, &values)));
2608 setId_Widget(page, "xlt.langs");
2609 iLabelWidget *fromLang, *toLang;
2610 /* Source language. */ {
2611 addChild_Widget(headings, iClob(makeHeading_Widget("${dlg.translate.from}")));
2612 setId_Widget(
2613 addChildFlags_Widget(values,
2614 iClob(fromLang = makeMenuButton_LabelWidget(
2615 "${lang.pt}", languages, iElemCount(languages) - 1)),
2616 alignLeft_WidgetFlag),
2617 "xlt.from");
2618 setBackgroundColor_Widget(findChild_Widget(as_Widget(fromLang), "menu"),
2619 uiBackgroundMenu_ColorId);
2620 }
2621 /* Target language. */ {
2622 addChild_Widget(headings, iClob(makeHeading_Widget("${dlg.translate.to}")));
2623 setId_Widget(
2624 addChildFlags_Widget(values,
2625 iClob(toLang = makeMenuButton_LabelWidget(
2626 "${lang.pt}", languages, iElemCount(languages) - 1)),
2627 alignLeft_WidgetFlag),
2628 "xlt.to");
2629 setBackgroundColor_Widget(findChild_Widget(as_Widget(toLang), "menu"),
2630 uiBackgroundMenu_ColorId);
2631 }
2632 addChild_Widget(dlg, iClob(makePadding_Widget(lineHeight_Text(uiLabel_FontId))));
2633 addChild_Widget(dlg, iClob(makeDialogButtons_Widget(actions, iElemCount(actions))));
2634 addChild_Widget(parent, iClob(dlg));
2635 arrange_Widget(dlg);
2636 }
2637 /* Update choices. */
2638 updateText_LabelWidget(
2639 findChild_Widget(dlg, "xlt.from"),
2640 text_LabelWidget(child_Widget(findChild_Widget(findChild_Widget(dlg, "xlt.from"), "menu"),
2641 prefs_App()->langFrom)));
2642 updateText_LabelWidget(
2643 findChild_Widget(dlg, "xlt.to"),
2644 text_LabelWidget(child_Widget(findChild_Widget(findChild_Widget(dlg, "xlt.to"), "menu"),
2645 prefs_App()->langTo)));
2552 setCommandHandler_Widget(dlg, translationHandler_); 2646 setCommandHandler_Widget(dlg, translationHandler_);
2553 addChildFlags_Widget(dlg, 2647 setupSheetTransition_Mobile(dlg, iTrue);
2554 iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.translate}", NULL)),
2555 frameless_WidgetFlag);
2556 addChild_Widget(dlg, iClob(makePadding_Widget(lineHeight_Text(uiLabel_FontId))));
2557 iWidget *headings, *values;
2558 iWidget *page;
2559 addChild_Widget(dlg, iClob(page = makeTwoColumns_Widget(&headings, &values)));
2560 setId_Widget(page, "xlt.langs");
2561 iLabelWidget *fromLang, *toLang;
2562 /* Source language. */ {
2563 addChild_Widget(headings, iClob(makeHeading_Widget("${dlg.translate.from}")));
2564 setId_Widget(
2565 addChildFlags_Widget(values,
2566 iClob(fromLang = makeMenuButton_LabelWidget(
2567 "${lang.pt}", languages, iElemCount(languages))),
2568 alignLeft_WidgetFlag),
2569 "xlt.from");
2570 iWidget *langMenu = findChild_Widget(as_Widget(fromLang), "menu");
2571 updateText_LabelWidget(fromLang,
2572 text_LabelWidget(child_Widget(langMenu, prefs_App()->langFrom)));
2573 setBackgroundColor_Widget(langMenu, uiBackgroundMenu_ColorId);
2574 }
2575 /* Target language. */ {
2576 addChild_Widget(headings, iClob(makeHeading_Widget("${dlg.translate.to}")));
2577 setId_Widget(addChildFlags_Widget(values,
2578 iClob(toLang = makeMenuButton_LabelWidget(
2579 "${lang.pt}", languages, iElemCount(languages))),
2580 alignLeft_WidgetFlag),
2581 "xlt.to");
2582 iWidget *langMenu = findChild_Widget(as_Widget(toLang), "menu");
2583 setBackgroundColor_Widget(langMenu, uiBackgroundMenu_ColorId);
2584 updateText_LabelWidget(toLang,
2585 text_LabelWidget(child_Widget(langMenu, prefs_App()->langTo)));
2586 }
2587 addChild_Widget(dlg, iClob(makePadding_Widget(lineHeight_Text(uiLabel_FontId))));
2588 addChild_Widget(
2589 dlg,
2590 iClob(makeDialogButtons_Widget(
2591 (iMenuItem[]){
2592 { "${cancel}", SDLK_ESCAPE, 0, "translation.cancel" },
2593 { uiTextAction_ColorEscape "${dlg.translate}", SDLK_RETURN, 0, "translation.submit" } },
2594 2)));
2595 addChild_Widget(parent, iClob(dlg));
2596 arrange_Widget(dlg);
2597 finalizeSheet_Mobile(dlg);
2598 return dlg; 2648 return dlg;
2599} 2649}
diff --git a/src/ui/util.h b/src/ui/util.h
index 0dff8978..74a95827 100644
--- a/src/ui/util.h
+++ b/src/ui/util.h
@@ -272,6 +272,8 @@ void useSheetStyle_Widget (iWidget *);
272iWidget * makeDialogButtons_Widget (const iMenuItem *actions, size_t numActions); 272iWidget * makeDialogButtons_Widget (const iMenuItem *actions, size_t numActions);
273iWidget * makeTwoColumns_Widget (iWidget **headings, iWidget **values); 273iWidget * makeTwoColumns_Widget (iWidget **headings, iWidget **values);
274 274
275iLabelWidget *dialogAcceptButton_Widget (const iWidget *);
276
275iInputWidget *addTwoColumnDialogInputField_Widget(iWidget *headings, iWidget *values, 277iInputWidget *addTwoColumnDialogInputField_Widget(iWidget *headings, iWidget *values,
276 const char *labelText, const char *inputId, 278 const char *labelText, const char *inputId,
277 iInputWidget *input); 279 iInputWidget *input);