diff --git a/data/Application.css b/data/app.css similarity index 75% rename from data/Application.css rename to data/app.css index 87ab074..0b9909c 100644 --- a/data/Application.css +++ b/data/app.css @@ -1,6 +1,3 @@ -@define-color colorAccent #9aa7c8; -@define-color colorPrimary #9aa7c8; - .mode .button{ border-radius:0px; border-top:none; @@ -24,12 +21,8 @@ background-position: 50%; opacity: 0.15; } -.header-counters{ - background:rgba(255,255,255,.4); -} .attachment{ - background: #fff; border-radius: 3px; } diff --git a/data/com.github.bleakgrey.tootle.gresource.xml b/data/com.github.bleakgrey.tootle.gresource.xml index 11eb9e2..71d04bb 100644 --- a/data/com.github.bleakgrey.tootle.gresource.xml +++ b/data/com.github.bleakgrey.tootle.gresource.xml @@ -1,7 +1,9 @@ - Application.css + app.css + light.css + dark.css logo128.png empty_state.png diff --git a/data/com.github.bleakgrey.tootle.gschema.xml b/data/com.github.bleakgrey.tootle.gschema.xml index d843e0f..830f202 100644 --- a/data/com.github.bleakgrey.tootle.gschema.xml +++ b/data/com.github.bleakgrey.tootle.gschema.xml @@ -46,5 +46,10 @@ Update timelines in real-time + + false + Sets application theme to dark + + diff --git a/data/dark.css b/data/dark.css new file mode 100644 index 0000000..d77782d --- /dev/null +++ b/data/dark.css @@ -0,0 +1,14 @@ +@define-color colorAccent #9aa7c8; +@define-color colorPrimary #333542; + +.header-counters{ + background: rgba(0,0,0,.4); +} + +.attachment{ + background: rgba (255,255,255,.3); +} + +.card{ + background: rgba (255,255,255,.15); +} diff --git a/data/light.css b/data/light.css new file mode 100644 index 0000000..65d4409 --- /dev/null +++ b/data/light.css @@ -0,0 +1,14 @@ +@define-color colorAccent #9aa7c8; +@define-color colorPrimary #9aa7c8; + +.header-counters{ + background: rgba(255,255,255,.4); +} + +.attachment{ + background: rgba (255,255,255,.8); +} + +.card{ + background: #fff; +} diff --git a/src/Dialogs/SettingsDialog.vala b/src/Dialogs/SettingsDialog.vala index 27cdb7f..48f9cc7 100644 --- a/src/Dialogs/SettingsDialog.vala +++ b/src/Dialogs/SettingsDialog.vala @@ -19,6 +19,10 @@ public class Tootle.SettingsDialog : Gtk.Dialog { int i = 0; grid = new Gtk.Grid (); + grid.attach (new Granite.HeaderLabel (_("Appearance")), 0, i++, 2, 1); + grid.attach (new SettingsLabel (_("Dark theme:")), 0, i); + grid.attach (new SettingsSwitch ("dark-theme"), 1, i++); + grid.attach (new Granite.HeaderLabel (_("Timelines")), 0, i++, 2, 1); grid.attach (new SettingsLabel (_("Real-time updates:")), 0, i); grid.attach (new SettingsSwitch ("live-updates"), 1, i++); diff --git a/src/MainWindow.vala b/src/MainWindow.vala index cde26cd..e4fd4cc 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -15,8 +15,11 @@ public class Tootle.MainWindow: Gtk.Window { settings = Tootle.settings; var provider = new Gtk.CssProvider (); - provider.load_from_resource ("/com/github/bleakgrey/tootle/Application.css"); + provider.load_from_resource ("/com/github/bleakgrey/tootle/app.css"); StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + + settings.changed.connect (update_theme); + update_theme (); toast = new Granite.Widgets.Toast (""); overlay = new Gtk.Overlay (); @@ -120,9 +123,18 @@ public class Tootle.MainWindow: Gtk.Window { if (!Tootle.settings.always_online) Tootle.app.remove_window (Tootle.window_dummy); Tootle.window = null; - this.dispose (); }); return false; } + + private void update_theme () { + var provider = new Gtk.CssProvider (); + var is_dark = settings.dark_theme; + var theme = is_dark ? "dark" : "light"; + provider.load_from_resource ("/com/github/bleakgrey/tootle/%s.css".printf (theme)); + StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + + Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = is_dark; + } } diff --git a/src/SettingsManager.vala b/src/SettingsManager.vala index cf14573..9930f55 100644 --- a/src/SettingsManager.vala +++ b/src/SettingsManager.vala @@ -9,6 +9,7 @@ public class Tootle.SettingsManager : Granite.Services.Settings { public bool cache { get; set; } public int cache_size { get; set; } public bool live_updates { get; set; } + public bool dark_theme { get; set; } public void clear_account (){ access_token = "null"; diff --git a/src/Widgets/StatusWidget.vala b/src/Widgets/StatusWidget.vala index 87c1c49..3623561 100644 --- a/src/Widgets/StatusWidget.vala +++ b/src/Widgets/StatusWidget.vala @@ -112,7 +112,6 @@ public class Tootle.StatusWidget : Gtk.EventBox { public StatusWidget (ref Status status) { this.status = status; this.status.updated.connect (rebind); - get_style_context ().add_class ("status"); if (this.status.reblog != null) { var image = new Gtk.Image.from_icon_name("go-up-symbolic", Gtk.IconSize.BUTTON);