Merge lp:~elementary-pantheon/pantheon-greeter/fingerprint-rewrite into lp:~elementary-pantheon/pantheon-greeter/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: Zisu Andrei
Approved revision: 496
Merged at revision: 497
Proposed branch: lp:~elementary-pantheon/pantheon-greeter/fingerprint-rewrite
Merge into: lp:~elementary-pantheon/pantheon-greeter/trunk
Diff against target: 324 lines (+152/-120)
4 files modified
CMakeLists.txt (+1/-1)
data/fingerprint.svg (+56/-0)
src/FingerprintIndicatorArea.vala (+95/-68)
src/LoginMask.vala (+0/-51)
To merge this branch: bzr merge lp:~elementary-pantheon/pantheon-greeter/fingerprint-rewrite
Reviewer Review Type Date Requested Status
Zisu Andrei (community) Approve
elementary Pantheon team Pending
Review via email: mp+306714@code.launchpad.net

Commit message

FingerprintIndicatorArea.vala
* Replace fingerprint.png with fingerprint.svg
* Move fingerprint related enums here
* Add styles here instead of in the system stylesheet
* Use Gtk.Image instead of manual cairo drawing
* Set margins and column spacing on the grid instead of each widget
* whitespace
* Use Switch case, not else if/else if/else if
* Use Gtk style constants
* Remove obvious comments

Description of the change

Please make sure this branch is actually tested. I don't have a fingerprint reader so this is all theoretical for me.

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

box doesn't need to be outside

Revision history for this message
Zisu Andrei (matzipan) wrote :

Wouldn't the fingerprint be a good candidate to be included in the OS icons? The same icon will need to be used in the polkit dialog.

Revision history for this message
Zisu Andrei (matzipan) wrote :

You forgot to change the CMakeLists.txt file to point to the .svg.

But it seems to be unable to render the icon. Are you sure it's supposed to work like this? I don't know if Gtk.Image knows how to render SVGs, but just to load rendered bitmaps.

review: Needs Fixing
494. By Danielle Foré

update cmake

Revision history for this message
Danielle Foré (danrabbit) wrote :

I agree it would probably be a useful icon to have. I'll have to talk to Sam about coming up with an icon name. But I think this branch should probably not require a new release of icons.

Yes Gtk.Image can render svg. Updated the CMakeLists.txt

Revision history for this message
Zisu Andrei (matzipan) wrote :

Ok, so the icon works now.

The CSS doesn't seem to be applied, though. It gets applied if I replace the EventBox on line 81 of FingerprintIndicatorArea with Grid and remove line 83 with visible_window.

review: Needs Fixing
495. By Danielle Foré

replace event box with a grid

496. By Danielle Foré

update fprint style

Revision history for this message
Zisu Andrei (matzipan) wrote :

LGTM. Code and test.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-08-29 16:04:07 +0000
3+++ CMakeLists.txt 2016-10-26 17:18:44 +0000
4@@ -67,4 +67,4 @@
5 install (TARGETS pantheon-greeter RUNTIME DESTINATION sbin)
6 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/pantheon-greeter.desktop DESTINATION share/xgreeters)
7 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/pantheon-greeter.conf DESTINATION ${CONF_DIR})
8-install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/fingerprint.png DESTINATION ${PKGDATADIR})
9\ No newline at end of file
10+install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/fingerprint.svg DESTINATION ${PKGDATADIR})
11
12=== removed file 'data/fingerprint.png'
13Binary files data/fingerprint.png 2016-08-29 17:32:50 +0000 and data/fingerprint.png 1970-01-01 00:00:00 +0000 differ
14=== added file 'data/fingerprint.svg'
15--- data/fingerprint.svg 1970-01-01 00:00:00 +0000
16+++ data/fingerprint.svg 2016-10-26 17:18:44 +0000
17@@ -0,0 +1,56 @@
18+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
19+<svg
20+ xmlns:dc="http://purl.org/dc/elements/1.1/"
21+ xmlns:cc="http://creativecommons.org/ns#"
22+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
23+ xmlns:svg="http://www.w3.org/2000/svg"
24+ xmlns="http://www.w3.org/2000/svg"
25+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
26+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
27+ version="1.1"
28+ width="24"
29+ height="24"
30+ viewBox="0 0 24 24"
31+ id="svg2"
32+ inkscape:version="0.91 r13725"
33+ sodipodi:docname="fingerprint.svg">
34+ <sodipodi:namedview
35+ pagecolor="#ffffff"
36+ bordercolor="#666666"
37+ borderopacity="1"
38+ objecttolerance="10"
39+ gridtolerance="10"
40+ guidetolerance="10"
41+ inkscape:pageopacity="0"
42+ inkscape:pageshadow="2"
43+ inkscape:window-width="1704"
44+ inkscape:window-height="1000"
45+ id="namedview6"
46+ showgrid="false"
47+ inkscape:zoom="14.75"
48+ inkscape:cx="-6.6440678"
49+ inkscape:cy="8"
50+ inkscape:window-x="853"
51+ inkscape:window-y="398"
52+ inkscape:window-maximized="0"
53+ inkscape:current-layer="svg2" />
54+ <metadata
55+ id="metadata10">
56+ <rdf:RDF>
57+ <cc:Work
58+ rdf:about="">
59+ <dc:format>image/svg+xml</dc:format>
60+ <dc:type
61+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
62+ <dc:title></dc:title>
63+ </cc:Work>
64+ </rdf:RDF>
65+ </metadata>
66+ <defs
67+ id="defs8" />
68+ <path
69+ style="display:inline;opacity:1;fill:#333333;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
70+ d="m 11.52247,0.002921 c -3.0228898,-0.0645 -6.0691054,0.939045 -8.5253856,3.0249 a 0.75034339,0.75034339 0 1 0 0.9711902,1.14405 C 8.3115246,0.483626 14.708665,0.619586 18.890634,4.489736 a 0.75007465,0.75007465 0 1 0 1.019535,-1.1001 C 17.545089,1.200911 14.545361,0.067421 11.52247,0.002921 Z m -0.27246,2.994135 a 9.7499955,9.7499955 0 0 0 -9.7485306,9.70458 0.75007473,0.75007473 0 0 0 0,0.0015 0.75007473,0.75007473 0 0 0 -0.00147,0.0366 0.74999965,0.74999965 0 0 0 0,0.0075 0.74999965,0.74999965 0 0 0 0,0.0045 0.75007473,0.75007473 0 0 0 0,0.0045 c -1.5e-5,0.006 1.5e-5,0.0105 0,0.01605 a 0.74999965,0.74999965 0 0 0 0.00147,0.03375 c 9.151e-4,1.926016 0.35448,3.836099 1.04736,5.633789 A 0.75054078,0.75054078 0 1 0 3.9492246,17.899271 C 3.3171996,16.25944 2.9950444,14.517626 3.0000096,12.760601 a 0.75007473,0.75007473 0 0 0 0,-0.0135 8.2499962,8.2499962 0 0 1 8.2500004,-8.25 8.2499962,8.2499962 0 0 1 8.249999,8.25 2.249999,2.249999 0 0 1 -2.25,2.250001 2.249999,2.249999 0 0 1 -2.249999,-2.250001 3.7499983,3.7499983 0 0 0 -3.75,-3.75 3.7499983,3.7499983 0 0 0 -3.7485305,3.70605 3.7499983,3.7499983 0 0 0 -0.00147,0.04395 0.75007473,0.75007473 0 0 0 0,0.009 c -0.01515,5.333789 4.2989555,9.694109 9.6357435,9.741209 a 0.75007473,0.75007473 0 1 0 0.0135,-1.5 C 12.619286,20.95741 8.9875452,17.286191 9.0003402,12.760497 a 0.75007473,0.75007473 0 0 0 0,-0.0135 2.249999,2.249999 0 0 1 2.2499998,-2.250001 2.249999,2.249999 0 0 1 2.25,2.250001 3.7499983,3.7499983 0 0 0 3.749999,3.749999 3.7499983,3.7499983 0 0 0 3.75,-3.749999 9.7499955,9.7499955 0 0 0 -9.749999,-9.750001 z m 0,3 a 6.7499969,6.7499969 0 0 0 -6.7485304,6.703125 0.75007473,0.75007473 0 0 0 0,0.02055 6.7499969,6.7499969 0 0 0 -0.00147,0.0264 0.75007473,0.75007473 0 0 0 0,0.009 c -0.012,4.100625 1.9602,7.956359 5.2924807,10.350569 a 0.75007473,0.75007473 0 0 0 0.4936497,0.14505 0.75007473,0.75007473 0 0 0 0.0747,-0.009 0.75007473,0.75007473 0 0 0 0.30615,-1.354966 C 7.7265395,19.775095 5.9897646,16.377731 5.9999946,12.760346 a 0.75007473,0.75007473 0 0 0 0,-0.0135 5.2499976,5.2499976 0 0 1 5.2500004,-5.25 5.2499976,5.2499976 0 0 1 5.250001,5.25 0.74999965,0.74999965 0 0 0 0.749998,0.75 0.74999965,0.74999965 0 0 0 0.75,-0.75 0.74999965,0.74999965 0 0 0 -0.003,-0.07035 6.7499969,6.7499969 0 0 0 -6.747059,-6.67968 z m -0.009,5.97216 a 0.75007465,0.75007465 0 0 0 -0.74121,0.75879 c 0,0.003 1.4e-5,0.0075 0,0.0105 a 0.74999965,0.74999965 0 0 0 0,0.009 0.74999965,0.74999965 0 0 0 0.0045,0.07905 c 0.04275,3.658169 3.01545,6.63849 6.685543,6.670904 a 0.75007465,0.75007465 0 1 0 0.0135,-1.5 c -2.890857,-0.02549 -5.203393,-2.360915 -5.203123,-5.24999 a 0.74999965,0.74999965 0 0 0 0,-0.015 0.75007465,0.75007465 0 0 0 -0.75879,-0.763185 z"
71+ id="path4449"
72+ inkscape:connector-curvature="0" />
73+</svg>
74
75=== modified file 'src/FingerprintIndicatorArea.vala'
76--- src/FingerprintIndicatorArea.vala 2016-09-25 15:02:55 +0000
77+++ src/FingerprintIndicatorArea.vala 2016-10-26 17:18:44 +0000
78@@ -18,89 +18,116 @@
79 *
80 */
81
82+public enum MessageText {
83+ FPRINT_SWIPE,
84+ FPRINT_SWIPE_AGAIN,
85+ FPRINT_SWIPE_TOO_SHORT,
86+ FPRINT_NOT_CENTERED,
87+ FPRINT_REMOVE,
88+ FPRINT_PLACE,
89+ FPRINT_PLACE_AGAIN,
90+ FPRINT_NO_MATCH,
91+ FPRINT_TIMEOUT,
92+ FPRINT_ERROR,
93+ FAILED,
94+ OTHER
95+}
96+
97 public class FingerprintIndicatorArea : CredentialsArea {
98- Gtk.EventBox box = new Gtk.EventBox ();
99- Gtk.Label label = new Gtk.Label (null);
100-
101+ Gtk.Label label;
102+
103+ const string STYLE_CSS = """
104+ .fingerprint {
105+ background-image:
106+ linear-gradient(
107+ @bg_color,
108+ @bg_color 80%,
109+ shade (
110+ @bg_color,
111+ 0.94
112+ )
113+ );
114+ border-radius: 50%;
115+ box-shadow:
116+ inset 0 0 0 1px alpha (@bg_highlight_color, 0.1),
117+ inset 0 1px 0 0 alpha (@bg_highlight_color, 0.9),
118+ inset 0 -1px 0 0 alpha (@bg_highlight_color, 0.3),
119+ 0 0 0 1px alpha (#000, 0.2),
120+ 0 1px 2px alpha (#000, 0.15),
121+ 0 2px 6px alpha (#000, 0.10);
122+ }
123+
124+ .fingerprint-label {
125+ text-shadow: 0 0 3px alpha (#000, 0.4);
126+ }
127+
128+ .fingerprint-label.info {
129+ color: alpha (#fff, 0.8);
130+ }
131+
132+ .fingerprint-label.error {
133+ color: lighter (@error_color);
134+ }
135+ """;
136+
137 public FingerprintIndicatorArea () {
138- this.margin_top = 15;
139-
140- Gdk.Pixbuf image = null;
141- var margin = 2;
142-
143+ var provider = new Gtk.CssProvider ();
144 try {
145- image = new Gdk.Pixbuf.from_file_at_size (Constants.PKGDATADIR+"/fingerprint.png", 26, 26);
146+ provider.load_from_data (STYLE_CSS, STYLE_CSS.length);
147+ Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
148 } catch (Error e) {
149- warning (@"Can't load fingerprint icon due to $(e.message)");
150- }
151-
152- box.valign = Gtk.Align.START;
153- box.visible_window = false;
154- box.margin_top = 5;
155- box.margin_left = 10;
156-
157- if (image != null) {
158- box.set_size_request (image.width + 4*margin, image.height + 4*margin);
159- }
160-
161- var box_style_context = box.get_style_context ();
162-
163- box_style_context.add_class ("fingerprint");
164-
165- box.draw.connect ((ctx) => {
166- int width = box.get_allocated_width () - 2*margin;
167- int height = box.get_allocated_height () - 2*margin;
168-
169- if (image != null) {
170- Gdk.cairo_set_source_pixbuf (ctx, image, 2*margin, 2*margin);
171- }
172-
173- box_style_context.render_background (ctx, margin, margin, width, height);
174- box_style_context.render_frame (ctx, margin, margin, width, height);
175-
176- ctx.paint ();
177-
178- return false;
179- });
180-
181- attach(box, 0, 0,1,1);
182-
183- label.margin_left = 7;
184- label.margin_top = 2;
185+ warning (e.message);
186+ }
187+
188+ var image = new Gtk.Image.from_file (Constants.PKGDATADIR + "/fingerprint.svg");
189+ image.margin = 6;
190+
191+ var box = new Gtk.Grid ();
192+ box.get_style_context ().add_class ("fingerprint");
193+ box.add (image);
194+
195+ label = new Gtk.Label ("");
196+ label.valign = Gtk.Align.CENTER;
197
198 var label_style_context = label.get_style_context ();
199-
200 label_style_context.add_class ("h3");
201 label_style_context.add_class ("fingerprint-label");
202-
203- attach(label, 1, 0 ,1,1);
204+
205+ attach (box, 0, 0, 1, 1);
206+ attach (label, 1, 0, 1, 1);
207+ column_spacing = 6;
208 }
209-
210+
211 public override void pass_focus () {
212 }
213-
214+
215 public override void show_message (LightDM.MessageType type, MessageText messagetext = MessageText.OTHER, string text = "") {
216 var label_style_context = label.get_style_context ();
217
218 if (type == LightDM.MessageType.INFO) {
219- label_style_context. remove_class("error");
220- label_style_context. add_class ("info");
221+ label_style_context.remove_class (Gtk.STYLE_CLASS_ERROR);
222+ label_style_context.add_class (Gtk.STYLE_CLASS_INFO);
223 } else {
224- label_style_context. remove_class("info");
225- label_style_context. add_class ("error");
226- }
227-
228- // some fprint messages are too long, so we override them
229- if (messagetext == MessageText.FPRINT_SWIPE) {
230- text = _("Swipe your finger");
231- } else if (messagetext == MessageText.FPRINT_PLACE) {
232- text = _("Place your finger");
233- } else if (messagetext == MessageText.FPRINT_REMOVE) {
234- text = _("Remove your finger and try again.");
235- } else if (messagetext == MessageText.FPRINT_NOT_CENTERED) {
236- text = _("Center your finger and try again.");
237- }
238-
239- label.set_text(text);
240+ label_style_context.remove_class (Gtk.STYLE_CLASS_INFO);
241+ label_style_context.add_class (Gtk.STYLE_CLASS_ERROR);
242+ }
243+
244+ switch (messagetext) {
245+ case MessageText.FPRINT_SWIPE:
246+ label.label = _("Swipe your finger");
247+ break;
248+ case MessageText.FPRINT_PLACE:
249+ label.label = _("Place your finger");
250+ break;
251+ case MessageText.FPRINT_REMOVE:
252+ label.label = _("Remove your finger and try again.");
253+ break;
254+ case MessageText.FPRINT_NOT_CENTERED:
255+ label.label = _("Center your finger and try again.");
256+ break;
257+ default:
258+ label.label = text;
259+ break;
260+ }
261 }
262 }
263
264=== modified file 'src/LoginMask.vala'
265--- src/LoginMask.vala 2016-09-25 14:52:44 +0000
266+++ src/LoginMask.vala 2016-10-26 17:18:44 +0000
267@@ -52,57 +52,6 @@
268 OTHER
269 }
270
271-public enum MessageText {
272- /**
273- * fprintd message to swipe finger
274- */
275- FPRINT_SWIPE,
276- /**
277- * fprintd message to swipe again
278- */
279- FPRINT_SWIPE_AGAIN,
280- /**
281- * fprintd message to swipe longer
282- */
283- FPRINT_SWIPE_TOO_SHORT,
284- /**
285- * fprintd message to center finger
286- */
287- FPRINT_NOT_CENTERED,
288- /**
289- * fprintd message to remove finger
290- */
291- FPRINT_REMOVE,
292- /**
293- * fprintd message to place finger on device again
294- */
295- FPRINT_PLACE,
296- /**
297- * fprintd message to place finger on device again
298- */
299- FPRINT_PLACE_AGAIN,
300- /**
301- * fprintd failure message
302- */
303- FPRINT_NO_MATCH,
304- /**
305- * fprintd timeout message
306- */
307- FPRINT_TIMEOUT,
308- /**
309- * Unknown fprintd error
310- */
311- FPRINT_ERROR,
312- /**
313- * Login failed
314- */
315- FAILED,
316- /**
317- * The message was not in the expected list
318- */
319- OTHER
320-}
321-
322 /**
323 * A LoginMask is for example a UI such as the LoginBox that communicates with
324 * the user.

Subscribers

People subscribed via source and target branches