fix main css reloading
This commit is contained in:
parent
7a11b6bc92
commit
5f5bdc43b1
|
@ -128,6 +128,14 @@ class LibraryPage(Enum):
|
|||
HELP = 'help'
|
||||
|
||||
|
||||
class StylePriority(IntEnum):
|
||||
FALLBACK = Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK #1
|
||||
THEME = Gtk.STYLE_PROVIDER_PRIORITY_THEME #200
|
||||
SETTINGS = Gtk.STYLE_PROVIDER_PRIORITY_SETTINGS #400
|
||||
APPLICATION = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION #600
|
||||
USER = Gtk.STYLE_PROVIDER_PRIORITY_USER #800
|
||||
|
||||
|
||||
@register
|
||||
class WebviewContextActions(Enum):
|
||||
AUDIO_COPY = WebKit2.ContextMenuAction.COPY_AUDIO_LINK_TO_CLIPBOARD
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from izzylib.logging import LogLevel
|
||||
from izzylib.path import Path
|
||||
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
from watchdog.observers import Observer
|
||||
|
||||
from .enums import StylePriority
|
||||
|
||||
|
||||
class Themes(DotDict):
|
||||
def __init__(self, window):
|
||||
|
@ -35,11 +36,6 @@ class Themes(DotDict):
|
|||
return self._current_theme
|
||||
|
||||
|
||||
@property
|
||||
def screen(self):
|
||||
return Gdk.Screen.get_default()
|
||||
|
||||
|
||||
@property
|
||||
def window(self):
|
||||
return self._window
|
||||
|
@ -88,7 +84,7 @@ class Themes(DotDict):
|
|||
if name.lower() == 'default':
|
||||
return
|
||||
|
||||
self._context.add_provider_for_screen(self.screen, self[name], Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
||||
self._context.add_provider(self[name], StylePriority.USER)
|
||||
self._current_theme = name
|
||||
|
||||
|
||||
|
@ -96,7 +92,7 @@ class Themes(DotDict):
|
|||
if not self._current_theme:
|
||||
return
|
||||
|
||||
self._context.remove_provider_for_screen(self.screen, self[self._current_theme])
|
||||
self._context.remove_provider(self[self._current_theme])
|
||||
self._current_theme = None
|
||||
|
||||
|
||||
|
@ -114,12 +110,12 @@ class Themes(DotDict):
|
|||
|
||||
def load_main(self):
|
||||
if self._main:
|
||||
self._context.remove_provider_for_screen(self.screen, self._main)
|
||||
self._context.remove_provider(self._main)
|
||||
|
||||
self._main = Gtk.CssProvider()
|
||||
self._main.load_from_file(Gio.File.new_for_path(self.app.path.resources.join('main.css')))
|
||||
|
||||
self._context.add_provider_for_screen(self.screen, self._main, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
||||
self._context.add_provider(self._main, StylePriority.FALLBACK)
|
||||
|
||||
|
||||
def setup(self):
|
||||
|
|
Reference in a new issue