fix: use St.IconTheme in the shell process

This commit is contained in:
Andy Holmes
2023-09-21 19:22:26 -07:00
parent 93f1777878
commit 70da5672e2

View File

@@ -26,7 +26,6 @@ import GdkPixbuf from 'gi://GdkPixbuf';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import Graphene from 'gi://Graphene';
import Gtk from 'gi://Gtk';
import Meta from 'gi://Meta';
import Shell from 'gi://Shell';
import St from 'gi://St';
@@ -696,14 +695,9 @@ export const DominantColorExtractor = class {
*/
_getIconPixBuf() {
let iconTexture = this._app.create_icon_texture(16);
let isGtk3 = !!Gtk.IconTheme.prototype.set_custom_theme;
if (themeLoader === null) {
let ifaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
let themeFunc = isGtk3 ? 'set_custom_theme' : 'set_theme_name';
themeLoader = new Gtk.IconTheme(),
themeLoader[themeFunc](ifaceSettings.get_string('icon-theme')); // Make sure the correct theme is loaded
themeLoader = new St.IconTheme();
}
// Unable to load the icon texture, use fallback
@@ -725,19 +719,11 @@ export const DominantColorExtractor = class {
// Get the pixel buffer from the icon theme
if (iconTexture instanceof Gio.ThemedIcon) {
let params = [iconTexture.get_names()[0], DOMINANT_COLOR_ICON_SIZE, 0];
if (!isGtk3) {
params.splice(1, 0, null);
params.splice(3, 1, 1, 1, 1);
}
let icon_info = themeLoader.lookup_icon.apply(themeLoader, params);
let icon_info = themeLoader.lookup_icon(iconTexture.get_names()[0],
DOMINANT_COLOR_ICON_SIZE, 0);
if (icon_info !== null) {
if (isGtk3) return icon_info.load_icon();
return GdkPixbuf.Pixbuf.new_from_file(icon_info.get_file().get_path());
return icon_info.load_icon();
}
}