diff options
author | Gene Z. Ragan <gzr@eazel.com> | 2001-03-14 04:39:38 +0000 |
---|---|---|
committer | Gene Ragan <gzr@src.gnome.org> | 2001-03-14 04:39:38 +0000 |
commit | fa8d59b3f728b714d69c8a464d91007cc180d954 (patch) | |
tree | 3bdd442d384c08f8b556fba39435ad4ca4ad8ce6 /src | |
parent | 8ce313c2a6483ab351fb56a9740a8260fff209ab (diff) | |
download | nautilus-fa8d59b3f728b714d69c8a464d91007cc180d954.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/file-manager/fm-desktop-icon-view.c | 75 |
1 files changed, 63 insertions, 12 deletions
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index 7ec9c8910..f442316b5 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -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 |