Lagrange [work/v1.10]

Don't have duplicate New Tab buttons

=> e9cca232c85400f4963ab221afe05c686594cda7

diff --git a/res/about/version.gmi b/res/about/version.gmi
index df532ab3..5dad2c58 100644
--- a/res/about/version.gmi
+++ b/res/about/version.gmi
@@ -8,6 +8,7 @@
 
 ## 1.10.3
 * Added a man page.
+* Hide the [+] on the row of tab buttons if the navbar has a New Tab button.
 * "/index.gmi" is considered equal to "/" when navigating to parent directory.
 * Gopher: Fixed navigating to root, e.g., when clicking on the page top banner. Set item type to 1 to show a gophermap and not the plain source.
 * Titan: When navigating to parent/root, switch URL scheme to "gemini". This action occurs on a Titan response page, so initiating a new upload with the parent/root URL is probably not appropriate.
diff --git a/src/app.c b/src/app.c
index a137dc23..9f35d727 100644
--- a/src/app.c
+++ b/src/app.c
@@ -2086,7 +2086,6 @@ iDocumentWidget *document_Command(const char *cmd) {
 }
 
 iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, iBool switchToNew) {
-    //iApp *d = &app_;
     iWidget *tabs = findWidget_Root("doctabs");
     setFlags_Widget(tabs, hidden_WidgetFlag, iFalse);
     iWidget *newTabButton = findChild_Widget(tabs, "newtab");
@@ -2102,6 +2101,7 @@ iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, iBool switchToNe
     iRelease(doc); /* now owned by the tabs */
     addTabCloseButton_Widget(tabs, as_Widget(doc), "tabs.close");
     addChild_Widget(findChild_Widget(tabs, "tabs.buttons"), iClob(newTabButton));
+    showOrHideNewTabButton_Root(tabs->root);
     if (switchToNew) {
         postCommandf_App("tabs.switch page:%p", doc);
     }
@@ -2852,6 +2852,7 @@ iBool handleCommand_App(const char *cmd) {
             return iTrue;
         }
         iDocumentWidget *doc = document_Command(cmd);
+        iAssert(doc);
         iDocumentWidget *origin = doc;
         if (hasLabel_Command(cmd, "origin")) {
             iDocumentWidget *cmdOrig = findWidget_App(cstr_Command(cmd, "origin"));
diff --git a/src/ui/root.c b/src/ui/root.c
index 776a9a35..6e187313 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -703,6 +703,20 @@ void updateToolbarColors_Root(iRoot *d) {
 #endif
 }
 
+void showOrHideNewTabButton_Root(iRoot *d) {
+    iWidget *tabs = findChild_Widget(d->widget, "doctabs");
+    iWidget *newTabButton = findChild_Widget(tabs, "newtab");
+    iBool hide = iFalse;
+    iForIndices(i, prefs_App()->navbarActions) {
+        if (prefs_App()->navbarActions[i] == newTab_ToolbarAction) {
+            hide = iTrue;
+            break;
+        }
+    }
+    setFlags_Widget(newTabButton, hidden_WidgetFlag, hide);
+    arrange_Widget(findChild_Widget(tabs, "tabs.buttons"));
+}
+
 void notifyVisualOffsetChange_Root(iRoot *d) {
     if (d && (d->didAnimateVisualOffsets || d->didChangeArrangement)) {
         iNotifyAudience(d, visualOffsetsChanged, RootVisualOffsetsChanged);
@@ -848,6 +862,7 @@ static void updateNavBarActions_(iWidget *navBar) {
         }
         iEndCollect();
     }
+    showOrHideNewTabButton_Root(navBar->root);
 }
 
 static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
@@ -1526,7 +1541,7 @@ void createUserInterface_Root(iRoot *d) {
         }
         setId_Widget(
             addChildFlags_Widget(buttons, iClob(newIcon_LabelWidget(add_Icon, 0, 0, "tabs.new")),
-                                 moveToParentRightEdge_WidgetFlag),
+                                 moveToParentRightEdge_WidgetFlag | collapse_WidgetFlag),
             "newtab");
     }
     /* Sidebars. */ {
diff --git a/src/ui/root.h b/src/ui/root.h
index 7e831be3..a81ebdf7 100644
--- a/src/ui/root.h
+++ b/src/ui/root.h
@@ -43,6 +43,8 @@ void        updatePadding_Root                  (iRoot *); /* TODO: is part of m
 void        dismissPortraitPhoneSidebars_Root   (iRoot *);
 void        showToolbar_Root                    (iRoot *, iBool show);
 void        updateToolbarColors_Root            (iRoot *);
+void        showOrHideNewTabButton_Root         (iRoot *);
+
 void        notifyVisualOffsetChange_Root       (iRoot *);
 
 iInt2       size_Root                           (const iRoot *);
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.10/cdiff/e9cca232c85400f4963ab221afe05c686594cda7
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
64.033421 milliseconds
Gemini-to-HTML Time
0.657074 milliseconds

This content has been proxied by September (3851b).