[GtkUI] Add a way to change themes
Currently, the only way to change the themes is by manually set a value in the command line or set it as env variable. Closes: https://dev.deluge-torrent.org/ticket/3536 Closes: https://github.com/deluge-torrent/deluge/pull/392
This commit is contained in:
parent
848d668af9
commit
ee97864086
|
@ -429,6 +429,77 @@
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkFrame" id="frame_theme">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label_xalign">0</property>
|
||||||
|
<property name="shadow_type">none</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkAlignment" id="alignment_theme">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="top_padding">3</property>
|
||||||
|
<property name="left_padding">10</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="hbox_theme">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkRadioButton" id="radio_theme_light">
|
||||||
|
<property name="label" translatable="yes">Light</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip_text" translatable="yes">The light theme</property>
|
||||||
|
<property name="active">True</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkRadioButton" id="radio_theme_dark">
|
||||||
|
<property name="label" translatable="yes">Dark</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip_text" translatable="yes">The dark theme</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<property name="group">radio_theme_light</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="padding">7</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="label">
|
||||||
|
<object class="GtkLabel" id="label_theme">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Theme</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="padding">5</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFrame" id="frame29">
|
<object class="GtkFrame" id="frame29">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -736,7 +807,7 @@ and daemon (does not apply in Standalone mode).</property>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="padding">5</property>
|
<property name="padding">5</property>
|
||||||
<property name="position">1</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -964,7 +1035,7 @@ and daemon (does not apply in Standalone mode).</property>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="padding">5</property>
|
<property name="padding">5</property>
|
||||||
<property name="position">2</property>
|
<property name="position">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -1024,7 +1095,7 @@ and daemon (does not apply in Standalone mode).</property>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="padding">5</property>
|
<property name="padding">5</property>
|
||||||
<property name="position">3</property>
|
<property name="position">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -1101,7 +1172,7 @@ and daemon (does not apply in Standalone mode).</property>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">4</property>
|
<property name="position">5</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -84,6 +84,7 @@ except ImportError:
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
'standalone': True,
|
'standalone': True,
|
||||||
|
'dark_theme': False,
|
||||||
'interactive_add': True,
|
'interactive_add': True,
|
||||||
'focus_add_dialog': True,
|
'focus_add_dialog': True,
|
||||||
'enable_system_tray': True,
|
'enable_system_tray': True,
|
||||||
|
|
|
@ -72,6 +72,12 @@ class MainWindow(component.Component):
|
||||||
self.config = ConfigManager('gtk3ui.conf')
|
self.config = ConfigManager('gtk3ui.conf')
|
||||||
self.main_builder = Gtk.Builder()
|
self.main_builder = Gtk.Builder()
|
||||||
|
|
||||||
|
# Set theme
|
||||||
|
Gtk.Settings.get_default().set_property(
|
||||||
|
'gtk-application-prefer-dark-theme',
|
||||||
|
self.config['dark_theme'],
|
||||||
|
)
|
||||||
|
|
||||||
# Patch this GtkBuilder to avoid connecting signals from elsewhere
|
# Patch this GtkBuilder to avoid connecting signals from elsewhere
|
||||||
#
|
#
|
||||||
# Think about splitting up mainwindow gtkbuilder file into the necessary parts
|
# Think about splitting up mainwindow gtkbuilder file into the necessary parts
|
||||||
|
|
|
@ -13,7 +13,7 @@ from hashlib import sha1 as sha
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from gi import require_version
|
from gi import require_version
|
||||||
from gi.repository import Gtk
|
from gi.repository import GObject, Gtk
|
||||||
from gi.repository.Gdk import Color
|
from gi.repository.Gdk import Color
|
||||||
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
@ -171,6 +171,14 @@ class Preferences(component.Component):
|
||||||
# Radio buttons to choose between systray and appindicator
|
# Radio buttons to choose between systray and appindicator
|
||||||
self.builder.get_object('alignment_tray_type').set_visible(appindicator)
|
self.builder.get_object('alignment_tray_type').set_visible(appindicator)
|
||||||
|
|
||||||
|
# Initialize a binding for dark theme
|
||||||
|
Gtk.Settings.get_default().bind_property(
|
||||||
|
'gtk-application-prefer-dark-theme',
|
||||||
|
self.builder.get_object('radio_theme_dark'),
|
||||||
|
'active',
|
||||||
|
GObject.BindingFlags.BIDIRECTIONAL | GObject.BindingFlags.SYNC_CREATE,
|
||||||
|
)
|
||||||
|
|
||||||
from .gtkui import DEFAULT_PREFS
|
from .gtkui import DEFAULT_PREFS
|
||||||
|
|
||||||
self.COLOR_DEFAULTS = {}
|
self.COLOR_DEFAULTS = {}
|
||||||
|
@ -557,6 +565,9 @@ class Preferences(component.Component):
|
||||||
self.builder.get_object('radio_thinclient').set_active(
|
self.builder.get_object('radio_thinclient').set_active(
|
||||||
not self.gtkui_config['standalone']
|
not self.gtkui_config['standalone']
|
||||||
)
|
)
|
||||||
|
self.builder.get_object('radio_theme_dark').set_active(
|
||||||
|
self.gtkui_config['dark_theme']
|
||||||
|
)
|
||||||
self.builder.get_object('chk_show_rate_in_title').set_active(
|
self.builder.get_object('chk_show_rate_in_title').set_active(
|
||||||
self.gtkui_config['show_rate_in_title']
|
self.gtkui_config['show_rate_in_title']
|
||||||
)
|
)
|
||||||
|
@ -741,6 +752,9 @@ class Preferences(component.Component):
|
||||||
).get_active()
|
).get_active()
|
||||||
|
|
||||||
# Interface tab #
|
# Interface tab #
|
||||||
|
new_gtkui_config['dark_theme'] = self.builder.get_object(
|
||||||
|
'radio_theme_dark'
|
||||||
|
).get_active()
|
||||||
new_gtkui_config['enable_system_tray'] = self.builder.get_object(
|
new_gtkui_config['enable_system_tray'] = self.builder.get_object(
|
||||||
'chk_use_tray'
|
'chk_use_tray'
|
||||||
).get_active()
|
).get_active()
|
||||||
|
@ -1074,6 +1088,10 @@ class Preferences(component.Component):
|
||||||
|
|
||||||
def on_button_cancel_clicked(self, data):
|
def on_button_cancel_clicked(self, data):
|
||||||
log.debug('on_button_cancel_clicked')
|
log.debug('on_button_cancel_clicked')
|
||||||
|
Gtk.Settings.get_default().set_property(
|
||||||
|
'gtk-application-prefer-dark-theme',
|
||||||
|
self.gtkui_config['dark_theme'],
|
||||||
|
)
|
||||||
self.hide()
|
self.hide()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue