diff --git a/libdino/src/application.vala b/libdino/src/application.vala index 0fcee731..ca6d580d 100644 --- a/libdino/src/application.vala +++ b/libdino/src/application.vala @@ -25,13 +25,13 @@ public interface Application : GLib.Application { public abstract void handle_uri(string jid, string query, Gee.Map options); - public void init() throws Error { + public void init(bool default_dark_theme) throws Error { if (DirUtils.create_with_parents(get_storage_dir(), 0700) == -1) { throw new Error(-1, 0, "Could not create storage dir \"%s\": %s", get_storage_dir(), FileUtils.error_from_errno(errno).to_string()); } this.db = new Database(Path.build_filename(get_storage_dir(), "dino.db")); - this.settings = new Dino.Entities.Settings.from_db(db); + this.settings = new Dino.Entities.Settings.from_db(db, default_dark_theme); this.stream_interactor = new StreamInteractor(db); MessageProcessor.start(stream_interactor, db); diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala index 9b1efa3a..fef6f4d3 100644 --- a/libdino/src/entity/settings.vala +++ b/libdino/src/entity/settings.vala @@ -4,7 +4,7 @@ public class Settings : Object { private Database db; - public Settings.from_db(Database db) { + public Settings.from_db(Database db, bool default_dark_theme) { this.db = db; send_typing_ = col_to_bool_or_default("send_typing", true); @@ -15,7 +15,7 @@ public class Settings : Object { default_encryption = col_to_encryption_or_default("default_encryption", Encryption.UNKNOWN); send_button = col_to_bool_or_default("send_button", false); enter_newline = col_to_bool_or_default("enter_newline", false); - dark_theme = col_to_bool_or_default("dark_theme", false); + dark_theme = col_to_bool_or_default("dark_theme", default_dark_theme); } private bool col_to_bool_or_default(string key, bool def) { diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui index 5fafe36d..c1c1358f 100644 --- a/main/data/settings_dialog.ui +++ b/main/data/settings_dialog.ui @@ -145,7 +145,6 @@ _Dark theme - If disabled, use system settings True dark_theme diff --git a/main/po/en.po b/main/po/en.po index c217e2d9..24410623 100644 --- a/main/po/en.po +++ b/main/po/en.po @@ -1054,10 +1054,6 @@ msgstr "" msgid "_Dark theme" msgstr "" -#: main/data/settings_dialog.ui:148 -msgid "If disabled, use system settings" -msgstr "" - #: main/data/im.dino.Dino.appdata.xml.in:7 msgid "Modern XMPP Chat Client" msgstr "" diff --git a/main/po/ru.po b/main/po/ru.po index dad1e6f4..afb1a518 100644 --- a/main/po/ru.po +++ b/main/po/ru.po @@ -1072,10 +1072,6 @@ msgstr "Если опция недоступна, используйте Shift+E msgid "_Dark theme" msgstr "Тёмная тема" -#: main/data/settings_dialog.ui:148 -msgid "If disabled, use system settings" -msgstr "Если опция недоступна, используйте настройки системы" - #: main/data/im.dino.Dino.appdata.xml.in:7 msgid "Modern XMPP Chat Client" msgstr "Современный XMPP клиент" diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 1a7b4170..bfbdf2ab 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -29,7 +29,10 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application { public Application() throws Error { Object(application_id: "im.dino.Dino", flags: ApplicationFlags.HANDLES_OPEN); - init(); + + var style_manager = Adw.StyleManager.get_default(); + bool system_dark_theme = style_manager.system_supports_color_schemes && style_manager.dark; + init(system_dark_theme); Environment.set_application_name("Dino"); Window.set_default_icon_name("im.dino.Dino"); @@ -73,9 +76,9 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application { var manager = Adw.StyleManager.get_default(); if (is_dark != manager.dark) { if (is_dark) { - manager.set_color_scheme(Adw.ColorScheme.PREFER_DARK); + manager.set_color_scheme(Adw.ColorScheme.FORCE_DARK); } else { - manager.set_color_scheme(Adw.ColorScheme.PREFER_LIGHT); + manager.set_color_scheme(Adw.ColorScheme.FORCE_LIGHT); } } }); diff --git a/main/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala index 8c20a84b..7be89576 100644 --- a/main/src/ui/settings_dialog.vala +++ b/main/src/ui/settings_dialog.vala @@ -34,7 +34,6 @@ class SettingsDialog : Adw.PreferencesWindow { enter_newline_switch.active = settings.enter_newline; enter_newline_switch.sensitive = settings.send_button; dark_theme.active = settings.dark_theme; - dark_theme.sensitive = !Adw.StyleManager.get_default().system_supports_color_schemes; typing_switch.notify["active"].connect(() => { settings.send_typing = typing_switch.active; } ); marker_switch.notify["active"].connect(() => { settings.send_marker = marker_switch.active; } );