Skip to content

Commit

Permalink
Don't add style provider before startup
Browse files Browse the repository at this point in the history
Should fix #1267
  • Loading branch information
johnfactotum committed Apr 2, 2024
1 parent 9617e18 commit 2f2d05b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/book-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
7 changes: 1 addition & 6 deletions src/themes.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 2f2d05b

Please sign in to comment.