Commit bf697b81 authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

Themes: Apply change of dark/light theme instantly

Fixes #10441
parent 17b5488c
......@@ -121,8 +121,7 @@ def prefer_dark(self):
return settings.get_property('gtk-application-prefer-dark-theme')
return setting == Theme.DARK
@staticmethod
def set_dark_theme(value=None):
def set_dark_theme(self, value=None):
if value is None:
value = app.settings.get('dark_theme')
else:
......@@ -134,6 +133,7 @@ def set_dark_theme(value=None):
settings.reset_property('gtk-application-prefer-dark-theme')
return
settings.set_property('gtk-application-prefer-dark-theme', bool(value))
self._load_css()
def _load_css(self):
self._load_css_from_file('gajim.css', CSSPriority.APPLICATION)
......@@ -156,14 +156,16 @@ def _load_css_from_file(self, filename, priority):
return
self._activate_css(css, priority)
@staticmethod
def _activate_css(css, priority):
def _activate_css(self, css, priority):
try:
provider = Gtk.CssProvider()
provider.load_from_data(bytes(css.encode('utf-8')))
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
provider,
priority)
self._load_selected()
self._activate_theme()
except Exception:
log.exception('Error loading application css')
......
......@@ -719,12 +719,14 @@ def _on_edit_themes(self, *args):
def _on_theme_changed(value, *args):
app.css_config.change_theme(value)
app.nec.push_incoming_event(NetworkEvent('theme-update'))
app.nec.push_incoming_event(NetworkEvent('style-changed'))
app.interface.roster.repaint_themed_widgets()
app.interface.roster.change_roster_style(None)
@staticmethod
def _on_dark_theme(value, *args):
app.css_config.set_dark_theme(int(value))
app.nec.push_incoming_event(NetworkEvent('style-changed'))
class Emoji(PreferenceBox):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment