diff options
Diffstat (limited to 'deluge/ui/gtk3')
-rw-r--r-- | deluge/ui/gtk3/glade/preferences_dialog.ui | 48 | ||||
-rw-r--r-- | deluge/ui/gtk3/gtkui.py | 1 | ||||
-rw-r--r-- | deluge/ui/gtk3/mainwindow.py | 6 | ||||
-rw-r--r-- | deluge/ui/gtk3/preferences.py | 20 |
4 files changed, 71 insertions, 4 deletions
diff --git a/deluge/ui/gtk3/glade/preferences_dialog.ui b/deluge/ui/gtk3/glade/preferences_dialog.ui index aa1531d..720dc6b 100644 --- a/deluge/ui/gtk3/glade/preferences_dialog.ui +++ b/deluge/ui/gtk3/glade/preferences_dialog.ui @@ -736,7 +736,7 @@ and daemon (does not apply in Standalone mode).</property> <property name="expand">False</property> <property name="fill">False</property> <property name="padding">5</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> @@ -968,6 +968,48 @@ and daemon (does not apply in Standalone mode).</property> </packing> </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="GtkCheckButton" id="chk_prefer_dark_theme"> + <property name="label" translatable="yes">Prefer 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">If available, use dark variant of GTK theme.</property> + <property name="draw-indicator">True</property> + </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">3</property> + </packing> + </child> + <child> <object class="GtkFrame" id="frame19"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -1024,7 +1066,7 @@ and daemon (does not apply in Standalone mode).</property> <property name="expand">False</property> <property name="fill">False</property> <property name="padding">5</property> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> <child> @@ -1101,7 +1143,7 @@ and daemon (does not apply in Standalone mode).</property> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">4</property> + <property name="position">5</property> </packing> </child> </object> diff --git a/deluge/ui/gtk3/gtkui.py b/deluge/ui/gtk3/gtkui.py index 434d1b8..73a7c97 100644 --- a/deluge/ui/gtk3/gtkui.py +++ b/deluge/ui/gtk3/gtkui.py @@ -84,6 +84,7 @@ except ImportError: DEFAULT_PREFS = { 'standalone': True, + 'prefer_dark_theme': False, 'interactive_add': True, 'focus_add_dialog': True, 'enable_system_tray': True, diff --git a/deluge/ui/gtk3/mainwindow.py b/deluge/ui/gtk3/mainwindow.py index e1e3bb3..6c871d2 100644 --- a/deluge/ui/gtk3/mainwindow.py +++ b/deluge/ui/gtk3/mainwindow.py @@ -72,6 +72,12 @@ class MainWindow(component.Component): self.config = ConfigManager('gtk3ui.conf') self.main_builder = Gtk.Builder() + # Set theme + Gtk.Settings.get_default().set_property( + 'gtk-application-prefer-dark-theme', + self.config['prefer_dark_theme'], + ) + # Patch this GtkBuilder to avoid connecting signals from elsewhere # # Think about splitting up mainwindow gtkbuilder file into the necessary parts diff --git a/deluge/ui/gtk3/preferences.py b/deluge/ui/gtk3/preferences.py index a024a59..cd67a5b 100644 --- a/deluge/ui/gtk3/preferences.py +++ b/deluge/ui/gtk3/preferences.py @@ -13,7 +13,7 @@ from hashlib import sha1 as sha from urllib.parse import urlparse from gi import require_version -from gi.repository import Gtk +from gi.repository import GObject, Gtk from gi.repository.Gdk import Color import deluge.common @@ -171,6 +171,14 @@ class Preferences(component.Component): # Radio buttons to choose between systray and 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('chk_prefer_dark_theme'), + 'active', + GObject.BindingFlags.BIDIRECTIONAL | GObject.BindingFlags.SYNC_CREATE, + ) + from .gtkui import DEFAULT_PREFS self.COLOR_DEFAULTS = {} @@ -557,6 +565,9 @@ class Preferences(component.Component): self.builder.get_object('radio_thinclient').set_active( not self.gtkui_config['standalone'] ) + self.builder.get_object('chk_prefer_dark_theme').set_active( + self.gtkui_config['prefer_dark_theme'] + ) self.builder.get_object('chk_show_rate_in_title').set_active( self.gtkui_config['show_rate_in_title'] ) @@ -741,6 +752,9 @@ class Preferences(component.Component): ).get_active() # Interface tab # + new_gtkui_config['prefer_dark_theme'] = self.builder.get_object( + 'chk_prefer_dark_theme' + ).get_active() new_gtkui_config['enable_system_tray'] = self.builder.get_object( 'chk_use_tray' ).get_active() @@ -1074,6 +1088,10 @@ class Preferences(component.Component): def on_button_cancel_clicked(self, data): log.debug('on_button_cancel_clicked') + Gtk.Settings.get_default().set_property( + 'gtk-application-prefer-dark-theme', + self.gtkui_config['prefer_dark_theme'], + ) self.hide() return True |