summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index e7b412a9..e13f8da9 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -318,6 +318,7 @@ void init_DocumentWidget(iDocumentWidget *d) {
318 init_PersistentDocumentState(&d->mod); 318 init_PersistentDocumentState(&d->mod);
319 d->flags = 0; 319 d->flags = 0;
320 d->phoneToolbar = NULL; 320 d->phoneToolbar = NULL;
321 d->footerButtons = NULL;
321 iZap(d->certExpiry); 322 iZap(d->certExpiry);
322 d->certFingerprint = new_Block(0); 323 d->certFingerprint = new_Block(0);
323 d->certFlags = 0; 324 d->certFlags = 0;
@@ -331,7 +332,6 @@ void init_DocumentWidget(iDocumentWidget *d) {
331 d->redirectCount = 0; 332 d->redirectCount = 0;
332 d->ordinalBase = 0; 333 d->ordinalBase = 0;
333 d->initNormScrollY = 0; 334 d->initNormScrollY = 0;
334 //init_Anim(&d->scrollY, 0);
335 init_SmoothScroll(&d->scrollY, w, scrollBegan_DocumentWidget_); 335 init_SmoothScroll(&d->scrollY, w, scrollBegan_DocumentWidget_);
336 d->animWideRunId = 0; 336 d->animWideRunId = 0;
337 init_Anim(&d->animWideRunOffset, 0); 337 init_Anim(&d->animWideRunOffset, 0);
@@ -1032,6 +1032,37 @@ static enum iGmDocumentBanner bannerType_DocumentWidget_(const iDocumentWidget *
1032 return siteDomain_GmDocumentBanner; 1032 return siteDomain_GmDocumentBanner;
1033} 1033}
1034 1034
1035static void makeFooterButtons_DocumentWidget_(iDocumentWidget *d, const iMenuItem *items, size_t count) {
1036 iWidget *w = as_Widget(d);
1037 destroy_Widget(d->footerButtons);
1038 d->footerButtons = NULL;
1039 if (count == 0) {
1040 return;
1041 }
1042 d->footerButtons = new_Widget();
1043 setFlags_Widget(d->footerButtons,
1044 unhittable_WidgetFlag | arrangeVertical_WidgetFlag |
1045 resizeWidthOfChildren_WidgetFlag | arrangeHeight_WidgetFlag |
1046 fixedPosition_WidgetFlag | resizeToParentWidth_WidgetFlag,
1047 iTrue);
1048 setBackgroundColor_Widget(d->footerButtons, tmBannerBackground_ColorId);
1049 const iRect bounds = bounds_Widget(w);
1050 const iRect docBounds = documentBounds_DocumentWidget_(d);
1051 const int hPad = (width_Rect(bounds) - width_Rect(docBounds)) / 2;
1052 const int vPad = 3 * gap_UI;
1053 setPadding_Widget(d->footerButtons, hPad, vPad, hPad, vPad);
1054 for (size_t i = 0; i < count; ++i) {
1055 iLabelWidget *button =
1056 addChild_Widget(d->footerButtons,
1057 iClob(newKeyMods_LabelWidget(
1058 items[i].label, items[i].key, items[i].kmods, items[i].command)));
1059 checkIcon_LabelWidget(button);
1060 setFont_LabelWidget(button, uiContent_FontId);
1061 }
1062 addChild_Widget(as_Widget(d), iClob(d->footerButtons));
1063 arrange_Widget(d->footerButtons);
1064}
1065
1035static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode code, 1066static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode code,
1036 const iString *meta) { 1067 const iString *meta) {
1037 iString *src = collectNewCStr_String("# "); 1068 iString *src = collectNewCStr_String("# ");
@@ -1061,6 +1092,13 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode
1061 cstr_Lang("error.unsupported.suggestsave"), 1092 cstr_Lang("error.unsupported.suggestsave"),
1062 cstr_String(key), 1093 cstr_String(key),
1063 saveToDownloads_Label); 1094 saveToDownloads_Label);
1095 makeFooterButtons_DocumentWidget_(
1096 d,
1097 (iMenuItem[]){ { translateCStr_Lang(download_Icon " " saveToDownloads_Label),
1098 0,
1099 0,
1100 "document.save" } },
1101 1);
1064 break; 1102 break;
1065 } 1103 }
1066 case slowDown_GmStatusCode: 1104 case slowDown_GmStatusCode: