From 0de81a7ae363e467cda383869c38b0251cf29c55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Mon, 19 Jun 2023 14:55:29 +0300
Subject: [PATCH 1/1] "New Tab" should append tabs to the right edge of tab bar
res/about/version.gmi | 3 +++
src/app.c | 12 +++++++-----
src/app.h | 1 +
src/macos.m | 2 +-
src/ui/keys.c | 2 +-
src/ui/mobile.c | 2 +-
src/ui/root.c | 9 +++++----
src/ui/window.c | 2 +-
8 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/res/about/version.gmi b/res/about/version.gmi
index f56e8d23..55469551 100644
--- a/res/about/version.gmi
+++ b/res/about/version.gmi
@@ -6,6 +6,9 @@
+## 1.16.5
+* "New Tab" (Ctrl+T/⌘T) and the tab bar [+] button append the tab to the right edge. Previously it was inserted next to the active tab.
diff --git a/src/app.c b/src/app.c
index 0f8ba208..366037dd 100644
--- a/src/app.c
+++ b/src/app.c
@@ -2961,7 +2961,6 @@ iDocumentWidget *document_Command(const char *cmd) {
iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, int newTabFlags) {
iWidget *tabs = findWidget_Root("doctabs");
setFlags_Widget(tabs, hidden_WidgetFlag, iFalse);
iWidget *newTabButton = findChild_Widget(tabs, "newtab");
removeChild_Widget(newTabButton->parent, newTabButton);
@@ -2974,15 +2973,16 @@ iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, int newTabFlags)
}
appendTabPage_Widget(tabs, as_Widget(doc), "", 0, 0);
iRelease(doc); /* now owned by the tabs */
const size_t insertAt = tabPageIndex_Widget(
tabs, findChild_Widget(tabs, cstr_String(&get_Root()->tabInsertId)));
if (insertAt != iInvalidPos) {
moveTabPage_Widget(tabs, tabCount_Widget(tabs) - 1, insertAt + 1);
}
/* The next tab comes here. */
set_String(&as_Widget(doc)->root->tabInsertId, id_Widget(as_Widget(doc)));
}
addTabCloseButton_Widget(tabs, as_Widget(doc), "tabs.close");
addChild_Widget(findChild_Widget(tabs, "tabs.buttons"), iClob(newTabButton));
showOrHideNewTabButton_Root(tabs->root);
@@ -4302,8 +4302,10 @@ iBool handleCommand_App(const char *cmd) {
}
return iTrue;
}
const iBool isAppend = argLabel_Command(cmd, "append") != 0;
const iBool isDuplicate = argLabel_Command(cmd, "duplicate") != 0;
newTab_App(isDuplicate ? document_App() : NULL, switchTo_NewTabFlag);
newTab_App(isDuplicate ? document_App() : NULL,
switchTo_NewTabFlag | (isAppend ? append_NewTabFlag : 0));
if (!isDuplicate) {
postCommandf_App("navigate.home focus:%d", deviceType_App() == desktop_AppDeviceType);
}
diff --git a/src/app.h b/src/app.h
index 47be3f19..5a533ff1 100644
--- a/src/app.h
+++ b/src/app.h
@@ -79,6 +79,7 @@ enum iUserEventCode {
enum iNewTabFlag {
switchTo_NewTabFlag = iBit(1),
};
const iString *execPath_App (void);
diff --git a/src/macos.m b/src/macos.m
index 91e2d50c..fb8acf5a 100644
--- a/src/macos.m
+++ b/src/macos.m
@@ -419,7 +419,7 @@ static void appearanceChanged_MacOS_(NSString *name) {
return [[CommandButton alloc] initWithIdentifier:identifier
image:[NSImage imageNamed:NSImageNameTouchBarAddTemplate]
widget:nil
command:@"tabs.new"];
command:@"tabs.new append:1"];
}
return nil;
}
diff --git a/src/ui/keys.c b/src/ui/keys.c
index 3bfa9302..4913f582 100644
--- a/src/ui/keys.c
+++ b/src/ui/keys.c
@@ -226,7 +226,7 @@ static const struct { int id; iMenuItem bind; int flags; } defaultBindings_[] =
#if !defined (iPlatformApple) /* Ctrl-Cmd-F on macOS */
{ 73, { "${keys.fullscreen}", SDLK_F11, 0, "window.fullscreen" }, 0 },
#endif
{ 77, { "${keys.tab.close}", closeTab_KeyShortcut, "tabs.close" }, 0 },
{ 78, { "${keys.tab.close.other}", SDLK_w, KMOD_SECONDARY, "tabs.close toleft:1 toright:1" }, 0 },
{ 79, { "${LC:menu.reopentab}", SDLK_t, KMOD_SECONDARY, "tabs.new reopen:1" }, 0 },
diff --git a/src/ui/mobile.c b/src/ui/mobile.c
index 404c39a1..419298a5 100644
--- a/src/ui/mobile.c
+++ b/src/ui/mobile.c
@@ -43,7 +43,7 @@ const iToolbarActionSpec toolbarActions_Mobile[max_ToolbarAction] = {
{ home_Icon, "${menu.home}", "navigate.home" },
{ upArrow_Icon, "${menu.parent}", "navigate.parent" },
{ reload_Icon, "${menu.reload}", "navigate.reload" },
{ close_Icon, "${menu.closetab}", "tabs.close" },
{ bookmark_Icon, "${menu.page.bookmark}", "bookmark.add" },
{ globe_Icon, "${menu.page.translate}", "document.translate" },
diff --git a/src/ui/root.c b/src/ui/root.c
index ac708342..bc7cf4b4 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -55,7 +55,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
static const iMenuItem desktopNavMenuItems_[] = {
{ openWindow_Icon " ${menu.newwindow}", SDLK_n, KMOD_PRIMARY, "window.new" },
{ close_Icon " ${menu.closetab}", SDLK_w, KMOD_PRIMARY, "tabs.close" },
{ "${menu.openlocation}", SDLK_l, KMOD_PRIMARY, "navigate.focus" },
{ "---" },
@@ -85,7 +85,7 @@ static const iMenuItem desktopNavMenuItems_[] = {
};
static const iMenuItem tabletNavMenuItems_[] = {
{ folder_Icon " ${menu.openfile}", SDLK_o, KMOD_PRIMARY, "file.open" },
{ "---" },
{ close_Icon " ${menu.closetab}", 'w', KMOD_PRIMARY, "tabs.close" },
@@ -102,7 +102,7 @@ static const iMenuItem tabletNavMenuItems_[] = {
};
static const iMenuItem phoneNavMenuItems_[] = {
{ folder_Icon " ${menu.openfile}", SDLK_o, KMOD_PRIMARY, "file.open" },
{ "---" },
{ close_Icon " ${menu.closetab}", 'w', KMOD_PRIMARY, "tabs.close" },
@@ -1792,7 +1792,8 @@ void createUserInterface_Root(iRoot *d) {
setBackgroundColor_Widget(buttons, uiBackground_ColorId);
}
setId_Widget(
addChildFlags_Widget(buttons, iClob(newIcon_LabelWidget(add_Icon, 0, 0, "tabs.new")),
addChildFlags_Widget(buttons,
iClob(newIcon_LabelWidget(add_Icon, 0, 0, "tabs.new append:1")),
moveToParentRightEdge_WidgetFlag | collapse_WidgetFlag),
"newtab");
}
diff --git a/src/ui/window.c b/src/ui/window.c
index 94df1c7a..8c2a36ac 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -73,7 +73,7 @@ iDefineTypeConstructionArgs(MainWindow, (iRect rect), rect)
static const iMenuItem fileMenuItems_[] = {
{ "${menu.newwindow}", SDLK_n, KMOD_PRIMARY, "window.new" },
{ "${menu.openlocation}", SDLK_l, KMOD_PRIMARY, "navigate.focus" },
{ "${menu.reopentab}", SDLK_t, KMOD_SECONDARY, "tabs.new reopen:1" },
{ "---" },
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).