]>
Commit | Line | Data |
---|---|---|
a992cc22 JP |
1 | diff -urN synapse-0.2.10.orig/src/plugins/Makefile.am synapse-0.2.10/src/plugins/Makefile.am |
2 | --- synapse-0.2.10.orig/src/plugins/Makefile.am 2013-08-18 18:33:35.710536590 +0200 | |
3 | +++ synapse-0.2.10/src/plugins/Makefile.am 2013-08-18 18:33:44.427203171 +0200 | |
4 | @@ -45,6 +45,7 @@ | |
5 | hybrid-search-plugin.vala \ | |
6 | launchpad-plugin.vala \ | |
7 | locate-plugin.vala \ | |
8 | + mate-session-plugin.vala \ | |
9 | opensearch.vala \ | |
10 | pastebin-plugin.vala \ | |
11 | pidgin-plugin.vala \ | |
12 | diff -urN synapse-0.2.10.orig/src/plugins/mate-session-plugin.vala synapse-0.2.10/src/plugins/mate-session-plugin.vala | |
13 | --- synapse-0.2.10.orig/src/plugins/mate-session-plugin.vala 1970-01-01 01:00:00.000000000 +0100 | |
14 | +++ synapse-0.2.10/src/plugins/mate-session-plugin.vala 2013-08-18 18:33:44.427203171 +0200 | |
9027cc73 | 15 | @@ -0,0 +1,196 @@ |
a992cc22 JP |
16 | +/* |
17 | + * Copyright (C) 2010 Michal Hruby <michal.mhr@gmail.com> | |
18 | + * | |
19 | + * This program is free software; you can redistribute it and/or modify | |
20 | + * it under the terms of the GNU General Public License as published by | |
21 | + * the Free Software Foundation; either version 2 of the License, or | |
22 | + * (at your option) any later version. | |
23 | + * | |
24 | + * This program is distributed in the hope that it will be useful, | |
25 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 | + * GNU General Public License for more details. | |
28 | + * | |
29 | + * You should have received a copy of the GNU General Public License | |
30 | + * along with this program; if not, write to the Free Software | |
31 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
32 | + * | |
33 | + * Authored by Michal Hruby <michal.mhr@gmail.com> | |
34 | + * | |
35 | + */ | |
36 | + | |
37 | +namespace Synapse | |
38 | +{ | |
39 | + [DBus (name = "org.mate.SessionManager")] | |
40 | + public interface MateSessionManager: Object | |
41 | + { | |
42 | + public const string UNIQUE_NAME = "org.mate.SessionManager"; | |
43 | + public const string OBJECT_PATH = "/org/mate/SessionManager"; | |
44 | + | |
45 | + public abstract bool can_shutdown () throws IOError; | |
46 | + public abstract void shutdown () throws IOError; | |
47 | + public abstract void request_reboot () throws IOError; | |
48 | + public abstract void logout (uint32 mode = 0) throws IOError; | |
49 | + } | |
50 | + | |
51 | + public class MateSessionPlugin: Object, Activatable, ItemProvider | |
52 | + { | |
53 | + public bool enabled { get; set; default = true; } | |
54 | + | |
55 | + public void activate () | |
56 | + { | |
57 | + | |
58 | + } | |
59 | + | |
60 | + public void deactivate () | |
61 | + { | |
62 | + | |
63 | + } | |
64 | + | |
9027cc73 | 65 | + private class ShutDownAction: ActionMatch |
a992cc22 | 66 | + { |
a992cc22 JP |
67 | + public ShutDownAction () |
68 | + { | |
9027cc73 JP |
69 | + Object (title: _("Shut Down"), |
70 | + description: _("Turn your computer off"), | |
a992cc22 JP |
71 | + icon_name: "system-shutdown", has_thumbnail: false); |
72 | + } | |
73 | + | |
9027cc73 | 74 | + public override void do_action () |
a992cc22 JP |
75 | + { |
76 | + try | |
77 | + { | |
78 | + MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION, | |
79 | + MateSessionManager.UNIQUE_NAME, | |
80 | + MateSessionManager.OBJECT_PATH); | |
81 | + | |
82 | + dbus_interface.shutdown (); | |
83 | + } | |
84 | + catch (IOError err) | |
85 | + { | |
86 | + warning ("%s", err.message); | |
87 | + } | |
88 | + } | |
89 | + } | |
90 | + | |
9027cc73 | 91 | + private class RebootAction: ActionMatch |
a992cc22 | 92 | + { |
a992cc22 JP |
93 | + public RebootAction () |
94 | + { | |
9027cc73 JP |
95 | + Object (title: _("Restart"), |
96 | + description: _("Restart your computer"), | |
abc84f0b | 97 | + icon_name: "system-shutdown", has_thumbnail: false); |
a992cc22 JP |
98 | + } |
99 | + | |
9027cc73 | 100 | + public override void do_action () |
a992cc22 JP |
101 | + { |
102 | + try | |
103 | + { | |
104 | + MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION, | |
105 | + MateSessionManager.UNIQUE_NAME, | |
106 | + MateSessionManager.OBJECT_PATH); | |
107 | + | |
108 | + dbus_interface.request_reboot (); | |
109 | + } | |
110 | + catch (IOError err) | |
111 | + { | |
112 | + warning ("%s", err.message); | |
113 | + } | |
114 | + } | |
115 | + } | |
116 | + | |
9027cc73 | 117 | + private class LogOutAction: ActionMatch |
a992cc22 | 118 | + { |
a992cc22 JP |
119 | + public LogOutAction () |
120 | + { | |
9027cc73 JP |
121 | + Object (title: _("Log Out"), |
122 | + description: _("Close your session and return to the login screen"), | |
abc84f0b | 123 | + icon_name: "gnome-logout", has_thumbnail: false); |
a992cc22 JP |
124 | + } |
125 | + | |
9027cc73 | 126 | + public override void do_action () |
a992cc22 JP |
127 | + { |
128 | + try | |
129 | + { | |
130 | + MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION, | |
131 | + MateSessionManager.UNIQUE_NAME, | |
132 | + MateSessionManager.OBJECT_PATH); | |
133 | + | |
134 | + /* | |
135 | + * 0: Normal. | |
136 | + * 1: No confirmation inferface should be shown. | |
137 | + * 2: Forcefully logout. No confirmation will be shown and any inhibitors will be ignored. | |
138 | + */ | |
139 | + dbus_interface.logout (1); | |
140 | + } | |
141 | + catch (IOError err) | |
142 | + { | |
143 | + warning ("%s", err.message); | |
144 | + } | |
145 | + } | |
146 | + } | |
147 | + | |
148 | + static void register_plugin () | |
149 | + { | |
9027cc73 | 150 | + PluginRegistry.get_default ().register_plugin ( |
a992cc22 JP |
151 | + typeof (MateSessionPlugin), |
152 | + "MATE Session", | |
153 | + _ ("Log out from your session."), | |
154 | + "mate-session-logout", | |
155 | + register_plugin, | |
156 | + DBusService.get_default ().name_has_owner (MateSessionManager.UNIQUE_NAME), | |
157 | + _ ("MATE Session Manager wasn't found") | |
158 | + ); | |
159 | + } | |
160 | + | |
161 | + static construct | |
162 | + { | |
163 | + register_plugin (); | |
164 | + } | |
165 | + | |
166 | + private bool session_manager_available = false; | |
167 | + private Gee.List<Match> actions; | |
168 | + | |
169 | + construct | |
170 | + { | |
171 | + var cache = DBusService.get_default (); | |
172 | + session_manager_available = cache.name_has_owner (MateSessionManager.UNIQUE_NAME); | |
9027cc73 | 173 | + message ("%s %s available", MateSessionManager.UNIQUE_NAME, |
a992cc22 JP |
174 | + session_manager_available ? "is" : "isn't"); |
175 | + | |
176 | + actions = new Gee.LinkedList<Match> (); | |
177 | + actions.add (new LogOutAction ()); | |
178 | + // TODO: add a config option to enable these actions (for example when ConsoleKit is not available) | |
179 | + //actions.add (new RebootAction ()); | |
180 | + //actions.add (new ShutDownAction ()); | |
181 | + } | |
182 | + | |
183 | + public async ResultSet? search (Query q) throws SearchError | |
184 | + { | |
185 | + if (!session_manager_available) return null; | |
186 | + // we only search for actions | |
187 | + if (!(QueryFlags.ACTIONS in q.query_type)) return null; | |
188 | + | |
189 | + var result = new ResultSet (); | |
190 | + | |
191 | + var matchers = Query.get_matchers_for_query (q.query_string, 0, | |
192 | + RegexCompileFlags.OPTIMIZE | RegexCompileFlags.CASELESS); | |
193 | + | |
194 | + foreach (var action in actions) | |
195 | + { | |
196 | + foreach (var matcher in matchers) | |
197 | + { | |
198 | + if (matcher.key.match (action.title)) | |
199 | + { | |
9027cc73 | 200 | + result.add (action, matcher.value - MatchScore.INCREMENT_SMALL); |
a992cc22 JP |
201 | + break; |
202 | + } | |
203 | + } | |
204 | + } | |
205 | + | |
206 | + q.check_cancellable (); | |
207 | + | |
208 | + return result; | |
209 | + } | |
210 | + } | |
211 | +} | |
212 | diff -urN synapse-0.2.10.orig/src/ui/synapse-main.vala synapse-0.2.10/src/ui/synapse-main.vala | |
213 | --- synapse-0.2.10.orig/src/ui/synapse-main.vala 2013-08-18 18:33:35.710536590 +0200 | |
214 | +++ synapse-0.2.10/src/ui/synapse-main.vala 2013-08-18 18:33:44.427203171 +0200 | |
215 | @@ -165,6 +165,7 @@ | |
216 | typeof (DesktopFilePlugin), | |
217 | typeof (HybridSearchPlugin), | |
218 | typeof (GnomeSessionPlugin), | |
219 | + typeof (MateSessionPlugin), | |
220 | typeof (GnomeScreenSaverPlugin), | |
221 | typeof (SystemManagementPlugin), | |
222 | typeof (CommandPlugin), | |
abc84f0b JP |
223 | diff -urN synapse-0.2.99.orig/src/plugins/Makefile.am synapse-0.2.99/src/plugins/Makefile.am |
224 | --- synapse-0.2.99.orig/src/plugins/Makefile.am 2014-12-02 21:09:40.877899345 +0100 | |
225 | +++ synapse-0.2.99/src/plugins/Makefile.am 2014-12-02 21:13:38.577901026 +0100 | |
226 | @@ -44,6 +44,7 @@ | |
227 | gnome-bookmarks-plugin.vala \ | |
228 | gnome-session-plugin.vala \ | |
229 | gnome-screensaver-plugin.vala \ | |
230 | + mate-screensaver-plugin.vala \ | |
231 | hello-world-plugin.vala \ | |
232 | hybrid-search-plugin.vala \ | |
233 | launchpad-plugin.vala \ | |
234 | diff -urN synapse-0.2.99.orig/src/plugins/mate-screensaver-plugin.vala synapse-0.2.99/src/plugins/mate-screensaver-plugin.vala | |
235 | --- synapse-0.2.99.orig/src/plugins/mate-screensaver-plugin.vala 1970-01-01 01:00:00.000000000 +0100 | |
236 | +++ synapse-0.2.99/src/plugins/mate-screensaver-plugin.vala 2014-12-02 21:12:56.697900730 +0100 | |
237 | @@ -0,0 +1,128 @@ | |
238 | +/* | |
239 | + * Copyright (C) 2010 Igor S. Mandrigin <i@mandrigin.ru> | |
240 | + * | |
241 | + * This program is free software; you can redistribute it and/or modify | |
242 | + * it under the terms of the GNU General Public License as published by | |
243 | + * the Free Software Foundation; either version 2 of the License, or | |
244 | + * (at your option) any later version. | |
245 | + * | |
246 | + * This program is distributed in the hope that it will be useful, | |
247 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
248 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
249 | + * GNU General Public License for more details. | |
250 | + * | |
251 | + * You should have received a copy of the GNU General Public License | |
252 | + * along with this program; if not, write to the Free Software | |
253 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
254 | + * | |
255 | + * Based on plugins code by Michal Hruby <michal.mhr@gmail.com> | |
256 | + * | |
257 | + */ | |
258 | + | |
259 | +namespace Synapse | |
260 | +{ | |
261 | + [DBus (name = "org.mate.ScreenSaver")] | |
262 | + public interface MateScreenSaver : Object | |
263 | + { | |
264 | + public const string UNIQUE_NAME = "org.mate.ScreenSaver"; | |
265 | + public const string OBJECT_PATH = "/org/mate/ScreenSaver"; | |
266 | + | |
267 | + public abstract async void lock () throws IOError; | |
268 | + } | |
269 | + | |
270 | + public class MateScreenSaverPlugin : Object, Activatable, ItemProvider | |
271 | + { | |
272 | + public bool enabled { get; set; default = true; } | |
273 | + | |
274 | + public void activate () | |
275 | + { | |
276 | + | |
277 | + } | |
278 | + | |
279 | + public void deactivate () | |
280 | + { | |
281 | + | |
282 | + } | |
283 | + | |
284 | + private class LockScreenAction : ActionMatch | |
285 | + { | |
286 | + public LockScreenAction () | |
287 | + { | |
288 | + Object (title: _("Lock Screen"), | |
289 | + description: _("Locks screen and starts screensaver."), | |
290 | + icon_name: "system-lock-screen", has_thumbnail: false); | |
291 | + } | |
292 | + | |
293 | + public override void do_action () | |
294 | + { | |
295 | + MateScreenSaverPlugin.lock_screen (); | |
296 | + } | |
297 | + } | |
298 | + | |
299 | + public static void lock_screen () | |
300 | + { | |
301 | + try { | |
302 | + MateScreenSaver dbus_interface = Bus.get_proxy_sync (BusType.SESSION, | |
303 | + MateScreenSaver.UNIQUE_NAME, | |
304 | + MateScreenSaver.OBJECT_PATH); | |
305 | + // we need the async variant cause Screensaver doesn't send the reply | |
306 | + dbus_interface.lock.begin (); | |
307 | + } catch (IOError err) { | |
308 | + warning ("%s", err.message); | |
309 | + } | |
310 | + } | |
311 | + | |
312 | + static void register_plugin () | |
313 | + { | |
314 | + PluginRegistry.get_default ().register_plugin ( | |
315 | + typeof (MateScreenSaverPlugin), | |
316 | + "Mate screensaver plugin", | |
317 | + _("Lock screen of your computer."), | |
318 | + "system-lock-screen", | |
319 | + register_plugin, | |
320 | + DBusService.get_default ().name_is_activatable (MateScreenSaver.UNIQUE_NAME), | |
321 | + _("Mate Screen Saver wasn't found") | |
322 | + ); | |
323 | + } | |
324 | + | |
325 | + static construct | |
326 | + { | |
327 | + register_plugin (); | |
328 | + } | |
329 | + | |
330 | + private Gee.List<Match> actions; | |
331 | + | |
332 | + construct | |
333 | + { | |
334 | + actions = new Gee.LinkedList<Match> (); | |
335 | + actions.add (new LockScreenAction ()); | |
336 | + } | |
337 | + | |
338 | + public async ResultSet? search (Query q) throws SearchError | |
339 | + { | |
340 | + // we only search for actions | |
341 | + if (!(QueryFlags.ACTIONS in q.query_type)) return null; | |
342 | + | |
343 | + var result = new ResultSet (); | |
344 | + | |
345 | + var matchers = Query.get_matchers_for_query (q.query_string, 0, | |
346 | + RegexCompileFlags.OPTIMIZE | RegexCompileFlags.CASELESS); | |
347 | + | |
348 | + foreach (var action in actions) | |
349 | + { | |
350 | + foreach (var matcher in matchers) | |
351 | + { | |
352 | + if (matcher.key.match (action.title)) | |
353 | + { | |
354 | + result.add (action, matcher.value - MatchScore.INCREMENT_SMALL); | |
355 | + break; | |
356 | + } | |
357 | + } | |
358 | + } | |
359 | + | |
360 | + q.check_cancellable (); | |
361 | + | |
362 | + return result; | |
363 | + } | |
364 | + } | |
365 | +} | |
366 | diff -urN synapse-0.2.99.orig/src/ui/synapse-main.vala synapse-0.2.99/src/ui/synapse-main.vala | |
367 | --- synapse-0.2.99.orig/src/ui/synapse-main.vala 2014-12-02 21:09:40.881232678 +0100 | |
368 | +++ synapse-0.2.99/src/ui/synapse-main.vala 2014-12-02 21:13:26.064567604 +0100 | |
369 | @@ -166,6 +166,7 @@ | |
370 | typeof (GnomeSessionPlugin), | |
371 | typeof (MateSessionPlugin), | |
372 | typeof (GnomeScreenSaverPlugin), | |
373 | + typeof (MateScreenSaverPlugin), | |
374 | typeof (SystemManagementPlugin), | |
375 | typeof (CommandPlugin), | |
376 | typeof (RhythmboxActions), |