Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit 60b9dfc

Browse files
authored
Dark mode Gsettings as a boolean (#61)
* set dark as a boolean * shorthand
1 parent 54e96a8 commit 60b9dfc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

data/com.github.mdh34.quickdocs.gschema.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<schema path="/com/github/mdh34/quickdocs/"
44
id="com.github.mdh34.quickdocs"
55
gettext-domain="com.github.mdh34.quickdocs">
6-
<key name="dark" type="i">
7-
<default>0</default>
6+
<key name="dark" type="b">
7+
<default>false</default>
88
<summary>Dark Mode</summary>
99
<description>Sets dark mode status</description>
1010
</key>

src/MainWindow.vala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ public class MainWindow : Gtk.Window {
216216

217217
private void init_theme () {
218218
var window_settings = Gtk.Settings.get_default ();
219-
var dark = Docs.settings.get_int ("dark");
219+
var dark = Docs.settings.get_boolean ("dark");
220220

221-
if (dark == 1) {
221+
if (dark) {
222222
window_settings.set ("gtk-application-prefer-dark-theme", true);
223223
} else {
224224
window_settings.set ("gtk-application-prefer-dark-theme", false);
@@ -233,12 +233,12 @@ public class MainWindow : Gtk.Window {
233233
private void toggle_theme (View view, bool online, Gtk.Settings gtk_settings) {
234234
if (!gtk_settings.gtk_application_prefer_dark_theme) {
235235
view.run_javascript.begin ("document.cookie = 'dark=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';", null);
236-
Docs.settings.set_int ("dark", 0);
236+
Docs.settings.set_boolean ("dark", false);
237237
view.get_settings ().enable_offline_web_application_cache = true;
238238
view.reload_bypass_cache ();
239239
} else {
240240
view.run_javascript.begin ("document.cookie = 'dark=1; expires=01 Jan 2100 00:00:00 UTC';", null);
241-
Docs.settings.set_int ("dark", 1);
241+
Docs.settings.set_boolean ("dark", true);
242242
if (online) {
243243
view.get_settings ().enable_offline_web_application_cache = false;
244244
}

0 commit comments

Comments
 (0)