Skip to content

Commit 7a80d8b

Browse files
mmstickjackpot51
authored andcommitted
feat: Improved HighContrast Support
1 parent 4175b24 commit 7a80d8b

File tree

3 files changed

+97
-22
lines changed

3 files changed

+97
-22
lines changed

highcontrast.css

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.pop-shell-active-hint {
2+
border-style: solid;
3+
border-color: #FBB86C;
4+
border-radius: 5px;
5+
box-shadow: inset 0 0 0 1px rgba(24, 23, 23, 0)
6+
}
7+
8+
.pop-shell-overlay {
9+
background-color: rgba(53, 132, 228, 0.3);
10+
}
11+
12+
.pop-shell-border-normal {
13+
border-width: 3px;
14+
}
15+
16+
.pop-shell-border-maximize {
17+
border-width: 3px;
18+
}
19+
20+
.pop-shell-search-element:select{
21+
background: #fff;
22+
border-radius: 5px;
23+
color: #000;
24+
}
25+
26+
.pop-shell-search-icon {
27+
margin-right: 10px;
28+
}
29+
30+
.pop-shell-search-cat {
31+
margin-right: 10px;
32+
}
33+
34+
.pop-shell-search-element {
35+
padding-left: 10px;
36+
padding-right: 2px;
37+
padding-top: 6px;
38+
padding-bottom: 6px;
39+
}
40+
41+
.pop-shell-gaps-entry {
42+
/* Seems to get the width just right to fit 3 digits */
43+
width: 75px;
44+
}
45+
46+
.pop-shell-tab {
47+
border: 1px solid #333;
48+
color: #000;
49+
padding: 0 1em;
50+
}
51+
52+
.pop-shell-tab-active {
53+
background: #FBB86C;
54+
}
55+
56+
.pop-shell-tab-inactive {
57+
background: #9B8E8A;
58+
}
59+
60+
.pop-shell-tab-urgent {
61+
background: #D00;
62+
}
63+
64+
.pop-shell-entry:indeterminate {
65+
font-style: italic
66+
}

src/extension.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ const { Workspace } = imports.ui.workspace;
5252
const { WorkspaceThumbnail } = imports.ui.workspaceThumbnail;
5353
const Tags = Me.imports.tags;
5454

55-
const STYLESHEET_PATHS = ['light', 'dark'].map(stylesheet_path);
55+
const STYLESHEET_PATHS = ['light', 'dark', 'highcontrast'].map(stylesheet_path);
5656
const STYLESHEETS = STYLESHEET_PATHS.map((path) => Gio.File.new_for_path(path));
5757
const GNOME_VERSION = imports.misc.config.PACKAGE_VERSION;
5858

59-
enum Style { Light, Dark }
59+
enum Style { Light, Dark, HighContrast }
6060

6161
interface Display {
6262
area: Rectangle;
@@ -108,7 +108,7 @@ export class Ext extends Ecs.System<ExtEvent> {
108108
column_size: number = 32;
109109

110110
/** The currently-loaded theme variant */
111-
current_style: Style = this.settings.is_dark_shell() ? Style.Dark : Style.Light;
111+
current_style: Style = Style.Dark;
112112

113113
/** Set when the display configuration has been triggered for execution */
114114
displays_updating: SignalID | null = null;
@@ -215,6 +215,7 @@ export class Ext extends Ecs.System<ExtEvent> {
215215
super(new Executor.GLibExecutor());
216216

217217
this.load_settings();
218+
this.reload_theme()
218219

219220
this.register_fn(() => load_theme(this.current_style));
220221

@@ -1379,11 +1380,19 @@ export class Ext extends Ecs.System<ExtEvent> {
13791380
}
13801381

13811382
on_gtk_shell_changed() {
1382-
load_theme(this.settings.is_dark_shell() ? Style.Dark : Style.Light);
1383+
this.reload_theme();
1384+
load_theme(this.current_style)
13831385
}
13841386

13851387
on_gtk_theme_change() {
1386-
load_theme(this.settings.is_dark_shell() ? Style.Dark : Style.Light);
1388+
this.reload_theme()
1389+
load_theme(this.current_style)
1390+
}
1391+
1392+
reload_theme() {
1393+
this.current_style = this.settings.is_dark()
1394+
? Style.Dark
1395+
: this.settings.is_high_contrast() ? Style.HighContrast : Style.Light
13871396
}
13881397

13891398
/** Handle window maximization notifications */

src/settings.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const ExtensionUtils = imports.misc.extensionUtils;
2-
const extension = ExtensionUtils.getCurrentExtension();
1+
const Me = imports.misc.extensionUtils.getCurrentExtension();
2+
33
const { Gio, Gdk } = imports.gi;
44

55
const DARK = ["dark", "adapta", "plata", "dracula"]
@@ -31,7 +31,7 @@ function settings_new_id(schema_id: string): Settings | null {
3131

3232
function settings_new_schema(schema: string): Settings {
3333
const GioSSS = Gio.SettingsSchemaSource;
34-
const schemaDir = extension.dir.get_child("schemas");
34+
const schemaDir = Me.dir.get_child("schemas");
3535

3636
let schemaSource = schemaDir.query_exists(null) ?
3737
GioSSS.new_from_directory(schemaDir.get_path(), GioSSS.get_default(), false) :
@@ -41,7 +41,7 @@ function settings_new_schema(schema: string): Settings {
4141

4242
if (!schemaObj) {
4343
throw new Error("Schema " + schema + " could not be found for extension "
44-
+ extension.metadata.uuid + ". Please check your installation.")
44+
+ Me.metadata.uuid + ". Please check your installation.")
4545
}
4646

4747
return new Gio.Settings({ settings_schema: schemaObj });
@@ -62,7 +62,7 @@ const LOG_LEVEL = "log-level";
6262
const SHOW_SKIPTASKBAR = "show-skip-taskbar";
6363

6464
export class ExtensionSettings {
65-
ext: Settings = settings_new_schema(extension.metadata["settings-schema"]);
65+
ext: Settings = settings_new_schema(Me.metadata["settings-schema"]);
6666
int: Settings | null = settings_new_id("org.gnome.desktop.interface");
6767
mutter: Settings | null = settings_new_id("org.gnome.mutter");
6868
shell: Settings | null = settings_new_id("org.gnome.shell.extensions.user-theme");
@@ -100,21 +100,21 @@ export class ExtensionSettings {
100100
return rgba;
101101
}
102102

103-
is_dark(): boolean {
104-
if (this.int) {
105-
let theme = this.int.get_string("gtk-theme").toLowerCase();
106-
return DARK.some(dark => theme.includes(dark))
107-
}
103+
theme(): string {
104+
return this.shell
105+
? this.shell.get_string("name")
106+
: this.int
107+
? this.int.get_string("gtk-theme")
108+
: "Adwaita"
109+
}
108110

109-
return false
111+
is_dark(): boolean {
112+
const theme = this.theme().toLowerCase()
113+
return DARK.some(dark => theme.includes(dark))
110114
}
111115

112-
is_dark_shell(): boolean {
113-
if (this.shell) {
114-
let theme = this.shell.get_string("name").toLowerCase()
115-
return DARK.some(dark => theme.includes(dark) || theme.length === 0)
116-
}
117-
return this.is_dark();
116+
is_high_contrast(): boolean {
117+
return this.theme().toLowerCase() === "highcontrast"
118118
}
119119

120120
row_size(): number {

0 commit comments

Comments
 (0)