From 8a588f71b187d5d07ca218747dd5f6708264e2fb Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sun, 2 Aug 2020 21:22:36 +0300 Subject: Compose window title with host name --- src/ui/documentwidget.c | 23 ++++++++++++++++------- src/ui/window.c | 10 ++++++---- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index c8755fd2..f8a2e330 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -257,16 +258,24 @@ static void updateVisible_DocumentWidget_(iDocumentWidget *d) { } static void updateWindowTitle_DocumentWidget_(const iDocumentWidget *d) { - const char *titleSep = " \u2013 "; - iString *title = collect_String(copy_String(title_GmDocument(d->doc))); + iStringArray *title = iClob(new_StringArray()); + if (!isEmpty_String(title_GmDocument(d->doc))) { + pushBack_StringArray(title, title_GmDocument(d->doc)); + } if (!isEmpty_String(d->titleUser)) { - if (!isEmpty_String(title)) appendCStr_String(title, titleSep); - append_String(title, d->titleUser); + pushBack_StringArray(title, d->titleUser); + } + else { + iUrl parts; + init_Url(&parts, d->url); + if (!isEmpty_Range(&parts.host)) { + pushBackRange_StringArray(title, parts.host); + } } - if (isEmpty_String(title)) { - setCStr_String(title, "Lagrange"); + if (isEmpty_StringArray(title)) { + pushBackCStr_StringArray(title, "Lagrange"); } - setTitle_Window(get_Window(), title); + setTitle_Window(get_Window(), collect_String(joinCStr_StringArray(title, " \u2013 "))); } static void setSource_DocumentWidget_(iDocumentWidget *d, const iString *source) { diff --git a/src/ui/window.c b/src/ui/window.c index be84b6c2..9a523ce9 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -200,11 +200,13 @@ static void setupUserInterface_Window(iWindow *d) { addChild_Widget(navBar, iClob(newIcon_LabelWidget(" \U0001f850 ", 0, 0, "navigate.back"))); addChild_Widget(navBar, iClob(newIcon_LabelWidget("\U0001f852", 0, 0, "navigate.forward"))); addChild_Widget(navBar, iClob(newIcon_LabelWidget("\U0001f3e0", 0, 0, "navigate.home"))); - iLabelWidget *lock = addChildFlags_Widget(navBar, - iClob(newIcon_LabelWidget("\U0001f512", 0, 0, "cert.server")), - frameless_WidgetFlag | tight_WidgetFlag); - setId_Widget(as_Widget(lock), "lock"); + iLabelWidget *lock = + addChildFlags_Widget(navBar, + iClob(newIcon_LabelWidget("\U0001f513", 0, 0, "server.showcert")), + frameless_WidgetFlag | tight_WidgetFlag); + setId_Widget(as_Widget(lock), "navbar.lock"); setFont_LabelWidget(lock, symbols_FontId); + updateTextCStr_LabelWidget(lock, "\U0001f512"); iInputWidget *url = new_InputWidget(0); setId_Widget(as_Widget(url), "url"); setTextCStr_InputWidget(url, "gemini://"); -- cgit v1.2.3