Merge lp:~donadigo/granite/set-color-primary-refine into lp:~elementary-pantheon/granite/granite

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Cody Garver
Approved revision: 973
Merged at revision: 974
Proposed branch: lp:~donadigo/granite/set-color-primary-refine
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 29 lines (+5/-10)
1 file modified
lib/Widgets/Utils.vala (+5/-10)
To merge this branch: bzr merge lp:~donadigo/granite/set-color-primary-refine
Reviewer Review Type Date Requested Status
Felipe Escoto (community) Approve
Review via email: mp+301720@code.launchpad.net

Commit message

Granite.Widgets.Utils.set_color_primary: return the added provider and simplify the contents of the method

Description of the change

This branch changes the Granite.Widgets.Utils.set_color_primary definition to include the return value in order to then remove the added provider from the screen if needed. It also replaces the most code in this function with a single call to existing Granite.Widgets.Utils.set_theming_for_screen function.

To post a comment you must log in.
Revision history for this message
Felipe Escoto (philip.scott) wrote :

It passed the ABI test and it doesn't break apps that depend on it. so it should be good to merge.

Only i'm not sure if it's too late in the cycle

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Widgets/Utils.vala'
2--- lib/Widgets/Utils.vala 2015-11-01 12:59:58 +0000
3+++ lib/Widgets/Utils.vala 2016-08-01 21:29:32 +0000
4@@ -140,20 +140,15 @@
5 * @param window the widget to apply the color
6 * @param color the color to apply
7 * @param priority the priority of the style provider
8+ *
9+ * @return the added {@link Gtk.CssProvider}, or null in case the parsing of
10+ * stylesheet failed.
11 */
12- public void set_color_primary (Gtk.Widget window, Gdk.RGBA color, int priority = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) {
13+ public Gtk.CssProvider? set_color_primary (Gtk.Widget window, Gdk.RGBA color, int priority = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) {
14 assert (window != null);
15
16- var css_provider = new Gtk.CssProvider ();
17 string hex = color.to_string ();
18- try {
19- css_provider.load_from_data (@"@define-color colorPrimary $hex;", -1);
20- } catch (Error e) {
21- warning ("Could not apply primary color: %s\n", e.message);
22- return;
23- }
24-
25- Gtk.StyleContext.add_provider_for_screen (window.get_screen (), css_provider, priority);
26+ return set_theming_for_screen (window.get_screen (), @"@define-color colorPrimary $hex;", priority);
27 }
28
29 /**

Subscribers

People subscribed via source and target branches