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 - allows user to specify window zoom level as a preference How to test Signed-off-by: seantan22 <[email protected]>
- Loading branch information
seantan22
committed
Feb 17, 2021
1 parent
f3a15db
commit 3802aad
Showing
4 changed files
with
100 additions
and
1 deletion.
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
50 changes: 50 additions & 0 deletions
50
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,50 @@ | ||
/******************************************************************************** | ||
* 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', | ||
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 }); | ||
} |