summaryrefslogtreecommitdiff
path: root/src/plugins/save-file
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2019-02-05 18:08:38 +0100
committerBastien Nocera <hadess@hadess.net>2019-02-07 02:24:35 +0100
commitb4f1f12de1ca6ee1f3d0b388c76e28705108bf0d (patch)
tree63861a76770ae1519a56ebeb6696c312b9ba2741 /src/plugins/save-file
parent08f4293f8f3f66c858c1b1620b5ed182a9e87e06 (diff)
downloadtotem-b4f1f12de1ca6ee1f3d0b388c76e28705108bf0d.tar.gz
save-file: Add support for nautilus >= 3.30
The CopyFile API was removed without warning, update our code to use CopyURIs instead. See https://gitlab.gnome.org/GNOME/nautilus/commit/60c3f2ea839deaf3040872d1ee43d4fea22d543b Closes: #285
Diffstat (limited to 'src/plugins/save-file')
-rw-r--r--src/plugins/save-file/totem-save-file.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/plugins/save-file/totem-save-file.c b/src/plugins/save-file/totem-save-file.c
index 85f6a38f5..6d20c1868 100644
--- a/src/plugins/save-file/totem-save-file.c
+++ b/src/plugins/save-file/totem-save-file.c
@@ -64,6 +64,7 @@ copy_uris_with_nautilus (TotemSaveFilePlugin *pi,
GError *error = NULL;
GDBusProxyFlags flags;
GDBusProxy *proxy;
+ GVariant *ret;
g_return_if_fail (source != NULL);
g_return_if_fail (dest_dir != NULL);
@@ -92,12 +93,29 @@ copy_uris_with_nautilus (TotemSaveFilePlugin *pi,
return;
}
- if (g_dbus_proxy_call_sync (proxy,
- "CopyFile", g_variant_new ("(&s&s&s&s)", source, "", dest_dir, dest_name),
- G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, &error) == FALSE) {
+ ret = g_dbus_proxy_call_sync (proxy,
+ "CopyFile", g_variant_new ("(&s&s&s&s)", source, "", dest_dir, dest_name),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &error);
+
+ if (ret == NULL) {
+ /* nautilus >= 3.30.0? */
+ if (g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD)) {
+ const char *sources[2] = { source, NULL };
+
+ g_clear_error (&error);
+ ret = g_dbus_proxy_call_sync (proxy,
+ "CopyURIs", g_variant_new ("(^ass)", sources, dest_dir),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &error);
+ }
+ }
+
+ if (ret == NULL) {
g_warning ("Could not get nautilus to copy file: %s", error->message);
g_error_free (error);
+ } else {
+ g_variant_unref (ret);
}
g_object_unref (proxy);