]> git.pld-linux.org Git - packages/synapse.git/blame - synapse-mate.patch
- BR: libzeitgeist-devel instead of zeitgeist-devel
[packages/synapse.git] / synapse-mate.patch
CommitLineData
a992cc22
JP
1diff -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
4@@ -39,8 +39,9 @@
5 XFCE = 1 << 4,
6 OLD = 1 << 5,
7 UNITY = 1 << 6,
8+ MATE = 1 << 7,
9
10- ALL = 0x7F
11+ ALL = 0xFF
12 }
13
14 public string desktop_id { get; construct set; }
15@@ -92,6 +93,7 @@
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;
21 }
22 }
23@@ -284,6 +286,11 @@
24 session_type = DesktopFileInfo.EnvironmentType.ROX;
25 session_type_str = "ROX";
26 }
27+ else if (session.has_prefix ("mate"))
28+ {
29+ session_type = DesktopFileInfo.EnvironmentType.MATE;
30+ session_type_str = "MATE";
31+ }
32 else
33 {
34 warning ("Desktop session type is not recognized, assuming GNOME.");
35diff -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
38@@ -45,6 +45,7 @@
39 hybrid-search-plugin.vala \
40 launchpad-plugin.vala \
41 locate-plugin.vala \
42+ mate-session-plugin.vala \
43 opensearch.vala \
44 pastebin-plugin.vala \
45 pidgin-plugin.vala \
46diff -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
49@@ -0,0 +1,220 @@
50+/*
51+ * Copyright (C) 2010 Michal Hruby <michal.mhr@gmail.com>
52+ *
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.
57+ *
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.
62+ *
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.
66+ *
67+ * Authored by Michal Hruby <michal.mhr@gmail.com>
68+ *
69+ */
70+
71+namespace Synapse
72+{
73+ [DBus (name = "org.mate.SessionManager")]
74+ public interface MateSessionManager: Object
75+ {
76+ public const string UNIQUE_NAME = "org.mate.SessionManager";
77+ public const string OBJECT_PATH = "/org/mate/SessionManager";
78+
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;
83+ }
84+
85+ public class MateSessionPlugin: Object, Activatable, ItemProvider
86+ {
87+ public bool enabled { get; set; default = true; }
88+
89+ public void activate ()
90+ {
91+
92+ }
93+
94+ public void deactivate ()
95+ {
96+
97+ }
98+
99+ private class ShutDownAction: Object, Match
100+ {
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; }
108+
109+ public ShutDownAction ()
110+ {
111+ Object (match_type: MatchType.ACTION, title: _ ("Shut Down"),
112+ description: _ ("Turn your computer off"),
113+ icon_name: "system-shutdown", has_thumbnail: false);
114+ }
115+
116+ public void execute (Match? match)
117+ {
118+ try
119+ {
120+ MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION,
121+ MateSessionManager.UNIQUE_NAME,
122+ MateSessionManager.OBJECT_PATH);
123+
124+ dbus_interface.shutdown ();
125+ }
126+ catch (IOError err)
127+ {
128+ warning ("%s", err.message);
129+ }
130+ }
131+ }
132+
133+ private class RebootAction: Object, Match
134+ {
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; }
142+
143+ public RebootAction ()
144+ {
145+ Object (match_type: MatchType.ACTION, title: _ ("Restart"),
146+ description: _ ("Restart your computer"),
147+ icon_name: "system-shutdown", has_thumbnail: false);
148+ }
149+
150+ public void execute (Match? match)
151+ {
152+ try
153+ {
154+ MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION,
155+ MateSessionManager.UNIQUE_NAME,
156+ MateSessionManager.OBJECT_PATH);
157+
158+ dbus_interface.request_reboot ();
159+ }
160+ catch (IOError err)
161+ {
162+ warning ("%s", err.message);
163+ }
164+ }
165+ }
166+
167+ private class LogOutAction: Object, Match
168+ {
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; }
176+
177+ public LogOutAction ()
178+ {
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);
182+ }
183+
184+ public void execute (Match? match)
185+ {
186+ try
187+ {
188+ MateSessionManager dbus_interface = Bus.get_proxy_sync (BusType.SESSION,
189+ MateSessionManager.UNIQUE_NAME,
190+ MateSessionManager.OBJECT_PATH);
191+
192+ /*
193+ * 0: Normal.
194+ * 1: No confirmation inferface should be shown.
195+ * 2: Forcefully logout. No confirmation will be shown and any inhibitors will be ignored.
196+ */
197+ dbus_interface.logout (1);
198+ }
199+ catch (IOError err)
200+ {
201+ warning ("%s", err.message);
202+ }
203+ }
204+ }
205+
206+ static void register_plugin ()
207+ {
208+ DataSink.PluginRegistry.get_default ().register_plugin (
209+ typeof (MateSessionPlugin),
210+ "MATE Session",
211+ _ ("Log out from your session."),
212+ "mate-session-logout",
213+ register_plugin,
214+ DBusService.get_default ().name_has_owner (MateSessionManager.UNIQUE_NAME),
215+ _ ("MATE Session Manager wasn't found")
216+ );
217+ }
218+
219+ static construct
220+ {
221+ register_plugin ();
222+ }
223+
224+ private bool session_manager_available = false;
225+ private Gee.List<Match> actions;
226+
227+ construct
228+ {
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");
233+
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 ());
239+ }
240+
241+ public async ResultSet? search (Query q) throws SearchError
242+ {
243+ if (!session_manager_available) return null;
244+ // we only search for actions
245+ if (!(QueryFlags.ACTIONS in q.query_type)) return null;
246+
247+ var result = new ResultSet ();
248+
249+ var matchers = Query.get_matchers_for_query (q.query_string, 0,
250+ RegexCompileFlags.OPTIMIZE | RegexCompileFlags.CASELESS);
251+
252+ foreach (var action in actions)
253+ {
254+ foreach (var matcher in matchers)
255+ {
256+ if (matcher.key.match (action.title))
257+ {
258+ result.add (action, matcher.value - Match.Score.INCREMENT_SMALL);
259+ break;
260+ }
261+ }
262+ }
263+
264+ q.check_cancellable ();
265+
266+ return result;
267+ }
268+ }
269+}
270diff -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
273@@ -165,6 +165,7 @@
274 typeof (DesktopFilePlugin),
275 typeof (HybridSearchPlugin),
276 typeof (GnomeSessionPlugin),
277+ typeof (MateSessionPlugin),
278 typeof (GnomeScreenSaverPlugin),
279 typeof (SystemManagementPlugin),
280 typeof (CommandPlugin),
This page took 0.130314 seconds and 4 git commands to generate.