forked from eclipse-theia/theia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preferences: Support window.zoomLevel Preference
Fixes eclipse-theia#8751 What it does - Adds support to specify window zoom level as a preference How to test 1. Open `Preferences` view and locate the `window.zoomLevel` preference 2. Enter in a custom value or change the zoom level using ctrl + / - / 0 3. Observe that the zoom level preference is updated 4. Reload the window and observe that the preferred zoom level is preserved Signed-off-by: seantan22 <[email protected]>
- Loading branch information
seantan22
committed
Feb 18, 2021
1 parent
4e1c1d4
commit 694668f
Showing
4 changed files
with
131 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/core/src/electron-browser/window/window-preferences.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2021 Ericsson and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
import { interfaces } from 'inversify'; | ||
import { createPreferenceProxy, PreferenceContribution, PreferenceProxy, PreferenceSchema, PreferenceService } from '../../browser/preferences'; | ||
|
||
export const windowPreferencesSchema: PreferenceSchema = { | ||
type: 'object', | ||
scope: 'application', | ||
properties: { | ||
'window.zoomLevel': { | ||
'type': 'number', | ||
'default': 0, | ||
'minimum': -8, | ||
'maximum': 9, | ||
'description': 'Adjust the zoom level of the window. The original size is 0. Each increment above (e.g. 1) or below (e.g. -1) represents zooming 20% larger or smaller.' | ||
}, | ||
} | ||
}; | ||
|
||
export class WindowConfiguration { | ||
'window.zoomLevel': number; | ||
} | ||
|
||
export const WindowPreferences = Symbol('WindowPreferences'); | ||
export type WindowPreferences = PreferenceProxy<WindowConfiguration>; | ||
|
||
export function createWindowPreferences(preferences: PreferenceService): WindowPreferences { | ||
return createPreferenceProxy(preferences, windowPreferencesSchema); | ||
} | ||
|
||
export function bindWindowPreferences(bind: interfaces.Bind): void { | ||
bind(WindowPreferences).toDynamicValue(ctx => { | ||
const preferences = ctx.container.get<PreferenceService>(PreferenceService); | ||
return createWindowPreferences(preferences); | ||
}).inSingletonScope(); | ||
|
||
bind(PreferenceContribution).toConstantValue({ schema: windowPreferencesSchema }); | ||
} |