Commit fa8d59b3 authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan

I have been itching to check some code in for 1.2, so now I am doing it!

2001-03-13  Gene Z. Ragan  <gzr@eazel.com>

	I have been itching to check some code in for 1.2,
	so now I am doing it!

	This will enable drag support from Netscape to Nautilus.
	Only the desktop handles the drags for now. When I complete
	the async calls in NautilusFile, it will be safe to have the signal
	handled by other views such as FMDirectoryView.

	* libnautilus-extensions/nautilus-icon-container.c:
	* libnautilus-extensions/nautilus-icon-container.h:
	(nautilus_icon_container_initialize_class):
	Change name of signal create_nautilus_links
	to handle_uri_list.

	* libnautilus-extensions/nautilus-icon-dnd.c:
	(drag_data_received_callback), (receive_dropped_uri_list),
	(nautilus_icon_container_get_drop_action):
	Add more general logic to handle a drop of a list of URIs.
	Don't expect them to only contain only the paths to
	gmc desktop entries.

	* src/file-manager/fm-desktop-icon-view.c:
	(fm_desktop_icon_view_initialize):
	Connect to changed signal name handle_uri_list.

	(icon_view_handle_uri_list):
	Use more generalized logic to handle a drop of a URI list.
	Determine what the list element contains and either convert from
	a DesktopEntry or create a link that contains a URI.
parent 8ce313c2
2001-03-13 Gene Z. Ragan <gzr@eazel.com>
I have been itching to check some code in for 1.2,
so now I am doing it!
This will enable drag support from Netscape to Nautilus.
Only the desktop handles the drags for now. When I complete
the async calls in NautilusFile, it will be safe to have the signal
handled by other views such as FMDirectoryView.
* libnautilus-extensions/nautilus-icon-container.c:
* libnautilus-extensions/nautilus-icon-container.h:
(nautilus_icon_container_initialize_class):
Change name of signal create_nautilus_links
to handle_uri_list.
* libnautilus-extensions/nautilus-icon-dnd.c:
(drag_data_received_callback), (receive_dropped_uri_list),
(nautilus_icon_container_get_drop_action):
Add more general logic to handle a drop of a list of URIs.
Don't expect them to only contain only the paths to
gmc desktop entries.
* src/file-manager/fm-desktop-icon-view.c:
(fm_desktop_icon_view_initialize):
Connect to changed signal name handle_uri_list.
(icon_view_handle_uri_list):
Use more generalized logic to handle a drop of a URI list.
Determine what the list element contains and either convert from
a DesktopEntry or create a link that contains a URI.
2001-03-13 Jason Leach <jasonleach@usa.net>
reviewed by: Darin Adler <darin@eazel.com>
......
......@@ -176,7 +176,7 @@ enum {
RENAMING_ICON,
LAYOUT_CHANGED,
MOVE_COPY_ITEMS,
CREATE_NAUTILUS_LINKS,
HANDLE_URI_LIST,
PREVIEW,
SELECTION_CHANGED,
LAST_SIGNAL
......@@ -3210,12 +3210,12 @@ nautilus_icon_container_initialize_class (NautilusIconContainerClass *class)
GTK_TYPE_INT,
GTK_TYPE_INT,
GTK_TYPE_INT);
signals[CREATE_NAUTILUS_LINKS]
= gtk_signal_new ("create_nautilus_links",
signals[HANDLE_URI_LIST]
= gtk_signal_new ("handle_uri_list",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusIconContainerClass,
create_nautilus_links),
handle_uri_list),
gtk_marshal_NONE__POINTER_INT_INT,
GTK_TYPE_NONE, 3,
GTK_TYPE_POINTER,
......
......@@ -88,7 +88,7 @@ typedef struct {
int copy_action,
int x,
int y);
void (* create_nautilus_links) (NautilusIconContainer *container,
void (* handle_uri_list) (NautilusIconContainer *container,
GList *item_uris,
int x,
int y);
......
......@@ -47,7 +47,6 @@
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-mime.h>
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-uidefs.h>
......@@ -374,7 +373,7 @@ nautilus_icon_container_dropped_icon_feedback (GtkWidget *widget,
It is called upon drag_motion events to get the actual data
In that case, it just makes sure it gets the data.
It is called upon drop_drop events to execute the actual
actions on the received action. In that case, it actually fist makes sure
actions on the received action. In that case, it actually first makes sure
that we have got the data then processes it.
*/
......@@ -389,7 +388,7 @@ drag_data_received_callback (GtkWidget *widget,
gpointer user_data)
{
NautilusDragInfo *drag_info;
drag_info = &(NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info->drag_info);
drag_info->got_drop_data_type = TRUE;
......@@ -401,13 +400,24 @@ drag_data_received_callback (GtkWidget *widget,
break;
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_BGIMAGE:
case NAUTILUS_ICON_DND_KEYWORD:
case NAUTILUS_ICON_DND_KEYWORD:
case NAUTILUS_ICON_DND_URI_LIST:
case NAUTILUS_ICON_DND_URL:
/* Save the data so we can do the actual work on drop. */
g_assert (drag_info->selection_data == NULL);
drag_info->selection_data = nautilus_gtk_selection_data_copy_deep (data);
break;
/* Netscape keeps sending us the data, even though we accept the first drag */
//case NAUTILUS_ICON_DND_URL:
// if (drag_info->selection_data != NULL) {
// nautilus_gtk_selection_data_free_deep (drag_info->selection_data);
// drag_info->selection_data = nautilus_gtk_selection_data_copy_deep (data);
// }
// break;
default:
g_message ("drag_data_received_callback unknown");
break;
}
......@@ -443,6 +453,7 @@ drag_data_received_callback (GtkWidget *widget,
gtk_drag_finish (context, FALSE, FALSE, time);
break;
case NAUTILUS_ICON_DND_URI_LIST:
case NAUTILUS_ICON_DND_URL:
receive_dropped_uri_list
(NAUTILUS_ICON_CONTAINER (widget),
(char*) data->data, x, y);
......@@ -637,35 +648,14 @@ receive_dropped_keyword (NautilusIconContainer *container, char* keyword, int x,
/* handle dropped uri list */
static void
receive_dropped_uri_list (NautilusIconContainer *container, char *uri_list, int x, int y)
{
/* FIXME bugzilla.eazel.com 5080:
* this needs a better name - it's link/desktop specific
*/
GList *li, *files;
int argc;
char **argv;
int i;
{
if (uri_list == NULL) {
return;
}
files = gnome_uri_list_extract_filenames (uri_list);
argc = g_list_length (files);
argv = g_new (char *, argc + 1);
argv[argc] = NULL;
for (i=0, li = files; li; i++, li = g_list_next (li)) {
argv[i] = li->data;
}
/* Extract .desktop info and create link/links */
gtk_signal_emit_by_name (GTK_OBJECT (container), "create_nautilus_links",
files,
gtk_signal_emit_by_name (GTK_OBJECT (container), "handle_uri_list",
uri_list,
x, y);
gnome_uri_list_free_strings (files);
g_free(argv);
}
static int
......@@ -1089,6 +1079,7 @@ nautilus_icon_container_get_drop_action (NautilusIconContainer *container,
break;
case NAUTILUS_ICON_DND_URI_LIST:
case NAUTILUS_ICON_DND_URL:
*default_action = context->suggested_action;
*non_default_action = context->suggested_action;
break;
......
......@@ -176,7 +176,7 @@ enum {
RENAMING_ICON,
LAYOUT_CHANGED,
MOVE_COPY_ITEMS,
CREATE_NAUTILUS_LINKS,
HANDLE_URI_LIST,
PREVIEW,
SELECTION_CHANGED,
LAST_SIGNAL
......@@ -3210,12 +3210,12 @@ nautilus_icon_container_initialize_class (NautilusIconContainerClass *class)
GTK_TYPE_INT,
GTK_TYPE_INT,
GTK_TYPE_INT);
signals[CREATE_NAUTILUS_LINKS]
= gtk_signal_new ("create_nautilus_links",
signals[HANDLE_URI_LIST]
= gtk_signal_new ("handle_uri_list",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusIconContainerClass,
create_nautilus_links),
handle_uri_list),
gtk_marshal_NONE__POINTER_INT_INT,
GTK_TYPE_NONE, 3,
GTK_TYPE_POINTER,
......
......@@ -88,7 +88,7 @@ typedef struct {
int copy_action,
int x,
int y);
void (* create_nautilus_links) (NautilusIconContainer *container,
void (* handle_uri_list) (NautilusIconContainer *container,
GList *item_uris,
int x,
int y);
......
......@@ -47,7 +47,6 @@
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-mime.h>
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-uidefs.h>
......@@ -374,7 +373,7 @@ nautilus_icon_container_dropped_icon_feedback (GtkWidget *widget,
It is called upon drag_motion events to get the actual data
In that case, it just makes sure it gets the data.
It is called upon drop_drop events to execute the actual
actions on the received action. In that case, it actually fist makes sure
actions on the received action. In that case, it actually first makes sure
that we have got the data then processes it.
*/
......@@ -389,7 +388,7 @@ drag_data_received_callback (GtkWidget *widget,
gpointer user_data)
{
NautilusDragInfo *drag_info;
drag_info = &(NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info->drag_info);
drag_info->got_drop_data_type = TRUE;
......@@ -401,13 +400,24 @@ drag_data_received_callback (GtkWidget *widget,
break;
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_BGIMAGE:
case NAUTILUS_ICON_DND_KEYWORD:
case NAUTILUS_ICON_DND_KEYWORD:
case NAUTILUS_ICON_DND_URI_LIST:
case NAUTILUS_ICON_DND_URL:
/* Save the data so we can do the actual work on drop. */
g_assert (drag_info->selection_data == NULL);
drag_info->selection_data = nautilus_gtk_selection_data_copy_deep (data);
break;
/* Netscape keeps sending us the data, even though we accept the first drag */
//case NAUTILUS_ICON_DND_URL:
// if (drag_info->selection_data != NULL) {
// nautilus_gtk_selection_data_free_deep (drag_info->selection_data);
// drag_info->selection_data = nautilus_gtk_selection_data_copy_deep (data);
// }
// break;
default:
g_message ("drag_data_received_callback unknown");
break;
}
......@@ -443,6 +453,7 @@ drag_data_received_callback (GtkWidget *widget,
gtk_drag_finish (context, FALSE, FALSE, time);
break;
case NAUTILUS_ICON_DND_URI_LIST:
case NAUTILUS_ICON_DND_URL:
receive_dropped_uri_list
(NAUTILUS_ICON_CONTAINER (widget),
(char*) data->data, x, y);
......@@ -637,35 +648,14 @@ receive_dropped_keyword (NautilusIconContainer *container, char* keyword, int x,
/* handle dropped uri list */
static void
receive_dropped_uri_list (NautilusIconContainer *container, char *uri_list, int x, int y)
{
/* FIXME bugzilla.eazel.com 5080:
* this needs a better name - it's link/desktop specific
*/
GList *li, *files;
int argc;
char **argv;
int i;
{
if (uri_list == NULL) {
return;
}
files = gnome_uri_list_extract_filenames (uri_list);
argc = g_list_length (files);
argv = g_new (char *, argc + 1);
argv[argc] = NULL;
for (i=0, li = files; li; i++, li = g_list_next (li)) {
argv[i] = li->data;
}
/* Extract .desktop info and create link/links */
gtk_signal_emit_by_name (GTK_OBJECT (container), "create_nautilus_links",
files,
gtk_signal_emit_by_name (GTK_OBJECT (container), "handle_uri_list",
uri_list,
x, y);
gnome_uri_list_free_strings (files);
g_free(argv);
}
static int
......@@ -1089,6 +1079,7 @@ nautilus_icon_container_get_drop_action (NautilusIconContainer *container,
break;
case NAUTILUS_ICON_DND_URI_LIST:
case NAUTILUS_ICON_DND_URL:
*default_action = context->suggested_action;
*non_default_action = context->suggested_action;
break;
......
......@@ -31,9 +31,11 @@
#include <fcntl.h>
#include <bonobo/bonobo-ui-util.h>
#include <gdk/gdkx.h>
#include <X11/Xatom.h>
#include <gtk/gtkcheckmenuitem.h>
#include <libgnome/gnome-dentry.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-mime.h>
#include <libgnome/gnome-util.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-extensions/nautilus-bonobo-extensions.h>
......@@ -93,8 +95,8 @@ static void volume_mounted_callback (NautilusVolum
static void volume_unmounted_callback (NautilusVolumeMonitor *monitor,
NautilusVolume *volume,
FMDesktopIconView *icon_view);
static void icon_view_create_nautilus_links (NautilusIconContainer *container,
const GList *item_uris,
static void icon_view_handle_uri_list (NautilusIconContainer *container,
const char *item_uris,
int x,
int y,
FMDirectoryView *view);
......@@ -436,8 +438,8 @@ fm_desktop_icon_view_initialize (FMDesktopIconView *desktop_icon_view)
GTK_OBJECT (desktop_icon_view));
gtk_signal_connect (GTK_OBJECT (icon_container),
"create_nautilus_links",
GTK_SIGNAL_FUNC (icon_view_create_nautilus_links),
"handle_uri_list",
GTK_SIGNAL_FUNC (icon_view_handle_uri_list),
desktop_icon_view);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HOME_URI,
......@@ -644,14 +646,18 @@ volume_unmounted_callback (NautilusVolumeMonitor *monitor,
}
static void
icon_view_create_nautilus_links (NautilusIconContainer *container, const GList *item_uris,
int x, int y, FMDirectoryView *view)
icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_uris,
int x, int y, FMDirectoryView *view)
{
const GList *element;
char *desktop_path;
GList *uri_list;
char *desktop_path, *local_path;
GnomeDesktopEntry *entry;
int index;
GdkPoint point;
const char *uri;
char *stripped_uri, *linkname;
gboolean made_entry_link;
if (item_uris == NULL) {
return;
......@@ -660,15 +666,60 @@ icon_view_create_nautilus_links (NautilusIconContainer *container, const GList *
desktop_path = nautilus_get_desktop_directory ();
point.x = x;
point.y = y;
uri_list = gnome_uri_list_extract_uris (item_uris);
/* Iterate through all of the URIs in the list */
for (element = item_uris, index = 0; element != NULL; element = element->next, index++) {
entry = gnome_desktop_entry_load ((char *)element->data);
nautilus_link_local_create_from_gnome_entry (entry, desktop_path, &point);
gnome_desktop_entry_free (entry);
for (element = uri_list, index = 0; element != NULL; element = element->next, index++) {
uri = element->data;
/* I would use gnome_vfs_get_local_path_from_uri here, but it requires that the URI
* be in the file:// format and the URIs we get from Netscape and panel drags are in
* the file: format
*/
local_path = NULL;
stripped_uri = NULL;
made_entry_link = FALSE;
if (nautilus_istr_has_prefix (uri, "file://")) {
local_path = nautilus_str_get_after_prefix (uri, "file://");
} else if (nautilus_istr_has_prefix (uri, "file:")) {
local_path = g_strdup (uri += strlen ("file:"));
}
/* Is this a path that points to a .desktop file? */
if (local_path != NULL) {
entry = gnome_desktop_entry_load (local_path);
if (entry != NULL) {
nautilus_link_local_create_from_gnome_entry (entry, desktop_path, &point);
gnome_desktop_entry_free (entry);
made_entry_link = TRUE;
}
g_free (local_path);
}
if (!made_entry_link) {
/* We have some type of URI. Create a Nautilus link for it.
* Generate the file name by extracting the basename of the URI.
*/
if (nautilus_str_has_suffix (uri, "/")) {
stripped_uri = nautilus_str_strip_trailing_chr (uri, '/');
linkname = strrchr (stripped_uri, '/');
} else {
linkname = strrchr (uri, '/');
}
if (linkname != NULL) {
linkname++;
nautilus_link_local_create (desktop_path, linkname, "gnome-http-url.png", uri,
&point, NAUTILUS_LINK_GENERIC);
}
g_free (stripped_uri);
}
}
g_free (desktop_path);
gnome_uri_list_free_strings (uri_list);
}
static gboolean
......
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