Merge lp:~robert-ancell/indicator-session/lp-861171 into lp:indicator-session/13.04

Proposed by Robert Ancell
Status: Work in progress
Proposed branch: lp:~robert-ancell/indicator-session/lp-861171
Merge into: lp:indicator-session/13.04
Diff against target: 183 lines (+99/-9)
2 files modified
src/dialog.c (+69/-2)
src/gtk-logout-helper.c (+30/-7)
To merge this branch: bzr merge lp:~robert-ancell/indicator-session/lp-861171
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Needs Resubmitting
Matthew Paul Thomas (community) design Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+137085@code.launchpad.net
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

The code looks fine, but I'd like to get mpt to weigh in on the UI change...

Revision history for this message
Sebastien Bacher (seb128) wrote :

(sorry, changed the status on the wrong one)

Revision history for this message
Matthew Paul Thomas (mpt) wrote :

> +/* TRANSLATORS: This button appears on the logout dialog when
> + there are other users logged in. It will do a log out
> + in place of a restart / shutdown. */

That can't be right: there's already a Log Out button in the Log Out dialog. Did you mean "in the Restart and Shut Down dialogs"?

> +static const gchar * restart_other_session = N_("You need to close all sessions before restarting.");
> +static const gchar * shutdown_other_session = N_("You need to close all sessions before shutting down.");

Very few people will understand what "close all sessions" means. And even to those who do, it may seem like misdirection. Because if it it was reworded in plain language -- for example, "Two other accounts are logged in. They need to log out before the computer can restart." -- it would become obvious that Ubuntu is being unhelpful by not letting you just click a button to do that.

> + _("Ok"), GTK_RESPONSE_CANCEL,

Buttons should always use "OK", not "Ok". If you had used a stock GTK_OK button, that mistake wouldn't have happened.

review: Disapprove (design)
378. By Robert Ancell

Merge with trunk

379. By Robert Ancell

Fix incorrect translator comment

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
380. By Robert Ancell

Update dialogs to match design

381. By Robert Ancell

Remove debugging

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Allan LeSage (allanlesage) wrote :

Robert, sorry that Jenkins' Coverity scans are making a bit of a fuss above--I'll disable for the moment, please carry on :) .

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
382. By Robert Ancell

Remove unused additional reponse handlers

383. By Robert Ancell

Call ConsoleKit directly when force shutdown/restart

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
James M. Leddy (jm-leddy) wrote :

Hi Mathew, is Robert's redesign any better?

Revision history for this message
Matthew Paul Thomas (mpt) wrote :

Sorry, I missed the notification about this. Thanks to Lars Uebernickel for the screenshots: http://imgur.com/z5Ppeq8 http://imgur.com/K3CzMrV

The "Log Out Instead" button has different spacing in the two, but otherwise that looks good. Thanks Robert!

review: Approve (design)
Revision history for this message
James M. Leddy (jm-leddy) wrote :

This is neither here nor there, but it looks to me that the reason the buttons are different sizes is because all of the buttons are the same size by default, and "Shut Down Anyway" is longer than "Restart Anyway", so the size of the "Cancel" and "Log Out Instead" buttons are different.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

I'm assuming this all needs updating now we have the new logout dialogs?

Revision history for this message
Sebastien Bacher (seb128) wrote :

@Robert: the current dialog is still used out of unity (e.g in unity-greeter or gnome classic) and we are pondering reverting the unity dialogs for raring (there are several issues with those), so in any case it would be good to land those. If you are happy with the code I can file the FFe tomorrow

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Let's resubmit this against lp:indicator-session.

review: Needs Resubmitting

Unmerged revisions

383. By Robert Ancell

Call ConsoleKit directly when force shutdown/restart

382. By Robert Ancell

Remove unused additional reponse handlers

381. By Robert Ancell

Remove debugging

380. By Robert Ancell

Update dialogs to match design

379. By Robert Ancell

Fix incorrect translator comment

378. By Robert Ancell

Merge with trunk

377. By Robert Ancell

Don't allow shutdown/restart when other sessions are open

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dialog.c'
2--- src/dialog.c 2012-10-03 19:35:57 +0000
3+++ src/dialog.c 2013-01-11 04:02:22 +0000
4@@ -64,6 +64,17 @@
5 static const gchar * restart_auth = N_("Restart Instead…");
6 static const gchar * body_logout_update = N_("Some software updates won’t apply until the computer next restarts.");
7
8+/* TRANSLATORS: This button appears on the restart/shutdown dialog when
9+ there are other users logged in. It will do a log out
10+ in place of a restart / shutdown. */
11+static const gchar * other_session = N_("Log Out Instead");
12+static const gchar * restart_other_session = N_("Other users are logged in. Restarting the computer will log them out without warning.");
13+static const gchar * restart_greeter_other_session = N_("Other users are logged in. You must log out these sessions before restarting.");
14+static const gchar * shutdown_other_session = N_("Other users are logged in. Shutting down the computer will log them out without warning.");
15+static const gchar * shutdown_greeter_other_session = N_("Other users are logged in. You must log out these sessions before shutting down.");
16+static const gchar * restart_anyway = N_("Restart Anyway");
17+static const gchar * shutdown_anyway = N_("Shut Down Anyway");
18+
19 static const gchar * icon_strings[LOGOUT_DIALOG_TYPE_CNT] = {
20 /* LOGOUT_DIALOG_LOGOUT, */ "system-log-out",
21 /* LOGOUT_DIALOG_RESTART, */ "system-restart",
22@@ -164,10 +175,42 @@
23 return allowed;
24 }
25
26+/* Checks with console kit how many sessions are open */
27+static guint
28+ck_get_n_sessions (void)
29+{
30+ gchar **sessions = NULL;
31+ guint n_sessions = 0;
32+
33+ ConsoleKitManager * ck_proxy = console_kit_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
34+ G_DBUS_PROXY_FLAGS_NONE,
35+ "org.freedesktop.ConsoleKit",
36+ "/org/freedesktop/ConsoleKit/Manager",
37+ NULL,
38+ NULL);
39+ if (ck_proxy != NULL)
40+ {
41+ console_kit_manager_call_get_sessions_sync (ck_proxy, &sessions, NULL, NULL);
42+ n_sessions = g_strv_length (sessions);
43+
44+ g_object_unref (ck_proxy);
45+ }
46+
47+ return n_sessions;
48+}
49+
50+static inline gboolean
51+is_greeter_mode (void)
52+{
53+ return !g_strcmp0 (g_getenv ("INDICATOR_GREETER_MODE"), "1");
54+}
55+
56 LogoutDialog *
57 logout_dialog_new (LogoutDialogType type)
58 {
59- GtkWidget * image = gtk_image_new_from_icon_name(icon_strings[type], GTK_ICON_SIZE_DIALOG);
60+ guint n_sessions = ck_get_n_sessions ();
61+
62+ GtkWidget * image = gtk_image_new_from_icon_name(n_sessions > 1 ? GTK_STOCK_DIALOG_WARNING : icon_strings[type], GTK_ICON_SIZE_DIALOG);
63 gtk_widget_show(image);
64
65 LogoutDialog * dialog = LOGOUT_DIALOG(g_object_new(LOGOUT_DIALOG_TYPE,
66@@ -205,7 +248,31 @@
67 button_text = g_dpgettext2 (NULL, "button auth", button_auth_strings[type]);
68 }
69
70- if (restart_required) {
71+ if ((type == LOGOUT_DIALOG_TYPE_RESTART || type == LOGOUT_DIALOG_TYPE_SHUTDOWN) && n_sessions > 1) {
72+ if (!is_greeter_mode ()) {
73+ if (type == LOGOUT_DIALOG_TYPE_RESTART) {
74+ g_object_set(dialog, "text", _(restart_other_session), NULL);
75+ button_text = _(restart_anyway);
76+ } else {
77+ g_object_set(dialog, "text", _(shutdown_other_session), NULL);
78+ button_text = _(shutdown_anyway);
79+ }
80+ gtk_dialog_add_buttons(GTK_DIALOG(dialog),
81+ _(other_session), GTK_RESPONSE_HELP,
82+ _("Cancel"), GTK_RESPONSE_CANCEL,
83+ button_text, GTK_RESPONSE_YES,
84+ NULL);
85+ } else {
86+ if (type == LOGOUT_DIALOG_TYPE_RESTART) {
87+ g_object_set(dialog, "text", _(restart_greeter_other_session), NULL);
88+ } else {
89+ g_object_set(dialog, "text", _(shutdown_greeter_other_session), NULL);
90+ }
91+ gtk_dialog_add_buttons(GTK_DIALOG(dialog),
92+ GTK_STOCK_OK, GTK_RESPONSE_CANCEL,
93+ NULL);
94+ }
95+ } else if (restart_required) {
96 const gchar * restart_req;
97 if (allowed) {
98 restart_req = restart_updates;
99
100=== modified file 'src/gtk-logout-helper.c'
101--- src/gtk-logout-helper.c 2012-11-29 22:09:57 +0000
102+++ src/gtk-logout-helper.c 2013-01-11 04:02:22 +0000
103@@ -124,7 +124,7 @@
104 }
105
106 static void
107-session_action (LogoutDialogType action)
108+session_action (LogoutDialogType action, gboolean force)
109 {
110 GError * error = NULL;
111 GVariant *result = NULL;
112@@ -133,11 +133,21 @@
113 g_debug("Asking Session manager to 'Logout'");
114 result = call_gnome_session ("Logout", g_variant_new ("(u)", 1), &error);
115 } else if (action == LOGOUT_DIALOG_TYPE_SHUTDOWN) {
116- g_debug("Asking Session manager to 'RequestShutdown'");
117- result = call_gnome_session ("RequestShutdown", g_variant_new ("()"), &error);
118+ if (force) {
119+ consolekit_fallback(action);
120+ return;
121+ } else {
122+ g_debug("Asking Session manager to 'RequestShutdown'");
123+ result = call_gnome_session ("RequestShutdown", g_variant_new ("()"), &error);
124+ }
125 } else if (action == LOGOUT_DIALOG_TYPE_RESTART) {
126- g_debug("Asking Session manager to 'RequestReboot'");
127- result = call_gnome_session ("RequestReboot", g_variant_new ("()"), &error);
128+ if (force) {
129+ consolekit_fallback(action);
130+ return;
131+ } else {
132+ g_debug("Asking Session manager to 'RequestReboot'");
133+ result = call_gnome_session ("RequestReboot", g_variant_new ("()"), &error);
134+ }
135 } else {
136 g_warning ("Unknown session action");
137 }
138@@ -236,12 +246,15 @@
139 dialog = GTK_WIDGET(logout_dialog_new(type));
140 }
141
142+ gboolean force = FALSE;
143 if (dialog != NULL) {
144 GtkResponseType response = gtk_dialog_run(GTK_DIALOG(dialog));
145 gtk_widget_hide(dialog);
146
147 if (response == GTK_RESPONSE_OK) {
148 g_debug("Dialog return response: 'okay'");
149+ } else if (response == GTK_RESPONSE_YES) {
150+ g_debug("Dialog return response: 'yes'");
151 } else if (response == GTK_RESPONSE_HELP) {
152 g_debug("Dialog return response: 'help'");
153 } else {
154@@ -249,17 +262,27 @@
155 }
156
157 if (response == GTK_RESPONSE_HELP) {
158- type = LOGOUT_DIALOG_TYPE_RESTART;
159+ if (type == LOGOUT_DIALOG_TYPE_LOG_OUT)
160+ type = LOGOUT_DIALOG_TYPE_RESTART;
161+ else
162+ type = LOGOUT_DIALOG_TYPE_LOG_OUT;
163 response = GTK_RESPONSE_OK;
164 }
165
166+ /* If we know we're going to need PolicyKit authorization then call ConsoleKit directly
167+ * rather than using Gnome session - it will just log us out instead and not prompt */
168+ if (response == GTK_RESPONSE_YES) {
169+ response = GTK_RESPONSE_OK;
170+ force = TRUE;
171+ }
172+
173 if (response != GTK_RESPONSE_OK) {
174 g_debug("Final response was not okay, quiting");
175 return 0;
176 }
177 }
178
179- session_action(type);
180+ session_action(type, force);
181 g_debug("Finished action, quiting");
182
183 return 0;

Subscribers

People subscribed via source and target branches