Skip to content

Commit 324e042

Browse files
Remove new APIs
This will allow the extension to work well with older versions of GNOME. This is the whole point to the legacy branch.
1 parent 8b468ca commit 324e042

13 files changed

Lines changed: 198 additions & 188 deletions

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ Desktop Icons: Neo - Version 1.4 LTS
2424

2525
## Requirements
2626

27-
* GNOME Shell >= 3.34
28-
* Nautilus >= 3.34
27+
The versions referenced here are GUARANTEED to completely work with the extension.
28+
* GNOME Shell >= 3.32
29+
* Nautilus >= 3.32
2930

3031
## Setting permissions
3132

askConfirmPopup.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* DING: Desktop Icons New Generation for GNOME Shell
2+
*
3+
* Copyright (C) 2019 Sergio Costas (rastersoft@gmail.com)
4+
* Based on code original (C) Carlos Soriano
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, version 3 of the License.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
const Gtk = imports.gi.Gtk;
20+
const Pango = imports.gi.Pango;
21+
const Gettext = imports.gettext.domain('desktopicons-neo');
22+
23+
const _ = Gettext.gettext;
24+
25+
var AskConfirmPopup = class {
26+
27+
constructor(text, secondaryText, parentWindow) {
28+
29+
this._window = new Gtk.MessageDialog({window_position: Gtk.WindowPosition.CENTER_ON_PARENT,
30+
transient_for: parentWindow,
31+
message_type: Gtk.MessageType.WARNING,
32+
buttons: Gtk.ButtonsType.NONE,
33+
text: text,
34+
secondary_text: secondaryText});
35+
this._window.add_button(_("Cancel"), Gtk.ResponseType.CANCEL);
36+
let deleteButton = this._window.add_button(_("Delete"), Gtk.ResponseType.OK);
37+
deleteButton.get_style_context().add_class("destructive-action");
38+
}
39+
40+
run() {
41+
this._window.show_all();
42+
let retval = this._window.run();
43+
this._window.hide();
44+
if (retval == Gtk.ResponseType.OK) {
45+
return true;
46+
} else {
47+
return false;
48+
}
49+
}
50+
};

askRenamePopup.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ var AskRenamePopup = class {
7777
}
7878

7979
_do_rename() {
80-
DBusUtils.NautilusFileOperations2Proxy.RenameURIRemote(
81-
this._fileItem.file.get_uri(), this._textArea.text,
82-
DBusUtils.NautilusFileOperations2Proxy.platformData(),
80+
DBusUtils.NautilusFileOperationsProxy.RenameFileRemote(this._fileItem.file.get_uri(),
81+
this._textArea.text,
8382
(result, error) => {
8483
if (error)
8584
throw new Error('Error renaming file: ' + error.message);

dbusUtils.js

Lines changed: 16 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
const Gio = imports.gi.Gio;
1919
const GLib = imports.gi.GLib;
20-
var NautilusFileOperations2Proxy;
20+
var NautilusFileOperationsProxy;
2121
var FreeDesktopFileManagerProxy;
2222
var GnomeNautilusPreviewProxy;
2323
var SwitcherooControlProxyClass;
@@ -26,51 +26,37 @@ var discreteGpuAvailable;
2626
var GnomeArchiveManagerProxy;
2727
var GtkVfsMetadataProxy;
2828

29-
const NautilusFileOperations2Interface = `<node>
30-
<interface name='org.gnome.Nautilus.FileOperations2'>
29+
const NautilusFileOperationsInterface = `<node>
30+
<interface name='org.gnome.Nautilus.FileOperations'>
3131
<method name='CopyURIs'>
32-
<arg type='as' name='sources' direction='in'/>
33-
<arg type='s' name='destination' direction='in'/>
34-
<arg type='a{sv}' name='platform_data' direction='in'/>
32+
<arg name='URIs' type='as' direction='in'/>
33+
<arg name='Destination' type='s' direction='in'/>
3534
</method>
3635
<method name='MoveURIs'>
37-
<arg type='as' name='sources' direction='in'/>
38-
<arg type='s' name='destination' direction='in'/>
39-
<arg type='a{sv}' name='platform_data' direction='in'/>
36+
<arg name='URIs' type='as' direction='in'/>
37+
<arg name='Destination' type='s' direction='in'/>
4038
</method>
4139
<method name='EmptyTrash'>
42-
<arg type="b" name="ask_confirmation" direction='in'/>
43-
<arg type='a{sv}' name='platform_data' direction='in'/>
4440
</method>
45-
<method name='TrashURIs'>
46-
<arg type='as' name='uris' direction='in'/>
47-
<arg type='a{sv}' name='platform_data' direction='in'/>
48-
</method>
49-
<method name='DeleteURIs'>
50-
<arg type='as' name='uris' direction='in'/>
51-
<arg type='a{sv}' name='platform_data' direction='in'/>
41+
<method name='TrashFiles'>
42+
<arg name='URIs' type='as' direction='in'/>
5243
</method>
5344
<method name='CreateFolder'>
54-
<arg type='s' name='parent_uri' direction='in'/>
55-
<arg type='s' name='new_folder_name' direction='in'/>
56-
<arg type='a{sv}' name='platform_data' direction='in'/>
45+
<arg name='URI' type='s' direction='in'/>
5746
</method>
58-
<method name='RenameURI'>
59-
<arg type='s' name='uri' direction='in'/>
60-
<arg type='s' name='new_name' direction='in'/>
61-
<arg type='a{sv}' name='platform_data' direction='in'/>
47+
<method name='RenameFile'>
48+
<arg name='URI' type='s' direction='in'/>
49+
<arg name='NewName' type='s' direction='in'/>
6250
</method>
6351
<method name='Undo'>
64-
<arg type='a{sv}' name='platform_data' direction='in'/>
6552
</method>
6653
<method name='Redo'>
67-
<arg type='a{sv}' name='platform_data' direction='in'/>
6854
</method>
6955
<property name="UndoStatus" type="i" access="read"/>
7056
</interface>
7157
</node>`;
7258

73-
const NautilusFileOperations2ProxyInterface = Gio.DBusProxy.makeProxyWrapper(NautilusFileOperations2Interface);
59+
const NautilusFileOperationsProxyInterface = Gio.DBusProxy.makeProxyWrapper(NautilusFileOperationsInterface);
7460

7561
const FreeDesktopFileManagerInterface = `<node>
7662
<interface name='org.freedesktop.FileManager1'>
@@ -254,58 +240,17 @@ const GtkVfsMetadataInterface = `<node>
254240
const GtkVfsMetadataProxyInterface = Gio.DBusProxy.makeProxyWrapper(GtkVfsMetadataInterface);
255241

256242
function init() {
257-
NautilusFileOperations2Proxy = new NautilusFileOperations2ProxyInterface(
243+
NautilusFileOperationsProxy = new NautilusFileOperationsProxyInterface(
258244
Gio.DBus.session,
259245
'org.gnome.Nautilus',
260-
'/org/gnome/Nautilus/FileOperations2',
246+
'/org/gnome/Nautilus',
261247
(proxy, error) => {
262248
if (error) {
263249
log('Error connecting to Nautilus');
264250
}
265251
}
266252
);
267253

268-
NautilusFileOperations2Proxy.platformData = params => {
269-
const inShell = typeof global !== 'undefined';
270-
const defaultParams = {
271-
timestamp: inShell ? global.get_current_time() :
272-
imports.gi.Gtk.get_current_event_time(),
273-
parentWindow: inShell ? null :
274-
imports.gi.Gtk.get_current_event().get_window(),
275-
windowPosition: 'center',
276-
};
277-
const { parentWindow, timestamp, windowPosition } = {
278-
...defaultParams,
279-
...params,
280-
};
281-
282-
let { parentHandle } = params ?? { parentHandle: ''};
283-
if (!parentHandle && parentWindow) {
284-
try {
285-
imports.gi.versions.GdkX11 = '3.0';
286-
const { GdkX11 } = imports.gi;
287-
const topLevel = parentWindow.get_effective_toplevel();
288-
289-
if (topLevel.constructor.$gtype === GdkX11.X11Window.$gtype) {
290-
const xid = GdkX11.X11Window.prototype.get_xid.call(topLevel);
291-
parentHandle = `x11:${xid}`;
292-
} /* else if (topLevel instanceof GdkWayland.Toplevel) {
293-
FIXME: Need Gtk4 to use GdkWayland
294-
const handle = GdkWayland.Toplevel.prototype.export_handle.call(topLevel);
295-
parentHandle = `wayland:${handle}`;
296-
} */
297-
} catch (e) {
298-
logError(e, 'Impossible to determine the parent window');
299-
}
300-
}
301-
302-
return {
303-
'parent-handle': new GLib.Variant('s', parentHandle),
304-
'timestamp': new GLib.Variant('u', timestamp),
305-
'window-position': new GLib.Variant('s', windowPosition),
306-
};
307-
}
308-
309254
FreeDesktopFileManagerProxy = new FreeDesktopFileManagerProxyInterface(
310255
Gio.DBus.session,
311256
'org.freedesktop.FileManager1',

desktopIconsUtil.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ function getExtraFolders() {
116116

117117
function getMounts(volumeMonitor) {
118118
let show_volumes = Prefs.desktopSettings.get_boolean('show-volumes');
119-
let show_network = Prefs.desktopSettings.get_boolean('show-network-volumes');
120119

121120
try {
122121
var mounts = volumeMonitor.get_mounts();
@@ -130,9 +129,9 @@ function getMounts(volumeMonitor) {
130129
for (let mount of mounts) {
131130
try {
132131
let is_drive = (mount.get_drive() != null) || (mount.get_volume() != null);
133-
let uri = mount.get_default_location().get_uri();
134-
if (((is_drive && show_volumes) || (!is_drive && show_network)) && (!(uris.includes(uri)))) {
135-
result.push([mount.get_default_location(), Enums.FileType.EXTERNAL_DRIVE, mount]);
132+
let uri = mount.get_root().get_uri();
133+
if ((is_drive && show_volumes) && (!(uris.includes(uri)))) {
134+
result.push([mount.get_root(), Enums.FileType.EXTERNAL_DRIVE, mount]);
136135
uris.push(uri);
137136
}
138137
} catch(e) {
@@ -206,9 +205,9 @@ function isExecutable(mimetype, file_name) {
206205
message_type: Gtk.MessageType.QUESTION,
207206
buttons: Gtk.ButtonsType.NONE
208207
});
209-
dialog.add_button(_("Execute in a terminal"),
208+
dialog.add_button(_("Run in terminal"),
210209
Enums.WhatToDoWithExecutable.EXECUTE_IN_TERMINAL);
211-
dialog.add_button(_("Show"),
210+
dialog.add_button(_("Display Text"),
212211
Enums.WhatToDoWithExecutable.DISPLAY);
213212
dialog.add_button(_("Cancel"),
214213
Gtk.ResponseType.CANCEL);

0 commit comments

Comments
 (0)