diff options
author | Corey Berla <corey@berla.me> | 2022-07-19 10:10:39 -0700 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2022-07-20 13:52:55 +0000 |
commit | 1d431d186512a4d5e56eea45d24bdd0c0bd8e104 (patch) | |
tree | 4769171bbdb48e1be979ccbc8b8bca3e48508a35 | |
parent | 295825bb7d380e74c20b03c50d0fc826140e50de (diff) | |
download | nautilus-1d431d186512a4d5e56eea45d24bdd0c0bd8e104.tar.gz |
location-entry: Drop DnD code
There's a complex set of code to handle DnD on the location entry.
This may have been very useful in the past, but it now a very corner
case situation. Furthermore, the Editable has a DropTarget on it
already within Gtk. The comments themself, indicate that likely
when a user is dropping multiple URI's it's a mistake.
-rw-r--r-- | src/nautilus-location-entry.c | 208 |
1 files changed, 0 insertions, 208 deletions
diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c index 8b8481aa1..aca4c6e1b 100644 --- a/src/nautilus-location-entry.c +++ b/src/nautilus-location-entry.c @@ -44,23 +44,6 @@ #include <stdio.h> #include <string.h> -#if 0 && NAUTILUS_DND_NEEDS_GTK4_REIMPLEMENTATION -#define NAUTILUS_DND_URI_LIST_TYPE "text/uri-list" -#define NAUTILUS_DND_TEXT_PLAIN_TYPE "text/plain" - -enum -{ - NAUTILUS_DND_URI_LIST, - NAUTILUS_DND_TEXT_PLAIN, - NAUTILUS_DND_NTARGETS -}; - -static const GtkTargetEntry drop_types [] = -{ - { NAUTILUS_DND_URI_LIST_TYPE, 0, NAUTILUS_DND_URI_LIST }, - { NAUTILUS_DND_TEXT_PLAIN_TYPE, 0, NAUTILUS_DND_TEXT_PLAIN }, -}; -#endif typedef struct _NautilusLocationEntryPrivate { @@ -271,183 +254,6 @@ nautilus_location_entry_set_location (NautilusLocationEntry *entry, g_free (formatted_uri); } -#if 0 && NAUTILUS_DND_NEEDS_GTK4_REIMPLEMENTATION -typedef struct -{ - NautilusLocationEntry *self; - GdkDragContext *context; - char **names; - guint time; -} OpenWindowsOnDragData; - -static void -do_open_windows (OpenWindowsOnDragData *data, - gboolean new_windows_for_extras) -{ - GFile *location; - - location = g_file_new_for_uri (data->names[0]); - nautilus_location_entry_set_location (data->self, location); - emit_location_changed (data->self); - g_object_unref (location); - - if (new_windows_for_extras) - { - int i; - - for (i = 1; data->names[i] != NULL; ++i) - { - location = g_file_new_for_uri (data->names[i]); - nautilus_application_open_location_full (NAUTILUS_APPLICATION (g_application_get_default ()), - location, NAUTILUS_OPEN_FLAG_NEW_WINDOW, NULL, NULL, NULL); - g_object_unref (location); - } - } - - g_strfreev (data->names); - g_object_unref (data->self); - g_object_unref (data->context); - g_free (data); -} - -static void -confirm_multiple_windows_cb (GtkDialog *dialog, - gint response_id, - gpointer user_data) -{ - OpenWindowsOnDragData *data = user_data; - gboolean open_multiple; - - if (response_id == GTK_RESPONSE_NONE || response_id == GTK_RESPONSE_DELETE_EVENT) - { - return; - } - - open_multiple = (response_id == GTK_RESPONSE_OK); - - gtk_window_destroy (GTK_WINDOW (dialog)); - do_open_windows (data, open_multiple); - gtk_drag_finish (data->context, open_multiple, FALSE, data->time); -} - -static void -drag_data_received_callback (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - GtkSelectionData *data, - guint info, - guint32 time, - gpointer callback_data) -{ - char **names; - int name_count; - GtkRoot *window; - char *prompt; - char *detail; - GtkDialog *dialog; - OpenWindowsOnDragData *op_data; - NautilusLocationEntry *self = NAUTILUS_LOCATION_ENTRY (widget); - - g_assert (data != NULL); - g_assert (callback_data == NULL); - - names = g_uri_list_extract_uris ((const gchar *) gtk_selection_data_get_data (data)); - - if (names == NULL || *names == NULL) - { - g_warning ("No D&D URI's"); - gtk_drag_finish (context, FALSE, FALSE, time); - return; - } - - window = gtk_widget_get_root (widget); - - op_data = g_new0 (OpenWindowsOnDragData, 1); - op_data->self = g_object_ref (self); - op_data->context = g_object_ref (context); - op_data->names = names; - op_data->time = time; - - /* Ask user if they really want to open multiple windows - * for multiple dropped URIs. This is likely to have been - * a mistake. - */ - name_count = g_strv_length (names); - if (name_count > 1) - { - prompt = g_strdup_printf (ngettext ("Do you want to view %d location?", - "Do you want to view %d locations?", - name_count), - name_count); - detail = g_strdup_printf (ngettext ("This will open %d separate window.", - "This will open %d separate windows.", - name_count), - name_count); - - /* eel_show_simple_dialog should really take in pairs - * like gtk_dialog_new_with_buttons() does. */ - dialog = eel_show_simple_dialog (window, - GTK_MESSAGE_QUESTION, - prompt, - detail, - _("_Cancel"), _("_OK"), - NULL); - - /* calls gtk_drag_finish and do_open_windows, frees op_data */ - g_signal_connect (dialog, "response", G_CALLBACK (confirm_multiple_windows_cb), op_data); - - g_free (prompt); - g_free (detail); - - return; - } - - /* frees op_data */ - do_open_windows (op_data, FALSE); - gtk_drag_finish (context, TRUE, FALSE, time); -} - -static void -drag_data_get_callback (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint32 time, - gpointer callback_data) -{ - NautilusLocationEntry *self; - GFile *location; - gchar *uri; - - g_assert (selection_data != NULL); - self = callback_data; - - location = nautilus_location_entry_get_location (self); - uri = g_file_get_uri (location); - - switch (info) - { - case NAUTILUS_DND_URI_LIST: - case NAUTILUS_DND_TEXT_PLAIN: - { - gtk_selection_data_set (selection_data, - gtk_selection_data_get_target (selection_data), - 8, (guchar *) uri, - strlen (uri)); - } - break; - - default: - { - g_assert_not_reached (); - } - } - g_free (uri); - g_object_unref (location); -} -#endif - static void set_prefix_dimming (GtkCellRenderer *completion_cell, char *user_location) @@ -982,20 +788,6 @@ nautilus_location_entry_init (NautilusLocationEntry *entry) g_signal_connect (priv->completer, "got-completion-data", G_CALLBACK (got_completion_data_callback), entry); -#if 0 && NAUTILUS_DND_NEEDS_GTK4_REIMPLEMENTATION - /* Drag source */ - g_signal_connect_object (entry, "drag-data-get", - G_CALLBACK (drag_data_get_callback), entry, 0); - - /* Drag dest. */ - gtk_drag_dest_set (GTK_WIDGET (entry), - GTK_DEST_DEFAULT_ALL, - drop_types, G_N_ELEMENTS (drop_types), - GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); - g_signal_connect (entry, "drag-data-received", - G_CALLBACK (drag_data_received_callback), NULL); -#endif - g_signal_connect_object (entry, "activate", G_CALLBACK (editable_activate_callback), entry, G_CONNECT_AFTER); g_signal_connect_object (entry, "changed", |