1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/***
Copyright (c) 2017 elementary LLC.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License version 3, as published
by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranties of
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
Authors: Jeremy Wootten <jeremy@elementaryos.org>
***/
[DBus (name = "org.freedesktop.FileManager1")]
public class FileManager1 : Object {
[DBus (name = "ShowFolders")]
public void show_folders (string[] uris, string startup_id) throws DBusError, IOError {
open_items_and_folders (uris, startup_id);
}
[DBus (name = "ShowItems")]
public void show_items (string[] uris, string startup_id) throws DBusError, IOError {
open_items_and_folders (uris, startup_id);
}
[DBus (name = "ShowItemProperties")]
public void show_item_properties (string[] uris, string startup_id) throws DBusError, IOError {
var msg = "ShowItemProperties method not currently supported by Files.";
throw new DBusError.NOT_SUPPORTED (msg);
}
private void open_items_and_folders (string[] uris, string startup_id) throws DBusError, IOError {
/* The pantheon-files app will open folder uris as view, other items will cause the parent folder
* to open and the item be selected. Each view will open in a separate tab in one window */
AppInfo? pf_app_info = null;
string cmd = "pantheon-files -t";
foreach (string s in uris) {
cmd += (" " + s);
}
try {
pf_app_info = AppInfo.create_from_commandline (cmd,
null,
AppInfoCreateFlags.NONE);
} catch (Error e) {
var msg = "Unable to open item or folder with command %s. %s".printf (cmd, e.message);
throw new IOError.FAILED (msg);
}
if (pf_app_info != null) {
try {
pf_app_info.launch (null, null);
} catch (Error e) {
var msg = "Unable to open item or folder with command %s. %s".printf (cmd, e.message);
throw new IOError.FAILED (msg);
}
}
}
}
|