Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Georg Pfuetzenreuter
gajim
Commits
bf697b81
Commit
bf697b81
authored
Jun 06, 2021
by
Daniel Brötzmann
Browse files
Themes: Apply change of dark/light theme instantly
Fixes #10441
parent
17b5488c
Changes
2
Hide whitespace changes
Inline
Side-by-side
gajim/gtk/css_config.py
View file @
bf697b81
...
@@ -121,8 +121,7 @@ def prefer_dark(self):
...
@@ -121,8 +121,7 @@ def prefer_dark(self):
return
settings
.
get_property
(
'gtk-application-prefer-dark-theme'
)
return
settings
.
get_property
(
'gtk-application-prefer-dark-theme'
)
return
setting
==
Theme
.
DARK
return
setting
==
Theme
.
DARK
@
staticmethod
def
set_dark_theme
(
self
,
value
=
None
):
def
set_dark_theme
(
value
=
None
):
if
value
is
None
:
if
value
is
None
:
value
=
app
.
settings
.
get
(
'dark_theme'
)
value
=
app
.
settings
.
get
(
'dark_theme'
)
else
:
else
:
...
@@ -134,6 +133,7 @@ def set_dark_theme(value=None):
...
@@ -134,6 +133,7 @@ def set_dark_theme(value=None):
settings
.
reset_property
(
'gtk-application-prefer-dark-theme'
)
settings
.
reset_property
(
'gtk-application-prefer-dark-theme'
)
return
return
settings
.
set_property
(
'gtk-application-prefer-dark-theme'
,
bool
(
value
))
settings
.
set_property
(
'gtk-application-prefer-dark-theme'
,
bool
(
value
))
self
.
_load_css
()
def
_load_css
(
self
):
def
_load_css
(
self
):
self
.
_load_css_from_file
(
'gajim.css'
,
CSSPriority
.
APPLICATION
)
self
.
_load_css_from_file
(
'gajim.css'
,
CSSPriority
.
APPLICATION
)
...
@@ -156,14 +156,16 @@ def _load_css_from_file(self, filename, priority):
...
@@ -156,14 +156,16 @@ def _load_css_from_file(self, filename, priority):
return
return
self
.
_activate_css
(
css
,
priority
)
self
.
_activate_css
(
css
,
priority
)
@
staticmethod
def
_activate_css
(
self
,
css
,
priority
):
def
_activate_css
(
css
,
priority
):
try
:
try
:
provider
=
Gtk
.
CssProvider
()
provider
=
Gtk
.
CssProvider
()
provider
.
load_from_data
(
bytes
(
css
.
encode
(
'utf-8'
)))
provider
.
load_from_data
(
bytes
(
css
.
encode
(
'utf-8'
)))
Gtk
.
StyleContext
.
add_provider_for_screen
(
Gdk
.
Screen
.
get_default
(),
Gtk
.
StyleContext
.
add_provider_for_screen
(
Gdk
.
Screen
.
get_default
(),
provider
,
provider
,
priority
)
priority
)
self
.
_load_selected
()
self
.
_activate_theme
()
except
Exception
:
except
Exception
:
log
.
exception
(
'Error loading application css'
)
log
.
exception
(
'Error loading application css'
)
...
...
gajim/gtk/preferences.py
View file @
bf697b81
...
@@ -719,12 +719,14 @@ def _on_edit_themes(self, *args):
...
@@ -719,12 +719,14 @@ def _on_edit_themes(self, *args):
def
_on_theme_changed
(
value
,
*
args
):
def
_on_theme_changed
(
value
,
*
args
):
app
.
css_config
.
change_theme
(
value
)
app
.
css_config
.
change_theme
(
value
)
app
.
nec
.
push_incoming_event
(
NetworkEvent
(
'theme-update'
))
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
.
repaint_themed_widgets
()
app
.
interface
.
roster
.
change_roster_style
(
None
)
app
.
interface
.
roster
.
change_roster_style
(
None
)
@
staticmethod
@
staticmethod
def
_on_dark_theme
(
value
,
*
args
):
def
_on_dark_theme
(
value
,
*
args
):
app
.
css_config
.
set_dark_theme
(
int
(
value
))
app
.
css_config
.
set_dark_theme
(
int
(
value
))
app
.
nec
.
push_incoming_event
(
NetworkEvent
(
'style-changed'
))
class
Emoji
(
PreferenceBox
):
class
Emoji
(
PreferenceBox
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment