From 64eaaaac57fc909a9c9d47302f17f0801b7f2965 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 15 Feb 2022 17:49:17 +0200 Subject: Working on site-specific settings dialog --- src/ui/documentwidget.c | 12 ++++++++---- src/ui/util.c | 43 ++++++++++++++++++++++++++++++++++--------- src/ui/util.h | 15 ++++++++------- 3 files changed, 50 insertions(+), 20 deletions(-) (limited to 'src/ui') diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 293e4507..7d9ac154 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -3936,12 +3936,12 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) const char *unchecked = red_ColorEscape "\u2610"; const char *checked = green_ColorEscape "\u2611"; const iBool haveFingerprint = (d->certFlags & haveFingerprint_GmCertFlag) != 0; - const int requiredForTrust = (available_GmCertFlag | haveFingerprint_GmCertFlag | - timeVerified_GmCertFlag); + const int requiredForTrust = + (available_GmCertFlag | haveFingerprint_GmCertFlag | timeVerified_GmCertFlag); const iBool canTrust = ~d->certFlags & trusted_GmCertFlag && ((d->certFlags & requiredForTrust) == requiredForTrust); const iRecentUrl *recent = constMostRecentUrl_History(d->mod.history); - const iString *meta = &d->sourceMime; + const iString *meta = &d->sourceMime; if (recent && recent->cachedResponse) { meta = &recent->cachedResponse->meta; } @@ -4006,6 +4006,10 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) if (haveFingerprint) { pushBack_Array(items, &(iMenuItem){ "${dlg.cert.fingerprint}", 0, 0, "server.copycert" }); } + const iRangecc root = urlRoot_String(d->mod.url); + if (!isEmpty_Range(&root)) { + pushBack_Array(items, &(iMenuItem){ "${pageinfo.settings}", 0, 0, "document.sitespec" }); + } if (!isEmpty_Array(items)) { pushBack_Array(items, &(iMenuItem){ "---", 0, 0, 0 }); } @@ -4937,7 +4941,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e for (size_t i = 0; i < 64; ++i) { setByte_Block(seed, i, iRandom(0, 256)); } - setThemeSeed_GmDocument(view->doc, seed); + setThemeSeed_GmDocument(view->doc, seed, NULL); delete_Block(seed); invalidate_DocumentWidget_(d); refresh_Widget(w); diff --git a/src/ui/util.c b/src/ui/util.c index befc2fd5..54715121 100644 --- a/src/ui/util.c +++ b/src/ui/util.c @@ -3169,15 +3169,14 @@ static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) { } iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) { - const char *headingText = bookmarkId ? uiHeading_ColorEscape "${heading.feedcfg}" - : uiHeading_ColorEscape "${heading.subscribe}"; - const iMenuItem actions[] = { { "${cancel}" }, - { bookmarkId ? uiTextCaution_ColorEscape "${dlg.feed.save}" - : uiTextCaution_ColorEscape "${dlg.feed.sub}", - SDLK_RETURN, - KMOD_PRIMARY, - format_CStr("feedcfg.accept bmid:%d", bookmarkId) } }; - iWidget *dlg; + iWidget *dlg; + const char *headingText = bookmarkId ? "${heading.feedcfg}" : "${heading.subscribe}"; + const iMenuItem actions[] = { { "${cancel}" }, + { bookmarkId ? uiTextCaution_ColorEscape "${dlg.feed.save}" + : uiTextCaution_ColorEscape "${dlg.feed.sub}", + SDLK_RETURN, + KMOD_PRIMARY, + format_CStr("feedcfg.accept bmid:%d", bookmarkId) } }; if (isUsingPanelLayout_Mobile()) { const iMenuItem typeItems[] = { { "button id:feedcfg.type.gemini label:dlg.feed.type.gemini", 0, 0, "feedcfg.type arg:0" }, @@ -3234,6 +3233,32 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) { return dlg; } +iWidget *makeSiteSpecificSettings_Widget(const iString *url) { + iWidget *dlg; + const iMenuItem actions[] = { + { "${cancel}" }, { "${sitespec.accept}", SDLK_RETURN, KMOD_PRIMARY, "sitespec.accept" } + }; + if (isUsingPanelLayout_Mobile()) { + iAssert(iFalse); + } + else { + iWidget *headings, *values; + dlg = makeSheet_Widget("sitespec"); + addDialogTitle_(dlg, "${heading.sitespec}", "heading.sitespec"); + addChild_Widget(dlg, iClob(makeTwoColumns_Widget(&headings, &values))); + addDialogToggle_(headings, values, "${sitespec.ansi}", "sitespec.ansi"); + iInputWidget *palInput = new_InputWidget(0); + addPrefsInputWithHeading_(headings, values, "sitespec.palette", iClob(palInput)); + as_Widget(palInput)->rect.size.x = 80 * gap_UI; + addChild_Widget(dlg, iClob(makeDialogButtons_Widget(actions, iElemCount(actions)))); + } + /* Initialize. */ { + const iRangecc root = urlRoot_String(url); + + } + return dlg; +} + iWidget *makeIdentityCreation_Widget(void) { const iMenuItem actions[] = { { "${dlg.newident.more}", 0, 0, "ident.showmore" }, { "---" }, diff --git a/src/ui/util.h b/src/ui/util.h index 0289d579..31c8cedc 100644 --- a/src/ui/util.h +++ b/src/ui/util.h @@ -336,13 +336,14 @@ iWidget * makeQuestion_Widget (const char *title, const char *msg, iWidget * makePreferences_Widget (void); void updatePreferencesLayout_Widget (iWidget *prefs); -iWidget * makeBookmarkEditor_Widget (void); -void setBookmarkEditorFolder_Widget(iWidget *editor, uint32_t folderId); -iWidget * makeBookmarkCreation_Widget (const iString *url, const iString *title, iChar icon); -iWidget * makeIdentityCreation_Widget (void); -iWidget * makeFeedSettings_Widget (uint32_t bookmarkId); -iWidget * makeTranslation_Widget (iWidget *parent); -iWidget * makeGlyphFinder_Widget (void); +iWidget * makeBookmarkEditor_Widget (void); +void setBookmarkEditorFolder_Widget (iWidget *editor, uint32_t folderId); +iWidget * makeBookmarkCreation_Widget (const iString *url, const iString *title, iChar icon); +iWidget * makeIdentityCreation_Widget (void); +iWidget * makeFeedSettings_Widget (uint32_t bookmarkId); +iWidget * makeSiteSpecificSettings_Widget (const iString *url); +iWidget * makeTranslation_Widget (iWidget *parent); +iWidget * makeGlyphFinder_Widget (void); const char * languageId_String (const iString *menuItemLabel); int languageIndex_CStr (const char *langId); -- cgit v1.2.3