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
5 hybrid-search-plugin.vala \
6 launchpad-plugin.vala \
8 + mate-session-plugin.vala \
10 pastebin-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
17 + * Copyright (C) 2010 Michal Hruby <michal.mhr@gmail.com>
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.
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.
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.
33 + * Authored by Michal Hruby <michal.mhr@gmail.com>
39 + [DBus (name = "org.mate.SessionManager")]
40 + public interface MateSessionManager: Object
42 + public const string UNIQUE_NAME = "org.mate.SessionManager";
43 + public const string OBJECT_PATH = "/org/mate/SessionManager";
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;
51 + public class MateSessionPlugin: Object, Activatable, ItemProvider
53 + public bool enabled { get; set; default = true; }
55 + public void activate ()
60 + public void deactivate ()
65 + private class ShutDownAction: ActionMatch
67 + public ShutDownAction ()
69 + Object (title: _("Shut Down"),
70 + description: _("Turn your computer off"),
71 + icon_name: "system-shutdown", has_thumbnail: false);
74 + public override void do_action ()
78 + MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION,
79 + MateSessionManager.UNIQUE_NAME,
80 + MateSessionManager.OBJECT_PATH);
82 + dbus_interface.shutdown ();
86 + warning ("%s", err.message);
91 + private class RebootAction: ActionMatch
93 + public RebootAction ()
95 + Object (title: _("Restart"),
96 + description: _("Restart your computer"),
97 + icon_name: "system-shutdown", has_thumbnail: false);
100 + public override void do_action ()
104 + MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION,
105 + MateSessionManager.UNIQUE_NAME,
106 + MateSessionManager.OBJECT_PATH);
108 + dbus_interface.request_reboot ();
110 + catch (IOError err)
112 + warning ("%s", err.message);
117 + private class LogOutAction: ActionMatch
119 + public LogOutAction ()
121 + Object (title: _("Log Out"),
122 + description: _("Close your session and return to the login screen"),
123 + icon_name: "gnome-logout", has_thumbnail: false);
126 + public override void do_action ()
130 + MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION,
131 + MateSessionManager.UNIQUE_NAME,
132 + MateSessionManager.OBJECT_PATH);
136 + * 1: No confirmation inferface should be shown.
137 + * 2: Forcefully logout. No confirmation will be shown and any inhibitors will be ignored.
139 + dbus_interface.logout (1);
141 + catch (IOError err)
143 + warning ("%s", err.message);
148 + static void register_plugin ()
150 + PluginRegistry.get_default ().register_plugin (
151 + typeof (MateSessionPlugin),
153 + _ ("Log out from your session."),
154 + "mate-session-logout",
156 + DBusService.get_default ().name_has_owner (MateSessionManager.UNIQUE_NAME),
157 + _ ("MATE Session Manager wasn't found")
163 + register_plugin ();
166 + private bool session_manager_available = false;
167 + private Gee.List<Match> actions;
171 + var cache = DBusService.get_default ();
172 + session_manager_available = cache.name_has_owner (MateSessionManager.UNIQUE_NAME);
173 + message ("%s %s available", MateSessionManager.UNIQUE_NAME,
174 + session_manager_available ? "is" : "isn't");
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 ());
183 + public async ResultSet? search (Query q) throws SearchError
185 + if (!session_manager_available) return null;
186 + // we only search for actions
187 + if (!(QueryFlags.ACTIONS in q.query_type)) return null;
189 + var result = new ResultSet ();
191 + var matchers = Query.get_matchers_for_query (q.query_string, 0,
192 + RegexCompileFlags.OPTIMIZE | RegexCompileFlags.CASELESS);
194 + foreach (var action in actions)
196 + foreach (var matcher in matchers)
198 + if (matcher.key.match (action.title))
200 + result.add (action, matcher.value - MatchScore.INCREMENT_SMALL);
206 + q.check_cancellable ();
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
216 typeof (HybridSearchPlugin),
217 typeof (GnomeBookmarksPlugin),
218 typeof (GnomeSessionPlugin),
219 + typeof (MateSessionPlugin),
220 typeof (ScreenSaverPlugin),
221 typeof (SystemManagementPlugin),
222 typeof (CommandPlugin),