diff --git a/data/Application.css b/data/Application.css
index 04aac58..d146964 100644
--- a/data/Application.css
+++ b/data/Application.css
@@ -15,6 +15,10 @@ row:selected {
background-color: #e6e6e6;
}
+.dark row:selected {
+ background-color: #666666
+}
+
/* Label styling */
.accent {
color: @colorAccent;
diff --git a/data/com.github.mdh34.hackup.gschema.xml b/data/com.github.mdh34.hackup.gschema.xml
index 2717d83..49fe96b 100644
--- a/data/com.github.mdh34.hackup.gschema.xml
+++ b/data/com.github.mdh34.hackup.gschema.xml
@@ -38,5 +38,10 @@
cookies storage
Stores whether to keep cookies
+
+ false
+ dark mode state
+ stores the last known dark mode state
+
\ No newline at end of file
diff --git a/src/MainWindow.vala b/src/MainWindow.vala
index a8eaec6..db2b8df 100644
--- a/src/MainWindow.vala
+++ b/src/MainWindow.vala
@@ -64,6 +64,21 @@ public class MainWindow : Gtk.Window {
back_button.no_show_all = true;
header.pack_start (back_button);
+ PostList list;
+ var gtk_settings = Gtk.Settings.get_default ();
+ var theme_switch = new Granite.ModeSwitch.from_icon_name ("display-brightness-symbolic", "weather-clear-night-symbolic");
+ theme_switch.row_homogeneous = true;
+ theme_switch.active = HackUp.settings.get_boolean ("dark");
+ theme_switch.bind_property ("active", gtk_settings, "gtk_application_prefer_dark_theme");
+ theme_switch.notify["active"].connect (() => {
+ if (theme_switch.active) {
+ list.get_style_context ().add_class ("dark");
+ } else {
+ list.get_style_context ().remove_class ("dark");
+ }
+ });
+ header.pack_end (theme_switch);
+
var window_width = HackUp.settings.get_int ("width");
var window_height = HackUp.settings.get_int ("height");
set_default_size (window_width, window_height);
@@ -74,11 +89,17 @@ public class MainWindow : Gtk.Window {
move (window_x, window_y);
}
- var list = new PostList ();
+ list = new PostList ();
var scroller = new Gtk.ScrolledWindow (null, null);
scroller.hscrollbar_policy = Gtk.PolicyType.NEVER;
scroller.add (list);
+ var dark = HackUp.settings.get_boolean ("dark");
+ if (dark) {
+ gtk_settings.set ("gtk-application-prefer-dark-theme", true);
+ list.get_style_context ().add_class ("dark");
+ }
+
settings_popover.closed.connect (() => {
var list_sorting = HackUp.settings.get_string ("listtype");
if (settings_popover.current_sort != list_sorting) {
@@ -107,6 +128,7 @@ public class MainWindow : Gtk.Window {
int current_x, current_y, width, height;
get_position (out current_x, out current_y);
get_size (out width, out height);
+ HackUp.settings.set_boolean ("dark", theme_switch.active);
HackUp.settings.set_int ("x", current_x);
HackUp.settings.set_int ("y", current_y);
HackUp.settings.set_int ("width", width);