diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-01-29 18:57:52 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-01-29 18:57:52 +0200 |
commit | e9cca232c85400f4963ab221afe05c686594cda7 (patch) | |
tree | 879f5cd2b46c43241f079913f6df46d0e6f0b580 /src | |
parent | 07804493ac17ff430302c7940f44b7525c0620e8 (diff) |
Don't have duplicate New Tab buttons
There tab buttons don't need a New Tab button if the navbar has it.
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 3 | ||||
-rw-r--r-- | src/ui/root.c | 17 | ||||
-rw-r--r-- | src/ui/root.h | 2 |
3 files changed, 20 insertions, 2 deletions
@@ -2086,7 +2086,6 @@ iDocumentWidget *document_Command(const char *cmd) { | |||
2086 | } | 2086 | } |
2087 | 2087 | ||
2088 | iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, iBool switchToNew) { | 2088 | iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, iBool switchToNew) { |
2089 | //iApp *d = &app_; | ||
2090 | iWidget *tabs = findWidget_Root("doctabs"); | 2089 | iWidget *tabs = findWidget_Root("doctabs"); |
2091 | setFlags_Widget(tabs, hidden_WidgetFlag, iFalse); | 2090 | setFlags_Widget(tabs, hidden_WidgetFlag, iFalse); |
2092 | iWidget *newTabButton = findChild_Widget(tabs, "newtab"); | 2091 | iWidget *newTabButton = findChild_Widget(tabs, "newtab"); |
@@ -2102,6 +2101,7 @@ iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, iBool switchToNe | |||
2102 | iRelease(doc); /* now owned by the tabs */ | 2101 | iRelease(doc); /* now owned by the tabs */ |
2103 | addTabCloseButton_Widget(tabs, as_Widget(doc), "tabs.close"); | 2102 | addTabCloseButton_Widget(tabs, as_Widget(doc), "tabs.close"); |
2104 | addChild_Widget(findChild_Widget(tabs, "tabs.buttons"), iClob(newTabButton)); | 2103 | addChild_Widget(findChild_Widget(tabs, "tabs.buttons"), iClob(newTabButton)); |
2104 | showOrHideNewTabButton_Root(tabs->root); | ||
2105 | if (switchToNew) { | 2105 | if (switchToNew) { |
2106 | postCommandf_App("tabs.switch page:%p", doc); | 2106 | postCommandf_App("tabs.switch page:%p", doc); |
2107 | } | 2107 | } |
@@ -2852,6 +2852,7 @@ iBool handleCommand_App(const char *cmd) { | |||
2852 | return iTrue; | 2852 | return iTrue; |
2853 | } | 2853 | } |
2854 | iDocumentWidget *doc = document_Command(cmd); | 2854 | iDocumentWidget *doc = document_Command(cmd); |
2855 | iAssert(doc); | ||
2855 | iDocumentWidget *origin = doc; | 2856 | iDocumentWidget *origin = doc; |
2856 | if (hasLabel_Command(cmd, "origin")) { | 2857 | if (hasLabel_Command(cmd, "origin")) { |
2857 | iDocumentWidget *cmdOrig = findWidget_App(cstr_Command(cmd, "origin")); | 2858 | 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) { | |||
703 | #endif | 703 | #endif |
704 | } | 704 | } |
705 | 705 | ||
706 | void showOrHideNewTabButton_Root(iRoot *d) { | ||
707 | iWidget *tabs = findChild_Widget(d->widget, "doctabs"); | ||
708 | iWidget *newTabButton = findChild_Widget(tabs, "newtab"); | ||
709 | iBool hide = iFalse; | ||
710 | iForIndices(i, prefs_App()->navbarActions) { | ||
711 | if (prefs_App()->navbarActions[i] == newTab_ToolbarAction) { | ||
712 | hide = iTrue; | ||
713 | break; | ||
714 | } | ||
715 | } | ||
716 | setFlags_Widget(newTabButton, hidden_WidgetFlag, hide); | ||
717 | arrange_Widget(findChild_Widget(tabs, "tabs.buttons")); | ||
718 | } | ||
719 | |||
706 | void notifyVisualOffsetChange_Root(iRoot *d) { | 720 | void notifyVisualOffsetChange_Root(iRoot *d) { |
707 | if (d && (d->didAnimateVisualOffsets || d->didChangeArrangement)) { | 721 | if (d && (d->didAnimateVisualOffsets || d->didChangeArrangement)) { |
708 | iNotifyAudience(d, visualOffsetsChanged, RootVisualOffsetsChanged); | 722 | iNotifyAudience(d, visualOffsetsChanged, RootVisualOffsetsChanged); |
@@ -848,6 +862,7 @@ static void updateNavBarActions_(iWidget *navBar) { | |||
848 | } | 862 | } |
849 | iEndCollect(); | 863 | iEndCollect(); |
850 | } | 864 | } |
865 | showOrHideNewTabButton_Root(navBar->root); | ||
851 | } | 866 | } |
852 | 867 | ||
853 | static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | 868 | static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { |
@@ -1526,7 +1541,7 @@ void createUserInterface_Root(iRoot *d) { | |||
1526 | } | 1541 | } |
1527 | setId_Widget( | 1542 | setId_Widget( |
1528 | addChildFlags_Widget(buttons, iClob(newIcon_LabelWidget(add_Icon, 0, 0, "tabs.new")), | 1543 | addChildFlags_Widget(buttons, iClob(newIcon_LabelWidget(add_Icon, 0, 0, "tabs.new")), |
1529 | moveToParentRightEdge_WidgetFlag), | 1544 | moveToParentRightEdge_WidgetFlag | collapse_WidgetFlag), |
1530 | "newtab"); | 1545 | "newtab"); |
1531 | } | 1546 | } |
1532 | /* Sidebars. */ { | 1547 | /* 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 | |||
43 | void dismissPortraitPhoneSidebars_Root (iRoot *); | 43 | void dismissPortraitPhoneSidebars_Root (iRoot *); |
44 | void showToolbar_Root (iRoot *, iBool show); | 44 | void showToolbar_Root (iRoot *, iBool show); |
45 | void updateToolbarColors_Root (iRoot *); | 45 | void updateToolbarColors_Root (iRoot *); |
46 | void showOrHideNewTabButton_Root (iRoot *); | ||
47 | |||
46 | void notifyVisualOffsetChange_Root (iRoot *); | 48 | void notifyVisualOffsetChange_Root (iRoot *); |
47 | 49 | ||
48 | iInt2 size_Root (const iRoot *); | 50 | iInt2 size_Root (const iRoot *); |