Merge lp:~elementary-pantheon/pantheon-greeter/shake-css into lp:~elementary-pantheon/pantheon-greeter/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: Adam Bieńkowski
Approved revision: 457
Merged at revision: 457
Proposed branch: lp:~elementary-pantheon/pantheon-greeter/shake-css
Merge into: lp:~elementary-pantheon/pantheon-greeter/trunk
Diff against target: 103 lines (+34/-27)
2 files modified
src/CredentialsAreaActor.vala (+30/-0)
src/LoginBox.vala (+4/-27)
To merge this branch: bzr merge lp:~elementary-pantheon/pantheon-greeter/shake-css
Reviewer Review Type Date Requested Status
Adam Bieńkowski (community) code / testing Approve
Review via email: mp+297239@code.launchpad.net

Commit message

Use Gtk.CSS to do shake animation instead of Clutter

Description of the change

Tada

To post a comment you must log in.
457. By Danielle Foré

reduce timeout duration

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Looks & works well.

review: Approve (code / testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CredentialsAreaActor.vala'
2--- src/CredentialsAreaActor.vala 2016-06-09 23:38:29 +0000
3+++ src/CredentialsAreaActor.vala 2016-06-14 16:52:43 +0000
4@@ -22,6 +22,20 @@
5 CredentialsArea credentials;
6 public string current_session { get; set; }
7
8+ const string SHAKE_STYLE_CSS = """
9+ @keyframes shake {
10+ 0% { padding-left: 0 }
11+ 25% { padding-left: 64px }
12+ 50% { padding-left: 0 }
13+ 75% { padding-left: 32px }
14+ 100% { padding-left: 0}
15+ }
16+
17+ .shake {
18+ animation: shake 0.4s ease-in-out 1;
19+ }
20+ """;
21+
22 /**
23 * Fired when the user has replied to a prompt (aka: password,
24 * login-button was pressed). Should get forwarded to the
25@@ -49,6 +63,14 @@
26 height = 188;
27 credentials = null;
28
29+ var provider = new Gtk.CssProvider ();
30+ try {
31+ provider.load_from_data (SHAKE_STYLE_CSS, SHAKE_STYLE_CSS.length);
32+ Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
33+ } catch (Error e) {
34+ warning (e.message);
35+ }
36+
37 var login_name_label = new Gtk.Label (login_option.get_markup ());
38 login_name_label.get_style_context ().add_class ("h2");
39 login_name_label.set_xalign (0);
40@@ -127,6 +149,14 @@
41 }
42 }
43
44+ public void shake () {
45+ revealer.get_style_context ().add_class ("shake");
46+ Timeout.add (450, () => {
47+ revealer.get_style_context ().remove_class ("shake");
48+ return false;
49+ });
50+ }
51+
52 public void remove_credentials () {
53 if (credentials != null) {
54 grid.remove (credentials);
55
56=== modified file 'src/LoginBox.vala'
57--- src/LoginBox.vala 2016-06-09 23:38:58 +0000
58+++ src/LoginBox.vala 2016-06-14 16:52:43 +0000
59@@ -42,7 +42,6 @@
60 public LoginBox (LoginOption user) {
61 this.user = user;
62 this.reactive = true;
63- this.pivot_point = Clutter.Point.alloc ().init (0.5f, 0.5f);
64
65 create_credentials ();
66
67@@ -94,32 +93,10 @@
68 credentials_actor.pass_focus ();
69 }
70
71- /* The relative positions to the previous one the shake function should
72- * use. The values get smaller because the shaking should fade out to
73- * look smooth.
74- */
75- float[] shake_positions = {50, -80, 60, -30, 50, -80, 30};
76-
77- /**
78- * Shakes the LoginBox and then sets selected back to true.
79- */
80- void shake (int num = 0) {
81- if (num >= shake_positions.length) {
82- start_login ();
83- return;
84- }
85- var transition = new Clutter.PropertyTransition ("x");
86- transition.animatable = this;
87- transition.set_duration (60);
88- transition.set_progress_mode (Clutter.AnimationMode.EASE_IN_OUT_CIRC);
89- transition.set_from_value (this.x);
90- transition.set_to_value (this.x + shake_positions[num]);
91- transition.remove_on_complete = true;
92- transition.auto_reverse = false;
93- transition.completed.connect (() => {
94- shake (num + 1);
95- });
96- this.add_transition ("shake" + num.to_string (), transition);
97+ void shake () {
98+ credentials_actor.shake ();
99+ start_login ();
100+ return;
101 }
102
103 /* LoginMask interface */

Subscribers

People subscribed via source and target branches