Merge lp:~fabiozaramella/slingshot/add-logout-lock-actions into lp:~elementary-pantheon/slingshot/trunk

Proposed by Fabio Zaramella on 2017-01-31
Status: Merged
Approved by: Daniel Fore on 2017-01-31
Approved revision: 730
Merged at revision: 729
Proposed branch: lp:~fabiozaramella/slingshot/add-logout-lock-actions
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 557 lines (+198/-139)
2 files modified
lib/synapse-plugins/system-managment.vala (+90/-49)
po/slingshot.pot (+108/-90)
To merge this branch: bzr merge lp:~fabiozaramella/slingshot/add-logout-lock-actions
Reviewer Review Type Date Requested Status
Daniel Fore 2017-01-31 Approve on 2017-01-31
Review via email: mp+316022@code.launchpad.net

Commit message

Add lock and logout actions

Description of the change

This branch adds logout and lock actions.

To post a comment you must log in.
Daniel Fore (danrabbit) wrote :

Instead of "Lock your computer", we should probably use device-agnostic terms and avoid questions about formal/informal "you" in translations with "Lock this device".

Daniel Fore (danrabbit) wrote :

I can confirm that both the lock and logout functions work as expected. Nice work :)

review: Approve
730. By Fabio Zaramella on 2017-01-31

Use correct terminology

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/synapse-plugins/system-managment.vala'
2--- lib/synapse-plugins/system-managment.vala 2017-01-26 19:54:30 +0000
3+++ lib/synapse-plugins/system-managment.vala 2017-01-31 18:58:37 +0000
4@@ -45,6 +45,23 @@
5 public abstract async bool can_stop () throws IOError;
6 }
7
8+ [DBus (name = "org.freedesktop.ScreenSaver")]
9+ public interface LockObject : Object {
10+ public const string UNIQUE_NAME = "org.freedesktop.ScreenSaver";
11+ public const string OBJECT_PATH = "/org/freedesktop/ScreenSaver";
12+
13+ public abstract void lock () throws IOError;
14+ public abstract bool get_active () throws IOError;
15+ }
16+
17+ [DBus (name = "org.freedesktop.login1.User")]
18+ interface LogOutObject : Object {
19+ public const string UNIQUE_NAME = "org.freedesktop.login1";
20+ public const string OBJECT_PATH = "/org/freedesktop/login1/user/self";
21+
22+ public abstract void terminate () throws IOError;
23+ }
24+
25 [DBus (name = "org.freedesktop.login1.Manager")]
26 public interface SystemdObject : Object {
27 public const string UNIQUE_NAME = "org.freedesktop.login1";
28@@ -85,6 +102,60 @@
29 }
30 }
31
32+ private class LockAction : SystemAction {
33+ public LockAction () {
34+ Object (title: _("Lock"), match_type: MatchType.ACTION,
35+ description: _("Lock this device"),
36+ icon_name: "system-lock-screen", has_thumbnail: false);
37+ }
38+
39+ public override bool action_allowed () {
40+ return true;
41+ }
42+
43+ private async void do_lock () {
44+ try {
45+ LockObject dbus_interface = Bus.get_proxy_sync (BusType.SESSION, LockObject.UNIQUE_NAME, LockObject.OBJECT_PATH);
46+
47+ dbus_interface.lock ();
48+ return;
49+ } catch (IOError err) {
50+ warning ("%s", err.message);
51+ }
52+ }
53+
54+ public override void do_action () {
55+ do_lock.begin ();
56+ }
57+ }
58+
59+ private class LogOutAction : SystemAction {
60+ public LogOutAction () {
61+ Object (title: _("Log Out"), match_type: MatchType.ACTION,
62+ description: _("Close all open applications and quit"),
63+ icon_name: "system-log-out", has_thumbnail: false);
64+ }
65+
66+ public override bool action_allowed () {
67+ return true;
68+ }
69+
70+ private async void do_log_out () {
71+ try {
72+ LogOutObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, LogOutObject.UNIQUE_NAME, LogOutObject.OBJECT_PATH);
73+
74+ dbus_interface.terminate ();
75+ return;
76+ } catch (IOError err) {
77+ warning ("%s", err.message);
78+ }
79+ }
80+
81+ public override void do_action () {
82+ do_log_out.begin ();
83+ }
84+ }
85+
86 private class SuspendAction : SystemAction {
87 public SuspendAction () {
88 Object (title: _("Suspend"), match_type: MatchType.ACTION,
89@@ -98,9 +169,7 @@
90
91 private async void check_allowed (){
92 try {
93- SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
94- SystemdObject.UNIQUE_NAME,
95- SystemdObject.OBJECT_PATH);
96+ SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, SystemdObject.UNIQUE_NAME, SystemdObject.OBJECT_PATH);
97
98 allowed = (dbus_interface.can_suspend () == "yes");
99 return;
100@@ -110,9 +179,7 @@
101 }
102
103 try {
104- UPowerObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
105- UPowerObject.UNIQUE_NAME,
106- UPowerObject.OBJECT_PATH);
107+ UPowerObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, UPowerObject.UNIQUE_NAME, UPowerObject.OBJECT_PATH);
108
109 allowed = yield dbus_interface.suspend_allowed ();
110 } catch (IOError err) {
111@@ -129,9 +196,7 @@
112
113 private async void do_suspend () {
114 try {
115- SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
116- SystemdObject.UNIQUE_NAME,
117- SystemdObject.OBJECT_PATH);
118+ SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, SystemdObject.UNIQUE_NAME, SystemdObject.OBJECT_PATH);
119
120 dbus_interface.suspend (true);
121 return;
122@@ -140,9 +205,7 @@
123 }
124
125 try {
126- UPowerObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
127- UPowerObject.UNIQUE_NAME,
128- UPowerObject.OBJECT_PATH);
129+ UPowerObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, UPowerObject.UNIQUE_NAME, UPowerObject.OBJECT_PATH);
130
131 try {
132 yield dbus_interface.about_to_sleep ();
133@@ -177,9 +240,7 @@
134
135 private async void check_allowed () {
136 try {
137- SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
138- SystemdObject.UNIQUE_NAME,
139- SystemdObject.OBJECT_PATH);
140+ SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, SystemdObject.UNIQUE_NAME, SystemdObject.OBJECT_PATH);
141
142 allowed = (dbus_interface.can_hibernate () == "yes");
143 return;
144@@ -189,9 +250,7 @@
145 }
146
147 try {
148- UPowerObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
149- UPowerObject.UNIQUE_NAME,
150- UPowerObject.OBJECT_PATH);
151+ UPowerObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, UPowerObject.UNIQUE_NAME, UPowerObject.OBJECT_PATH);
152
153 allowed = yield dbus_interface.hibernate_allowed ();
154 } catch (IOError err) {
155@@ -208,9 +267,7 @@
156
157 private async void do_hibernate () {
158 try {
159- SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
160- SystemdObject.UNIQUE_NAME,
161- SystemdObject.OBJECT_PATH);
162+ SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, SystemdObject.UNIQUE_NAME, SystemdObject.OBJECT_PATH);
163
164 dbus_interface.hibernate (true);
165 return;
166@@ -219,9 +276,7 @@
167 }
168
169 try {
170- UPowerObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
171- UPowerObject.UNIQUE_NAME,
172- UPowerObject.OBJECT_PATH);
173+ UPowerObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, UPowerObject.UNIQUE_NAME, UPowerObject.OBJECT_PATH);
174
175 try {
176 yield dbus_interface.about_to_sleep ();
177@@ -255,9 +310,7 @@
178
179 private async void check_allowed () {
180 try {
181- SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
182- SystemdObject.UNIQUE_NAME,
183- SystemdObject.OBJECT_PATH);
184+ SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, SystemdObject.UNIQUE_NAME, SystemdObject.OBJECT_PATH);
185
186 allowed = (dbus_interface.can_power_off () == "yes");
187 return;
188@@ -267,9 +320,7 @@
189 }
190
191 try {
192- ConsoleKitObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
193- ConsoleKitObject.UNIQUE_NAME,
194- ConsoleKitObject.OBJECT_PATH);
195+ ConsoleKitObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, ConsoleKitObject.UNIQUE_NAME, ConsoleKitObject.OBJECT_PATH);
196
197 allowed = yield dbus_interface.can_stop ();
198 } catch (IOError err) {
199@@ -286,9 +337,7 @@
200
201 public override void do_action () {
202 try {
203- SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
204- SystemdObject.UNIQUE_NAME,
205- SystemdObject.OBJECT_PATH);
206+ SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, SystemdObject.UNIQUE_NAME, SystemdObject.OBJECT_PATH);
207
208 dbus_interface.power_off (true);
209 return;
210@@ -297,9 +346,7 @@
211 }
212
213 try {
214- ConsoleKitObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
215- ConsoleKitObject.UNIQUE_NAME,
216- ConsoleKitObject.OBJECT_PATH);
217+ ConsoleKitObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, ConsoleKitObject.UNIQUE_NAME, ConsoleKitObject.OBJECT_PATH);
218
219 dbus_interface.stop ();
220 } catch (IOError err) {
221@@ -321,9 +368,7 @@
222
223 private async void check_allowed () {
224 try {
225- SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
226- SystemdObject.UNIQUE_NAME,
227- SystemdObject.OBJECT_PATH);
228+ SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, SystemdObject.UNIQUE_NAME, SystemdObject.OBJECT_PATH);
229
230 allowed = (dbus_interface.can_reboot () == "yes");
231 return;
232@@ -333,9 +378,7 @@
233 }
234
235 try {
236- ConsoleKitObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
237- ConsoleKitObject.UNIQUE_NAME,
238- ConsoleKitObject.OBJECT_PATH);
239+ ConsoleKitObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, ConsoleKitObject.UNIQUE_NAME, ConsoleKitObject.OBJECT_PATH);
240
241 allowed = yield dbus_interface.can_restart ();
242 } catch (IOError err) {
243@@ -352,9 +395,7 @@
244
245 public override void do_action () {
246 try {
247- SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
248- SystemdObject.UNIQUE_NAME,
249- SystemdObject.OBJECT_PATH);
250+ SystemdObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, SystemdObject.UNIQUE_NAME, SystemdObject.OBJECT_PATH);
251
252 dbus_interface.reboot (true);
253 return;
254@@ -363,9 +404,7 @@
255 }
256
257 try {
258- ConsoleKitObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM,
259- ConsoleKitObject.UNIQUE_NAME,
260- ConsoleKitObject.OBJECT_PATH);
261+ ConsoleKitObject dbus_interface = Bus.get_proxy_sync (BusType.SYSTEM, ConsoleKitObject.UNIQUE_NAME, ConsoleKitObject.OBJECT_PATH);
262
263 dbus_interface.restart ();
264 } catch (IOError err) {
265@@ -377,7 +416,7 @@
266 static void register_plugin () {
267 DataSink.PluginRegistry.get_default ().register_plugin (typeof (SystemManagementPlugin),
268 "System Management",
269- _("Suspend, hibernate, restart or shutdown your computer."),
270+ _("Lock the session or Log Out from it. Suspend, hibernate, restart or shutdown your computer."),
271 "system-restart",
272 register_plugin,
273 DBusService.get_default ().service_is_available (SystemdObject.UNIQUE_NAME) ||
274@@ -393,6 +432,8 @@
275
276 construct {
277 actions = new Gee.LinkedList<SystemAction> ();
278+ actions.add (new LockAction ());
279+ actions.add (new LogOutAction ());
280 actions.add (new SuspendAction ());
281 actions.add (new HibernateAction ());
282 actions.add (new ShutdownAction ());
283
284=== modified file 'po/slingshot.pot'
285--- po/slingshot.pot 2017-01-24 20:34:49 +0000
286+++ po/slingshot.pot 2017-01-31 18:58:37 +0000
287@@ -8,7 +8,7 @@
288 msgstr ""
289 "Project-Id-Version: PACKAGE VERSION\n"
290 "Report-Msgid-Bugs-To: \n"
291-"POT-Creation-Date: 2017-01-24 21:34+0100\n"
292+"POT-Creation-Date: 2017-01-31 19:56+0100\n"
293 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
294 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
295 "Language-Team: LANGUAGE <LL@li.org>\n"
296@@ -17,6 +17,18 @@
297 "Content-Type: text/plain; charset=UTF-8\n"
298 "Content-Transfer-Encoding: 8bit\n"
299
300+#: ../src/Slingshot.vala:31
301+msgid "Slingshot"
302+msgstr ""
303+
304+#: ../src/Slingshot.vala:32
305+msgid "The app-menu indicator"
306+msgstr ""
307+
308+#: ../src/Slingshot.vala:67 ../src/Widgets/SearchView.vala:222
309+msgid "Applications"
310+msgstr ""
311+
312 #: ../src/SlingshotView.vala:161
313 msgid "View as Grid"
314 msgstr ""
315@@ -37,6 +49,14 @@
316 msgid "Add to _Dock"
317 msgstr ""
318
319+#: ../src/Widgets/CategoryView.vala:27
320+msgid "All Applications"
321+msgstr ""
322+
323+#: ../src/Widgets/CategoryView.vala:28
324+msgid "Create a new Filter"
325+msgstr ""
326+
327 #: ../src/Widgets/SearchView.vala:110
328 msgid "Try changing search terms."
329 msgstr ""
330@@ -49,10 +69,6 @@
331 msgid "Text"
332 msgstr ""
333
334-#: ../src/Widgets/SearchView.vala:222 ../src/Slingshot.vala:67
335-msgid "Applications"
336-msgstr ""
337-
338 #: ../src/Widgets/SearchView.vala:225
339 msgid "Files"
340 msgstr ""
341@@ -85,22 +101,6 @@
342 msgid "Other"
343 msgstr ""
344
345-#: ../src/Widgets/CategoryView.vala:27
346-msgid "All Applications"
347-msgstr ""
348-
349-#: ../src/Widgets/CategoryView.vala:28
350-msgid "Create a new Filter"
351-msgstr ""
352-
353-#: ../src/Slingshot.vala:31
354-msgid "Slingshot"
355-msgstr ""
356-
357-#: ../src/Slingshot.vala:32
358-msgid "The app-menu indicator"
359-msgstr ""
360-
361 #: ../src/Backend/App.vala:91
362 msgid "Run this command…"
363 msgstr ""
364@@ -145,106 +145,124 @@
365 msgid "Copy selection to clipboard"
366 msgstr ""
367
368-#: ../lib/synapse-plugins/link-plugin.vala:46
369-msgid "Open %s in default web browser"
370-msgstr ""
371-
372-#: ../lib/synapse-plugins/link-plugin.vala:51
373-msgid "Open %s in %s"
374-msgstr ""
375-
376-#: ../lib/synapse-plugins/link-plugin.vala:57
377-msgid "Open this link in default browser"
378-msgstr ""
379-
380-#: ../lib/synapse-plugins/link-plugin.vala:79
381-msgid "Link"
382-msgstr ""
383-
384-#: ../lib/synapse-plugins/link-plugin.vala:80
385-msgid "Open link in default browser"
386-msgstr ""
387-
388-#: ../lib/synapse-plugins/system-managment.vala:89
389+#: ../lib/synapse-plugins/desktop-file-plugin.vala:127
390+msgid "Search for and run applications on your computer."
391+msgstr ""
392+
393+#: ../lib/synapse-plugins/desktop-file-plugin.vala:332
394+msgid "Open with %s"
395+msgstr ""
396+
397+#: ../lib/synapse-plugins/desktop-file-plugin.vala:334
398+msgid "Opens current selection using %s"
399+msgstr ""
400+
401+#: ../lib/synapse-plugins/calculator-plugin.vala:51
402+msgid "Calculator"
403+msgstr ""
404+
405+#: ../lib/synapse-plugins/calculator-plugin.vala:52
406+msgid "Calculate basic expressions."
407+msgstr ""
408+
409+#: ../lib/synapse-plugins/calculator-plugin.vala:56
410+msgid "bc is not installed"
411+msgstr ""
412+
413+#: ../lib/synapse-plugins/command-plugin.vala:47
414+msgid "Execute '%s'"
415+msgstr ""
416+
417+#: ../lib/synapse-plugins/command-plugin.vala:47
418+msgid "Run command"
419+msgstr ""
420+
421+#: ../lib/synapse-plugins/command-plugin.vala:63
422+msgid "Find and execute arbitrary commands."
423+msgstr ""
424+
425+#: ../lib/synapse-plugins/system-managment.vala:107
426+msgid "Lock"
427+msgstr ""
428+
429+#: ../lib/synapse-plugins/system-managment.vala:108
430+msgid "Lock this device"
431+msgstr ""
432+
433+#: ../lib/synapse-plugins/system-managment.vala:134
434+msgid "Log Out"
435+msgstr ""
436+
437+#: ../lib/synapse-plugins/system-managment.vala:135
438+msgid "Close all open applications and quit"
439+msgstr ""
440+
441+#: ../lib/synapse-plugins/system-managment.vala:161
442 msgid "Suspend"
443 msgstr ""
444
445-#: ../lib/synapse-plugins/system-managment.vala:90
446+#: ../lib/synapse-plugins/system-managment.vala:162
447 msgid "Put your computer into suspend mode"
448 msgstr ""
449
450-#: ../lib/synapse-plugins/system-managment.vala:168
451+#: ../lib/synapse-plugins/system-managment.vala:232
452 msgid "Hibernate"
453 msgstr ""
454
455-#: ../lib/synapse-plugins/system-managment.vala:169
456+#: ../lib/synapse-plugins/system-managment.vala:233
457 msgid "Put your computer into hibernation mode"
458 msgstr ""
459
460-#: ../lib/synapse-plugins/system-managment.vala:246
461+#: ../lib/synapse-plugins/system-managment.vala:302
462 msgid "Shut Down"
463 msgstr ""
464
465-#: ../lib/synapse-plugins/system-managment.vala:247
466+#: ../lib/synapse-plugins/system-managment.vala:303
467 msgid "Turn your computer off"
468 msgstr ""
469
470-#: ../lib/synapse-plugins/system-managment.vala:312
471+#: ../lib/synapse-plugins/system-managment.vala:360
472 msgid "Restart"
473 msgstr ""
474
475-#: ../lib/synapse-plugins/system-managment.vala:313
476+#: ../lib/synapse-plugins/system-managment.vala:361
477 msgid "Restart your computer"
478 msgstr ""
479
480-#: ../lib/synapse-plugins/system-managment.vala:379
481-msgid "Suspend, hibernate, restart or shutdown your computer."
482+#: ../lib/synapse-plugins/system-managment.vala:419
483+msgid ""
484+"Lock the session or Log Out from it. Suspend, hibernate, restart or shutdown "
485+"your computer."
486 msgstr ""
487
488-#: ../lib/synapse-plugins/system-managment.vala:384
489+#: ../lib/synapse-plugins/system-managment.vala:424
490 msgid "ConsoleKit wasn't found"
491 msgstr ""
492
493-#: ../lib/synapse-plugins/calculator-plugin.vala:50
494-msgid "Calculator"
495-msgstr ""
496-
497-#: ../lib/synapse-plugins/calculator-plugin.vala:51
498-msgid "Calculate basic expressions."
499-msgstr ""
500-
501-#: ../lib/synapse-plugins/calculator-plugin.vala:55
502-msgid "bc is not installed"
503-msgstr ""
504-
505-#: ../lib/synapse-plugins/desktop-file-plugin.vala:126
506-msgid "Search for and run applications on your computer."
507-msgstr ""
508-
509-#: ../lib/synapse-plugins/desktop-file-plugin.vala:331
510-msgid "Open with %s"
511-msgstr ""
512-
513-#: ../lib/synapse-plugins/desktop-file-plugin.vala:333
514-msgid "Opens current selection using %s"
515-msgstr ""
516-
517-#: ../lib/synapse-plugins/switchboard-plugin.vala:45
518+#: ../lib/synapse-plugins/link-plugin.vala:47
519+msgid "Open %s in default web browser"
520+msgstr ""
521+
522+#: ../lib/synapse-plugins/link-plugin.vala:52
523+msgid "Open %s in %s"
524+msgstr ""
525+
526+#: ../lib/synapse-plugins/link-plugin.vala:58
527+msgid "Open this link in default browser"
528+msgstr ""
529+
530+#: ../lib/synapse-plugins/link-plugin.vala:80
531+msgid "Link"
532+msgstr ""
533+
534+#: ../lib/synapse-plugins/link-plugin.vala:81
535+msgid "Open link in default browser"
536+msgstr ""
537+
538+#: ../lib/synapse-plugins/switchboard-plugin.vala:46
539 msgid "Open %s settings"
540 msgstr ""
541
542-#: ../lib/synapse-plugins/switchboard-plugin.vala:61
543+#: ../lib/synapse-plugins/switchboard-plugin.vala:62
544 msgid "Find switchboard plugs and open them."
545 msgstr ""
546-
547-#: ../lib/synapse-plugins/command-plugin.vala:46
548-msgid "Execute '%s'"
549-msgstr ""
550-
551-#: ../lib/synapse-plugins/command-plugin.vala:46
552-msgid "Run command"
553-msgstr ""
554-
555-#: ../lib/synapse-plugins/command-plugin.vala:62
556-msgid "Find and execute arbitrary commands."
557-msgstr ""

Subscribers

People subscribed via source and target branches