1 diff -urN synapse-0.2.10.orig/src/core/desktop-file-service.vala synapse-0.2.10/src/core/desktop-file-service.vala
2 --- synapse-0.2.10.orig/src/core/desktop-file-service.vala 2013-08-18 18:33:35.710536590 +0200
3 +++ synapse-0.2.10/src/core/desktop-file-service.vala 2013-08-18 18:33:55.187202928 +0200
14 public string desktop_id { get; construct set; }
16 case "ROX": result |= EnvironmentType.ROX; break;
17 case "OLD": result |= EnvironmentType.OLD; break;
18 case "UNITY": result |= EnvironmentType.UNITY; break;
19 + case "MATE": result |= EnvironmentType.MATE; break;
20 default: warning ("%s is not understood", env); break;
24 session_type = DesktopFileInfo.EnvironmentType.ROX;
25 session_type_str = "ROX";
27 + else if (session.has_prefix ("mate"))
29 + session_type = DesktopFileInfo.EnvironmentType.MATE;
30 + session_type_str = "MATE";
34 warning ("Desktop session type is not recognized, assuming GNOME.");
35 diff -urN synapse-0.2.10.orig/src/plugins/Makefile.am synapse-0.2.10/src/plugins/Makefile.am
36 --- synapse-0.2.10.orig/src/plugins/Makefile.am 2013-08-18 18:33:35.710536590 +0200
37 +++ synapse-0.2.10/src/plugins/Makefile.am 2013-08-18 18:33:44.427203171 +0200
39 hybrid-search-plugin.vala \
40 launchpad-plugin.vala \
42 + mate-session-plugin.vala \
44 pastebin-plugin.vala \
46 diff -urN synapse-0.2.10.orig/src/plugins/mate-session-plugin.vala synapse-0.2.10/src/plugins/mate-session-plugin.vala
47 --- synapse-0.2.10.orig/src/plugins/mate-session-plugin.vala 1970-01-01 01:00:00.000000000 +0100
48 +++ synapse-0.2.10/src/plugins/mate-session-plugin.vala 2013-08-18 18:33:44.427203171 +0200
51 + * Copyright (C) 2010 Michal Hruby <michal.mhr@gmail.com>
53 + * This program is free software; you can redistribute it and/or modify
54 + * it under the terms of the GNU General Public License as published by
55 + * the Free Software Foundation; either version 2 of the License, or
56 + * (at your option) any later version.
58 + * This program is distributed in the hope that it will be useful,
59 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
60 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61 + * GNU General Public License for more details.
63 + * You should have received a copy of the GNU General Public License
64 + * along with this program; if not, write to the Free Software
65 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
67 + * Authored by Michal Hruby <michal.mhr@gmail.com>
73 + [DBus (name = "org.mate.SessionManager")]
74 + public interface MateSessionManager: Object
76 + public const string UNIQUE_NAME = "org.mate.SessionManager";
77 + public const string OBJECT_PATH = "/org/mate/SessionManager";
79 + public abstract bool can_shutdown () throws IOError;
80 + public abstract void shutdown () throws IOError;
81 + public abstract void request_reboot () throws IOError;
82 + public abstract void logout (uint32 mode = 0) throws IOError;
85 + public class MateSessionPlugin: Object, Activatable, ItemProvider
87 + public bool enabled { get; set; default = true; }
89 + public void activate ()
94 + public void deactivate ()
99 + private class ShutDownAction: Object, Match
101 + // for Match interface
102 + public string title { get; construct set; }
103 + public string description { get; set; default = ""; }
104 + public string icon_name { get; construct set; default = ""; }
105 + public bool has_thumbnail { get; construct set; default = false; }
106 + public string thumbnail_path { get; construct set; }
107 + public MatchType match_type { get; construct set; }
109 + public ShutDownAction ()
111 + Object (match_type: MatchType.ACTION, title: _ ("Shut Down"),
112 + description: _ ("Turn your computer off"),
113 + icon_name: "system-shutdown", has_thumbnail: false);
116 + public void execute (Match? match)
120 + MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION,
121 + MateSessionManager.UNIQUE_NAME,
122 + MateSessionManager.OBJECT_PATH);
124 + dbus_interface.shutdown ();
126 + catch (IOError err)
128 + warning ("%s", err.message);
133 + private class RebootAction: Object, Match
135 + // for Match interface
136 + public string title { get; construct set; }
137 + public string description { get; set; default = ""; }
138 + public string icon_name { get; construct set; default = ""; }
139 + public bool has_thumbnail { get; construct set; default = false; }
140 + public string thumbnail_path { get; construct set; }
141 + public MatchType match_type { get; construct set; }
143 + public RebootAction ()
145 + Object (match_type: MatchType.ACTION, title: _ ("Restart"),
146 + description: _ ("Restart your computer"),
147 + icon_name: "system-shutdown", has_thumbnail: false);
150 + public void execute (Match? match)
154 + MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION,
155 + MateSessionManager.UNIQUE_NAME,
156 + MateSessionManager.OBJECT_PATH);
158 + dbus_interface.request_reboot ();
160 + catch (IOError err)
162 + warning ("%s", err.message);
167 + private class LogOutAction: Object, Match
169 + // for Match interface
170 + public string title { get; construct set; }
171 + public string description { get; set; default = ""; }
172 + public string icon_name { get; construct set; default = ""; }
173 + public bool has_thumbnail { get; construct set; default = false; }
174 + public string thumbnail_path { get; construct set; }
175 + public MatchType match_type { get; construct set; }
177 + public LogOutAction ()
179 + Object (match_type: MatchType.ACTION, title: _ ("Log Out"),
180 + description: _ ("Close your session and return to the login screen"),
181 + icon_name: "system-log-out", has_thumbnail: false);
184 + public void execute (Match? match)
188 + MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION,
189 + MateSessionManager.UNIQUE_NAME,
190 + MateSessionManager.OBJECT_PATH);
194 + * 1: No confirmation inferface should be shown.
195 + * 2: Forcefully logout. No confirmation will be shown and any inhibitors will be ignored.
197 + dbus_interface.logout (1);
199 + catch (IOError err)
201 + warning ("%s", err.message);
206 + static void register_plugin ()
208 + DataSink.PluginRegistry.get_default ().register_plugin (
209 + typeof (MateSessionPlugin),
211 + _ ("Log out from your session."),
212 + "mate-session-logout",
214 + DBusService.get_default ().name_has_owner (MateSessionManager.UNIQUE_NAME),
215 + _ ("MATE Session Manager wasn't found")
221 + register_plugin ();
224 + private bool session_manager_available = false;
225 + private Gee.List<Match> actions;
229 + var cache = DBusService.get_default ();
230 + session_manager_available = cache.name_has_owner (MateSessionManager.UNIQUE_NAME);
231 + Utils.Logger.log (this, "%s %s available", MateSessionManager.UNIQUE_NAME,
232 + session_manager_available ? "is" : "isn't");
234 + actions = new Gee.LinkedList<Match> ();
235 + actions.add (new LogOutAction ());
236 + // TODO: add a config option to enable these actions (for example when ConsoleKit is not available)
237 + //actions.add (new RebootAction ());
238 + //actions.add (new ShutDownAction ());
241 + public async ResultSet? search (Query q) throws SearchError
243 + if (!session_manager_available) return null;
244 + // we only search for actions
245 + if (!(QueryFlags.ACTIONS in q.query_type)) return null;
247 + var result = new ResultSet ();
249 + var matchers = Query.get_matchers_for_query (q.query_string, 0,
250 + RegexCompileFlags.OPTIMIZE | RegexCompileFlags.CASELESS);
252 + foreach (var action in actions)
254 + foreach (var matcher in matchers)
256 + if (matcher.key.match (action.title))
258 + result.add (action, matcher.value - Match.Score.INCREMENT_SMALL);
264 + q.check_cancellable ();
270 diff -urN synapse-0.2.10.orig/src/ui/synapse-main.vala synapse-0.2.10/src/ui/synapse-main.vala
271 --- synapse-0.2.10.orig/src/ui/synapse-main.vala 2013-08-18 18:33:35.710536590 +0200
272 +++ synapse-0.2.10/src/ui/synapse-main.vala 2013-08-18 18:33:44.427203171 +0200
274 typeof (DesktopFilePlugin),
275 typeof (HybridSearchPlugin),
276 typeof (GnomeSessionPlugin),
277 + typeof (MateSessionPlugin),
278 typeof (GnomeScreenSaverPlugin),
279 typeof (SystemManagementPlugin),
280 typeof (CommandPlugin),