Skip to content

Commit 184204a

Browse files
nemo-dnd: Have the drag and drop text data not be uris but plain paths. (#3356)
Some programs get confused when presented with uris when they requested text typed data (even though the uris are just text...). See #3354.
1 parent f3dce08 commit 184204a

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

libnemo-private/nemo-dnd.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ nemo_drag_default_drop_action_for_uri_list (GdkDragContext *context,
662662
the location and size of each icon relative to the cursor.
663663
*/
664664
static void
665-
add_one_gnome_icon (const char *uri, int x, int y, int w, int h,
665+
add_one_gnome_icon (const char *uri, const char *path_str, int x, int y, int w, int h,
666666
gpointer data)
667667
{
668668
GString *result;
@@ -747,7 +747,7 @@ add_one_compatible_uri (const char *uri, int x, int y, int w, int h, gpointer da
747747
#endif
748748

749749
static void
750-
add_one_uri (const char *uri, int x, int y, int w, int h, gpointer data)
750+
add_one_uri (const char *uri, const char *path_str, int x, int y, int w, int h, gpointer data)
751751
{
752752
GString *result;
753753

@@ -757,6 +757,17 @@ add_one_uri (const char *uri, int x, int y, int w, int h, gpointer data)
757757
g_string_append (result, "\r\n");
758758
}
759759

760+
static void
761+
add_one_path (const char *uri, const char *path_str, int x, int y, int w, int h, gpointer data)
762+
{
763+
GString *result;
764+
765+
result = (GString *) data;
766+
767+
g_string_append (result, path_str);
768+
g_string_append (result, "\r\n");
769+
}
770+
760771
/* Common function for drag_data_get_callback calls.
761772
* Returns FALSE if it doesn't handle drag data */
762773
gboolean
@@ -777,11 +788,13 @@ nemo_drag_drag_data_get (GtkWidget *widget,
777788
break;
778789

779790
case NEMO_ICON_DND_URI_LIST:
780-
case NEMO_ICON_DND_TEXT:
781791
result = g_string_new (NULL);
782792
(* each_selected_item_iterator) (add_one_uri, container_context, result);
783793
break;
784-
794+
case NEMO_ICON_DND_TEXT:
795+
result = g_string_new (NULL);
796+
(* each_selected_item_iterator) (add_one_path, container_context, result);
797+
break;
785798
default:
786799
return FALSE;
787800
}

libnemo-private/nemo-dnd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ typedef struct {
9898

9999
} NemoDragInfo;
100100

101-
typedef void (* NemoDragEachSelectedItemDataGet) (const char *url,
101+
typedef void (* NemoDragEachSelectedItemDataGet) (const char *url,
102+
const char *path_str,
102103
int x, int y, int w, int h,
103104
gpointer data);
104105
typedef void (* NemoDragEachSelectedItemIterator) (NemoDragEachSelectedItemDataGet iteratee,

libnemo-private/nemo-icon-dnd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ icon_get_data_binder (NemoIcon *icon, gpointer data)
283283
EelDRect world_rect;
284284
EelIRect widget_rect;
285285
char *uri;
286+
char *path_str;
286287
NemoIconContainer *container;
287288

288289
context = (IconGetDataBinderContext *)data;
@@ -300,6 +301,7 @@ icon_get_data_binder (NemoIcon *icon, gpointer data)
300301
g_warning ("no URI for one of the iterated icons");
301302
return TRUE;
302303
}
304+
path_str = nemo_file_get_path (NEMO_FILE (icon->data));
303305

304306
widget_rect = eel_irect_offset_by (widget_rect,
305307
- container->details->dnd_info->drag_info.start_x,
@@ -310,6 +312,7 @@ icon_get_data_binder (NemoIcon *icon, gpointer data)
310312

311313
/* pass the uri, mouse-relative x/y and icon width/height */
312314
context->iteratee (uri,
315+
path_str,
313316
(int) widget_rect.x0,
314317
(int) widget_rect.y0,
315318
widget_rect.x1 - widget_rect.x0,

src/nemo-list-model.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,7 @@ each_path_get_data_binder (NemoDragEachSelectedItemDataGet data_get,
892892
GtkTreeRowReference *row;
893893
GtkTreePath *path;
894894
char *uri;
895+
char *path_str;
895896
GdkRectangle cell_area;
896897
GtkTreeViewColumn *column;
897898

@@ -914,8 +915,10 @@ each_path_get_data_binder (NemoDragEachSelectedItemDataGet data_get,
914915
&cell_area);
915916

916917
uri = nemo_file_get_local_uri (file);
918+
path_str = nemo_file_get_path (file);
917919

918920
(*data_get) (uri,
921+
path_str,
919922
0,
920923
cell_area.y - info->model->details->drag_begin_y,
921924
cell_area.width, cell_area.height,

0 commit comments

Comments
 (0)