Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utils: add force_elementary_style () #486

Merged
merged 10 commits into from
Apr 20, 2021
13 changes: 13 additions & 0 deletions data/granite.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@
<p>A companion library for GTK and GLib that provides complex widgets and convenience methods designed for use in apps built for elementary OS.</p>
</description>
<releases>
<release version="6.1.0" date="2021-04-19" urgency="medium">
<description>
<p>Additions:</p>
<ul>
<li>Settings.prefers_accent_color to get a user's accent color preference</li>
<li>force_elementary_style to set the app's icons, cursors, and stylesheet to elementary defaults</li>
</ul>
<p>Other Changes:</p>
<ul>
<li>Updated translations</li>
</ul>
</description>
</release>
<release version="6.0.0" date="2021-03-22" urgency="medium">
<description>
<p>Additions:</p>
Expand Down
17 changes: 16 additions & 1 deletion lib/Widgets/Utils.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012–2019 elementary, Inc.
* Copyright (C) 2012–2021 elementary, Inc.
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -290,6 +290,21 @@ public static Gdk.RGBA contrasting_foreground_color (Gdk.RGBA bg_color) {
return fg_color;
}

/**
* Sets the app's icons, cursors, and stylesheet to elementary defaults.
*/
public void force_elementary_style () {
const string STYLESHEET_PREFIX = "io.elementary.stylesheet";
unowned var gtk_settings = Gtk.Settings.get_default ();

gtk_settings.gtk_cursor_theme_name = "elementary";
gtk_settings.gtk_icon_theme_name = "elementary";

if (!gtk_settings.gtk_theme_name.has_prefix (STYLESHEET_PREFIX)) {
gtk_settings.gtk_theme_name = string.join (".", STYLESHEET_PREFIX, "blueberry");
}
}

}

/**
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project(
'granite',
'vala', 'c',
meson_version: '>= 0.48.2',
version: '6.0.0'
version: '6.1.0'
)

if meson.get_compiler('vala').version().version_compare('<0.40.0')
Expand Down