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
=== modified file 'src/background.vala'
--- src/background.vala 2013-08-14 00:42:48 +0000
+++ src/background.vala 2013-11-13 03:43:52 +0000
@@ -73,6 +73,8 @@
73 var pattern = new Cairo.Pattern.rgba (color.red, color.green, color.blue, color.alpha);73 var pattern = new Cairo.Pattern.rgba (color.red, color.green, color.blue, color.alpha);
74 for (var i = 0; i < widths.length; i++)74 for (var i = 0; i < widths.length; i++)
75 patterns[i] = pattern;75 patterns[i] = pattern;
76
77 average_color = color;
76 finished = true;78 finished = true;
77 debug ("Render of background %s complete", filename);79 debug ("Render of background %s complete", filename);
78 return true;80 return true;
@@ -386,6 +388,7 @@
386 public string? current_background { get; set; default = null; }388 public string? current_background { get; set; default = null; }
387 public bool draw_grid { get; set; default = true; }389 public bool draw_grid { get; set; default = true; }
388 public double alpha { get; private set; default = 1.0; }390 public double alpha { get; private set; default = 1.0; }
391 public Gdk.RGBA average_color { get { return current.average_color; } }
389392
390 private Cairo.Surface target_surface;393 private Cairo.Surface target_surface;
391394
392395
=== modified file 'src/main-window.vala'
--- src/main-window.vala 2013-11-05 04:14:44 +0000
+++ src/main-window.vala 2013-11-13 03:43:52 +0000
@@ -342,7 +342,7 @@
342 /* Stop input to login box */342 /* Stop input to login box */
343 login_box.sensitive = false;343 login_box.sensitive = false;
344344
345 shutdown_dialog = new ShutdownDialog (type);345 shutdown_dialog = new ShutdownDialog (type, background.average_color);
346 shutdown_dialog.visible = true;346 shutdown_dialog.visible = true;
347 shutdown_dialog.close.connect (close_shutdown_dialog);347 shutdown_dialog.close.connect (close_shutdown_dialog);
348 background.add (shutdown_dialog);348 background.add (shutdown_dialog);
349349
=== modified file 'src/shutdown-dialog.vala'
--- src/shutdown-dialog.vala 2013-11-13 03:43:52 +0000
+++ src/shutdown-dialog.vala 2013-11-13 03:43:52 +0000
@@ -47,8 +47,12 @@
47 private Gtk.EventBox monitor_events;47 private Gtk.EventBox monitor_events;
48 private Gtk.EventBox vbox_events;48 private Gtk.EventBox vbox_events;
4949
50 public ShutdownDialog (ShutdownDialogType type)50 private Gdk.RGBA avg_color;
51
52 public ShutdownDialog (ShutdownDialogType type, Gdk.RGBA average_color)
51 {53 {
54 this.avg_color = average_color;
55
52 // This event box covers the monitor size, and closes the dialog on click.56 // This event box covers the monitor size, and closes the dialog on click.
53 monitor_events = new Gtk.EventBox ();57 monitor_events = new Gtk.EventBox ();
54 monitor_events.visible = true;58 monitor_events.visible = true;
@@ -327,7 +331,9 @@
327331
328 /* Background */332 /* Background */
329 DashBox.cairo_rounded_rectangle (c, 20, 20, width - 40, height - 40, 4);333 DashBox.cairo_rounded_rectangle (c, 20, 20, width - 40, height - 40, 4);
330 c.set_source_rgba (0, 0, 0, 0.75);334 c.set_source_rgba (0.0, 0.0, 0.0, 0.75f);
335 c.fill_preserve ();
336 c.set_source_rgba (avg_color.red, avg_color.green, avg_color.blue, 0.35);
331 c.fill ();337 c.fill ();
332338
333 c.restore ();339 c.restore ();

Subscribers

People subscribed via source and target branches