Skip to content

Commit 89cf5cc

Browse files
authored
Use light and dark mode icons (#64)
Fixes #52
1 parent 2cf31d4 commit 89cf5cc

File tree

8 files changed

+33
-18
lines changed

8 files changed

+33
-18
lines changed

files/dark_mode_icon.svg

Lines changed: 1 addition & 0 deletions
Loading

files/light_mode_icon.svg

Lines changed: 1 addition & 0 deletions
Loading

src/features/terminal/terminalManager.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,15 @@ import {
2121
terminals,
2222
withProgress,
2323
} from '../../common/window.apis';
24-
import { IconPath, PythonEnvironment, PythonProject, PythonTerminalOptions } from '../../api';
24+
import { PythonEnvironment, PythonProject, PythonTerminalOptions } from '../../api';
2525
import { getActivationCommand, getDeactivationCommand, isActivatableEnvironment } from '../common/activation';
2626
import { showErrorMessage } from '../../common/errors/utils';
2727
import { quoteArgs } from '../execution/execUtils';
2828
import { createDeferred } from '../../common/utils/deferred';
2929
import { traceError, traceVerbose } from '../../common/logging';
3030
import { getConfiguration } from '../../common/workspace.apis';
3131
import { EnvironmentManagers } from '../../internal.api';
32-
33-
function getIconPath(i: IconPath | undefined): IconPath | undefined {
34-
if (i instanceof Uri) {
35-
return i.fsPath.endsWith('__icon__.py') ? undefined : i;
36-
}
37-
return i;
38-
}
32+
import { EXTENSION_ROOT_DIR } from '../../common/constants';
3933

4034
const SHELL_INTEGRATION_TIMEOUT = 500; // 0.5 seconds
4135
const SHELL_INTEGRATION_POLL_INTERVAL = 100; // 0.1 seconds
@@ -297,7 +291,10 @@ export class TerminalManagerImpl implements TerminalManager {
297291
env: options.env,
298292
strictEnv: options.strictEnv,
299293
message: options.message,
300-
iconPath: options.iconPath ?? getIconPath(environment.iconPath),
294+
iconPath: options.iconPath ?? {
295+
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
296+
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
297+
},
301298
hideFromUser: options.hideFromUser,
302299
color: options.color,
303300
location: options.location,

src/managers/sysPython/pipManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import {
1212
PythonEnvironmentApi,
1313
} from '../../api';
1414
import { installPackages, refreshPackages, uninstallPackages } from './utils';
15-
import { EXTENSION_ROOT_DIR } from '../../common/constants';
1615
import { Disposable } from 'vscode-jsonrpc';
1716
import { getProjectInstallable } from './venvUtils';
1817
import { VenvManager } from './venvManager';
18+
import { EXTENSION_ROOT_DIR } from '../../common/constants';
1919

2020
function getChanges(before: Package[], after: Package[]): { kind: PackageChangeKind; pkg: Package }[] {
2121
const changes: { kind: PackageChangeKind; pkg: Package }[] = [];
@@ -43,7 +43,10 @@ export class PipPackageManager implements PackageManager, Disposable {
4343
this.displayName = 'Pip';
4444
this.description = 'This package manager for python installs using pip.';
4545
this.tooltip = new MarkdownString('This package manager for python installs using `pip`.');
46-
this.iconPath = Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', '__icon__.py'));
46+
this.iconPath = {
47+
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
48+
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
49+
};
4750
}
4851
readonly name: string;
4952
readonly displayName?: string;

src/managers/sysPython/sysPythonManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import {
2424
setSystemEnvForGlobal,
2525
setSystemEnvForWorkspace,
2626
} from './utils';
27-
import { EXTENSION_ROOT_DIR } from '../../common/constants';
2827
import { NativePythonFinder } from '../common/nativePythonFinder';
2928
import { createDeferred, Deferred } from '../../common/utils/deferred';
3029
import { getLatest } from '../common/utils';
30+
import { EXTENSION_ROOT_DIR } from '../../common/constants';
3131

3232
export class SysPythonManager implements EnvironmentManager {
3333
private collection: PythonEnvironment[] = [];
@@ -57,7 +57,10 @@ export class SysPythonManager implements EnvironmentManager {
5757
this.preferredPackageManagerId = 'ms-python.python:pip';
5858
this.description = 'Manages Global python installs';
5959
this.tooltip = new MarkdownString('$(globe) Python Environment Manager', true);
60-
this.iconPath = Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', '__icon__.py'));
60+
this.iconPath = {
61+
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
62+
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
63+
};
6164
}
6265

6366
private _initialized: Deferred<void> | undefined;

src/managers/sysPython/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ function getPythonInfo(env: NativeEnvInfo): PythonEnvironmentInfo {
196196
version: env.version,
197197
description: env.executable,
198198
environmentPath: Uri.file(env.executable),
199-
iconPath: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', '__icon__.py')),
199+
iconPath: {
200+
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
201+
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
202+
},
200203
sysPrefix: env.prefix,
201204
execInfo: {
202205
run: {

src/managers/sysPython/venvManager.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ProgressLocation, Uri, window, LogOutputChannel, EventEmitter, MarkdownString } from 'vscode';
1+
import { ProgressLocation, Uri, LogOutputChannel, EventEmitter, MarkdownString } from 'vscode';
22
import {
33
CreateEnvironmentScope,
44
DidChangeEnvironmentEventArgs,
@@ -33,6 +33,7 @@ import { NativePythonFinder } from '../common/nativePythonFinder';
3333
import { ENVS_EXTENSION_ID, EXTENSION_ROOT_DIR } from '../../common/constants';
3434
import { createDeferred, Deferred } from '../../common/utils/deferred';
3535
import { getLatest, sortEnvironments } from '../common/utils';
36+
import { withProgress } from '../../common/window.apis';
3637

3738
export class VenvManager implements EnvironmentManager {
3839
private collection: PythonEnvironment[] = [];
@@ -63,7 +64,10 @@ export class VenvManager implements EnvironmentManager {
6364
this.description = 'Manages virtual environments created using venv';
6465
this.tooltip = new MarkdownString('Manages virtual environments created using `venv`', true);
6566
this.preferredPackageManagerId = 'ms-python.python:pip';
66-
this.iconPath = Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', '__icon__.py'));
67+
this.iconPath = {
68+
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
69+
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
70+
};
6771
}
6872

6973
private _initialized: Deferred<void> | undefined;
@@ -145,7 +149,7 @@ export class VenvManager implements EnvironmentManager {
145149
}
146150

147151
private async internalRefresh(scope: RefreshEnvironmentsScope, hardRefresh: boolean, title: string): Promise<void> {
148-
await window.withProgress(
152+
await withProgress(
149153
{
150154
location: ProgressLocation.Window,
151155
title,

src/managers/sysPython/venvUtils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ function getPythonInfo(env: NativeEnvInfo): PythonEnvironmentInfo {
129129
version: env.version,
130130
description: env.executable,
131131
environmentPath: Uri.file(env.executable),
132-
iconPath: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', '__icon__.py')),
132+
iconPath: {
133+
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
134+
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
135+
},
133136
sysPrefix: env.prefix,
134137
execInfo: {
135138
run: {

0 commit comments

Comments
 (0)