Skip to content
Snippets Groups Projects
Commit 819e64fd authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist
Browse files

Themes: Switch active theme when adding or removing theme

When adding a new theme, it is automatically applied. This enables users
to view their changes directly without switching the active theme in
Preferences first. Deleting the currently active theme will fallback to default.
parent 7d755dc2
No related branches found
No related tags found
No related merge requests found
...@@ -284,6 +284,21 @@ def _on_add_new_theme(self, *args): ...@@ -284,6 +284,21 @@ def _on_add_new_theme(self, *args):
self._remove_theme_button.set_sensitive(True) self._remove_theme_button.set_sensitive(True)
iter_ = self._theme_store.append([name]) iter_ = self._theme_store.append([name])
self._select_theme_row(iter_) self._select_theme_row(iter_)
self._apply_theme(name)
def _apply_theme(self, theme):
app.config.set('roster_theme', theme)
app.css_config.change_theme(theme)
app.nec.push_incoming_event(NetworkEvent('theme-update'))
# Begin repainting themed widgets throughout
app.interface.roster.repaint_themed_widgets()
app.interface.roster.change_roster_style(None)
# Update Preferences theme combobox
window = get_app_window('Preferences')
if window is not None:
window.update_theme_list()
@staticmethod @staticmethod
def _create_theme_name(): def _create_theme_name():
...@@ -298,15 +313,11 @@ def _on_remove_theme(self, *args): ...@@ -298,15 +313,11 @@ def _on_remove_theme(self, *args):
return return
theme = store[iter_][Column.THEME] theme = store[iter_][Column.THEME]
if theme == app.config.get('roster_theme'):
ErrorDialog(
_('Active Theme'),
_('You tried to delete the currently active theme. '
'Please switch to a different theme first.'),
transient_for=self)
return
def _remove_theme(): def _remove_theme():
if theme == app.config.get('roster_theme'):
self._apply_theme('default')
app.css_config.remove_theme(theme) app.css_config.remove_theme(theme)
store.remove(iter_) store.remove(iter_)
...@@ -316,10 +327,15 @@ def _remove_theme(): ...@@ -316,10 +327,15 @@ def _remove_theme():
self._add_option_button.set_sensitive(False) self._add_option_button.set_sensitive(False)
self._clear_options() self._clear_options()
text = _('Do you want to delete this theme?')
if theme == app.config.get('roster_theme'):
text = _('This is the theme you are currently using.\n'
'Do you want to delete this theme?')
NewConfirmationDialog( NewConfirmationDialog(
_('Delete'), _('Delete'),
_('Delete Theme'), _('Delete Theme'),
_('Do you want to permanently delete this theme?'), text,
[DialogButton.make('Cancel'), [DialogButton.make('Cancel'),
DialogButton.make('Delete', DialogButton.make('Delete',
callback=_remove_theme)], callback=_remove_theme)],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment