mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 18:59:58 +02:00
feat(pinned-tab-manager): Add shortcut options for closing, unloading, changing, and resetting pinned tabs
This commit is contained in:
parent
b8938b444d
commit
e28f8e131e
1 changed files with 33 additions and 15 deletions
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'zenPinnedTabRestorePinnedTabsToPinnedUrl', 'zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url', false);
|
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'zenPinnedTabRestorePinnedTabsToPinnedUrl', 'zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url', false);
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'zenPinnedTabResetOnCloseShortcut', 'zen.pinned-tab-manager.reset-pinned-tab-on-close-shortcut', false);
|
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'zenPinnedTabResetOnCloseShortcut', 'zen.pinned-tab-manager.reset-pinned-tab-on-close-shortcut', false);
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'zenPinnedTabUnloadOnCloseShortcut', 'zen.pinned-tab-manager.unload-pinned-tab-on-close-shortcut', false);
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'zenPinnedTabChangeOnCloseShortcut', 'zen.pinned-tab-manager.change-pinned-tab-on-close-shortcut', false);
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'zenPinnedTabCloseOnCloseShortcut', 'zen.pinned-tab-manager.close-pinned-tab-on-close-shortcut', false);
|
||||||
|
|
||||||
class ZenPinnedTabsObserver {
|
class ZenPinnedTabsObserver {
|
||||||
static ALL_EVENTS = ['TabPinned', 'TabUnpinned'];
|
static ALL_EVENTS = ['TabPinned', 'TabUnpinned'];
|
||||||
|
@ -125,10 +128,22 @@
|
||||||
if (
|
if (
|
||||||
event &&
|
event &&
|
||||||
(event.ctrlKey || event.metaKey || event.altKey) &&
|
(event.ctrlKey || event.metaKey || event.altKey) &&
|
||||||
gBrowser.selectedTab.pinned
|
gBrowser.selectedTab?.pinned
|
||||||
) {
|
) {
|
||||||
const selectedTab = gBrowser.selectedTab;
|
const selectedTab = gBrowser.selectedTab;
|
||||||
|
|
||||||
|
if (selectedTab) {
|
||||||
|
|
||||||
|
if (lazy.zenPinnedTabCloseOnCloseShortcut) {
|
||||||
|
gBrowser.removeTab(selectedTab, { animate: true });
|
||||||
|
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lazy.zenPinnedTabChangeOnCloseShortcut) {
|
||||||
|
|
||||||
let nextTab = gBrowser.tabContainer.findNextTab(selectedTab, {
|
let nextTab = gBrowser.tabContainer.findNextTab(selectedTab, {
|
||||||
direction: 1,
|
direction: 1,
|
||||||
filter: tab => !tab.hidden && !tab.pinned,
|
filter: tab => !tab.hidden && !tab.pinned,
|
||||||
|
@ -141,15 +156,18 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedTab) {
|
|
||||||
gBrowser.selectedTab = nextTab;
|
gBrowser.selectedTab = nextTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (lazy.zenPinnedTabResetOnCloseShortcut) {
|
if (lazy.zenPinnedTabResetOnCloseShortcut) {
|
||||||
this._resetTabToStoredState(selectedTab);
|
this._resetTabToStoredState(selectedTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBrowser.discardBrowser(selectedTab);
|
|
||||||
|
|
||||||
|
if(lazy.zenPinnedTabUnloadOnCloseShortcut) {
|
||||||
|
gBrowser.discardBrowser(selectedTab);
|
||||||
|
}
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue