feat(pinned-tab-url-reset): add option to reset pinned tab to originally pinned url

Adds a new setting to enable or disable pinned tab url resetting on pressing close tab shortcut.

Persists pinned tab url and label on browser closing.
This commit is contained in:
Kristijan Ribarić
2024-10-01 16:31:58 +02:00
parent 593a9244a4
commit b185773daf
5 changed files with 42 additions and 6 deletions

View File

@@ -111,6 +111,7 @@ pref('zen.themes.updated-value-observer', false);
pref('zen.tab-unloader.enabled', true); pref('zen.tab-unloader.enabled', true);
pref('zen.tab-unloader.timeout-minutes', 20); pref('zen.tab-unloader.timeout-minutes', 20);
pref('zen.tab-unloader.excluded-urls', "example.com,example.org"); pref('zen.tab-unloader.excluded-urls', "example.com,example.org");
pref('zen.tab-unloader.reset-pinned-tab-on-close-shortcut', true);
// Pref to enable the new profiles (TODO: Check this out!) // Pref to enable the new profiles (TODO: Check this out!)
//pref("browser.profiles.enabled", true); //pref("browser.profiles.enabled", true);

View File

@@ -1020,4 +1020,9 @@ Preferences.addAll([
type: 'bool', type: 'bool',
default: false, default: false,
}, },
{
id: 'zen.tab-unloader.reset-pinned-tab-on-close-shortcut',
type: 'bool',
default: true,
},
]); ]);

View File

@@ -48,6 +48,10 @@
data-l10n-id="zen-tabs-unloader-enabled" data-l10n-id="zen-tabs-unloader-enabled"
preference="zen.tab-unloader.enabled"/> preference="zen.tab-unloader.enabled"/>
<checkbox id="zenPinnedTabResetOnCloseShortcutEnable"
data-l10n-id="zen-tabs-pinned-reset-close-shortcut-enabled"
preference="zen.tab-unloader.reset-pinned-tab-on-close-shortcut"/>
<label><html:h2 data-l10n-id="zen-tabs-unloader-unload-delay"/></label> <label><html:h2 data-l10n-id="zen-tabs-unloader-unload-delay"/></label>
<hbox id="zenTabsUnloadDelayContainer"> <hbox id="zenTabsUnloadDelayContainer">
<description class="description-deemphasized" data-l10n-id="zen-tabs-unloader-unload-delay-description" /> <description class="description-deemphasized" data-l10n-id="zen-tabs-unloader-unload-delay-description" />

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..807eb0c493f15643412b05d8dad81d36d7470155 100644 index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b6835bdacdb 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js --- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js +++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -452,11 +452,26 @@ @@ -452,11 +452,26 @@
@@ -68,7 +68,7 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..807eb0c493f15643412b05d8dad81d36
if (!tabData.pinned) { if (!tabData.pinned) {
this.unpinTab(tab); this.unpinTab(tab);
} else { } else {
@@ -3297,6 +3328,13 @@ @@ -3297,6 +3328,12 @@
preferredRemoteType, preferredRemoteType,
}); });
@@ -78,11 +78,24 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..807eb0c493f15643412b05d8dad81d36
+ if (tabData.zenDefaultUserContextId) { + if (tabData.zenDefaultUserContextId) {
+ tab.setAttribute("zenDefaultUserContextId", "true"); + tab.setAttribute("zenDefaultUserContextId", "true");
+ } + }
+
if (select) { if (select) {
tabToSelect = tab; tabToSelect = tab;
} }
@@ -4184,6 +4222,7 @@ @@ -3331,7 +3368,13 @@
this.tabContainer._invalidateCachedTabs();
}
}
+ if (tabData.zenPinnedUrl) {
+ tab.setAttribute("zen-pinned-url", tabData.zenPinnedUrl);
+ }
+ if (tabData.zenPinnedTitle) {
+ tab.setAttribute("zen-pinned-title", tabData.zenPinnedTitle);
+ }
tab.initialize();
}
@@ -4184,6 +4227,7 @@
isLastTab || isLastTab ||
aTab.pinned || aTab.pinned ||
aTab.hidden || aTab.hidden ||
@@ -90,7 +103,7 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..807eb0c493f15643412b05d8dad81d36
this._removingTabs.size > this._removingTabs.size >
3 /* don't want lots of concurrent animations */ || 3 /* don't want lots of concurrent animations */ ||
!aTab.hasAttribute( !aTab.hasAttribute(
@@ -5117,10 +5156,10 @@ @@ -5117,10 +5161,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy"); SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
}, },
@@ -103,3 +116,15 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..807eb0c493f15643412b05d8dad81d36
aTab.selected || aTab.selected ||
aTab.closing || aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden. // Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -7822,7 +7866,10 @@ var TabContextMenu = {
);
contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !multiselectionContext;
-
+ let contextResetPinnedTab = document.getElementById("context_zen-reset-pinned-tab");
+ if(contextResetPinnedTab) {
+ contextResetPinnedTab.hidden = !this.contextTab.pinned || !this.contextTab.getAttribute("zen-pinned-url") || multiselectionContext;
+ }
// Move Tab items
let contextMoveTabOptions = document.getElementById(
"context_moveTabOptions"

View File

@@ -773,7 +773,8 @@ menuitem[id='placesContext_deleteHost'],
#context_reloadTab, #context_reloadTab,
#context_reloadSelectedTabs, #context_reloadSelectedTabs,
#toolbar-context-reloadSelectedTab, #toolbar-context-reloadSelectedTab,
#toolbar-context-reloadSelectedTabs { #toolbar-context-reloadSelectedTabs,
#context_zen-reset-pinned-tab {
--menu-image: url('reload.svg'); --menu-image: url('reload.svg');
} }