Skip to content

Commit

Permalink
fix: move GTK theme setting logic into StyleManager
Browse files Browse the repository at this point in the history
  • Loading branch information
lleyton committed Aug 21, 2023
1 parent ed22a9c commit e1ad60c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 0 additions & 7 deletions lib/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ namespace He {
// Ensure Gtk is properly initialized
Gtk.init ();

Gdk.Display display = Gdk.Display.get_default ();

// Ensure all classes listed here are available for use.
// Remove only if the class is not needed anymore.
typeof (He.AboutWindow).ensure ();
Expand Down Expand Up @@ -90,10 +88,5 @@ namespace He {
typeof (He.ViewTitle).ensure ();
typeof (He.WelcomeScreen).ensure ();
typeof (He.Window).ensure ();

// Setup the platform gtk theme, cursor theme and the default icon theme.
Gtk.Settings.get_for_display (display).gtk_theme_name = "Helium-empty";
Gtk.Settings.get_for_display (display).gtk_icon_theme_name = "Hydrogen";
Gtk.Settings.get_for_display (display).gtk_cursor_theme_name = "Hydrogen";
}
}
9 changes: 9 additions & 0 deletions lib/Models/StyleManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ public class He.StyleManager : Object {
Misc.toggle_style_provider (light, !is_dark, STYLE_PROVIDER_PRIORITY_PLATFORM);
Misc.toggle_style_provider (dark, is_dark, STYLE_PROVIDER_PRIORITY_PLATFORM);
Misc.toggle_style_provider (user_dark, is_dark, STYLE_PROVIDER_PRIORITY_USER_DARK);

var settings = Gtk.Settings.get_default ();
settings.gtk_application_prefer_dark_theme = is_dark;
}

/**
Expand All @@ -378,6 +381,12 @@ public class He.StyleManager : Object {
Misc.toggle_style_provider (accent, true, STYLE_PROVIDER_PRIORITY_ACCENT);
Misc.toggle_style_provider (user_base, true, STYLE_PROVIDER_PRIORITY_USER_BASE);

// Setup the platform gtk theme, cursor theme and the default icon theme.
var settings = Gtk.Settings.get_default ();
settings.gtk_theme_name = "Helium-empty";
settings.gtk_icon_theme_name = "Hydrogen";
settings.gtk_cursor_theme_name = "Hydrogen";

is_registered = true;

update ();
Expand Down

0 comments on commit e1ad60c

Please sign in to comment.