diff --git a/src/book-viewer.js b/src/book-viewer.js index 05c3860d..cc5a4776 100644 --- a/src/book-viewer.js +++ b/src/book-viewer.js @@ -19,7 +19,7 @@ import { AnnotationPopover, importAnnotations, exportAnnotations } from './annot import { SelectionPopover } from './selection-tools.js' import { ImageViewer } from './image-viewer.js' import { formatAuthors, makeBookInfoWindow } from './book-info.js' -import { themes, invertTheme } from './themes.js' +import { themes, invertTheme, themeCssProvider } from './themes.js' import { dataStore } from './data.js' // for use in the WebView @@ -489,6 +489,8 @@ export const BookViewer = GObject.registerClass({ this._zoom_button.label = format.percent(webView.zoom_level)) this._zoom_button.label = format.percent(this._view.webView.zoom_level) + Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), + themeCssProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) let lastThemeClass const recolorUI = view => { const theme = themes.find(theme => theme.name === view.theme) ?? themes[0] diff --git a/src/themes.js b/src/themes.js index b62a549a..df053fee 100644 --- a/src/themes.js +++ b/src/themes.js @@ -1,6 +1,5 @@ import Gtk from 'gi://Gtk' import GLib from 'gi://GLib' -import Gdk from 'gi://Gdk' import { gettext as _ } from 'gettext' import * as utils from './utils.js' @@ -73,7 +72,7 @@ for (const { file, name } of utils.listDir(pkg.configpath('themes'))) try { console.error(e) } -const themeCssProvider = new Gtk.CssProvider() +export const themeCssProvider = new Gtk.CssProvider() themeCssProvider.load_from_data(` .theme-container .card { padding: 9px; @@ -107,10 +106,6 @@ themeCssProvider.load_from_data(` } ` }).join(''), -1) -Gtk.StyleContext.add_provider_for_display( - Gdk.Display.get_default(), - themeCssProvider, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) export const invertTheme = ({ light, dark }) => ({ light, dark, inverted: { fg: utils.invertColor(dark.fg),