Merge lp:~robert-ancell/unity-greeter/lp-1121660 into lp:unity-greeter

Proposed by Robert Ancell
Status: Needs review
Proposed branch: lp:~robert-ancell/unity-greeter/lp-1121660
Merge into: lp:unity-greeter
Diff against target: 201 lines (+88/-9)
5 files modified
src/prompt-box.vala (+3/-1)
src/unity-greeter.vala (+16/-1)
src/user-list.vala (+58/-6)
tests/test.vala (+1/-1)
tests/unity-greeter.vala (+10/-0)
To merge this branch: bzr merge lp:~robert-ancell/unity-greeter/lp-1121660
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michael Terry Pending
Unity Greeter Development Team Pending
Review via email: mp+147595@code.launchpad.net

Commit message

Add visual indication of automatic login and abort when selected user changes

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

As discussed IRL, I'd prefer the countdown text to not be on the button itself.

Maybe a fake PAM info line with the phrase "You will be logged in after %d seconds"? (assuming it fits)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:759
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~robert-ancell/unity-greeter/lp-1121660/+merge/147595/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/unity-greeter-ci/4/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-greeter-ci/./label=precise/4/console

Click here to trigger a rebuild:
http://jenkins.qa.ubuntu.com/job/unity-greeter-ci/4//rebuild/?

review: Needs Fixing (continuous-integration)

Unmerged revisions

759. By Robert Ancell

Add visual indication of automatic login and abort when selected user changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/prompt-box.vala'
2--- src/prompt-box.vala 2013-01-01 20:26:59 +0000
3+++ src/prompt-box.vala 2013-02-11 04:22:23 +0000
4@@ -542,7 +542,7 @@
5 respond (response);
6 }
7
8- public void add_button (string text, string? accessible_text)
9+ public DashButton add_button (string text, string? accessible_text)
10 {
11 var button = new DashButton (text);
12
13@@ -552,6 +552,8 @@
14 button.clicked.connect (button_clicked_cb);
15
16 attach_item (button);
17+
18+ return button;
19 }
20
21 private void button_clicked_cb (Gtk.Button button)
22
23=== modified file 'src/unity-greeter.vala'
24--- src/unity-greeter.vala 2013-01-03 15:15:54 +0000
25+++ src/unity-greeter.vala 2013-02-11 04:22:23 +0000
26@@ -57,7 +57,6 @@
27 greeter = new LightDM.Greeter ();
28 greeter.show_message.connect ((text, type) => { show_message (text, type); });
29 greeter.show_prompt.connect ((text, type) => { show_prompt (text, type); });
30- greeter.autologin_timer_expired.connect (() => { greeter.authenticate_autologin (); });
31 greeter.authentication_complete.connect (() => { authentication_complete (); });
32 var connected = false;
33 try
34@@ -248,6 +247,22 @@
35 return greeter.select_user_hint;
36 }
37
38+ public string? autologin_user_hint ()
39+ {
40+ if (test_mode)
41+ return "autologin";
42+ else
43+ return greeter.autologin_user_hint;
44+ }
45+
46+ public int autologin_timeout_hint ()
47+ {
48+ if (test_mode)
49+ return 5;
50+ else
51+ return greeter.autologin_timeout_hint;
52+ }
53+
54 public bool show_manual_login_hint ()
55 {
56 return greeter.show_manual_login_hint;
57
58=== modified file 'src/user-list.vala'
59--- src/user-list.vala 2012-10-02 17:20:34 +0000
60+++ src/user-list.vala 2013-02-11 04:22:23 +0000
61@@ -51,6 +51,10 @@
62 private Gdk.Pixbuf message_pixbuf;
63
64 private uint change_background_timeout = 0;
65+
66+ private Timer? autologin_timer = null;
67+ private uint autologin_timeout = 0;
68+ private DashButton? login_button = null;
69
70 private uint remote_login_service_watch;
71 private RemoteLoginService remote_login_service;
72@@ -569,6 +573,15 @@
73
74 protected override void start_authentication ()
75 {
76+ if (autologin_timer != null && selected_entry.id != UnityGreeter.singleton.autologin_user_hint ())
77+ {
78+ debug ("Cancelling autologin");
79+ autologin_timer = null;
80+ if (autologin_timeout != 0)
81+ Source.remove (autologin_timeout);
82+ autologin_timeout = 0;
83+ }
84+
85 sensitive = true;
86 greeter_authenticating_user = "";
87 if (selected_entry.id.has_prefix ("*remote_directory"))
88@@ -743,8 +756,16 @@
89 if (successful)
90 {
91 /* 'Log In' here is the button for logging in. */
92- selected_entry.add_button (_("Log In"),
93- _("Login as %s").printf (selected_entry.label));
94+ var text = _("Log In");
95+ if (autologin_timer != null)
96+ {
97+ autologin_timer.start ();
98+ var n_seconds = UnityGreeter.singleton.autologin_timeout_hint ();
99+ text = ngettext ("Log In In %d Second", "Log In In %d Seconds", n_seconds).printf (n_seconds);
100+ }
101+
102+ login_button = selected_entry.add_button (text,
103+ _("Login as %s").printf (selected_entry.label));
104 }
105 else
106 {
107@@ -937,11 +958,37 @@
108 if (!have_entries () && !always_show_manual)
109 add_manual_entry ();
110
111- var last_user = UnityGreeter.singleton.get_state ("last-user");
112+ var selected_user = UnityGreeter.singleton.get_state ("last-user");
113 if (UnityGreeter.singleton.select_user_hint () != null)
114- set_active_entry (UnityGreeter.singleton.select_user_hint ());
115- else if (last_user != null)
116- set_active_entry (last_user);
117+ selected_user = UnityGreeter.singleton.select_user_hint ();
118+ else if (UnityGreeter.singleton.autologin_user_hint () != null)
119+ selected_user = UnityGreeter.singleton.autologin_user_hint ();
120+
121+ if (selected_user != null)
122+ set_active_entry (selected_user);
123+ }
124+
125+ if (UnityGreeter.singleton.autologin_user_hint () == selected_entry.id)
126+ {
127+ autologin_timer = new Timer ();
128+ autologin_timeout = Timeout.add (1000, () =>
129+ {
130+ var n_seconds = UnityGreeter.singleton.autologin_timeout_hint () - (int) (autologin_timer.elapsed () + 0.5);
131+ if (n_seconds < 0)
132+ n_seconds = 0;
133+
134+ if (login_button != null)
135+ login_button.text = ngettext ("Log In In %d Second", "Log In In %d Seconds", n_seconds).printf (n_seconds);
136+
137+ if (n_seconds == 0)
138+ {
139+ debug ("Automatically logging in");
140+ prompt_box_login_cb ();
141+ return false;
142+ }
143+
144+ return true;
145+ });
146 }
147 }
148
149@@ -1017,6 +1064,7 @@
150
151 private const TestEntry[] test_entries =
152 {
153+ { "autologin", "Autologin", "*", "gb;us", false, false, null },
154 { "has-password", "Has Password", "*", "gb;us", false, false, null },
155 { "different-prompt", "Different Prompt", "*", "gb;us", false, false, null },
156 { "no-password", "No Password", "*", "gb;us", false, false, null },
157@@ -1443,6 +1491,10 @@
158 case "different-prompt":
159 show_prompt_cb ("Secret word", LightDM.PromptType.SECRET);
160 break;
161+ case "autologin":
162+ test_is_authenticated = true;
163+ authentication_complete_cb ();
164+ break;
165 case "no-password":
166 test_is_authenticated = true;
167 authentication_complete_cb ();
168
169=== modified file 'tests/test.vala'
170--- tests/test.vala 2013-01-04 15:28:54 +0000
171+++ tests/test.vala 2013-02-11 04:22:23 +0000
172@@ -135,7 +135,7 @@
173 // Wait until remote login appears
174 scroll_to_remote_login (list);
175
176- GLib.assert (list.num_entries() == 30);
177+ GLib.assert (list.num_entries() == 31);
178
179 // Make sure we are at the beginning of the list
180 do_scroll (list, GreeterList.ScrollTarget.START);
181
182=== modified file 'tests/unity-greeter.vala'
183--- tests/unity-greeter.vala 2013-01-03 15:15:54 +0000
184+++ tests/unity-greeter.vala 2013-02-11 04:22:23 +0000
185@@ -72,6 +72,16 @@
186 return "";
187 }
188
189+ public string? autologin_user_hint ()
190+ {
191+ return null;
192+ }
193+
194+ public int autologin_timeout_hint ()
195+ {
196+ return 0;
197+ }
198+
199 public bool show_manual_login_hint ()
200 {
201 return false;

Subscribers

People subscribed via source and target branches