Merge lp:~teemperor/pantheon-greeter/fix-caps-lock into lp:~elementary-pantheon/pantheon-greeter/trunk

Proposed by Raphael Isemann
Status: Rejected
Rejected by: Cody Garver
Proposed branch: lp:~teemperor/pantheon-greeter/fix-caps-lock
Merge into: lp:~elementary-pantheon/pantheon-greeter/trunk
Diff against target: 181 lines (+116/-9)
3 files modified
src/CredentialsArea.vala (+94/-1)
src/LoginBox.vala (+1/-1)
src/Utilities.vala (+21/-7)
To merge this branch: bzr merge lp:~teemperor/pantheon-greeter/fix-caps-lock
Reviewer Review Type Date Requested Status
Danielle Foré Needs Fixing
Review via email: mp+242263@code.launchpad.net

Commit message

Implemented caps lock warning.

Description of the change

Adds a caps lock warning as a popover. The popover is not red as it was in the original mockup as this would requirea extra CSS class and there is currently no decision how we handle all those custom CSS classes that we need for the greeter.

What to test:

* Warning appears at the correct position?
* Warning appears and disappears when switching caps lock on/off
* Warning correctly handles scrolling the login options up/down with activated caps lock
* Warning correctly disappears when the user scrolls to a login option that isn't requiring keyboard input (guest login for example).
* Warning disappears when logging in
* Warning is appearing when starting the greeter with already activated caps lock.

What NOT to test:

* Warning is red? (as this can't be implemented without having a decision about the already mentioned theming infrastructure).

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Hm the alignment is pretty weird here. I'm not sure what it's supposed to be aligning to.

The shadow is very harsh and it gets cut off at the bottom. It doesn't look like these values are coming from the theme.

The padding underneath the label is greater than the padding above. The padding to the left and right seems pretty extreme.

The warning disappears if you move the cursor over it.

review: Needs Fixing

Unmerged revisions

325. By Raphael Isemann

No more PopOver-clones appearing when typing. PopOver is now at the correct position.

324. By Raphael Isemann

First version of the caps-lock popver. Uploading for tom

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CredentialsArea.vala'
2--- src/CredentialsArea.vala 2014-10-26 19:31:56 +0000
3+++ src/CredentialsArea.vala 2014-11-19 19:55:42 +0000
4@@ -30,10 +30,32 @@
5
6 Entry password;
7
8- public PasswordArea () {
9+ /**
10+ * Parent of this area needed for calculations regarding
11+ * the position of the caps_lock_popover.
12+ */
13+ GtkClutter.Actor area;
14+ Grid parent_grid;
15+
16+ /**
17+ * The PopOver that displays the warning when caps
18+ * lock is activated. Otherwise null if there is no
19+ * active PopOver at the moment.
20+ */
21+ PopOver caps_lock_popover = null;
22+
23+ public PasswordArea (GtkClutter.Actor area, Grid parent_grid) {
24+ this.area = area;
25+ this.parent_grid = parent_grid;
26 create_password_field ();
27 }
28
29+ ~PasswordArea () {
30+ if (caps_lock_popover != null) {
31+ caps_lock_popover.fade_out ();
32+ }
33+ }
34+
35 void create_password_field () {
36 password = new Entry ();
37 password.margin_top = 32;
38@@ -60,6 +82,77 @@
39 });
40
41 attach (password, 0, 0, 1, 1);
42+
43+ Gdk.Keymap.get_default ().state_changed.connect (() => {
44+ update_popup ();
45+ });
46+
47+ show.connect (() => {
48+ // We use idle we need to wait for
49+ // the widget-coordinates that are also calculated
50+ // during the current signal-call.
51+ Idle.add (() => {
52+ update_popup ();
53+ return false;
54+ });
55+ });
56+ }
57+
58+ void update_popup () {
59+ var keymap = Gdk.Keymap.get_default ();
60+ if (keymap.get_caps_lock_state ()) {
61+ create_popup ();
62+ } else if (caps_lock_popover != null) {
63+ caps_lock_popover.fade_out ();
64+ // The PopOver removes itself from the area
65+ // at the end of the animation, so this is
66+ // safe.
67+ caps_lock_popover = null;
68+ }
69+ }
70+
71+ /**
72+ * Creates an popup if possible and shows it.
73+ * To destroy that popup, call caps_lock_popover.fade_out ();
74+ */
75+ void create_popup () {
76+ // We do nothing in case we already have a popover
77+ if (caps_lock_popover != null)
78+ return;
79+
80+ caps_lock_popover = new PopOver ();
81+
82+ var box = new Box (Orientation.VERTICAL, 0);
83+ (caps_lock_popover.get_content_area () as Container).add (box);
84+
85+ var warning = new Label (_("Caps lock is turned on!"));
86+ box.add (warning);
87+
88+ // Find the right position for the PopOver
89+ area.get_stage ().add_child (caps_lock_popover);
90+ float actor_x = 0;
91+ float actor_y = 0;
92+
93+ area.get_transformed_position (out actor_x, out actor_y);
94+
95+ // We got the upper-left corner of the login-box,
96+ // now we need to find the coordinates of our
97+ // password box in there.
98+ int po_x = 0;
99+ int po_y = 0;
100+ password.translate_coordinates (parent_grid,
101+ password.get_allocated_width () / 2,
102+ password.get_allocated_height (),
103+ out po_x, out po_y);
104+
105+ caps_lock_popover.width = 245;
106+
107+ // FIXME the two magic values here should be calculated
108+ // by some fancy algorithm if possible, but it works
109+ // for now.
110+ caps_lock_popover.x = actor_x + po_x - caps_lock_popover.width + 80;
111+ caps_lock_popover.y = actor_y + po_x - 32;
112+ caps_lock_popover.get_widget ().show_all ();
113 }
114
115 public override void pass_focus () {
116
117=== modified file 'src/LoginBox.vala'
118--- src/LoginBox.vala 2014-10-26 19:31:56 +0000
119+++ src/LoginBox.vala 2014-11-19 19:55:42 +0000
120@@ -293,7 +293,7 @@
121
122 switch (type) {
123 case PromptType.PASSWORD:
124- credentials = new PasswordArea ();
125+ credentials = new PasswordArea (this, grid);
126 break;
127 case PromptType.CONFIRM_LOGIN:
128 credentials = new LoginButtonArea ();
129
130=== modified file 'src/Utilities.vala'
131--- src/Utilities.vala 2014-07-09 10:25:25 +0000
132+++ src/Utilities.vala 2014-11-19 19:55:42 +0000
133@@ -139,6 +139,12 @@
134 Granite.Drawing.BufferSurface buffer;
135 Gtk.EventBox container;
136
137+ /**
138+ * If the PopOver is currently fading out.
139+ * Used to prevent that we start multiple fading out animations.
140+ */
141+ bool fading_out = false;
142+
143 public PopOver () {
144 this.container = new Gtk.EventBox ();
145 this.container.visible_window = false;
146@@ -191,13 +197,7 @@
147 });
148
149 this.leave_event.connect (() => {
150- this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:0).
151-
152- completed.connect (() => {
153- this.get_stage ().remove_child (this);
154- this.destroy ();
155- });
156-
157+ fade_out ();
158 return true;
159 });
160
161@@ -205,6 +205,20 @@
162 this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:255);
163 }
164
165+ public void fade_out () {
166+ // prevent multiple callings of this function
167+ if (fading_out)
168+ return;
169+ fading_out = true;
170+
171+ this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:0).
172+
173+ completed.connect (() => {
174+ this.get_stage ().remove_child (this);
175+ this.destroy ();
176+ });
177+ }
178+
179 public Gtk.Widget get_content_area () {
180 return this.container;
181 }

Subscribers

People subscribed via source and target branches