diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 8 | ||||
-rw-r--r-- | src/ui/labelwidget.c | 17 | ||||
-rw-r--r-- | src/ui/labelwidget.h | 1 | ||||
-rw-r--r-- | src/ui/mobile.c | 11 | ||||
-rw-r--r-- | src/ui/mobile.h | 1 | ||||
-rw-r--r-- | src/ui/root.c | 88 | ||||
-rw-r--r-- | src/ui/sidebarwidget.c | 20 | ||||
-rw-r--r-- | src/ui/uploadwidget.c | 7 | ||||
-rw-r--r-- | src/ui/util.c | 9 | ||||
-rw-r--r-- | src/ui/util.h | 3 | ||||
-rw-r--r-- | src/ui/widget.c | 10 |
11 files changed, 125 insertions, 50 deletions
@@ -2667,6 +2667,9 @@ iBool handleCommand_App(const char *cmd) { | |||
2667 | if (!urlArg) { | 2667 | if (!urlArg) { |
2668 | return iTrue; /* invalid command */ | 2668 | return iTrue; /* invalid command */ |
2669 | } | 2669 | } |
2670 | if (findWidget_App("prefs")) { | ||
2671 | postCommand_App("prefs.dismiss"); | ||
2672 | } | ||
2670 | iString *url = collectNewCStr_String(urlArg); | 2673 | iString *url = collectNewCStr_String(urlArg); |
2671 | const iBool noProxy = argLabel_Command(cmd, "noproxy") != 0; | 2674 | const iBool noProxy = argLabel_Command(cmd, "noproxy") != 0; |
2672 | const iBool fromSidebar = argLabel_Command(cmd, "fromsidebar") != 0; | 2675 | const iBool fromSidebar = argLabel_Command(cmd, "fromsidebar") != 0; |
@@ -2979,6 +2982,11 @@ iBool handleCommand_App(const char *cmd) { | |||
2979 | showTabPage_Widget(tabs, tabPage_Widget(tabs, d->prefs.dialogTab)); | 2982 | showTabPage_Widget(tabs, tabPage_Widget(tabs, d->prefs.dialogTab)); |
2980 | } | 2983 | } |
2981 | setCommandHandler_Widget(dlg, handlePrefsCommands_); | 2984 | setCommandHandler_Widget(dlg, handlePrefsCommands_); |
2985 | if (argLabel_Command(cmd, "idents") && deviceType_App() != desktop_AppDeviceType) { | ||
2986 | iWidget *idPanel = panel_Mobile(dlg, 2); | ||
2987 | iWidget *button = findUserData_Widget(findChild_Widget(dlg, "panel.top"), idPanel); | ||
2988 | postCommand_Widget(button, "panel.open"); | ||
2989 | } | ||
2982 | } | 2990 | } |
2983 | else if (equal_Command(cmd, "navigate.home")) { | 2991 | else if (equal_Command(cmd, "navigate.home")) { |
2984 | /* Look for bookmarks tagged "homepage". */ | 2992 | /* Look for bookmarks tagged "homepage". */ |
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 947d5daa..d00733e1 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -36,6 +36,7 @@ struct Impl_LabelWidget { | |||
36 | iWidget widget; | 36 | iWidget widget; |
37 | iString srcLabel; | 37 | iString srcLabel; |
38 | iString label; | 38 | iString label; |
39 | iInt2 labelOffset; | ||
39 | int font; | 40 | int font; |
40 | int key; | 41 | int key; |
41 | int kmods; | 42 | int kmods; |
@@ -362,10 +363,6 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
362 | } | 363 | } |
363 | setClip_Paint(&p, rect); | 364 | setClip_Paint(&p, rect); |
364 | const int iconPad = iconPadding_LabelWidget_(d); | 365 | const int iconPad = iconPadding_LabelWidget_(d); |
365 | // const int iconColor = isCaution ? uiTextCaution_ColorId | ||
366 | // : flags & (disabled_WidgetFlag | pressed_WidgetFlag) ? fg | ||
367 | // : isHover ? uiIconHover_ColorId | ||
368 | // : uiIcon_ColorId; | ||
369 | if (d->icon && d->icon != 0x20) { /* no need to draw an empty icon */ | 366 | if (d->icon && d->icon != 0x20) { /* no need to draw an empty icon */ |
370 | iString str; | 367 | iString str; |
371 | initUnicodeN_String(&str, &d->icon, 1); | 368 | initUnicodeN_String(&str, &d->icon, 1); |
@@ -427,8 +424,11 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
427 | else { | 424 | else { |
428 | drawCenteredOutline_Text( | 425 | drawCenteredOutline_Text( |
429 | d->font, | 426 | d->font, |
430 | adjusted_Rect(bounds, init_I2(iconPad * (flags & tight_WidgetFlag ? 1.0f : 1.5f), 0), | 427 | moved_Rect( |
431 | init_I2(-iconPad * (flags & tight_WidgetFlag ? 0.5f : 1.0f), 0)), | 428 | adjusted_Rect(bounds, |
429 | init_I2(iconPad * (flags & tight_WidgetFlag ? 1.0f : 1.5f), 0), | ||
430 | init_I2(-iconPad * (flags & tight_WidgetFlag ? 0.5f : 1.0f), 0)), | ||
431 | d->labelOffset), | ||
432 | d->flags.alignVisual, | 432 | d->flags.alignVisual, |
433 | d->flags.drawAsOutline ? fg : none_ColorId, | 433 | d->flags.drawAsOutline ? fg : none_ColorId, |
434 | d->flags.drawAsOutline ? d->widget.bgColor : fg, | 434 | d->flags.drawAsOutline ? d->widget.bgColor : fg, |
@@ -523,6 +523,7 @@ void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { | |||
523 | d->font = uiLabel_FontId; | 523 | d->font = uiLabel_FontId; |
524 | d->forceFg = none_ColorId; | 524 | d->forceFg = none_ColorId; |
525 | d->icon = 0; | 525 | d->icon = 0; |
526 | d->labelOffset = zero_I2(); | ||
526 | initCStr_String(&d->srcLabel, label); | 527 | initCStr_String(&d->srcLabel, label); |
527 | initCopy_String(&d->label, &d->srcLabel); | 528 | initCopy_String(&d->label, &d->srcLabel); |
528 | replaceVariables_LabelWidget_(d); | 529 | replaceVariables_LabelWidget_(d); |
@@ -623,6 +624,10 @@ void setRemoveTrailingColon_LabelWidget(iLabelWidget *d, iBool removeTrailingCol | |||
623 | } | 624 | } |
624 | } | 625 | } |
625 | 626 | ||
627 | void setTextOffset_LabelWidget(iLabelWidget *d, iInt2 offset) { | ||
628 | d->labelOffset = offset; | ||
629 | } | ||
630 | |||
626 | void updateText_LabelWidget(iLabelWidget *d, const iString *text) { | 631 | void updateText_LabelWidget(iLabelWidget *d, const iString *text) { |
627 | set_String(&d->label, text); | 632 | set_String(&d->label, text); |
628 | set_String(&d->srcLabel, text); | 633 | set_String(&d->srcLabel, text); |
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h index 6f1b7902..4f605d6b 100644 --- a/src/ui/labelwidget.h +++ b/src/ui/labelwidget.h | |||
@@ -38,6 +38,7 @@ void setWrap_LabelWidget (iLabelWidget *, iBool wrap); | |||
38 | void setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline); | 38 | void setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline); |
39 | void setAllCaps_LabelWidget (iLabelWidget *, iBool allCaps); | 39 | void setAllCaps_LabelWidget (iLabelWidget *, iBool allCaps); |
40 | void setRemoveTrailingColon_LabelWidget (iLabelWidget *, iBool removeTrailingColon); | 40 | void setRemoveTrailingColon_LabelWidget (iLabelWidget *, iBool removeTrailingColon); |
41 | void setTextOffset_LabelWidget (iLabelWidget *, iInt2 offset); | ||
41 | void setFont_LabelWidget (iLabelWidget *, int fontId); | 42 | void setFont_LabelWidget (iLabelWidget *, int fontId); |
42 | void setTextColor_LabelWidget (iLabelWidget *, int color); | 43 | void setTextColor_LabelWidget (iLabelWidget *, int color); |
43 | void setText_LabelWidget (iLabelWidget *, const iString *text); /* resizes widget */ | 44 | void setText_LabelWidget (iLabelWidget *, const iString *text); /* resizes widget */ |
diff --git a/src/ui/mobile.c b/src/ui/mobile.c index 5382cbce..ab282a86 100644 --- a/src/ui/mobile.c +++ b/src/ui/mobile.c | |||
@@ -180,13 +180,16 @@ size_t currentPanelIndex_Mobile(const iWidget *panels) { | |||
180 | return iInvalidPos; | 180 | return iInvalidPos; |
181 | } | 181 | } |
182 | 182 | ||
183 | iWidget *panel_Mobile(const iWidget *panels, size_t index) { | ||
184 | return child_Widget(findChild_Widget(panels, "detailstack"), index); | ||
185 | } | ||
186 | |||
183 | static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) { | 187 | static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) { |
184 | const iBool isPortrait = !isSideBySideLayout_(); | 188 | const iBool isPortrait = !isSideBySideLayout_(); |
185 | if (equal_Command(cmd, "panel.open")) { | 189 | if (equal_Command(cmd, "panel.open")) { |
186 | iWidget *button = pointer_Command(cmd); | 190 | /* This command is sent by the button that opens the panel. */ |
191 | iWidget *button = pointer_Command(cmd); | ||
187 | iWidget *panel = userData_Object(button); | 192 | iWidget *panel = userData_Object(button); |
188 | // openMenu_Widget(panel, innerToWindow_Widget(panel, zero_I2())); | ||
189 | // setFlags_Widget(panel, hidden_WidgetFlag, iFalse); | ||
190 | unselectAllPanelButtons_(topPanel); | 193 | unselectAllPanelButtons_(topPanel); |
191 | int panelIndex = -1; | 194 | int panelIndex = -1; |
192 | size_t childIndex = 0; | 195 | size_t childIndex = 0; |
@@ -208,8 +211,6 @@ static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) { | |||
208 | setText_LabelWidget(detailTitle, text_LabelWidget((iLabelWidget *) findTitleLabel_(panel))); | 211 | setText_LabelWidget(detailTitle, text_LabelWidget((iLabelWidget *) findTitleLabel_(panel))); |
209 | setFlags_Widget(button, selected_WidgetFlag, iTrue); | 212 | setFlags_Widget(button, selected_WidgetFlag, iTrue); |
210 | postCommand_Widget(topPanel, "panel.changed arg:%d", panelIndex); | 213 | postCommand_Widget(topPanel, "panel.changed arg:%d", panelIndex); |
211 | //printTree_Widget(findDetailStack_(topPanel)); | ||
212 | // updateVisible_ListWidget(findChild_Widget(findDetailStack_(topPanel), "certlist")); | ||
213 | updateCertListHeight_(findDetailStack_(topPanel)); | 214 | updateCertListHeight_(findDetailStack_(topPanel)); |
214 | return iTrue; | 215 | return iTrue; |
215 | } | 216 | } |
diff --git a/src/ui/mobile.h b/src/ui/mobile.h index 9d7ac8e4..06955945 100644 --- a/src/ui/mobile.h +++ b/src/ui/mobile.h | |||
@@ -39,6 +39,7 @@ void initPanels_Mobile (iWidget *panels, iWidget *parentWidget, | |||
39 | const iMenuItem *itemsNullTerminated, | 39 | const iMenuItem *itemsNullTerminated, |
40 | const iMenuItem *actions, size_t numActions); | 40 | const iMenuItem *actions, size_t numActions); |
41 | 41 | ||
42 | iWidget * panel_Mobile (const iWidget *panels, size_t index); | ||
42 | size_t currentPanelIndex_Mobile (const iWidget *panels); | 43 | size_t currentPanelIndex_Mobile (const iWidget *panels); |
43 | 44 | ||
44 | enum iTransitionFlags { | 45 | enum iTransitionFlags { |
diff --git a/src/ui/root.c b/src/ui/root.c index b7a2e5c8..5df4b36f 100644 --- a/src/ui/root.c +++ b/src/ui/root.c | |||
@@ -333,19 +333,28 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) { | |||
333 | } | 333 | } |
334 | else if (equal_Command(cmd, "identmenu.open")) { | 334 | else if (equal_Command(cmd, "identmenu.open")) { |
335 | iWidget *toolBar = findWidget_Root("toolbar"); | 335 | iWidget *toolBar = findWidget_Root("toolbar"); |
336 | iWidget *button = findWidget_Root(toolBar ? "toolbar.ident" : "navbar.ident"); | 336 | iWidget *button = findWidget_Root(toolBar && isPortraitPhone_App() ? "toolbar.ident" : "navbar.ident"); |
337 | iArray items; | 337 | iArray items; |
338 | init_Array(&items, sizeof(iMenuItem)); | 338 | init_Array(&items, sizeof(iMenuItem)); |
339 | /* Current identity. */ | 339 | /* Current identity. */ |
340 | const iString *docUrl = url_DocumentWidget(document_App()); | 340 | const iString *docUrl = url_DocumentWidget(document_App()); |
341 | const iGmIdentity *ident = identityForUrl_GmCerts(certs_App(), docUrl); | 341 | const iGmIdentity *ident = identityForUrl_GmCerts(certs_App(), docUrl); |
342 | const iString *fp = ident ? collect_String(hexEncode_Block(&ident->fingerprint)) : NULL; | 342 | const iString *fp = ident ? collect_String(hexEncode_Block(&ident->fingerprint)) : NULL; |
343 | pushBackN_Array(&items, | 343 | iString *str = NULL; |
344 | (iMenuItem[]){ { format_CStr("///" uiHeading_ColorEscape "%s", | 344 | if (ident) { |
345 | ident ? cstr_String(name_GmIdentity(ident)) | 345 | str = copy_String(name_GmIdentity(ident)); |
346 | : "${menu.identity.notactive}") }, | 346 | if (!isEmpty_String(&ident->notes)) { |
347 | { "---" } }, | 347 | appendFormat_String(str, "\n%s%s", escape_Color(uiAnnotation_ColorId), |
348 | 2); | 348 | cstr_String(&ident->notes)); |
349 | } | ||
350 | } | ||
351 | pushBackN_Array( | ||
352 | &items, | ||
353 | (iMenuItem[]){ { format_CStr("///" uiHeading_ColorEscape "%s", | ||
354 | str ? cstr_String(str) : "${menu.identity.notactive}") }, | ||
355 | { "---" } }, | ||
356 | 2); | ||
357 | delete_String(str); | ||
349 | /* Alternate identities. */ | 358 | /* Alternate identities. */ |
350 | if (ident) { | 359 | if (ident) { |
351 | const iString *site = collectNewRange_String(urlRoot_String(docUrl)); | 360 | const iString *site = collectNewRange_String(urlRoot_String(docUrl)); |
@@ -385,8 +394,8 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) { | |||
385 | : leftHalf_Icon " ${menu.show.identities}", | 394 | : leftHalf_Icon " ${menu.show.identities}", |
386 | 0, | 395 | 0, |
387 | 0, | 396 | 0, |
388 | deviceType_App() == phone_AppDeviceType ? "toolbar.showident" | 397 | //deviceType_App() == phone_AppDeviceType ? "toolbar.showident" |
389 | : "sidebar.mode arg:3 toggle:1" }); | 398 | "sidebar.mode arg:3 toggle:1" }); |
390 | } | 399 | } |
391 | else { | 400 | else { |
392 | pushBack_Array(&items, &(iMenuItem){ gear_Icon " ${menu.identities}", 0, 0, | 401 | pushBack_Array(&items, &(iMenuItem){ gear_Icon " ${menu.identities}", 0, 0, |
@@ -517,9 +526,21 @@ static void updateNavBarIdentity_(iWidget *navBar) { | |||
517 | iLabelWidget *toolName = findWidget_App("toolbar.name"); | 526 | iLabelWidget *toolName = findWidget_App("toolbar.name"); |
518 | if (toolName) { | 527 | if (toolName) { |
519 | setOutline_LabelWidget(toolButton, ident == NULL); | 528 | setOutline_LabelWidget(toolButton, ident == NULL); |
520 | updateTextCStr_LabelWidget(toolName, subjectName ? cstr_String(subjectName) : ""); | 529 | /* Fit the name in the widget. */ |
530 | if (subjectName) { | ||
531 | const char *endPos; | ||
532 | tryAdvanceNoWrap_Text(uiLabelTiny_FontId, range_String(subjectName), width_Widget(toolName), | ||
533 | &endPos); | ||
534 | updateText_LabelWidget( | ||
535 | toolName, | ||
536 | collectNewRange_String((iRangecc){ constBegin_String(subjectName), endPos })); | ||
537 | } | ||
538 | else { | ||
539 | updateTextCStr_LabelWidget(toolName, ""); | ||
540 | } | ||
521 | setFont_LabelWidget(toolButton, subjectName ? uiLabelMedium_FontId : uiLabelLarge_FontId); | 541 | setFont_LabelWidget(toolButton, subjectName ? uiLabelMedium_FontId : uiLabelLarge_FontId); |
522 | arrange_Widget(parent_Widget(toolButton)); | 542 | setTextOffset_LabelWidget(toolButton, init_I2(0, subjectName ? -1.5f * gap_UI : 0)); |
543 | arrange_Widget(parent_Widget(toolButton)); | ||
523 | } | 544 | } |
524 | } | 545 | } |
525 | 546 | ||
@@ -604,11 +625,13 @@ void updateToolbarColors_Root(iRoot *d) { | |||
604 | tmBannerBackground_ColorId; | 625 | tmBannerBackground_ColorId; |
605 | setBackgroundColor_Widget(toolBar, bg); | 626 | setBackgroundColor_Widget(toolBar, bg); |
606 | iForEach(ObjectList, i, children_Widget(toolBar)) { | 627 | iForEach(ObjectList, i, children_Widget(toolBar)) { |
607 | iLabelWidget *btn = i.object; | 628 | // iLabelWidget *btn = i.object; |
608 | setTextColor_LabelWidget(i.object, isSidebarVisible ? uiTextDim_ColorId : | 629 | setTextColor_LabelWidget(i.object, isSidebarVisible ? uiTextDim_ColorId : |
609 | tmBannerIcon_ColorId); | 630 | tmBannerIcon_ColorId); |
610 | setBackgroundColor_Widget(i.object, bg); /* using noBackground, but ident has outline */ | 631 | setBackgroundColor_Widget(i.object, bg); /* using noBackground, but ident has outline */ |
611 | } | 632 | } |
633 | setTextColor_LabelWidget(findChild_Widget(toolBar, "toolbar.name"), | ||
634 | isSidebarVisible ? uiTextDim_ColorId : tmBannerIcon_ColorId); | ||
612 | } | 635 | } |
613 | #else | 636 | #else |
614 | iUnused(d); | 637 | iUnused(d); |
@@ -1014,8 +1037,13 @@ static iBool handleToolBarCommands_(iWidget *toolBar, const char *cmd) { | |||
1014 | return iTrue; | 1037 | return iTrue; |
1015 | } | 1038 | } |
1016 | else if (equal_Command(cmd, "toolbar.showident")) { | 1039 | else if (equal_Command(cmd, "toolbar.showident")) { |
1017 | /* TODO: Clean this up. */ | ||
1018 | iWidget *sidebar = findWidget_App("sidebar"); | 1040 | iWidget *sidebar = findWidget_App("sidebar"); |
1041 | if (isVisible_Widget(sidebar)) { | ||
1042 | postCommandf_App("sidebar.toggle"); | ||
1043 | } | ||
1044 | postCommand_App("preferences idents:1"); | ||
1045 | #if 0 | ||
1046 | /* TODO: Clean this up. */ | ||
1019 | iWidget *sidebar2 = findWidget_App("sidebar2"); | 1047 | iWidget *sidebar2 = findWidget_App("sidebar2"); |
1020 | //dismissSidebar_(sidebar, "toolbar.view"); | 1048 | //dismissSidebar_(sidebar, "toolbar.view"); |
1021 | if (isVisible_Widget(sidebar)) { | 1049 | if (isVisible_Widget(sidebar)) { |
@@ -1036,6 +1064,7 @@ static iBool handleToolBarCommands_(iWidget *toolBar, const char *cmd) { | |||
1036 | setVisualOffset_Widget(sidebar2, offset, 0, 0); | 1064 | setVisualOffset_Widget(sidebar2, offset, 0, 0); |
1037 | setVisualOffset_Widget(sidebar2, 0, 400, easeOut_AnimFlag | softer_AnimFlag); | 1065 | setVisualOffset_Widget(sidebar2, 0, 400, easeOut_AnimFlag | softer_AnimFlag); |
1038 | } | 1066 | } |
1067 | #endif | ||
1039 | return iTrue; | 1068 | return iTrue; |
1040 | } | 1069 | } |
1041 | else if (equal_Command(cmd, "sidebar.mode.changed")) { | 1070 | else if (equal_Command(cmd, "sidebar.mode.changed")) { |
@@ -1099,15 +1128,16 @@ void updateMetrics_Root(iRoot *d) { | |||
1099 | const iWidget *toolBar = findChild_Widget(d->widget, "toolbar"); | 1128 | const iWidget *toolBar = findChild_Widget(d->widget, "toolbar"); |
1100 | const iWidget *viewButton = findChild_Widget(d->widget, "toolbar.view"); | 1129 | const iWidget *viewButton = findChild_Widget(d->widget, "toolbar.view"); |
1101 | const iWidget *idButton = findChild_Widget(toolBar, "toolbar.ident"); | 1130 | const iWidget *idButton = findChild_Widget(toolBar, "toolbar.ident"); |
1102 | const int font = uiLabelTiny_FontId; | 1131 | // const int font = uiLabelTiny_FontId; |
1103 | setFont_LabelWidget(idName, font); | 1132 | setFixedSize_Widget(as_Widget(idName), init_I2(-1, 2 * gap_UI + lineHeight_Text(uiLabelTiny_FontId))); |
1104 | setPos_Widget(as_Widget(idName), | 1133 | // setFont_LabelWidget(idName, font); |
1134 | /*setPos_Widget(as_Widget(idName), | ||
1105 | windowToLocal_Widget(as_Widget(idName), | 1135 | windowToLocal_Widget(as_Widget(idName), |
1106 | init_I2(left_Rect(bounds_Widget(idButton)), | 1136 | init_I2(left_Rect(bounds_Widget(idButton)), |
1107 | bottom_Rect(bounds_Widget(viewButton)) - | 1137 | bottom_Rect(bounds_Widget(viewButton)) - |
1108 | lineHeight_Text(font) - gap_UI / 2))); | 1138 | lineHeight_Text(font) - gap_UI / 2))); |
1109 | setFixedSize_Widget(as_Widget(idName), init_I2(width_Widget(idButton), | 1139 | setFixedSize_Widget(as_Widget(idName), init_I2(width_Widget(idButton), |
1110 | lineHeight_Text(font))); | 1140 | lineHeight_Text(font)));*/ |
1111 | } | 1141 | } |
1112 | } | 1142 | } |
1113 | postRefresh_App(); | 1143 | postRefresh_App(); |
@@ -1413,15 +1443,17 @@ void createUserInterface_Root(iRoot *d) { | |||
1413 | iWidget *content = findChild_Widget(root, "tabs.content"); | 1443 | iWidget *content = findChild_Widget(root, "tabs.content"); |
1414 | iSidebarWidget *sidebar1 = new_SidebarWidget(left_SidebarSide); | 1444 | iSidebarWidget *sidebar1 = new_SidebarWidget(left_SidebarSide); |
1415 | addChildPos_Widget(content, iClob(sidebar1), front_WidgetAddPos); | 1445 | addChildPos_Widget(content, iClob(sidebar1), front_WidgetAddPos); |
1416 | iSidebarWidget *sidebar2 = new_SidebarWidget(right_SidebarSide); | ||
1417 | if (deviceType_App() != phone_AppDeviceType) { | 1446 | if (deviceType_App() != phone_AppDeviceType) { |
1447 | iSidebarWidget *sidebar2 = new_SidebarWidget(right_SidebarSide); | ||
1418 | addChildPos_Widget(content, iClob(sidebar2), back_WidgetAddPos); | 1448 | addChildPos_Widget(content, iClob(sidebar2), back_WidgetAddPos); |
1419 | } | 1449 | } |
1450 | #if 0 | ||
1420 | else { | 1451 | else { |
1421 | /* The identities sidebar is always in the main area. */ | 1452 | /* The identities sidebar is always in the main area. */ |
1422 | addChild_Widget(findChild_Widget(root, "stack"), iClob(sidebar2)); | 1453 | addChild_Widget(findChild_Widget(root, "stack"), iClob(sidebar2)); |
1423 | setFlags_Widget(as_Widget(sidebar2), hidden_WidgetFlag, iTrue); | 1454 | setFlags_Widget(as_Widget(sidebar2), hidden_WidgetFlag, iTrue); |
1424 | } | 1455 | } |
1456 | #endif | ||
1425 | } | 1457 | } |
1426 | /* Lookup results. */ { | 1458 | /* Lookup results. */ { |
1427 | iLookupWidget *lookup = new_LookupWidget(); | 1459 | iLookupWidget *lookup = new_LookupWidget(); |
@@ -1481,23 +1513,29 @@ void createUserInterface_Root(iRoot *d) { | |||
1481 | iClob(newLargeIcon_LabelWidget(forwardArrow_Icon, "navigate.forward")), | 1513 | iClob(newLargeIcon_LabelWidget(forwardArrow_Icon, "navigate.forward")), |
1482 | frameless_WidgetFlag), | 1514 | frameless_WidgetFlag), |
1483 | "toolbar.forward"); | 1515 | "toolbar.forward"); |
1484 | setId_Widget(addChildFlags_Widget(toolBar, | 1516 | iWidget *identButton; |
1485 | iClob(newLargeIcon_LabelWidget("\U0001f464", "identmenu.open")), | 1517 | setId_Widget(identButton = addChildFlags_Widget( |
1486 | frameless_WidgetFlag), | 1518 | toolBar, |
1519 | iClob(newLargeIcon_LabelWidget("\U0001f464", "identmenu.open")), | ||
1520 | frameless_WidgetFlag | fixedHeight_WidgetFlag), | ||
1487 | "toolbar.ident"); | 1521 | "toolbar.ident"); |
1488 | setId_Widget(addChildFlags_Widget(toolBar, | 1522 | setId_Widget(addChildFlags_Widget(toolBar, |
1489 | iClob(newLargeIcon_LabelWidget(book_Icon, "toolbar.showview arg:-1")), | 1523 | iClob(newLargeIcon_LabelWidget(book_Icon, "toolbar.showview arg:-1")), |
1490 | frameless_WidgetFlag | commandOnClick_WidgetFlag), | 1524 | frameless_WidgetFlag | commandOnClick_WidgetFlag), |
1491 | "toolbar.view"); | 1525 | "toolbar.view"); |
1492 | setId_Widget(addChildFlags_Widget(toolBar, | 1526 | iLabelWidget *idName; |
1493 | iClob(new_LabelWidget("", "toolbar.showident")), | 1527 | setId_Widget(addChildFlags_Widget(identButton, |
1528 | iClob(idName = new_LabelWidget("", NULL)), | ||
1494 | frameless_WidgetFlag | | 1529 | frameless_WidgetFlag | |
1495 | noBackground_WidgetFlag | | 1530 | noBackground_WidgetFlag | |
1496 | fixedPosition_WidgetFlag | | 1531 | moveToParentBottomEdge_WidgetFlag | |
1532 | resizeToParentWidth_WidgetFlag | ||
1533 | /*fixedPosition_WidgetFlag | | ||
1497 | fixedSize_WidgetFlag | | 1534 | fixedSize_WidgetFlag | |
1498 | ignoreForParentWidth_WidgetFlag | | 1535 | ignoreForParentWidth_WidgetFlag | |
1499 | ignoreForParentHeight_WidgetFlag), | 1536 | ignoreForParentHeight_WidgetFlag*/), |
1500 | "toolbar.name"); | 1537 | "toolbar.name"); |
1538 | setFont_LabelWidget(idName, uiLabelTiny_FontId); | ||
1501 | iLabelWidget *menuButton = makeMenuButton_LabelWidget(menu_Icon, phoneNavMenuItems_, | 1539 | iLabelWidget *menuButton = makeMenuButton_LabelWidget(menu_Icon, phoneNavMenuItems_, |
1502 | iElemCount(phoneNavMenuItems_)); | 1540 | iElemCount(phoneNavMenuItems_)); |
1503 | setFont_LabelWidget(menuButton, uiLabelLarge_FontId); | 1541 | setFont_LabelWidget(menuButton, uiLabelLarge_FontId); |
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 674e2b7c..9b94f4d9 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -608,8 +608,10 @@ iBool setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { | |||
608 | } | 608 | } |
609 | 609 | ||
610 | void setClosedFolders_SidebarWidget(iSidebarWidget *d, const iIntSet *closedFolders) { | 610 | void setClosedFolders_SidebarWidget(iSidebarWidget *d, const iIntSet *closedFolders) { |
611 | delete_IntSet(d->closedFolders); | 611 | if (d) { |
612 | d->closedFolders = copy_IntSet(closedFolders); | 612 | delete_IntSet(d->closedFolders); |
613 | d->closedFolders = copy_IntSet(closedFolders); | ||
614 | } | ||
613 | } | 615 | } |
614 | 616 | ||
615 | enum iSidebarMode mode_SidebarWidget(const iSidebarWidget *d) { | 617 | enum iSidebarMode mode_SidebarWidget(const iSidebarWidget *d) { |
@@ -625,7 +627,7 @@ float width_SidebarWidget(const iSidebarWidget *d) { | |||
625 | } | 627 | } |
626 | 628 | ||
627 | const iIntSet *closedFolders_SidebarWidget(const iSidebarWidget *d) { | 629 | const iIntSet *closedFolders_SidebarWidget(const iSidebarWidget *d) { |
628 | return d->closedFolders; | 630 | return d ? d->closedFolders : collect_IntSet(new_IntSet()); |
629 | } | 631 | } |
630 | 632 | ||
631 | static const char *normalModeLabels_[max_SidebarMode] = { | 633 | static const char *normalModeLabels_[max_SidebarMode] = { |
@@ -710,7 +712,8 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) { | |||
710 | setId_Widget(buttons, "buttons"); | 712 | setId_Widget(buttons, "buttons"); |
711 | setDrawBufferEnabled_Widget(buttons, iTrue); | 713 | setDrawBufferEnabled_Widget(buttons, iTrue); |
712 | for (int i = 0; i < max_SidebarMode; i++) { | 714 | for (int i = 0; i < max_SidebarMode; i++) { |
713 | if (deviceType_App() == phone_AppDeviceType && i == identities_SidebarMode) { | 715 | if (i == identities_SidebarMode && deviceType_App() != desktop_AppDeviceType) { |
716 | /* On mobile, identities are managed via Settings. */ | ||
714 | continue; | 717 | continue; |
715 | } | 718 | } |
716 | d->modeButtons[i] = addChildFlags_Widget( | 719 | d->modeButtons[i] = addChildFlags_Widget( |
@@ -911,6 +914,7 @@ static void checkModeButtonLayout_SidebarWidget_(iSidebarWidget *d) { | |||
911 | } | 914 | } |
912 | 915 | ||
913 | void setWidth_SidebarWidget(iSidebarWidget *d, float widthAsGaps) { | 916 | void setWidth_SidebarWidget(iSidebarWidget *d, float widthAsGaps) { |
917 | if (!d) return; | ||
914 | iWidget *w = as_Widget(d); | 918 | iWidget *w = as_Widget(d); |
915 | const iBool isFixedWidth = deviceType_App() == phone_AppDeviceType; | 919 | const iBool isFixedWidth = deviceType_App() == phone_AppDeviceType; |
916 | int width = widthAsGaps * gap_UI; /* in pixels */ | 920 | int width = widthAsGaps * gap_UI; /* in pixels */ |
@@ -1148,10 +1152,10 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
1148 | } | 1152 | } |
1149 | } | 1153 | } |
1150 | } | 1154 | } |
1151 | else if (deviceType_App() == tablet_AppDeviceType && equal_Command(cmd, "toolbar.showident")) { | 1155 | // else if (deviceType_App() == tablet_AppDeviceType && equal_Command(cmd, "toolbar.showident")) { |
1152 | postCommandf_App("sidebar.mode arg:%d toggle:1", identities_SidebarMode); | 1156 | // postCommandf_App("sidebar.mode arg:%d toggle:1", identities_SidebarMode); |
1153 | return iTrue; | 1157 | // return iTrue; |
1154 | } | 1158 | // } |
1155 | else if (isPortraitPhone_App() && isVisible_Widget(w) && d->side == left_SidebarSide && | 1159 | else if (isPortraitPhone_App() && isVisible_Widget(w) && d->side == left_SidebarSide && |
1156 | equal_Command(cmd, "swipe.forward")) { | 1160 | equal_Command(cmd, "swipe.forward")) { |
1157 | postCommand_App("sidebar.toggle"); | 1161 | postCommand_App("sidebar.toggle"); |
diff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c index c22bfe86..89376633 100644 --- a/src/ui/uploadwidget.c +++ b/src/ui/uploadwidget.c | |||
@@ -123,9 +123,14 @@ static const iArray *makeIdentityItems_UploadWidget_(const iUploadWidget *d) { | |||
123 | pushBack_Array(items, &(iMenuItem){ "---" }); | 123 | pushBack_Array(items, &(iMenuItem){ "---" }); |
124 | iConstForEach(PtrArray, i, listIdentities_GmCerts(certs_App(), NULL, NULL)) { | 124 | iConstForEach(PtrArray, i, listIdentities_GmCerts(certs_App(), NULL, NULL)) { |
125 | const iGmIdentity *id = i.ptr; | 125 | const iGmIdentity *id = i.ptr; |
126 | iString *str = collect_String(copy_String(name_GmIdentity(id))); | ||
127 | if (!isEmpty_String(&id->notes)) { | ||
128 | appendFormat_String( | ||
129 | str, "\n%s%s", escape_Color(uiAnnotation_ColorId), cstr_String(&id->notes)); | ||
130 | } | ||
126 | pushBack_Array( | 131 | pushBack_Array( |
127 | items, | 132 | items, |
128 | &(iMenuItem){ cstr_String(name_GmIdentity(id)), 0, 0, | 133 | &(iMenuItem){ cstr_String(str), 0, 0, |
129 | format_CStr("upload.setid fp:%s", | 134 | format_CStr("upload.setid fp:%s", |
130 | cstrCollect_String(hexEncode_Block(&id->fingerprint))) }); | 135 | cstrCollect_String(hexEncode_Block(&id->fingerprint))) }); |
131 | } | 136 | } |
diff --git a/src/ui/util.c b/src/ui/util.c index 61d3e9bb..de838769 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1215,6 +1215,15 @@ iLabelWidget *findMenuItem_Widget(iWidget *menu, const char *command) { | |||
1215 | return NULL; | 1215 | return NULL; |
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | iWidget *findUserData_Widget(iWidget *d, void *userData) { | ||
1219 | iForEach(ObjectList, i, children_Widget(d)) { | ||
1220 | if (userData_Object(i.object) == userData) { | ||
1221 | return i.object; | ||
1222 | } | ||
1223 | } | ||
1224 | return NULL; | ||
1225 | } | ||
1226 | |||
1218 | void setMenuItemDisabled_Widget(iWidget *menu, const char *command, iBool disable) { | 1227 | void setMenuItemDisabled_Widget(iWidget *menu, const char *command, iBool disable) { |
1219 | if (flags_Widget(menu) & nativeMenu_WidgetFlag) { | 1228 | if (flags_Widget(menu) & nativeMenu_WidgetFlag) { |
1220 | setDisabled_NativeMenuItem(findNativeMenuItem_Widget(menu, command), disable); | 1229 | setDisabled_NativeMenuItem(findNativeMenuItem_Widget(menu, command), disable); |
diff --git a/src/ui/util.h b/src/ui/util.h index 81fb1cbd..7ee94f1d 100644 --- a/src/ui/util.h +++ b/src/ui/util.h | |||
@@ -249,7 +249,8 @@ void setMenuItemDisabled_Widget (iWidget *menu, const char *comm | |||
249 | void setMenuItemDisabledByIndex_Widget(iWidget *menu, size_t index, iBool disable); | 249 | void setMenuItemDisabledByIndex_Widget(iWidget *menu, size_t index, iBool disable); |
250 | void setMenuItemLabel_Widget (iWidget *menu, const char *command, const char *newLabel); | 250 | void setMenuItemLabel_Widget (iWidget *menu, const char *command, const char *newLabel); |
251 | void setMenuItemLabelByIndex_Widget (iWidget *menu, size_t index, const char *newLabel); | 251 | void setMenuItemLabelByIndex_Widget (iWidget *menu, size_t index, const char *newLabel); |
252 | void setNativeMenuItems_Widget (iWidget *, const iMenuItem *items, size_t n); | 252 | void setNativeMenuItems_Widget (iWidget *menu, const iMenuItem *items, size_t n); |
253 | iWidget * findUserData_Widget (iWidget *, void *userData); | ||
253 | 254 | ||
254 | int checkContextMenu_Widget (iWidget *, const SDL_Event *ev); /* see macro below */ | 255 | int checkContextMenu_Widget (iWidget *, const SDL_Event *ev); /* see macro below */ |
255 | 256 | ||
diff --git a/src/ui/widget.c b/src/ui/widget.c index 254c2590..210fe899 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -271,10 +271,12 @@ void setMinSize_Widget(iWidget *d, iInt2 minSize) { | |||
271 | } | 271 | } |
272 | 272 | ||
273 | void setPadding_Widget(iWidget *d, int left, int top, int right, int bottom) { | 273 | void setPadding_Widget(iWidget *d, int left, int top, int right, int bottom) { |
274 | d->padding[0] = left; | 274 | if (d) { |
275 | d->padding[1] = top; | 275 | d->padding[0] = left; |
276 | d->padding[2] = right; | 276 | d->padding[1] = top; |
277 | d->padding[3] = bottom; | 277 | d->padding[2] = right; |
278 | d->padding[3] = bottom; | ||
279 | } | ||
278 | } | 280 | } |
279 | 281 | ||
280 | iWidget *root_Widget(const iWidget *d) { | 282 | iWidget *root_Widget(const iWidget *d) { |