diff options
-rw-r--r-- | src/ui/uploadwidget.c | 29 | ||||
-rw-r--r-- | src/ui/util.c | 49 | ||||
-rw-r--r-- | src/ui/util.h | 1 |
3 files changed, 46 insertions, 33 deletions
diff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c index c199990e..b8591b8f 100644 --- a/src/ui/uploadwidget.c +++ b/src/ui/uploadwidget.c | |||
@@ -106,7 +106,7 @@ static void updateInputMaxHeight_UploadWidget_(iUploadWidget *d) { | |||
106 | 106 | ||
107 | static const iArray *makeIdentityItems_UploadWidget_(const iUploadWidget *d) { | 107 | static const iArray *makeIdentityItems_UploadWidget_(const iUploadWidget *d) { |
108 | iArray *items = collectNew_Array(sizeof(iMenuItem)); | 108 | iArray *items = collectNew_Array(sizeof(iMenuItem)); |
109 | const iGmIdentity *urlId = identityForUrl_GmCerts(certs_App(), &d->url); | 109 | const iGmIdentity *urlId = identityForUrl_GmCerts(certs_App(), &d->url); |
110 | pushBack_Array(items, &(iMenuItem){ format_CStr("${dlg.upload.id.default} (%s)", | 110 | pushBack_Array(items, &(iMenuItem){ format_CStr("${dlg.upload.id.default} (%s)", |
111 | urlId ? cstr_String(name_GmIdentity(urlId)) : "${dlg.upload.id.none}"), | 111 | urlId ? cstr_String(name_GmIdentity(urlId)) : "${dlg.upload.id.none}"), |
112 | 0, 0, "upload.setid arg:1" }); | 112 | 0, 0, "upload.setid arg:1" }); |
@@ -260,6 +260,22 @@ void deinit_UploadWidget(iUploadWidget *d) { | |||
260 | iRelease(d->request); | 260 | iRelease(d->request); |
261 | } | 261 | } |
262 | 262 | ||
263 | static void remakeIdentityItems_UploadWidget_(iUploadWidget *d) { | ||
264 | iWidget *dropMenu= findChild_Widget(findChild_Widget(as_Widget(d), "upload.id"), "menu"); | ||
265 | releaseChildren_Widget(dropMenu); | ||
266 | const iArray *items = makeIdentityItems_UploadWidget_(d); | ||
267 | makeMenuItems_Widget(dropMenu, constData_Array(items), size_Array(items)); | ||
268 | } | ||
269 | |||
270 | static void updateIdentityDropdown_UploadWidget_(iUploadWidget *d) { | ||
271 | updateDropdownSelection_LabelWidget( | ||
272 | findChild_Widget(as_Widget(d), "upload.id"), | ||
273 | d->idMode == none_UploadIdentity ? " arg:0" | ||
274 | : d->idMode == defaultForUrl_UploadIdentity | ||
275 | ? " arg:1" | ||
276 | : format_CStr(" fp:%s", cstrCollect_String(hexEncode_Block(&d->idFingerprint)))); | ||
277 | } | ||
278 | |||
263 | static uint16_t titanPortForUrl_(const iString *url) { | 279 | static uint16_t titanPortForUrl_(const iString *url) { |
264 | uint16_t port = 0; | 280 | uint16_t port = 0; |
265 | const iString *root = collectNewRange_String(urlRoot_String(url)); | 281 | const iString *root = collectNewRange_String(urlRoot_String(url)); |
@@ -289,6 +305,8 @@ static void setUrlPort_UploadWidget_(iUploadWidget *d, const iString *url, uint1 | |||
289 | 305 | ||
290 | void setUrl_UploadWidget(iUploadWidget *d, const iString *url) { | 306 | void setUrl_UploadWidget(iUploadWidget *d, const iString *url) { |
291 | setUrlPort_UploadWidget_(d, url, 0); | 307 | setUrlPort_UploadWidget_(d, url, 0); |
308 | remakeIdentityItems_UploadWidget_(d); | ||
309 | updateIdentityDropdown_UploadWidget_(d); | ||
292 | } | 310 | } |
293 | 311 | ||
294 | void setResponseViewer_UploadWidget(iUploadWidget *d, iDocumentWidget *doc) { | 312 | void setResponseViewer_UploadWidget(iUploadWidget *d, iDocumentWidget *doc) { |
@@ -311,15 +329,6 @@ static void requestFinished_UploadWidget_(iUploadWidget *d, iGmRequest *req) { | |||
311 | postCommand_Widget(d, "upload.request.finished reqid:%u", id_GmRequest(req)); | 329 | postCommand_Widget(d, "upload.request.finished reqid:%u", id_GmRequest(req)); |
312 | } | 330 | } |
313 | 331 | ||
314 | static void updateIdentityDropdown_UploadWidget_(iUploadWidget *d) { | ||
315 | updateDropdownSelection_LabelWidget( | ||
316 | findChild_Widget(as_Widget(d), "upload.id"), | ||
317 | d->idMode == none_UploadIdentity ? " arg:0" | ||
318 | : d->idMode == defaultForUrl_UploadIdentity | ||
319 | ? " arg:1" | ||
320 | : format_CStr(" fp:%s", cstrCollect_String(hexEncode_Block(&d->idFingerprint)))); | ||
321 | } | ||
322 | |||
323 | static void updateFileInfo_UploadWidget_(iUploadWidget *d) { | 332 | static void updateFileInfo_UploadWidget_(iUploadWidget *d) { |
324 | iFileInfo *info = iClob(new_FileInfo(&d->filePath)); | 333 | iFileInfo *info = iClob(new_FileInfo(&d->filePath)); |
325 | if (isDirectory_FileInfo(info)) { | 334 | if (isDirectory_FileInfo(info)) { |
diff --git a/src/ui/util.c b/src/ui/util.c index eb3d1cf2..b78cd6c6 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -683,29 +683,11 @@ static iWidget *makeMenuSeparator_(void) { | |||
683 | return sep; | 683 | return sep; |
684 | } | 684 | } |
685 | 685 | ||
686 | iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | 686 | void makeMenuItems_Widget(iWidget *menu, const iMenuItem *items, size_t n) { |
687 | iWidget *menu = new_Widget(); | ||
688 | setDrawBufferEnabled_Widget(menu, iTrue); | ||
689 | setBackgroundColor_Widget(menu, uiBackgroundMenu_ColorId); | ||
690 | if (deviceType_App() != desktop_AppDeviceType) { | ||
691 | setPadding1_Widget(menu, 2 * gap_UI); | ||
692 | } | ||
693 | else { | ||
694 | setPadding1_Widget(menu, gap_UI / 2); | ||
695 | } | ||
696 | const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); | 687 | const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); |
697 | int64_t itemFlags = (deviceType_App() != desktop_AppDeviceType ? 0 : 0) | | 688 | int64_t itemFlags = (deviceType_App() != desktop_AppDeviceType ? 0 : 0) | |
698 | (isPortraitPhone ? extraPadding_WidgetFlag : 0); | 689 | (isPortraitPhone ? extraPadding_WidgetFlag : 0); |
699 | setFlags_Widget(menu, | 690 | iBool haveIcons = iFalse; |
700 | keepOnTop_WidgetFlag | collapse_WidgetFlag | hidden_WidgetFlag | | ||
701 | arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag | | ||
702 | resizeChildrenToWidestChild_WidgetFlag | overflowScrollable_WidgetFlag | | ||
703 | (isPortraitPhone ? drawBackgroundToVerticalSafeArea_WidgetFlag : 0), | ||
704 | iTrue); | ||
705 | if (!isPortraitPhone) { | ||
706 | setFrameColor_Widget(menu, uiSeparator_ColorId); | ||
707 | } | ||
708 | iBool haveIcons = iFalse; | ||
709 | iWidget *horizGroup = NULL; | 691 | iWidget *horizGroup = NULL; |
710 | for (size_t i = 0; i < n; ++i) { | 692 | for (size_t i = 0; i < n; ++i) { |
711 | const iMenuItem *item = &items[i]; | 693 | const iMenuItem *item = &items[i]; |
@@ -739,7 +721,7 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | |||
739 | iClob(newKeyMods_LabelWidget(labelText, item->key, item->kmods, item->command)), | 721 | iClob(newKeyMods_LabelWidget(labelText, item->key, item->kmods, item->command)), |
740 | noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag | | 722 | noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag | |
741 | drawKey_WidgetFlag | itemFlags); | 723 | drawKey_WidgetFlag | itemFlags); |
742 | setWrap_LabelWidget(label, isInfo); | 724 | setWrap_LabelWidget(label, isInfo); |
743 | haveIcons |= checkIcon_LabelWidget(label); | 725 | haveIcons |= checkIcon_LabelWidget(label); |
744 | updateSize_LabelWidget(label); /* drawKey was set */ | 726 | updateSize_LabelWidget(label); /* drawKey was set */ |
745 | if (isInfo) { | 727 | if (isInfo) { |
@@ -765,7 +747,28 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | |||
765 | } | 747 | } |
766 | } | 748 | } |
767 | } | 749 | } |
750 | }} | ||
751 | |||
752 | iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | ||
753 | iWidget *menu = new_Widget(); | ||
754 | setDrawBufferEnabled_Widget(menu, iTrue); | ||
755 | setBackgroundColor_Widget(menu, uiBackgroundMenu_ColorId); | ||
756 | if (deviceType_App() != desktop_AppDeviceType) { | ||
757 | setPadding1_Widget(menu, 2 * gap_UI); | ||
758 | } | ||
759 | else { | ||
760 | setPadding1_Widget(menu, gap_UI / 2); | ||
761 | } | ||
762 | setFlags_Widget(menu, | ||
763 | keepOnTop_WidgetFlag | collapse_WidgetFlag | hidden_WidgetFlag | | ||
764 | arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag | | ||
765 | resizeChildrenToWidestChild_WidgetFlag | overflowScrollable_WidgetFlag | | ||
766 | (isPortraitPhone_App() ? drawBackgroundToVerticalSafeArea_WidgetFlag : 0), | ||
767 | iTrue); | ||
768 | if (!isPortraitPhone_App()) { | ||
769 | setFrameColor_Widget(menu, uiSeparator_ColorId); | ||
768 | } | 770 | } |
771 | makeMenuItems_Widget(menu, items, n); | ||
769 | addChild_Widget(parent, menu); | 772 | addChild_Widget(parent, menu); |
770 | iRelease(menu); /* owned by parent now */ | 773 | iRelease(menu); /* owned by parent now */ |
771 | setCommandHandler_Widget(menu, menuHandler_); | 774 | setCommandHandler_Widget(menu, menuHandler_); |
diff --git a/src/ui/util.h b/src/ui/util.h index 74a95827..938a200d 100644 --- a/src/ui/util.h +++ b/src/ui/util.h | |||
@@ -227,6 +227,7 @@ struct Impl_MenuItem { | |||
227 | }; | 227 | }; |
228 | 228 | ||
229 | iWidget * makeMenu_Widget (iWidget *parent, const iMenuItem *items, size_t n); /* returns no ref */ | 229 | iWidget * makeMenu_Widget (iWidget *parent, const iMenuItem *items, size_t n); /* returns no ref */ |
230 | void makeMenuItems_Widget(iWidget *menu, const iMenuItem *items, size_t n); | ||
230 | void openMenu_Widget (iWidget *, iInt2 windowCoord); | 231 | void openMenu_Widget (iWidget *, iInt2 windowCoord); |
231 | void openMenuFlags_Widget(iWidget *, iInt2 windowCoord, iBool postCommands); | 232 | void openMenuFlags_Widget(iWidget *, iInt2 windowCoord, iBool postCommands); |
232 | void closeMenu_Widget (iWidget *); | 233 | void closeMenu_Widget (iWidget *); |