Skip to content

Commit

Permalink
Rework scheme variant setting for apps
Browse files Browse the repository at this point in the history
  • Loading branch information
lainsce committed Sep 2, 2024
1 parent 10d8d34 commit f40377b
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions lib/Models/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,24 @@ public class He.Application : Gtk.Application {
}

/**
* A scheme variant to use for the application. If not set, the user's preferred scheme will be used.
* This is especially useful for applications with their own color needs, such as media applications using the Content variant.
* Sets the scheme variant to use for the application as Content.
* This is especially useful for applications with their own color needs, such as media apps.
*/
public SchemeVariant? default_scheme_variant = null;
private bool _is_content = false;
public bool is_content {
get { return _is_content; }
set { _is_content = value; update_style_manager (); }
}

/**
* Sets the scheme variant to use for the application as Monochrome.
* This is especially useful for applications with their own color needs, such as image apps.
*/
private bool _is_mono = false;
public bool is_mono {
get { return _is_mono; }
set { _is_mono = value; update_style_manager (); }
}

private void update_style_manager () {
if (default_accent_color != null && override_accent_color) {
Expand All @@ -85,8 +99,10 @@ public class He.Application : Gtk.Application {
style_manager.accent_color = default_accent_color;
}

if (default_scheme_variant != null) {
style_manager.scheme_variant = default_scheme_variant;
if (is_content) {
style_manager.scheme_variant = SchemeVariant.CONTENT;
} else if (is_mono) {
style_manager.scheme_variant = SchemeVariant.MONOCHROME;
} else {
style_manager.scheme_variant = desktop.ensor_scheme.to_variant ();
}
Expand Down

0 comments on commit f40377b

Please sign in to comment.