Merge lp:~robert-ancell/unity-greeter/end-session-dialog into lp:unity-greeter

Proposed by Robert Ancell
Status: Merged
Approved by: Michael Terry
Approved revision: 1031
Merged at revision: 1013
Proposed branch: lp:~robert-ancell/unity-greeter/end-session-dialog
Merge into: lp:unity-greeter
Diff against target: 820 lines (+575/-17)
12 files modified
configure.ac (+1/-1)
data/Makefile.am (+13/-0)
debian/changelog (+7/-0)
po/POTFILES.in (+1/-1)
po/POTFILES.skip (+1/-0)
src/Makefile.am (+1/-0)
src/fixes.vapi (+6/-0)
src/main-window.vala (+75/-14)
src/settings-daemon.vala (+36/-0)
src/shutdown-dialog.vala (+381/-0)
src/unity-greeter.vala (+51/-0)
tests/Makefile.am (+2/-1)
To merge this branch: bzr merge lp:~robert-ancell/unity-greeter/end-session-dialog
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michael Terry (community) Approve
Review via email: mp+193880@code.launchpad.net

This proposal supersedes a proposal from 2013-10-21.

Commit message

Use Unity style shutdown dialogs
Handle hardware power button in greeter

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote : Posted in a previous version of this proposal

So we talked about this on IRC. Sounds like it needs at least keyboard navigation before landing. Also mentioned was the use of a well-known DBus name vs unique.

Revision history for this message
Michael Terry (mterry) wrote : Posted in a previous version of this proposal

Whoops, forgot to set status.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Should be good now - can you re-review?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1031
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/end-session-dialog/+merge/193880/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/unity-greeter-ci/22/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-greeter-trusty-amd64-ci/5
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-greeter-trusty-armhf-ci/5

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/unity-greeter-ci/22/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

Works better for me now, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.ac'
--- configure.ac 2013-10-02 17:46:49 +0000
+++ configure.ac 2013-11-05 04:29:38 +0000
@@ -2,7 +2,7 @@
22
3dnl Process this file with autoconf to produce a configure script.3dnl Process this file with autoconf to produce a configure script.
44
5AC_INIT(unity-greeter, 13.10.3)5AC_INIT(unity-greeter, 14.04.0)
6AC_CONFIG_MACRO_DIR(m4)6AC_CONFIG_MACRO_DIR(m4)
7AM_INIT_AUTOMAKE7AM_INIT_AUTOMAKE
8AM_PROG_CC_C_O8AM_PROG_CC_C_O
99
=== modified file 'data/Makefile.am'
--- data/Makefile.am 2012-10-18 14:45:57 +0000
+++ data/Makefile.am 2013-11-05 04:29:38 +0000
@@ -9,13 +9,26 @@
9 arrow_left.png \9 arrow_left.png \
10 arrow_right.png \10 arrow_right.png \
11 cof.png \11 cof.png \
12 dialog_close_highlight.png \
13 dialog_close.png \
12 gnome_badge.png \14 gnome_badge.png \
15 hibernate_highlight.png \
16 hibernate.png \
13 kde_badge.png \17 kde_badge.png \
14 logo.png \18 logo.png \
15 message.png \19 message.png \
16 recovery_console_badge.png \20 recovery_console_badge.png \
17 remote_login_help.png \21 remote_login_help.png \
22 restart_highlight.png \
23 restart.png \
18 shadow.png \24 shadow.png \
25 shutdown_highlight.png \
26 shutdown.png \
27 suspend_highlight.png \
28 suspend.png \
29 switcher_corner.png \
30 switcher_left.png \
31 switcher_top.png \
19 ubuntu_badge.png \32 ubuntu_badge.png \
20 unknown_badge.png33 unknown_badge.png
2134
2235
=== added file 'data/dialog_close.png'
23Binary files data/dialog_close.png 1970-01-01 00:00:00 +0000 and data/dialog_close.png 2013-11-05 04:29:38 +0000 differ36Binary files data/dialog_close.png 1970-01-01 00:00:00 +0000 and data/dialog_close.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/dialog_close_highlight.png'
24Binary files data/dialog_close_highlight.png 1970-01-01 00:00:00 +0000 and data/dialog_close_highlight.png 2013-11-05 04:29:38 +0000 differ37Binary files data/dialog_close_highlight.png 1970-01-01 00:00:00 +0000 and data/dialog_close_highlight.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/hibernate.png'
25Binary files data/hibernate.png 1970-01-01 00:00:00 +0000 and data/hibernate.png 2013-11-05 04:29:38 +0000 differ38Binary files data/hibernate.png 1970-01-01 00:00:00 +0000 and data/hibernate.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/hibernate_highlight.png'
26Binary files data/hibernate_highlight.png 1970-01-01 00:00:00 +0000 and data/hibernate_highlight.png 2013-11-05 04:29:38 +0000 differ39Binary files data/hibernate_highlight.png 1970-01-01 00:00:00 +0000 and data/hibernate_highlight.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/restart.png'
27Binary files data/restart.png 1970-01-01 00:00:00 +0000 and data/restart.png 2013-11-05 04:29:38 +0000 differ40Binary files data/restart.png 1970-01-01 00:00:00 +0000 and data/restart.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/restart_highlight.png'
28Binary files data/restart_highlight.png 1970-01-01 00:00:00 +0000 and data/restart_highlight.png 2013-11-05 04:29:38 +0000 differ41Binary files data/restart_highlight.png 1970-01-01 00:00:00 +0000 and data/restart_highlight.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/shutdown.png'
29Binary files data/shutdown.png 1970-01-01 00:00:00 +0000 and data/shutdown.png 2013-11-05 04:29:38 +0000 differ42Binary files data/shutdown.png 1970-01-01 00:00:00 +0000 and data/shutdown.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/shutdown_highlight.png'
30Binary files data/shutdown_highlight.png 1970-01-01 00:00:00 +0000 and data/shutdown_highlight.png 2013-11-05 04:29:38 +0000 differ43Binary files data/shutdown_highlight.png 1970-01-01 00:00:00 +0000 and data/shutdown_highlight.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/suspend.png'
31Binary files data/suspend.png 1970-01-01 00:00:00 +0000 and data/suspend.png 2013-11-05 04:29:38 +0000 differ44Binary files data/suspend.png 1970-01-01 00:00:00 +0000 and data/suspend.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/suspend_highlight.png'
32Binary files data/suspend_highlight.png 1970-01-01 00:00:00 +0000 and data/suspend_highlight.png 2013-11-05 04:29:38 +0000 differ45Binary files data/suspend_highlight.png 1970-01-01 00:00:00 +0000 and data/suspend_highlight.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/switcher_corner.png'
33Binary files data/switcher_corner.png 1970-01-01 00:00:00 +0000 and data/switcher_corner.png 2013-11-05 04:29:38 +0000 differ46Binary files data/switcher_corner.png 1970-01-01 00:00:00 +0000 and data/switcher_corner.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/switcher_left.png'
34Binary files data/switcher_left.png 1970-01-01 00:00:00 +0000 and data/switcher_left.png 2013-11-05 04:29:38 +0000 differ47Binary files data/switcher_left.png 1970-01-01 00:00:00 +0000 and data/switcher_left.png 2013-11-05 04:29:38 +0000 differ
=== added file 'data/switcher_top.png'
35Binary files data/switcher_top.png 1970-01-01 00:00:00 +0000 and data/switcher_top.png 2013-11-05 04:29:38 +0000 differ48Binary files data/switcher_top.png 1970-01-01 00:00:00 +0000 and data/switcher_top.png 2013-11-05 04:29:38 +0000 differ
=== modified file 'debian/changelog'
--- debian/changelog 2013-10-03 13:59:34 +0000
+++ debian/changelog 2013-11-05 04:29:38 +0000
@@ -1,3 +1,10 @@
1unity-greeter (14.04.0-0ubuntu1) UNRELEASED; urgency=low
2
3 * Use Unity style shutdown dialogs
4 * Handle hardware power button in greeter
5
6 -- Robert Ancell <robert.ancell@canonical.com> Mon, 21 Oct 2013 17:15:38 +1300
7
1unity-greeter (13.10.3-0ubuntu1) saucy; urgency=low8unity-greeter (13.10.3-0ubuntu1) saucy; urgency=low
29
3 [ William Hua ]10 [ William Hua ]
411
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2012-11-08 15:48:14 +0000
+++ po/POTFILES.in 2013-11-05 04:29:38 +0000
@@ -19,8 +19,8 @@
19src/session-list.vala19src/session-list.vala
20src/settings-daemon.vala20src/settings-daemon.vala
21src/settings.vala21src/settings.vala
22src/shutdown-dialog.vala
22src/toggle-box.vala23src/toggle-box.vala
23src/unity-greeter.vala24src/unity-greeter.vala
24src/user-list.vala25src/user-list.vala
25src/user-prompt-box.vala26src/user-prompt-box.vala
26
2727
=== modified file 'po/POTFILES.skip'
--- po/POTFILES.skip 2012-11-08 15:48:14 +0000
+++ po/POTFILES.skip 2013-11-05 04:29:38 +0000
@@ -17,6 +17,7 @@
17src/session-list.c17src/session-list.c
18src/settings-daemon.c18src/settings-daemon.c
19src/settings.c19src/settings.c
20src/shutdown-dialog.c
20src/toggle-box.c21src/toggle-box.c
21src/unity-greeter.c22src/unity-greeter.c
22src/user-list.c23src/user-list.c
2324
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2013-10-17 22:09:16 +0000
+++ src/Makefile.am 2013-11-05 04:29:38 +0000
@@ -27,6 +27,7 @@
27 remote-login-service.vala \27 remote-login-service.vala \
28 settings.vala \28 settings.vala \
29 settings-daemon.vala \29 settings-daemon.vala \
30 shutdown-dialog.vala \
30 toggle-box.vala \31 toggle-box.vala \
31 unity-greeter.vala \32 unity-greeter.vala \
32 user-list.vala \33 user-list.vala \
3334
=== modified file 'src/fixes.vapi'
--- src/fixes.vapi 2013-10-24 12:27:03 +0000
+++ src/fixes.vapi 2013-11-05 04:29:38 +0000
@@ -33,12 +33,16 @@
33 public const int KEY_Page_Down;33 public const int KEY_Page_Down;
34 public const int KEY_Up;34 public const int KEY_Up;
35 public const int KEY_Down;35 public const int KEY_Down;
36 public const int KEY_Left;
37 public const int KEY_Right;
36 public const int KEY_KP_Home;38 public const int KEY_KP_Home;
37 public const int KEY_KP_End;39 public const int KEY_KP_End;
38 public const int KEY_KP_Page_Up;40 public const int KEY_KP_Page_Up;
39 public const int KEY_KP_Page_Down;41 public const int KEY_KP_Page_Down;
40 public const int KEY_KP_Up;42 public const int KEY_KP_Up;
41 public const int KEY_KP_Down;43 public const int KEY_KP_Down;
44 public const int KEY_KP_Left;
45 public const int KEY_KP_Right;
42 public const int KEY_F10;46 public const int KEY_F10;
43 public const int KEY_0;47 public const int KEY_0;
44 public const int KEY_g;48 public const int KEY_g;
@@ -47,10 +51,12 @@
47 public const int KEY_m;51 public const int KEY_m;
48 public const int KEY_M;52 public const int KEY_M;
49 public const int KEY_s;53 public const int KEY_s;
54 public const int KEY_z;
50 public const int KEY_plus;55 public const int KEY_plus;
51 public const int KEY_minus;56 public const int KEY_minus;
52 public const int KEY_equal;57 public const int KEY_equal;
53 public const int CONTROL_MASK;58 public const int CONTROL_MASK;
59 public const int KEY_PowerOff;
54}60}
5561
56namespace Gtk62namespace Gtk
5763
=== modified file 'src/main-window.vala'
--- src/main-window.vala 2013-02-08 15:53:16 +0000
+++ src/main-window.vala 2013-11-05 04:29:38 +0000
@@ -24,10 +24,12 @@
24 public MenuBar menubar;24 public MenuBar menubar;
2525
26 private List<Monitor> monitors;26 private List<Monitor> monitors;
27 private Monitor active_monitor;
27 private Background background;28 private Background background;
28 private Gtk.Box login_box;29 private Gtk.Box login_box;
29 private Gtk.Box hbox;30 private Gtk.Box hbox;
30 private Gtk.Button back_button;31 private Gtk.Button back_button;
32 private ShutdownDialog? shutdown_dialog = null;
3133
32 public ListStack stack;34 public ListStack stack;
3335
@@ -245,9 +247,16 @@
245247
246 private void move_to_monitor (Monitor monitor)248 private void move_to_monitor (Monitor monitor)
247 {249 {
250 active_monitor = monitor;
248 login_box.set_size_request (monitor.width, monitor.height);251 login_box.set_size_request (monitor.width, monitor.height);
249 background.set_active_monitor (monitor);252 background.set_active_monitor (monitor);
250 background.move (login_box, monitor.x, monitor.y);253 background.move (login_box, monitor.x, monitor.y);
254
255 if (shutdown_dialog != null)
256 {
257 shutdown_dialog.set_size_request (monitor.width, monitor.height);
258 background.move (shutdown_dialog, monitor.x, monitor.y);
259 }
251 }260 }
252261
253 private void add_user_list ()262 private void add_user_list ()
@@ -266,36 +275,88 @@
266 switch (event.keyval)275 switch (event.keyval)
267 {276 {
268 case Gdk.KEY_Escape:277 case Gdk.KEY_Escape:
269 top.cancel_authentication ();278 if (login_box.sensitive)
270 break;279 top.cancel_authentication ();
280 if (shutdown_dialog != null)
281 shutdown_dialog.cancel ();
282 return true;
271 case Gdk.KEY_Page_Up:283 case Gdk.KEY_Page_Up:
272 case Gdk.KEY_KP_Page_Up:284 case Gdk.KEY_KP_Page_Up:
273 top.scroll (GreeterList.ScrollTarget.START);285 if (login_box.sensitive)
274 break;286 top.scroll (GreeterList.ScrollTarget.START);
287 return true;
275 case Gdk.KEY_Page_Down:288 case Gdk.KEY_Page_Down:
276 case Gdk.KEY_KP_Page_Down:289 case Gdk.KEY_KP_Page_Down:
277 top.scroll (GreeterList.ScrollTarget.END);290 if (login_box.sensitive)
278 break;291 top.scroll (GreeterList.ScrollTarget.END);
292 return true;
279 case Gdk.KEY_Up:293 case Gdk.KEY_Up:
280 case Gdk.KEY_KP_Up:294 case Gdk.KEY_KP_Up:
281 top.scroll (GreeterList.ScrollTarget.UP);295 if (login_box.sensitive)
282 break;296 top.scroll (GreeterList.ScrollTarget.UP);
297 return true;
283 case Gdk.KEY_Down:298 case Gdk.KEY_Down:
284 case Gdk.KEY_KP_Down:299 case Gdk.KEY_KP_Down:
285 top.scroll (GreeterList.ScrollTarget.DOWN);300 if (login_box.sensitive)
286 break;301 top.scroll (GreeterList.ScrollTarget.DOWN);
302 return true;
303 case Gdk.KEY_Left:
304 case Gdk.KEY_KP_Left:
305 if (shutdown_dialog != null)
306 shutdown_dialog.focus_prev ();
307 return true;
308 case Gdk.KEY_Right:
309 case Gdk.KEY_KP_Right:
310 if (shutdown_dialog != null)
311 shutdown_dialog.focus_next ();
312 return true;
287 case Gdk.KEY_F10:313 case Gdk.KEY_F10:
288 menubar.select_first (false);314 if (login_box.sensitive)
315 menubar.select_first (false);
316 return true;
317 case Gdk.KEY_PowerOff:
318 show_shutdown_dialog (ShutdownDialogType.SHUTDOWN);
319 return true;
320 case Gdk.KEY_z:
321 if (UnityGreeter.singleton.test_mode && (event.state & Gdk.ModifierType.MOD1_MASK) != 0)
322 {
323 show_shutdown_dialog (ShutdownDialogType.SHUTDOWN);
324 return true;
325 }
289 break;326 break;
290 default:
291 return base.key_press_event (event);
292 }327 }
293328
294 return true;329 return base.key_press_event (event);
295 }330 }
296331
297 public void set_keyboard_state ()332 public void set_keyboard_state ()
298 {333 {
299 menubar.set_keyboard_state ();334 menubar.set_keyboard_state ();
300 }335 }
336
337 public void show_shutdown_dialog (ShutdownDialogType type)
338 {
339 if (shutdown_dialog != null)
340 shutdown_dialog.destroy ();
341
342 /* Stop input to login box */
343 login_box.sensitive = false;
344
345 shutdown_dialog = new ShutdownDialog (type);
346 shutdown_dialog.visible = true;
347 shutdown_dialog.close.connect (close_shutdown_dialog);
348 background.add (shutdown_dialog);
349 move_to_monitor (active_monitor);
350 }
351
352 public void close_shutdown_dialog ()
353 {
354 if (shutdown_dialog == null)
355 return;
356
357 shutdown_dialog.destroy ();
358 shutdown_dialog = null;
359
360 login_box.sensitive = true;
361 }
301}362}
302363
=== modified file 'src/settings-daemon.vala'
--- src/settings-daemon.vala 2013-01-30 20:31:38 +0000
+++ src/settings-daemon.vala 2013-11-05 04:29:38 +0000
@@ -19,6 +19,8 @@
1919
20public class SettingsDaemon : Object20public class SettingsDaemon : Object
21{21{
22 private int logind_inhibit_fd = -1;
23
22 public async void start ()24 public async void start ()
23 {25 {
24 configure ();26 configure ();
@@ -64,6 +66,40 @@
64 require gnome-session and it's Presence DBus interface to be run. */66 require gnome-session and it's Presence DBus interface to be run. */
65 GLib.Bus.own_name (GLib.BusType.SESSION, "org.gnome.ScreenSaver",67 GLib.Bus.own_name (GLib.BusType.SESSION, "org.gnome.ScreenSaver",
66 GLib.BusNameOwnerFlags.NONE);68 GLib.BusNameOwnerFlags.NONE);
69
70 /* The media-keys plugin inhibits the power key, but we don't want
71 all the other keys doing things. So inhibit it ourselves */
72 /* NOTE: We are using the synchronous method here since there is a bug in Vala/GLib in that
73 * g_dbus_connection_call_with_unix_fd_list_finish and g_dbus_proxy_call_with_unix_fd_list_finish
74 * don't have the GAsyncResult as the second argument.
75 * https://bugzilla.gnome.org/show_bug.cgi?id=688907
76 */
77 try
78 {
79 var b = Bus.get_sync (BusType.SYSTEM);
80 UnixFDList fd_list;
81 var result = b.call_with_unix_fd_list_sync ("org.freedesktop.login1",
82 "/org/freedesktop/login1",
83 "org.freedesktop.login1.Manager",
84 "Inhibit",
85 new Variant ("(ssss)",
86 "handle-power-key",
87 Environment.get_user_name (),
88 "Unity Greeter handling keypresses",
89 "block"),
90 new VariantType ("(h)"),
91 DBusCallFlags.NONE,
92 -1,
93 null,
94 out fd_list);
95 int32 index = -1;
96 result.get ("(h)", &index);
97 logind_inhibit_fd = fd_list.get (index);
98 }
99 catch (Error e)
100 {
101 warning ("Failed to inhibit power keys: %s", e.message);
102 }
67 }103 }
68104
69 private void set_plugin_enabled (string schema_name, bool enabled)105 private void set_plugin_enabled (string schema_name, bool enabled)
70106
=== added file 'src/shutdown-dialog.vala'
--- src/shutdown-dialog.vala 1970-01-01 00:00:00 +0000
+++ src/shutdown-dialog.vala 2013-11-05 04:29:38 +0000
@@ -0,0 +1,381 @@
1/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*-
2 *
3 * Copyright (C) 2013 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authors: Robert Ancell <robert.ancell@canonical.com>
18 */
19
20public enum ShutdownDialogType
21{
22 LOGOUT,
23 SHUTDOWN,
24 RESTART
25}
26
27public class ShutdownDialog : Gtk.Fixed
28{
29 public signal void close ();
30
31 private Cairo.ImageSurface? corner_surface = null;
32 private Cairo.ImageSurface? left_surface = null;
33 private Cairo.ImageSurface? top_surface = null;
34 private Cairo.Pattern? corner_pattern = null;
35 private Cairo.Pattern? left_pattern = null;
36 private Cairo.Pattern? top_pattern = null;
37
38 private const int BORDER_SIZE = 30;
39 private const int CLOSE_OFFSET = 3;
40
41 private Gtk.Box vbox;
42 private DialogButton close_button;
43 private Gtk.Box button_box;
44
45 public ShutdownDialog (ShutdownDialogType type)
46 {
47 vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
48 vbox.visible = true;
49 add (vbox);
50
51 vbox.border_width = 20;
52
53 var title_label = new Gtk.Label (_("Shutdown"));
54 title_label.override_font (Pango.FontDescription.from_string ("Ubuntu Light 15"));
55 title_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
56 title_label.set_alignment (0.0f, 0.5f);
57 vbox.pack_start (title_label, false, false, 0);
58
59 string text;
60 if (type == ShutdownDialogType.SHUTDOWN)
61 text = _("Goodbye. Would you like to…");
62 else
63 {
64 text = _("Are you sure you want to shut down the computer?");
65 title_label.visible = true;
66 }
67 var label = new Gtk.Label (text);
68 label.set_line_wrap (true);
69 label.override_font (Pango.FontDescription.from_string ("Ubuntu Light 12"));
70 label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
71 label.set_alignment (0.0f, 0.5f);
72 label.visible = true;
73 vbox.pack_start (label, false, false, 0);
74
75 button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
76 button_box.visible = true;
77 vbox.pack_start (button_box, false, false, 0);
78
79 if (type == ShutdownDialogType.SHUTDOWN)
80 {
81 if (LightDM.get_can_suspend ())
82 {
83 var button = add_button (_("Suspend"), Path.build_filename (Config.PKGDATADIR, "suspend.png"), Path.build_filename (Config.PKGDATADIR, "suspend_highlight.png"));
84 button.clicked.connect (() =>
85 {
86 try
87 {
88 LightDM.suspend ();
89 close ();
90 }
91 catch (Error e)
92 {
93 warning ("Failed to suspend: %s", e.message);
94 }
95 });
96 }
97
98 if (LightDM.get_can_hibernate ())
99 {
100 var button = add_button (_("Hibernate"), Path.build_filename (Config.PKGDATADIR, "hibernate.png"), Path.build_filename (Config.PKGDATADIR, "hibernate_highlight.png"));
101 button.clicked.connect (() =>
102 {
103 try
104 {
105 LightDM.hibernate ();
106 close ();
107 }
108 catch (Error e)
109 {
110 warning ("Failed to hibernate: %s", e.message);
111 }
112 });
113 }
114 }
115
116 if (LightDM.get_can_restart ())
117 {
118 var button = add_button (_("Restart"), Path.build_filename (Config.PKGDATADIR, "restart.png"), Path.build_filename (Config.PKGDATADIR, "restart_highlight.png"));
119 button.clicked.connect (() =>
120 {
121 try
122 {
123 LightDM.restart ();
124 close ();
125 }
126 catch (Error e)
127 {
128 warning ("Failed to restart: %s", e.message);
129 }
130 });
131 }
132
133 if (LightDM.get_can_shutdown ())
134 {
135 var button = add_button (_("Shutdown"), Path.build_filename (Config.PKGDATADIR, "shutdown.png"), Path.build_filename (Config.PKGDATADIR, "shutdown_highlight.png"));
136 button.clicked.connect (() =>
137 {
138 try
139 {
140 LightDM.shutdown ();
141 close ();
142 }
143 catch (Error e)
144 {
145 warning ("Failed to shutdown: %s", e.message);
146 }
147 });
148 }
149
150 close_button = new DialogButton (Path.build_filename (Config.PKGDATADIR, "dialog_close.png"), Path.build_filename (Config.PKGDATADIR, "dialog_close_highlight.png"));
151 close_button.can_focus = false;
152 close_button.clicked.connect (() => { close (); });
153 close_button.visible = true;
154 add (close_button);
155 }
156
157 public void focus_next ()
158 {
159 (get_toplevel () as Gtk.Window).move_focus (Gtk.DirectionType.TAB_FORWARD);
160 }
161
162 public void focus_prev ()
163 {
164 (get_toplevel () as Gtk.Window).move_focus (Gtk.DirectionType.TAB_BACKWARD);
165 }
166
167 public void cancel ()
168 {
169 var widget = (get_toplevel () as Gtk.Window).get_focus ();
170 if (widget is DialogButton)
171 (get_toplevel () as Gtk.Window).set_focus (null);
172 else
173 close ();
174 }
175
176 public override void size_allocate (Gtk.Allocation allocation)
177 {
178 base.size_allocate (allocation);
179
180 var content_allocation = Gtk.Allocation ();
181 int minimum_width, natural_width, minimum_height, natural_height;
182 vbox.get_preferred_width (out minimum_width, out natural_width);
183 vbox.get_preferred_height_for_width (minimum_width, out minimum_height, out natural_height);
184 content_allocation.x = allocation.x + (allocation.width - minimum_width) / 2;
185 content_allocation.y = allocation.y + (allocation.height - minimum_height) / 2;
186 content_allocation.width = minimum_width;
187 content_allocation.height = minimum_height;
188 vbox.size_allocate (content_allocation);
189
190 var a = Gtk.Allocation ();
191 close_button.get_preferred_width (out minimum_width, out natural_width);
192 close_button.get_preferred_height (out minimum_height, out natural_height);
193 a.x = content_allocation.x - BORDER_SIZE + CLOSE_OFFSET;
194 a.y = content_allocation.y - BORDER_SIZE + CLOSE_OFFSET;
195 a.width = minimum_width;
196 a.height = minimum_height;
197 close_button.size_allocate (a);
198 }
199
200 public override bool draw (Cairo.Context c)
201 {
202 if (corner_surface == null)
203 {
204 corner_surface = new Cairo.ImageSurface.from_png (Path.build_filename (Config.PKGDATADIR, "switcher_corner.png"));
205 left_surface = new Cairo.ImageSurface.from_png (Path.build_filename (Config.PKGDATADIR, "switcher_left.png"));
206 top_surface = new Cairo.ImageSurface.from_png (Path.build_filename (Config.PKGDATADIR, "switcher_top.png"));
207 corner_pattern = new Cairo.Pattern.for_surface (corner_surface);
208 left_pattern = new Cairo.Pattern.for_surface (left_surface);
209 left_pattern.set_extend (Cairo.Extend.REPEAT);
210 top_pattern = new Cairo.Pattern.for_surface (top_surface);
211 top_pattern.set_extend (Cairo.Extend.REPEAT);
212 }
213
214 var width = vbox.get_allocated_width () + 20 * 2 + BORDER_SIZE * 2;
215 var height = vbox.get_allocated_height () + 20 * 2 + BORDER_SIZE * 2;
216
217 /* Darken background */
218 c.set_source_rgba (0, 0, 0, 0.25);
219 c.paint ();
220
221 /* Draw dialog */
222 c.save ();
223 c.translate ((get_allocated_width () - width) * 0.5, (get_allocated_height () - height) * 0.5);
224
225 /* Top left */
226 var m = Cairo.Matrix.identity ();
227 corner_pattern.set_matrix (m);
228 c.set_source (corner_pattern);
229 c.rectangle (0, 0, BORDER_SIZE, BORDER_SIZE);
230 c.fill ();
231
232 /* Top right */
233 m = Cairo.Matrix.identity ();
234 m.translate (width, 0);
235 m.scale (-1, 1);
236 corner_pattern.set_matrix (m);
237 c.set_source (corner_pattern);
238 c.rectangle (width - BORDER_SIZE, 0, BORDER_SIZE, BORDER_SIZE);
239 c.fill ();
240
241 /* Bottom left */
242 m = Cairo.Matrix.identity ();
243 m.translate (0, height);
244 m.scale (1, -1);
245 corner_pattern.set_matrix (m);
246 c.set_source (corner_pattern);
247 c.rectangle (0, height - BORDER_SIZE, BORDER_SIZE, BORDER_SIZE);
248 c.fill ();
249
250 /* Bottom right */
251 m = Cairo.Matrix.identity ();
252 m.translate (width, height);
253 m.scale (-1, -1);
254 corner_pattern.set_matrix (m);
255 c.set_source (corner_pattern);
256 c.rectangle (width - BORDER_SIZE, height - BORDER_SIZE, BORDER_SIZE, BORDER_SIZE);
257 c.fill ();
258
259 /* Left */
260 m = Cairo.Matrix.identity ();
261 left_pattern.set_matrix (m);
262 c.set_source (left_pattern);
263 c.rectangle (0, BORDER_SIZE, BORDER_SIZE, height - BORDER_SIZE * 2);
264 c.fill ();
265
266 /* Right */
267 m = Cairo.Matrix.identity ();
268 m.translate (width, 0);
269 m.scale (-1, 1);
270 left_pattern.set_matrix (m);
271 c.set_source (left_pattern);
272 c.rectangle (width - BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, height - BORDER_SIZE * 2);
273 c.fill ();
274
275 /* Top */
276 m = Cairo.Matrix.identity ();
277 top_pattern.set_matrix (m);
278 c.set_source (top_pattern);
279 c.rectangle (BORDER_SIZE, 0, width - BORDER_SIZE * 2, BORDER_SIZE);
280 c.fill ();
281
282 /* Right */
283 m = Cairo.Matrix.identity ();
284 m.translate (0, height);
285 m.scale (1, -1);
286 top_pattern.set_matrix (m);
287 c.set_source (top_pattern);
288 c.rectangle (BORDER_SIZE, height - BORDER_SIZE, width - BORDER_SIZE * 2, BORDER_SIZE);
289 c.fill ();
290
291 /* Background */
292 DashBox.cairo_rounded_rectangle (c, 20, 20, width - 40, height - 40, 5);
293 c.set_source_rgba (0, 0, 0, 0.75);
294 c.fill ();
295
296 c.restore ();
297
298 return base.draw (c);
299 }
300
301 public override bool button_press_event (Gdk.EventButton event)
302 {
303 /* Close when selecting the background */
304 // FIXME: Broken..
305 close ();
306 return true;
307 }
308
309 private DialogButton add_button (string text, string inactive_filename, string active_filename)
310 {
311 var b = new Gtk.Box (Gtk.Orientation.VERTICAL, 9);
312 b.visible = true;
313 button_box.pack_start (b, false, false, 0);
314
315 var label = new Gtk.Label (text);
316 label.visible = true;
317 label.override_font (Pango.FontDescription.from_string ("Ubuntu Light 12"));
318 label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 0.0f });
319 var button = new DialogButton (inactive_filename, active_filename, label);
320 button.visible = true;
321
322 b.pack_start (button, false, false, 0);
323 b.pack_start (label, false, false, 0);
324
325 return button;
326 }
327}
328
329private class DialogButton : Gtk.Button
330{
331 private string inactive_filename;
332 private string active_filename;
333 private Gtk.Image i;
334 private Gtk.Label? l;
335
336 public DialogButton (string inactive_filename, string active_filename, Gtk.Label? label = null)
337 {
338 this.inactive_filename = inactive_filename;
339 this.active_filename = active_filename;
340 l = label;
341 relief = Gtk.ReliefStyle.NONE;
342 focus_on_click = false;
343 i = new Gtk.Image.from_file (inactive_filename);
344 i.visible = true;
345 add (i);
346 }
347
348 public override bool enter_notify_event (Gdk.EventCrossing event)
349 {
350 grab_focus ();
351 return base.enter_notify_event (event);
352 }
353
354 public override bool leave_notify_event (Gdk.EventCrossing event)
355 {
356 (get_toplevel () as Gtk.Window).set_focus (null);
357 return base.leave_notify_event (event);
358 }
359
360 public override bool focus_in_event (Gdk.EventFocus event)
361 {
362 i.set_from_file (active_filename);
363 if (l != null)
364 l.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
365 return base.focus_in_event (event);
366 }
367
368 public override bool focus_out_event (Gdk.EventFocus event)
369 {
370 i.set_from_file (inactive_filename);
371 if (l != null)
372 l.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 0.0f });
373 return base.focus_out_event (event);
374 }
375
376 public override bool draw (Cairo.Context c)
377 {
378 i.draw (c);
379 return true;
380 }
381}
0382
=== modified file 'src/unity-greeter.vala'
--- src/unity-greeter.vala 2013-10-02 17:46:49 +0000
+++ src/unity-greeter.vala 2013-11-05 04:29:38 +0000
@@ -46,6 +46,8 @@
4646
47 private static Timer log_timer;47 private static Timer log_timer;
4848
49 private DialogDBusInterface dbus_object;
50
49 private UnityGreeter (bool test_mode_)51 private UnityGreeter (bool test_mode_)
50 {52 {
51 singleton = this;53 singleton = this;
@@ -98,6 +100,38 @@
98100
99 main_window = new MainWindow ();101 main_window = new MainWindow ();
100102
103 dbus_object = new DialogDBusInterface ();
104 dbus_object.open_dialog.connect ((type) =>
105 {
106 ShutdownDialogType dialog_type;
107 switch (type)
108 {
109 default:
110 case 1:
111 dialog_type = ShutdownDialogType.LOGOUT;
112 break;
113 case 2:
114 dialog_type = ShutdownDialogType.RESTART;
115 break;
116 }
117 main_window.show_shutdown_dialog (dialog_type);
118 });
119 dbus_object.close_dialog.connect ((type) => { main_window.close_shutdown_dialog (); });
120 Bus.own_name (BusType.SESSION, "com.canonical.Unity", BusNameOwnerFlags.NONE,
121 (c) =>
122 {
123 try
124 {
125 c.register_object ("/org/gnome/SessionManager/EndSessionDialog", dbus_object);
126 }
127 catch (Error e)
128 {
129 warning ("Failed to register /org/gnome/SessionManager/EndSessionDialog: %s", e.message);
130 }
131 },
132 null,
133 () => debug ("Failed to acquire name com.canonical.Unity"));
134
101 start_fake_wm ();135 start_fake_wm ();
102 Gdk.threads_add_idle (ready_cb);136 Gdk.threads_add_idle (ready_cb);
103 }137 }
@@ -535,3 +569,20 @@
535 return Posix.EXIT_SUCCESS;569 return Posix.EXIT_SUCCESS;
536 }570 }
537}571}
572
573[DBus (name="org.gnome.SessionManager.EndSessionDialog")]
574public class DialogDBusInterface : Object
575{
576 public signal void open_dialog (uint32 type);
577 public signal void close_dialog ();
578
579 public void open (uint32 type, uint32 timestamp, uint32 seconds_to_stay_open, ObjectPath[] inhibitor_object_paths)
580 {
581 open_dialog (type);
582 }
583
584 public void close ()
585 {
586 close_dialog ();
587 }
588}
538589
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2013-10-17 22:09:16 +0000
+++ tests/Makefile.am 2013-11-05 04:29:38 +0000
@@ -34,7 +34,8 @@
34 ../src/session-list.vala \34 ../src/session-list.vala \
35 ../src/main-window.vala \35 ../src/main-window.vala \
36 ../src/list-stack.vala \36 ../src/list-stack.vala \
37 ../src/settings.vala37 ../src/settings.vala \
38 ../src/shutdown-dialog.vala
3839
3940
40unity_greeter_test_CFLAGS = \41unity_greeter_test_CFLAGS = \

Subscribers

People subscribed via source and target branches