Commit b72191a5 authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan
Browse files

reviewed by: Pavel Cisler<pavel@eazel.com>

2000-12-23  Gene Z. Ragan  <gzr@eazel.com>

	reviewed by: Pavel Cisler<pavel@eazel.com>

	Fixed bug 4158, dropping a file onto gnome-terminal
	doesn't insert a path name.

	* libnautilus-extensions/nautilus-drag.c: (add_one_path_list),
	(nautilus_drag_drag_data_get):
	Return a list a text paths.

	* libnautilus-extensions/nautilus-drag.h:
	Add new type and data type for "text/uri"
parent 37d51fd2
2000-12-23 Gene Z. Ragan <gzr@eazel.com>
reviewed by: Pavel Cisler<pavel@eazel.com>
Fixed bug 4158, dropping a file onto gnome-terminal
doesn't insert a path name.
* libnautilus-extensions/nautilus-drag.c: (add_one_path_list),
(nautilus_drag_drag_data_get):
Return a list a text paths.
* libnautilus-extensions/nautilus-drag.h:
Add new type and data type for "text/uri"
2000-12-22 Ramiro Estrugo <ramiro@eazel.com>
 
reviewed by: Gene Z. Ragan <gzr@eazel.com>
......
......@@ -355,6 +355,36 @@ add_one_uri_list (const char *uri, int x, int y, int w, int h,
g_string_append (result, "\r\n");
}
/* Encode a "text/path" selection. */
static void
add_one_path_list (const char *uri, int x, int y, int w, int h,
gpointer data)
{
GString *result = (GString *)data;
const char *path, *scheme;
GnomeVFSURI *vfs_uri;
vfs_uri = gnome_vfs_uri_new (uri);
if (vfs_uri == NULL) {
return;
}
/* Only accept the file scheme */
scheme = gnome_vfs_uri_get_scheme (vfs_uri);
if (strncmp (scheme, "file", strlen ("file") != 0)) {
gnome_vfs_uri_unref (vfs_uri);
return;
}
path = gnome_vfs_uri_get_path (vfs_uri);
g_string_append (result, path);
g_string_append (result, " ");
gnome_vfs_uri_unref (vfs_uri);
}
/* Common function for drag_data_get_callback calls.
* Returns FALSE if it doesn't handle drag data
*/
......@@ -369,22 +399,24 @@ nautilus_drag_drag_data_get (GtkWidget *widget,
{
GString *result;
if (info != NAUTILUS_ICON_DND_GNOME_ICON_LIST && info != NAUTILUS_ICON_DND_URI_LIST) {
/* don't know how to handle */
return FALSE;
}
result = g_string_new (NULL);
switch (info) {
case NAUTILUS_ICON_DND_GNOME_ICON_LIST:
result = g_string_new (NULL);
each_selected_item_iterator (add_one_gnome_icon_list, container_context, result);
break;
case NAUTILUS_ICON_DND_URI_LIST:
result = g_string_new (NULL);
each_selected_item_iterator (add_one_uri_list, container_context, result);
break;
case NAUTILUS_ICON_DND_TEXT:
result = g_string_new (NULL);
each_selected_item_iterator (add_one_path_list, container_context, result);
break;
default:
g_assert_not_reached ();
return FALSE;
}
gtk_selection_data_set (selection_data,
......
......@@ -51,7 +51,8 @@ typedef enum {
NAUTILUS_ICON_DND_URL,
NAUTILUS_ICON_DND_COLOR,
NAUTILUS_ICON_DND_BGIMAGE,
NAUTILUS_ICON_DND_KEYWORD
NAUTILUS_ICON_DND_KEYWORD,
NAUTILUS_ICON_DND_TEXT
} NautilusIconDndTargetType;
/* drag&drop-related information. */
......@@ -91,6 +92,7 @@ typedef struct {
/* Drag & Drop target names. */
#define NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE "x-special/gnome-icon-list"
#define NAUTILUS_ICON_DND_URI_LIST_TYPE "text/uri-list"
#define NAUTILUS_ICON_DND_TEXT_TYPE "text/plain"
#define NAUTILUS_ICON_DND_URL_TYPE "_NETSCAPE_URL"
#define NAUTILUS_ICON_DND_COLOR_TYPE "application/x-color"
#define NAUTILUS_ICON_DND_BGIMAGE_TYPE "property/bgimage"
......
......@@ -94,7 +94,9 @@ static void set_drop_target (NautilusIconCo
static GtkTargetEntry drag_types [] = {
{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL }
{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
{ NAUTILUS_ICON_DND_TEXT_TYPE, 0, NAUTILUS_ICON_DND_TEXT }
};
static GtkTargetEntry drop_types [] = {
......
......@@ -355,6 +355,36 @@ add_one_uri_list (const char *uri, int x, int y, int w, int h,
g_string_append (result, "\r\n");
}
/* Encode a "text/path" selection. */
static void
add_one_path_list (const char *uri, int x, int y, int w, int h,
gpointer data)
{
GString *result = (GString *)data;
const char *path, *scheme;
GnomeVFSURI *vfs_uri;
vfs_uri = gnome_vfs_uri_new (uri);
if (vfs_uri == NULL) {
return;
}
/* Only accept the file scheme */
scheme = gnome_vfs_uri_get_scheme (vfs_uri);
if (strncmp (scheme, "file", strlen ("file") != 0)) {
gnome_vfs_uri_unref (vfs_uri);
return;
}
path = gnome_vfs_uri_get_path (vfs_uri);
g_string_append (result, path);
g_string_append (result, " ");
gnome_vfs_uri_unref (vfs_uri);
}
/* Common function for drag_data_get_callback calls.
* Returns FALSE if it doesn't handle drag data
*/
......@@ -369,22 +399,24 @@ nautilus_drag_drag_data_get (GtkWidget *widget,
{
GString *result;
if (info != NAUTILUS_ICON_DND_GNOME_ICON_LIST && info != NAUTILUS_ICON_DND_URI_LIST) {
/* don't know how to handle */
return FALSE;
}
result = g_string_new (NULL);
switch (info) {
case NAUTILUS_ICON_DND_GNOME_ICON_LIST:
result = g_string_new (NULL);
each_selected_item_iterator (add_one_gnome_icon_list, container_context, result);
break;
case NAUTILUS_ICON_DND_URI_LIST:
result = g_string_new (NULL);
each_selected_item_iterator (add_one_uri_list, container_context, result);
break;
case NAUTILUS_ICON_DND_TEXT:
result = g_string_new (NULL);
each_selected_item_iterator (add_one_path_list, container_context, result);
break;
default:
g_assert_not_reached ();
return FALSE;
}
gtk_selection_data_set (selection_data,
......
......@@ -51,7 +51,8 @@ typedef enum {
NAUTILUS_ICON_DND_URL,
NAUTILUS_ICON_DND_COLOR,
NAUTILUS_ICON_DND_BGIMAGE,
NAUTILUS_ICON_DND_KEYWORD
NAUTILUS_ICON_DND_KEYWORD,
NAUTILUS_ICON_DND_TEXT
} NautilusIconDndTargetType;
/* drag&drop-related information. */
......@@ -91,6 +92,7 @@ typedef struct {
/* Drag & Drop target names. */
#define NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE "x-special/gnome-icon-list"
#define NAUTILUS_ICON_DND_URI_LIST_TYPE "text/uri-list"
#define NAUTILUS_ICON_DND_TEXT_TYPE "text/plain"
#define NAUTILUS_ICON_DND_URL_TYPE "_NETSCAPE_URL"
#define NAUTILUS_ICON_DND_COLOR_TYPE "application/x-color"
#define NAUTILUS_ICON_DND_BGIMAGE_TYPE "property/bgimage"
......
......@@ -94,7 +94,9 @@ static void set_drop_target (NautilusIconCo
static GtkTargetEntry drag_types [] = {
{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL }
{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
{ NAUTILUS_ICON_DND_TEXT_TYPE, 0, NAUTILUS_ICON_DND_TEXT }
};
static GtkTargetEntry drop_types [] = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment