mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-24 01:19:40 +01:00
added dark mode option
This commit is contained in:
@@ -612,6 +612,14 @@ class Settings:
|
|||||||
|
|
||||||
# *********** Appearance *********** #
|
# *********** Appearance *********** #
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dark_mode(self):
|
||||||
|
return self._settings.get("dark_mode", False)
|
||||||
|
|
||||||
|
@dark_mode.setter
|
||||||
|
def dark_mode(self, value):
|
||||||
|
self._settings["dark_mode"] = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_themes_support(self):
|
def is_themes_support(self):
|
||||||
return self._settings.get("is_themes_support", False)
|
return self._settings.get("is_themes_support", False)
|
||||||
|
|||||||
@@ -2461,6 +2461,57 @@ Author: Dmitriy Yefremov
|
|||||||
<property name="margin_bottom">5</property>
|
<property name="margin_bottom">5</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">5</property>
|
<property name="spacing">5</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkFrame" id="dark_mode_frame">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label_xalign">0</property>
|
||||||
|
<property name="shadow_type">in</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="dark_mode_box">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin_left">5</property>
|
||||||
|
<property name="margin_right">5</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="dark_mode_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Enable Dark Mode</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSwitch" id="dark_mode_switch">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<signal name="state-set" handler="on_icon_theme_changed" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="label_item">
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFrame" id="hemes_support_frame">
|
<object class="GtkFrame" id="hemes_support_frame">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@@ -2470,7 +2521,6 @@ Author: Dmitriy Yefremov
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="themes_support_box">
|
<object class="GtkBox" id="themes_support_box">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="sensitive">False</property>
|
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="margin_left">5</property>
|
<property name="margin_left">5</property>
|
||||||
<property name="margin_right">5</property>
|
<property name="margin_right">5</property>
|
||||||
@@ -2488,6 +2538,18 @@ Author: Dmitriy Yefremov
|
|||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child type="center">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">EXPERIMENTAL!</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSwitch" id="themes_support_switch">
|
<object class="GtkSwitch" id="themes_support_switch">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@@ -2510,7 +2572,7 @@ Author: Dmitriy Yefremov
|
|||||||
<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">0</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -2657,7 +2719,47 @@ Author: Dmitriy Yefremov
|
|||||||
<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">1</property>
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="themes_source_box">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="themes_source_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Gtk3 Themes and Icons:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLinkButton" id="themes_source_link_button">
|
||||||
|
<property name="label" translatable="yes">www.gnome-look.org</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="relief">none</property>
|
||||||
|
<property name="uri">https://www.gnome-look.org/</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -2753,47 +2855,7 @@ Author: Dmitriy Yefremov
|
|||||||
<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">2</property>
|
<property name="position">4</property>
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox" id="themes_source_box">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="halign">center</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="themes_source_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes">Gtk3 Themes and Icons:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLinkButton" id="themes_source_link_button">
|
|
||||||
<property name="label" translatable="yes">www.gnome-look.org</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="relief">none</property>
|
|
||||||
<property name="uri">https://www.gnome-look.org/</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ class SettingsDialog:
|
|||||||
self._theme_thumbnail_image = builder.get_object("theme_thumbnail_image")
|
self._theme_thumbnail_image = builder.get_object("theme_thumbnail_image")
|
||||||
self._theme_combo_box = builder.get_object("theme_combo_box")
|
self._theme_combo_box = builder.get_object("theme_combo_box")
|
||||||
self._icon_theme_combo_box = builder.get_object("icon_theme_combo_box")
|
self._icon_theme_combo_box = builder.get_object("icon_theme_combo_box")
|
||||||
|
self._dark_mode_switch = builder.get_object("dark_mode_switch")
|
||||||
self._themes_support_switch = builder.get_object("themes_support_switch")
|
self._themes_support_switch = builder.get_object("themes_support_switch")
|
||||||
self._themes_support_switch.bind_property("active", builder.get_object("gtk_theme_frame"), "sensitive")
|
self._themes_support_switch.bind_property("active", builder.get_object("gtk_theme_frame"), "sensitive")
|
||||||
self._themes_support_switch.bind_property("active", builder.get_object("icon_theme_frame"), "sensitive")
|
self._themes_support_switch.bind_property("active", builder.get_object("icon_theme_frame"), "sensitive")
|
||||||
@@ -359,6 +360,7 @@ class SettingsDialog:
|
|||||||
self._ext_settings.active_preset = self._presets_combo_box.get_active_id()
|
self._ext_settings.active_preset = self._presets_combo_box.get_active_id()
|
||||||
|
|
||||||
if self._ext_settings.is_darwin:
|
if self._ext_settings.is_darwin:
|
||||||
|
self._ext_settings.dark_mode = self._dark_mode_switch.get_active()
|
||||||
self._ext_settings.is_themes_support = self._themes_support_switch.get_active()
|
self._ext_settings.is_themes_support = self._themes_support_switch.get_active()
|
||||||
self._ext_settings.theme = self._theme_combo_box.get_active_id()
|
self._ext_settings.theme = self._theme_combo_box.get_active_id()
|
||||||
self._ext_settings.icon_theme = self._icon_theme_combo_box.get_active_id()
|
self._ext_settings.icon_theme = self._icon_theme_combo_box.get_active_id()
|
||||||
@@ -699,7 +701,9 @@ class SettingsDialog:
|
|||||||
self.add_theme(self._ext_settings.themes_path, self._theme_combo_box)
|
self.add_theme(self._ext_settings.themes_path, self._theme_combo_box)
|
||||||
|
|
||||||
def on_theme_remove(self, button):
|
def on_theme_remove(self, button):
|
||||||
self.remove_theme(self._theme_combo_box, self._ext_settings.themes_path)
|
if show_dialog(DialogType.QUESTION, self._dialog) == Gtk.ResponseType.OK:
|
||||||
|
Gtk.Settings().get_default().set_property("gtk-theme-name", "")
|
||||||
|
self.remove_theme(self._theme_combo_box, self._ext_settings.themes_path)
|
||||||
|
|
||||||
def on_icon_theme_changed(self, button, state=False):
|
def on_icon_theme_changed(self, button, state=False):
|
||||||
if self._main_stack.get_visible_child_name() != "appearance":
|
if self._main_stack.get_visible_child_name() != "appearance":
|
||||||
@@ -710,7 +714,9 @@ class SettingsDialog:
|
|||||||
self.add_theme(self._ext_settings.icon_themes_path, self._icon_theme_combo_box)
|
self.add_theme(self._ext_settings.icon_themes_path, self._icon_theme_combo_box)
|
||||||
|
|
||||||
def on_icon_theme_remove(self, button):
|
def on_icon_theme_remove(self, button):
|
||||||
self.remove_theme(self._icon_theme_combo_box, self._ext_settings.icon_themes_path)
|
if show_dialog(DialogType.QUESTION, self._dialog) == Gtk.ResponseType.OK:
|
||||||
|
Gtk.Settings().get_default().set_property("gtk-icon-theme-name", "")
|
||||||
|
self.remove_theme(self._icon_theme_combo_box, self._ext_settings.icon_themes_path)
|
||||||
|
|
||||||
@run_idle
|
@run_idle
|
||||||
def add_theme(self, path, button):
|
def add_theme(self, path, button):
|
||||||
@@ -723,14 +729,17 @@ class SettingsDialog:
|
|||||||
@run_task
|
@run_task
|
||||||
def unpack_theme(self, src, dst, button):
|
def unpack_theme(self, src, dst, button):
|
||||||
try:
|
try:
|
||||||
from shutil import unpack_archive
|
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
||||||
|
|
||||||
unpack_archive(src, dst)
|
import subprocess
|
||||||
except (KeyError, EOFError) as e:
|
log("Unpacking '{}' started...".format(src))
|
||||||
self.show_info_message(str(e), Gtk.MessageType.ERROR)
|
p = subprocess.Popen(["tar", "-xvf", src, "-C", dst],
|
||||||
else:
|
stdout=subprocess.PIPE,
|
||||||
self.update_theme_button(button, dst)
|
stderr=subprocess.STDOUT)
|
||||||
|
p.communicate()
|
||||||
|
log("Unpacking end.")
|
||||||
finally:
|
finally:
|
||||||
|
self.update_theme_button(button, dst)
|
||||||
self._appearance_box.set_sensitive(True)
|
self._appearance_box.set_sensitive(True)
|
||||||
|
|
||||||
@run_idle
|
@run_idle
|
||||||
@@ -752,9 +761,6 @@ class SettingsDialog:
|
|||||||
self.show_info_message("No selected item!", Gtk.MessageType.ERROR)
|
self.show_info_message("No selected item!", Gtk.MessageType.ERROR)
|
||||||
return
|
return
|
||||||
|
|
||||||
if show_dialog(DialogType.QUESTION, self._dialog) != Gtk.ResponseType.OK:
|
|
||||||
return
|
|
||||||
|
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -762,11 +768,16 @@ class SettingsDialog:
|
|||||||
except OSError as e:
|
except OSError as e:
|
||||||
self.show_info_message(str(e), Gtk.MessageType.ERROR)
|
self.show_info_message(str(e), Gtk.MessageType.ERROR)
|
||||||
else:
|
else:
|
||||||
button.remove(button.get_active())
|
self.theme_button_remove_active(button)
|
||||||
button.set_active(0)
|
|
||||||
|
@run_idle
|
||||||
|
def theme_button_remove_active(self, button):
|
||||||
|
button.remove(button.get_active())
|
||||||
|
button.set_active(0)
|
||||||
|
|
||||||
@run_idle
|
@run_idle
|
||||||
def init_appearance(self):
|
def init_appearance(self):
|
||||||
|
self._dark_mode_switch.set_active(self._ext_settings.dark_mode)
|
||||||
t_support = self._ext_settings.is_themes_support
|
t_support = self._ext_settings.is_themes_support
|
||||||
self._themes_support_switch.set_active(t_support)
|
self._themes_support_switch.set_active(t_support)
|
||||||
if t_support:
|
if t_support:
|
||||||
|
|||||||
Reference in New Issue
Block a user