mirror of
https://github.com/zen-browser/desktop.git
synced 2026-01-19 11:27:16 +00:00
feat: Add app menu and native menu items for new separate windows, b=no-bug, c=common, kbs
This commit is contained in:
@@ -353,4 +353,4 @@ zen-devtools-toggle-storage-shortcut = Toggle Storage
|
||||
zen-devtools-toggle-dom-shortcut = Toggle DOM
|
||||
zen-devtools-toggle-accessibility-shortcut = Toggle Accessibility
|
||||
zen-close-all-unpinned-tabs-shortcut = Close All Unpinned Tabs
|
||||
zen-new-unsynced-window-shortcut = New Unsynced Window
|
||||
zen-new-unsynced-window-shortcut = New Separate Window
|
||||
|
||||
@@ -20,4 +20,7 @@ zen-menubar-appearance-auto =
|
||||
zen-menubar-appearance-light =
|
||||
.label = Light
|
||||
zen-menubar-appearance-dark =
|
||||
.label = Dark
|
||||
.label = Dark
|
||||
|
||||
zen-menubar-new-unsynced-window =
|
||||
.label = New Separate Window
|
||||
@@ -4,10 +4,4 @@
|
||||
|
||||
#include zen-commands.inc.xhtml
|
||||
|
||||
<keyset id="zenKeyset">
|
||||
# Prefetch these keys because they are being used by the native menu bar
|
||||
# and they need to be available even before the XUL is fully loaded and
|
||||
# our KBS sysmtem is initialized.
|
||||
<key id="zen-workspace-forward" />
|
||||
<key id="zen-workspace-backward" />
|
||||
</keyset>
|
||||
<keyset id="zenKeyset" />
|
||||
|
||||
@@ -239,8 +239,7 @@
|
||||
list-style-image: url("privateBrowsing.svg") !important;
|
||||
}
|
||||
|
||||
#profiler-button-button > .toolbarbutton-icon,
|
||||
.subviewbutton[label="Task Manager"] {
|
||||
#profiler-button-button > .toolbarbutton-icon {
|
||||
list-style-image: url("tool-profiler.svg") !important;
|
||||
}
|
||||
|
||||
@@ -249,7 +248,8 @@
|
||||
}
|
||||
|
||||
#new-window-button,
|
||||
#appMenu-new-window-button2 {
|
||||
#appMenu-new-window-button2,
|
||||
#appMenu-new-zen-unsynced-window-button {
|
||||
list-style-image: url("window.svg") !important;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,21 @@ const WINDOW_SCHEME_MAPPING = {
|
||||
auto: 2,
|
||||
};
|
||||
|
||||
class nsZenMenuBar {
|
||||
init() {
|
||||
export class nsZenMenuBar {
|
||||
constructor() {
|
||||
window.addEventListener(
|
||||
"ZenKeyboardShortcutsReady",
|
||||
() => {
|
||||
this.#init();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
}
|
||||
|
||||
#init() {
|
||||
this.#initViewMenu();
|
||||
this.#initSpacesMenu();
|
||||
this.#initAppMenu();
|
||||
}
|
||||
|
||||
#initViewMenu() {
|
||||
@@ -89,6 +100,25 @@ class nsZenMenuBar {
|
||||
gZenWorkspaces.updateWorkspacesChangeContextMenu();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const ZenMenubar = new nsZenMenuBar();
|
||||
#initAppMenu() {
|
||||
const openUnsyncedWindowItem = window.MozXULElement.parseXULToFragment(
|
||||
`<toolbarbutton id="appMenu-new-zen-unsynced-window-button"
|
||||
class="subviewbutton"
|
||||
data-l10n-id="zen-menubar-new-unsynced-window"
|
||||
key="zen-new-unsynced-window"
|
||||
command="cmd_zenNewNavigatorUnsynced"/>`
|
||||
).querySelector("toolbarbutton");
|
||||
PanelMultiView.getViewNode(document, "appMenu-new-window-button2").after(
|
||||
openUnsyncedWindowItem
|
||||
);
|
||||
document.getElementById("menu_newNavigator").after(
|
||||
window.MozXULElement.parseXULToFragment(`
|
||||
<menuitem id="menu_new_zen_unsynced_window"
|
||||
class="subviewbutton"
|
||||
data-l10n-id="zen-menubar-new-unsynced-window"
|
||||
key="zen-new-unsynced-window"
|
||||
command="cmd_zenNewNavigatorUnsynced"/>`)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import { nsZenMultiWindowFeature } from "chrome://browser/content/zen-components/ZenCommonUtils.mjs";
|
||||
import { ZenMenubar } from "chrome://browser/content/zen-components/ZenMenubar.mjs";
|
||||
import { nsZenMenuBar } from "chrome://browser/content/zen-components/ZenMenubar.mjs";
|
||||
|
||||
window.gZenUIManager = {
|
||||
_popupTrackingElements: [],
|
||||
@@ -17,6 +17,8 @@ window.gZenUIManager = {
|
||||
_toastTimeouts: [],
|
||||
|
||||
init() {
|
||||
window.gZenMenubar = new nsZenMenuBar();
|
||||
|
||||
document.addEventListener("popupshowing", this.onPopupShowing.bind(this));
|
||||
document.addEventListener("popuphidden", this.onPopupHidden.bind(this));
|
||||
|
||||
@@ -63,7 +65,6 @@ window.gZenUIManager = {
|
||||
this._initOmnibox();
|
||||
this._initBookmarkCollapseListener();
|
||||
|
||||
ZenMenubar.init();
|
||||
gURLBar._setPlaceholder(null);
|
||||
},
|
||||
|
||||
|
||||
@@ -28,7 +28,9 @@ dialog::part(dialog-button) {
|
||||
border-color: light-dark(rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.2)) !important;
|
||||
border-bottom-width: 2px !important;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
dialog[defaultButton="accept"]::part(dialog-button) {
|
||||
&:is([dlgtype="accept"], [dlgtype="cancel"]) {
|
||||
padding-inline-end: 3.7em;
|
||||
@media (-moz-platform: windows) {
|
||||
|
||||
@@ -875,6 +875,7 @@ class nsZenKeyboardShortcutsVersioner {
|
||||
return out;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
migrate(data, version) {
|
||||
if (version < 1) {
|
||||
// Migrate from 0 to 1
|
||||
@@ -1111,7 +1112,9 @@ class nsZenKeyboardShortcutsVersioner {
|
||||
"N",
|
||||
"",
|
||||
ZEN_OTHER_SHORTCUTS_GROUP,
|
||||
nsKeyShortcutModifiers.fromObject({ accel: true, alt: true }),
|
||||
AppConstants.platform === "win"
|
||||
? nsKeyShortcutModifiers.fromObject({ alt: true })
|
||||
: nsKeyShortcutModifiers.fromObject({ accel: true, alt: true }),
|
||||
"cmd_zenNewNavigatorUnsynced",
|
||||
"zen-new-unsynced-window-shortcut"
|
||||
)
|
||||
@@ -1162,6 +1165,7 @@ window.gZenKeyboardShortcutsManager = {
|
||||
this._applyShortcuts();
|
||||
|
||||
await this._saveShortcuts();
|
||||
window.dispatchEvent(new Event("ZenKeyboardShortcutsReady", { bubbles: true }));
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ export default [
|
||||
"gZenUIManager",
|
||||
"gZenVerticalTabsManager",
|
||||
"gZenStartup",
|
||||
"gZenMenubar",
|
||||
|
||||
"gZenWorkspaces",
|
||||
"gZenKeyboardShortcutsManager",
|
||||
|
||||
Reference in New Issue
Block a user