[nautilus/wip/corey/dnd_features: 1/7] list-base: Allow dropping text to create a text file
- From: Corey Berla <coreyberla src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/corey/dnd_features: 1/7] list-base: Allow dropping text to create a text file
- Date: Thu, 18 Aug 2022 17:42:24 +0000 (UTC)
commit 5dcf877f53ec00fe1f9e0c6671ee2940af141d65
Author: Corey Berla <corey berla me>
Date: Thu Aug 18 08:29:03 2022 -0700
list-base: Allow dropping text to create a text file
We already have the function in nautilus-files-view-dnd.
Allow dropping G_TYPE_STRING and call nautilus_files_view_handle_text_drop()
to generate the filename and create a text file.
This only worked in the main view in previous versions, so lets keep
that the same for simplicity.
src/nautilus-list-base.c | 16 +++++++++++-----
src/nautilus-window-slot-dnd.c | 1 -
2 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index 2827220e1..deb3a122e 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -626,6 +626,10 @@ get_preferred_action (NautilusFile *target_file,
GSList *source_file_list = g_value_get_boxed (value);
action = nautilus_dnd_get_preferred_action (target_file, source_file_list->data);
}
+ else if (G_VALUE_HOLDS (value, G_TYPE_STRING))
+ {
+ action = GDK_ACTION_COPY;
+ }
return action;
}
@@ -636,19 +640,22 @@ real_perform_drop (NautilusListBase *self,
GdkDragAction action,
GFile *target_location)
{
+ g_autofree gchar *target_uri = g_file_get_uri (target_location);
+
if (!gdk_drag_action_is_unique (action))
{
/* TODO: Implement */
}
else if (G_VALUE_HOLDS (value, G_TYPE_STRING))
{
- /* TODO: Implement */
+ nautilus_files_view_handle_text_drop (NAUTILUS_FILES_VIEW (self),
+ g_value_get_string (value),
+ target_uri, action);
}
else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST))
{
GSList *source_file_list = g_value_get_boxed (value);
GList *source_uri_list = NULL;
- g_autofree gchar *target_uri = NULL;
for (GSList *l = source_file_list; l != NULL; l = l->next)
{
@@ -656,7 +663,6 @@ real_perform_drop (NautilusListBase *self,
}
source_uri_list = g_list_reverse (source_uri_list);
- target_uri = g_file_get_uri (target_location);
nautilus_files_view_drop_proxy_received_uris (NAUTILUS_FILES_VIEW (self),
source_uri_list,
target_uri,
@@ -899,7 +905,7 @@ setup_cell_common (GtkListItem *listitem,
drop_target = gtk_drop_target_new (G_TYPE_INVALID, GDK_ACTION_ALL);
gtk_drop_target_set_preload (drop_target, TRUE);
/* TODO: Implement GDK_TYPE_STRING */
- gtk_drop_target_set_gtypes (drop_target, (GType[1]) { GDK_TYPE_FILE_LIST }, 1);
+ gtk_drop_target_set_gtypes (drop_target, (GType[2]) { GDK_TYPE_FILE_LIST, G_TYPE_STRING }, 2);
g_signal_connect (drop_target, "enter", G_CALLBACK (on_item_drag_enter), cell);
g_signal_connect (drop_target, "notify::value", G_CALLBACK (on_item_drag_value_notify), cell);
g_signal_connect (drop_target, "leave", G_CALLBACK (on_item_drag_leave), cell);
@@ -1760,7 +1766,7 @@ nautilus_list_base_setup_gestures (NautilusListBase *self)
drop_target = gtk_drop_target_new (G_TYPE_INVALID, GDK_ACTION_ALL);
gtk_drop_target_set_preload (drop_target, TRUE);
/* TODO: Implement GDK_TYPE_STRING */
- gtk_drop_target_set_gtypes (drop_target, (GType[1]) { GDK_TYPE_FILE_LIST }, 1);
+ gtk_drop_target_set_gtypes (drop_target, (GType[2]) { GDK_TYPE_FILE_LIST, G_TYPE_STRING }, 2);
g_signal_connect (drop_target, "enter", G_CALLBACK (on_view_drag_enter), self);
g_signal_connect (drop_target, "notify::value", G_CALLBACK (on_view_drag_value_notify), self);
g_signal_connect (drop_target, "motion", G_CALLBACK (on_view_drag_motion), self);
diff --git a/src/nautilus-window-slot-dnd.c b/src/nautilus-window-slot-dnd.c
index 8645d472d..f352c155e 100644
--- a/src/nautilus-window-slot-dnd.c
+++ b/src/nautilus-window-slot-dnd.c
@@ -317,7 +317,6 @@ nautilus_drag_slot_proxy_init (GtkWidget *widget,
target = gtk_drop_target_new (G_TYPE_INVALID, GDK_ACTION_ALL);
gtk_drop_target_set_preload (target, TRUE);
- /* TODO: Implement GDK_TYPE_STRING */
gtk_drop_target_set_gtypes (target, (GType[1]) { GDK_TYPE_FILE_LIST }, 1);
g_signal_connect (target, "enter", G_CALLBACK (slot_proxy_drag_motion), drag_info);
g_signal_connect (target, "motion", G_CALLBACK (slot_proxy_drag_motion), drag_info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]