Merge lp:~robert-ancell/unity-greeter/shutdown-session-warning into lp:unity-greeter

Proposed by Robert Ancell on 2014-03-26
Status: Merged
Merged at revision: 1179
Proposed branch: lp:~robert-ancell/unity-greeter/shutdown-session-warning
Merge into: lp:unity-greeter
Diff against target: 64 lines (+32/-0)
3 files modified
src/fixes.vapi (+1/-0)
src/main-window.vala (+7/-0)
src/shutdown-dialog.vala (+24/-0)
To merge this branch: bzr merge lp:~robert-ancell/unity-greeter/shutdown-session-warning
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2014-03-26
Robert Ancell Approve on 2014-03-26
Review via email: mp+212949@code.launchpad.net

Commit message

Show a warning when shutting down and users are logged in

To post a comment you must log in.
review: Approve
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/fixes.vapi'
2--- src/fixes.vapi 2013-11-13 22:19:41 +0000
3+++ src/fixes.vapi 2014-03-26 20:46:52 +0000
4@@ -52,6 +52,7 @@
5 public const int KEY_M;
6 public const int KEY_s;
7 public const int KEY_z;
8+ public const int KEY_Z;
9 public const int KEY_plus;
10 public const int KEY_minus;
11 public const int KEY_equal;
12
13=== modified file 'src/main-window.vala'
14--- src/main-window.vala 2014-02-27 04:53:21 +0000
15+++ src/main-window.vala 2014-03-26 20:46:52 +0000
16@@ -335,6 +335,13 @@
17 return true;
18 }
19 break;
20+ case Gdk.KEY_Z:
21+ if (UnityGreeter.singleton.test_mode && (event.state & Gdk.ModifierType.MOD1_MASK) != 0)
22+ {
23+ show_shutdown_dialog (ShutdownDialogType.RESTART);
24+ return true;
25+ }
26+ break;
27 }
28
29 return base.key_press_event (event);
30
31=== modified file 'src/shutdown-dialog.vala'
32--- src/shutdown-dialog.vala 2014-02-16 22:15:43 +0000
33+++ src/shutdown-dialog.vala 2014-03-26 20:46:52 +0000
34@@ -112,6 +112,30 @@
35 text = _("Are you sure you want to shut down the computer?");
36 }
37
38+ var have_open_sessions = false;
39+ try
40+ {
41+ var b = Bus.get_sync (BusType.SYSTEM);
42+ var result = b.call_sync ("org.freedesktop.DisplayManager",
43+ "/org/freedesktop/DisplayManager",
44+ "org.freedesktop.DBus.Properties",
45+ "Get",
46+ new Variant ("(ss)", "org.freedesktop.DisplayManager", "Sessions"),
47+ new VariantType ("(v)"),
48+ DBusCallFlags.NONE,
49+ -1,
50+ null);
51+ Variant value;
52+ result.get ("(v)", out value);
53+ have_open_sessions = value.n_children () > 0;
54+ }
55+ catch (Error e)
56+ {
57+ warning ("Failed to check sessions from logind: %s", e.message);
58+ }
59+ if (have_open_sessions)
60+ text = "%s\n\n%s".printf (_("Other users are currently logged in to this computer, shutting down now will also close these other sessions."), text);
61+
62 var label = new Gtk.Label (text);
63 label.set_line_wrap (true);
64 label.override_font (Pango.FontDescription.from_string ("Ubuntu Light 12"));

Subscribers

People subscribed via source and target branches