Skip to content

Commit

Permalink
Dark mode: Delegate to libxapp
Browse files Browse the repository at this point in the history
  • Loading branch information
clefebvre committed May 29, 2023
1 parent 4b96a05 commit 7552c7a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 54 deletions.
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Rules-Requires-Root: no

Package: hypnotix
Architecture: all
Depends: gir1.2-xapp-1.0 (>= 2.2.11),
Depends: gir1.2-xapp-1.0 (>= 2.5.0),
python3,
python3-gi,
python3-requests,
Expand Down
10 changes: 1 addition & 9 deletions usr/lib/hypnotix/hypnotix.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,7 @@ def __init__(self, application):
self.bind_setting_widget("mpv-options", self.mpv_entry)

# Dark mode
prefer_dark_mode = self.settings.get_boolean("prefer-dark-mode")
Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", prefer_dark_mode)
self.darkmode_switch.set_active(prefer_dark_mode)
self.darkmode_switch.connect("notify::active", self.on_darkmode_switch_toggled)
XApp.DarkModeManager(prefer_dark_mode=True)

# Menubar
accel_group = Gtk.AccelGroup()
Expand Down Expand Up @@ -579,11 +576,6 @@ def bind_setting_widget(self, key, widget):
def on_entry_changed(self, widget, key):
self.settings.set_string(key, widget.get_text())

def on_darkmode_switch_toggled(self, widget, key):
prefer_dark_mode = widget.get_active()
self.settings.set_boolean("prefer-dark-mode", prefer_dark_mode)
Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", prefer_dark_mode)

@async_function
def download_channel_logos(self, logos_to_refresh):
headers = {
Expand Down
44 changes: 0 additions & 44 deletions usr/share/hypnotix/hypnotix.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1037,50 +1037,6 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="margin_top">20</property>
<property name="margin_bottom">20</property>
<property name="row_spacing">12</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">This option only works when used with light desktop themes which support dark mode.</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Prefer dark mode</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="darkmode_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">This option only works when used with light desktop themes which support dark mode.</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="title" translatable="yes">Preferences</property>
<property name="icon_name">preferences-other-symbolic</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
Expand Down

0 comments on commit 7552c7a

Please sign in to comment.