main: Add support for -high-contrast theme variants
While the default Shell style is fairly decent with regard to accessibility requirements, having the ability to tweak certain aspects where the regular style works less well is still useful. For this purpose, try to load a -high-contrast theme variant of the default stylesheet when a high-contrast theme is requested (as determined by the GTK+ theme name). https://bugzilla.gnome.org/show_bug.cgi?id=740447
This commit is contained in:
parent
977448b6bc
commit
f4cc3327e8
@ -4,6 +4,7 @@ const Clutter = imports.gi.Clutter;
|
|||||||
const Gdk = imports.gi.Gdk;
|
const Gdk = imports.gi.Gdk;
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
const GLib = imports.gi.GLib;
|
const GLib = imports.gi.GLib;
|
||||||
|
const Gtk = imports.gi.Gtk;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Mainloop = imports.mainloop;
|
const Mainloop = imports.mainloop;
|
||||||
const Meta = imports.gi.Meta;
|
const Meta = imports.gi.Meta;
|
||||||
@ -75,6 +76,7 @@ let _cssStylesheet = null;
|
|||||||
let _a11ySettings = null;
|
let _a11ySettings = null;
|
||||||
|
|
||||||
function _sessionUpdated() {
|
function _sessionUpdated() {
|
||||||
|
if (sessionMode.isPrimary)
|
||||||
_loadDefaultStylesheet();
|
_loadDefaultStylesheet();
|
||||||
|
|
||||||
wm.setCustomKeybindingHandler('panel-main-menu',
|
wm.setCustomKeybindingHandler('panel-main-menu',
|
||||||
@ -109,6 +111,8 @@ function start() {
|
|||||||
|
|
||||||
sessionMode = new SessionMode.SessionMode();
|
sessionMode = new SessionMode.SessionMode();
|
||||||
sessionMode.connect('updated', _sessionUpdated);
|
sessionMode.connect('updated', _sessionUpdated);
|
||||||
|
Gtk.Settings.get_default().connect('notify::gtk-theme-name',
|
||||||
|
_loadDefaultStylesheet);
|
||||||
_initializeUI();
|
_initializeUI();
|
||||||
|
|
||||||
shellDBusService = new ShellDBus.GnomeShell();
|
shellDBusService = new ShellDBus.GnomeShell();
|
||||||
@ -225,24 +229,36 @@ function _initializeUI() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getDefaultStylesheet() {
|
function _getStylesheet(name) {
|
||||||
let stylesheet;
|
let stylesheet;
|
||||||
|
|
||||||
stylesheet = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/' + sessionMode.stylesheetName);
|
stylesheet = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/' + name);
|
||||||
if (stylesheet.query_exists(null))
|
if (stylesheet.query_exists(null))
|
||||||
return stylesheet;
|
return stylesheet;
|
||||||
|
|
||||||
stylesheet = Gio.File.new_for_path(global.datadir + '/theme/' + sessionMode.stylesheetName);
|
stylesheet = Gio.File.new_for_path(global.datadir + '/theme/' + name);
|
||||||
if (stylesheet.query_exists(null))
|
if (stylesheet.query_exists(null))
|
||||||
return stylesheet;
|
return stylesheet;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _loadDefaultStylesheet() {
|
function _getDefaultStylesheet() {
|
||||||
if (!sessionMode.isPrimary)
|
let stylesheet = null;
|
||||||
return;
|
let name = sessionMode.stylesheetName;
|
||||||
|
|
||||||
|
// Look for a high-contrast variant first when using GTK+'s HighContrast
|
||||||
|
// theme
|
||||||
|
if (Gtk.Settings.get_default().gtk_theme_name == 'HighContrast')
|
||||||
|
stylesheet = _getStylesheet(name.replace('.css', '-high-contrast.css'));
|
||||||
|
|
||||||
|
if (stylesheet == null)
|
||||||
|
stylesheet = _getStylesheet(sessionMode.stylesheetName);
|
||||||
|
|
||||||
|
return stylesheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _loadDefaultStylesheet() {
|
||||||
let stylesheet = _getDefaultStylesheet();
|
let stylesheet = _getDefaultStylesheet();
|
||||||
if (_defaultCssStylesheet && _defaultCssStylesheet.equal(stylesheet))
|
if (_defaultCssStylesheet && _defaultCssStylesheet.equal(stylesheet))
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user