Merge lp:~3v1n0/unity-greeter/shutdown-average-color-bg into lp:unity-greeter

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Robert Ancell
Approved revision: 1025
Merged at revision: 1021
Proposed branch: lp:~3v1n0/unity-greeter/shutdown-average-color-bg
Merge into: lp:unity-greeter
Prerequisite: lp:~3v1n0/unity-greeter/shutdown-clicks-handling
Diff against target: 62 lines (+12/-3)
3 files modified
src/background.vala (+3/-0)
src/main-window.vala (+1/-1)
src/shutdown-dialog.vala (+8/-2)
To merge this branch: bzr merge lp:~3v1n0/unity-greeter/shutdown-average-color-bg
Reviewer Review Type Date Requested Status
Robert Ancell Approve
Review via email: mp+194758@code.launchpad.net

Commit message

ShutdownDialog: use the average color as source when drawing the background

Description of the change

Use the background average color for generating the background color of the shutdown dialogue. Also set the average color for static backgrounds.

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

This should be in BackgroundLoader.load:
8 + if (current_background[0] == '#' && current_background.length <= 7)
9 + {
10 + Gdk.Color c;
11 + Gdk.Color.parse (current_background, out c);
12 + current.average_color = {c.red/65535.0f, c.green/65535.0f, c.blue/65535.0f, 1.0f};
13 + }

You should probably use a property instead of a method for get_average_color (), i.e.

public Gdk.RGBA average_color
{
    get { return current.average_color; }
}

review: Needs Fixing
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Functionality wise works great!

1024. By Marco Trevisan (Treviño)

Background: make average_color a read-only property

1025. By Marco Trevisan (Treviño)

Background: move the hackish color parsing to the proper place into the Loader

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> This should be in BackgroundLoader.load:
> 8 + if (current_background[0] == '#' && current_background.length <= 7)
> 9 + {
> 10 + Gdk.Color c;
> 11 + Gdk.Color.parse (current_background, out c);
> 12 + current.average_color = {c.red/65535.0f, c.green/65535.0f,
> c.blue/65535.0f, 1.0f};
> 13 + }

Right... It was just an hack for my tests, then I left it there without noticing that it was just about to add one line into the loader... :)

> You should probably use a property instead of a method for get_average_color

As you prefer...

Fixed both.

Revision history for this message
Robert Ancell (robert-ancell) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/background.vala'
2--- src/background.vala 2013-08-14 00:42:48 +0000
3+++ src/background.vala 2013-11-13 03:43:52 +0000
4@@ -73,6 +73,8 @@
5 var pattern = new Cairo.Pattern.rgba (color.red, color.green, color.blue, color.alpha);
6 for (var i = 0; i < widths.length; i++)
7 patterns[i] = pattern;
8+
9+ average_color = color;
10 finished = true;
11 debug ("Render of background %s complete", filename);
12 return true;
13@@ -386,6 +388,7 @@
14 public string? current_background { get; set; default = null; }
15 public bool draw_grid { get; set; default = true; }
16 public double alpha { get; private set; default = 1.0; }
17+ public Gdk.RGBA average_color { get { return current.average_color; } }
18
19 private Cairo.Surface target_surface;
20
21
22=== modified file 'src/main-window.vala'
23--- src/main-window.vala 2013-11-05 04:14:44 +0000
24+++ src/main-window.vala 2013-11-13 03:43:52 +0000
25@@ -342,7 +342,7 @@
26 /* Stop input to login box */
27 login_box.sensitive = false;
28
29- shutdown_dialog = new ShutdownDialog (type);
30+ shutdown_dialog = new ShutdownDialog (type, background.average_color);
31 shutdown_dialog.visible = true;
32 shutdown_dialog.close.connect (close_shutdown_dialog);
33 background.add (shutdown_dialog);
34
35=== modified file 'src/shutdown-dialog.vala'
36--- src/shutdown-dialog.vala 2013-11-13 03:43:52 +0000
37+++ src/shutdown-dialog.vala 2013-11-13 03:43:52 +0000
38@@ -47,8 +47,12 @@
39 private Gtk.EventBox monitor_events;
40 private Gtk.EventBox vbox_events;
41
42- public ShutdownDialog (ShutdownDialogType type)
43+ private Gdk.RGBA avg_color;
44+
45+ public ShutdownDialog (ShutdownDialogType type, Gdk.RGBA average_color)
46 {
47+ this.avg_color = average_color;
48+
49 // This event box covers the monitor size, and closes the dialog on click.
50 monitor_events = new Gtk.EventBox ();
51 monitor_events.visible = true;
52@@ -327,7 +331,9 @@
53
54 /* Background */
55 DashBox.cairo_rounded_rectangle (c, 20, 20, width - 40, height - 40, 4);
56- c.set_source_rgba (0, 0, 0, 0.75);
57+ c.set_source_rgba (0.0, 0.0, 0.0, 0.75f);
58+ c.fill_preserve ();
59+ c.set_source_rgba (avg_color.red, avg_color.green, avg_color.blue, 0.35);
60 c.fill ();
61
62 c.restore ();

Subscribers

People subscribed via source and target branches