Skip to content

Commit

Permalink
Demo: use Granite styles
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Mar 20, 2024
1 parent cc80a99 commit bb3331f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions demo/GraniteDemo.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit bb3331f

Please sign in to comment.