Skip to content

Commit

Permalink
Use light and dark mode icons (#64)
Browse files Browse the repository at this point in the history
Fixes #52
  • Loading branch information
karthiknadig authored Dec 4, 2024
1 parent 2cf31d4 commit 89cf5cc
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 18 deletions.
1 change: 1 addition & 0 deletions files/dark_mode_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions files/light_mode_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 6 additions & 9 deletions src/features/terminal/terminalManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,15 @@ import {
terminals,
withProgress,
} from '../../common/window.apis';
import { IconPath, PythonEnvironment, PythonProject, PythonTerminalOptions } from '../../api';
import { PythonEnvironment, PythonProject, PythonTerminalOptions } from '../../api';
import { getActivationCommand, getDeactivationCommand, isActivatableEnvironment } from '../common/activation';
import { showErrorMessage } from '../../common/errors/utils';
import { quoteArgs } from '../execution/execUtils';
import { createDeferred } from '../../common/utils/deferred';
import { traceError, traceVerbose } from '../../common/logging';
import { getConfiguration } from '../../common/workspace.apis';
import { EnvironmentManagers } from '../../internal.api';

function getIconPath(i: IconPath | undefined): IconPath | undefined {
if (i instanceof Uri) {
return i.fsPath.endsWith('__icon__.py') ? undefined : i;
}
return i;
}
import { EXTENSION_ROOT_DIR } from '../../common/constants';

const SHELL_INTEGRATION_TIMEOUT = 500; // 0.5 seconds
const SHELL_INTEGRATION_POLL_INTERVAL = 100; // 0.1 seconds
Expand Down Expand Up @@ -297,7 +291,10 @@ export class TerminalManagerImpl implements TerminalManager {
env: options.env,
strictEnv: options.strictEnv,
message: options.message,
iconPath: options.iconPath ?? getIconPath(environment.iconPath),
iconPath: options.iconPath ?? {
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
},
hideFromUser: options.hideFromUser,
color: options.color,
location: options.location,
Expand Down
7 changes: 5 additions & 2 deletions src/managers/sysPython/pipManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
PythonEnvironmentApi,
} from '../../api';
import { installPackages, refreshPackages, uninstallPackages } from './utils';
import { EXTENSION_ROOT_DIR } from '../../common/constants';
import { Disposable } from 'vscode-jsonrpc';
import { getProjectInstallable } from './venvUtils';
import { VenvManager } from './venvManager';
import { EXTENSION_ROOT_DIR } from '../../common/constants';

function getChanges(before: Package[], after: Package[]): { kind: PackageChangeKind; pkg: Package }[] {
const changes: { kind: PackageChangeKind; pkg: Package }[] = [];
Expand Down Expand Up @@ -43,7 +43,10 @@ export class PipPackageManager implements PackageManager, Disposable {
this.displayName = 'Pip';
this.description = 'This package manager for python installs using pip.';
this.tooltip = new MarkdownString('This package manager for python installs using `pip`.');
this.iconPath = Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', '__icon__.py'));
this.iconPath = {
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
};
}
readonly name: string;
readonly displayName?: string;
Expand Down
7 changes: 5 additions & 2 deletions src/managers/sysPython/sysPythonManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import {
setSystemEnvForGlobal,
setSystemEnvForWorkspace,
} from './utils';
import { EXTENSION_ROOT_DIR } from '../../common/constants';
import { NativePythonFinder } from '../common/nativePythonFinder';
import { createDeferred, Deferred } from '../../common/utils/deferred';
import { getLatest } from '../common/utils';
import { EXTENSION_ROOT_DIR } from '../../common/constants';

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

private _initialized: Deferred<void> | undefined;
Expand Down
5 changes: 4 additions & 1 deletion src/managers/sysPython/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ function getPythonInfo(env: NativeEnvInfo): PythonEnvironmentInfo {
version: env.version,
description: env.executable,
environmentPath: Uri.file(env.executable),
iconPath: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', '__icon__.py')),
iconPath: {
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
},
sysPrefix: env.prefix,
execInfo: {
run: {
Expand Down
10 changes: 7 additions & 3 deletions src/managers/sysPython/venvManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProgressLocation, Uri, window, LogOutputChannel, EventEmitter, MarkdownString } from 'vscode';
import { ProgressLocation, Uri, LogOutputChannel, EventEmitter, MarkdownString } from 'vscode';
import {
CreateEnvironmentScope,
DidChangeEnvironmentEventArgs,
Expand Down Expand Up @@ -33,6 +33,7 @@ import { NativePythonFinder } from '../common/nativePythonFinder';
import { ENVS_EXTENSION_ID, EXTENSION_ROOT_DIR } from '../../common/constants';
import { createDeferred, Deferred } from '../../common/utils/deferred';
import { getLatest, sortEnvironments } from '../common/utils';
import { withProgress } from '../../common/window.apis';

export class VenvManager implements EnvironmentManager {
private collection: PythonEnvironment[] = [];
Expand Down Expand Up @@ -63,7 +64,10 @@ export class VenvManager implements EnvironmentManager {
this.description = 'Manages virtual environments created using venv';
this.tooltip = new MarkdownString('Manages virtual environments created using `venv`', true);
this.preferredPackageManagerId = 'ms-python.python:pip';
this.iconPath = Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', '__icon__.py'));
this.iconPath = {
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
};
}

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

private async internalRefresh(scope: RefreshEnvironmentsScope, hardRefresh: boolean, title: string): Promise<void> {
await window.withProgress(
await withProgress(
{
location: ProgressLocation.Window,
title,
Expand Down
5 changes: 4 additions & 1 deletion src/managers/sysPython/venvUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ function getPythonInfo(env: NativeEnvInfo): PythonEnvironmentInfo {
version: env.version,
description: env.executable,
environmentPath: Uri.file(env.executable),
iconPath: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', '__icon__.py')),
iconPath: {
light: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'light_mode_icon.svg')),
dark: Uri.file(path.join(EXTENSION_ROOT_DIR, 'files', 'dark_mode_icon.svg')),
},
sysPrefix: env.prefix,
execInfo: {
run: {
Expand Down

0 comments on commit 89cf5cc

Please sign in to comment.