From bb3331fb5e23359aeba5bc2276f52c4a25c66b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 20 Mar 2024 08:54:27 -0700 Subject: [PATCH] Demo: use Granite styles --- demo/GraniteDemo.vala | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/demo/GraniteDemo.vala b/demo/GraniteDemo.vala index 19cdb557a..cc03eb914 100644 --- a/demo/GraniteDemo.vala +++ b/demo/GraniteDemo.vala @@ -10,8 +10,19 @@ public class Granite.Demo : Gtk.Application { } public override void startup () { - Granite.init (); base.startup (); + + Granite.init (); + + var gtk_settings = Gtk.Settings.get_default (); + gtk_settings.gtk_theme_name = "Granite"; + + var granite_settings = Granite.Settings.get_default (); + gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == DARK; + + granite_settings.notify["prefers-color-scheme"].connect (() => { + gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == DARK; + }); } public override void activate () { @@ -70,9 +81,6 @@ public class Granite.Demo : Gtk.Application { mode_switch.valign = Gtk.Align.CENTER; mode_switch.bind_property ("active", gtk_settings, "gtk-application-prefer-dark-theme", GLib.BindingFlags.BIDIRECTIONAL); - var granite_settings = Granite.Settings.get_default (); - gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; - var headerbar = new Gtk.HeaderBar (); headerbar.add_css_class ("default-decoration"); headerbar.show_title_buttons = true; @@ -86,10 +94,6 @@ public class Granite.Demo : Gtk.Application { add_window (window); window.show (); - - granite_settings.notify["prefers-color-scheme"].connect (() => { - gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; - }); } public static int main (string[] args) {