[nautilus/gnome-3-30] files-view: Re-add _NETSCAPE_URL drop support
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gnome-3-30] files-view: Re-add _NETSCAPE_URL drop support
- Date: Wed, 21 Nov 2018 12:48:18 +0000 (UTC)
commit 493b6e471ec42813305c585c8149b52da5e8d4a9
Author: Bastien Nocera <hadess hadess net>
Date: Tue Nov 20 10:15:32 2018 +0000
files-view: Re-add _NETSCAPE_URL drop support
In dropping the support for creating website links from Firefox drops,
commit 0e0f5b9 also removed the ability to handle _NETSCAPE_URLs at all.
Re-add the necessary bits for drag'n'drop downloads to work as they did
in GNOME 3.28.
Closes: #687
(cherry picked from commit 6460e334a0c10a8299e1f53ccee8ab0ad3a9c324)
src/nautilus-canvas-view.c | 14 +++++++++
src/nautilus-files-view-dnd.c | 68 +++++++++++++++++++++++++++++++++++++++++++
src/nautilus-files-view-dnd.h | 4 +++
3 files changed, 86 insertions(+)
---
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 7552e2b34..4ee8d6ea3 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -1434,6 +1434,18 @@ canvas_view_handle_uri_list (NautilusCanvasContainer *container,
item_uris, target_uri, action);
}
+/* Handles an URL received from Mozilla */
+static void
+canvas_view_handle_netscape_url (NautilusCanvasContainer *container,
+ const char *encoded_url,
+ const char *target_uri,
+ GdkDragAction action,
+ NautilusCanvasView *view)
+{
+ nautilus_files_view_handle_netscape_url_drop (NAUTILUS_FILES_VIEW (view),
+ encoded_url, target_uri, action);
+}
+
static void
canvas_view_handle_text (NautilusCanvasContainer *container,
const char *text,
@@ -1614,6 +1626,8 @@ nautilus_canvas_view_init (NautilusCanvasView *canvas_view)
g_signal_connect_object (canvas_container, "handle-uri-list",
G_CALLBACK (canvas_view_handle_uri_list), canvas_view, 0);
+ g_signal_connect_object (canvas_container, "handle-netscape-url",
+ G_CALLBACK (canvas_view_handle_netscape_url), canvas_view, 0);
g_signal_connect_object (canvas_container, "handle-text",
G_CALLBACK (canvas_view_handle_text), canvas_view, 0);
g_signal_connect_object (canvas_container, "handle-raw",
diff --git a/src/nautilus-files-view-dnd.c b/src/nautilus-files-view-dnd.c
index 9a3a76b35..d5b4c21c8 100644
--- a/src/nautilus-files-view-dnd.c
+++ b/src/nautilus-files-view-dnd.c
@@ -43,6 +43,74 @@
#define GET_ANCESTOR(obj) \
GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (obj), GTK_TYPE_WINDOW))
+void
+nautilus_files_view_handle_netscape_url_drop (NautilusFilesView *view,
+ const char *encoded_url,
+ const char *target_uri,
+ GdkDragAction action)
+{
+ char *url;
+ char **bits;
+ GList *uri_list = NULL;
+ GFile *f;
+
+ f = g_file_new_for_uri (target_uri);
+
+ if (!g_file_is_native (f))
+ {
+ show_dialog (_("Drag and drop is not supported."),
+ _("Drag and drop is only supported on local file systems."),
+ GET_ANCESTOR (view),
+ GTK_MESSAGE_WARNING);
+ g_object_unref (f);
+ return;
+ }
+
+ g_object_unref (f);
+
+ /* _NETSCAPE_URL_ works like this: $URL\n$TITLE */
+ bits = g_strsplit (encoded_url, "\n", 0);
+ switch (g_strv_length (bits))
+ {
+ case 0:
+ {
+ g_strfreev (bits);
+ return;
+ }
+
+ default:
+ {
+ url = bits[0];
+ }
+ }
+
+ f = g_file_new_for_uri (url);
+
+ /* We don't support GDK_ACTION_ASK or GDK_ACTION_PRIVATE
+ * and we don't support combinations either. */
+ if ((action != GDK_ACTION_DEFAULT) &&
+ (action != GDK_ACTION_COPY) &&
+ (action != GDK_ACTION_MOVE))
+ {
+ show_dialog (_("Drag and drop is not supported."),
+ _("An invalid drag type was used."),
+ GET_ANCESTOR (view),
+ GTK_MESSAGE_WARNING);
+ return;
+ }
+
+ uri_list = g_list_append (uri_list, url);
+
+ nautilus_files_view_move_copy_items (view, uri_list,
+ target_uri,
+ action);
+
+ g_list_free (uri_list);
+
+ g_object_unref (f);
+ g_strfreev (bits);
+}
+
void
nautilus_files_view_handle_uri_list_drop (NautilusFilesView *view,
const char *item_uris,
diff --git a/src/nautilus-files-view-dnd.h b/src/nautilus-files-view-dnd.h
index 9cde15485..73b9263a7 100644
--- a/src/nautilus-files-view-dnd.h
+++ b/src/nautilus-files-view-dnd.h
@@ -44,6 +44,10 @@ void nautilus_files_view_handle_raw_drop (NautilusFilesView *view,
GdkDragAction action);
void nautilus_files_view_handle_hover (NautilusFilesView *view,
const char *target_uri);
+void nautilus_files_view_handle_netscape_url_drop (NautilusFilesView *view,
+ const char *encoded_url,
+ const char *target_uri,
+ GdkDragAction action);
void nautilus_files_view_drop_proxy_received_uris (NautilusFilesView *view,
const GList *uris,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]