- Updated XDS support in tree view patch (sync with gnomebz #171655)
This commit is contained in:
parent
ca101f0ba7
commit
72afc33c0d
@ -1,5 +1,7 @@
|
|||||||
--- nautilus-2.22.0-orig/libnautilus-private/nautilus-tree-view-drag-dest.c 2008-03-07 16:28:45.000000000 +0100
|
Index: libnautilus-private/nautilus-tree-view-drag-dest.c
|
||||||
+++ nautilus-2.22.0-xdstree/libnautilus-private/nautilus-tree-view-drag-dest.c 2008-03-18 15:01:32.000000000 +0100
|
===================================================================
|
||||||
|
--- libnautilus-private/nautilus-tree-view-drag-dest.c (Revision 14599)
|
||||||
|
+++ libnautilus-private/nautilus-tree-view-drag-dest.c (Arbeitskopie)
|
||||||
@@ -21,6 +21,7 @@
|
@@ -21,6 +21,7 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
@ -8,7 +10,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* nautilus-tree-view-drag-dest.c: Handles drag and drop for treeviews which
|
/* nautilus-tree-view-drag-dest.c: Handles drag and drop for treeviews which
|
||||||
@@ -38,6 +39,9 @@
|
@@ -34,9 +35,13 @@
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <libgnome/gnome-macros.h>
|
||||||
|
#include "nautilus-file-dnd.h"
|
||||||
|
+#include "nautilus-file-changes-queue.h"
|
||||||
#include "nautilus-icon-dnd.h"
|
#include "nautilus-icon-dnd.h"
|
||||||
#include "nautilus-link.h"
|
#include "nautilus-link.h"
|
||||||
#include "nautilus-marshal.h"
|
#include "nautilus-marshal.h"
|
||||||
@ -18,16 +24,16 @@
|
|||||||
|
|
||||||
#define AUTO_SCROLL_MARGIN 20
|
#define AUTO_SCROLL_MARGIN 20
|
||||||
|
|
||||||
@@ -56,6 +60,8 @@ struct _NautilusTreeViewDragDestDetails
|
@@ -55,6 +60,8 @@ struct _NautilusTreeViewDragDestDetails
|
||||||
guint highlight_id;
|
guint highlight_id;
|
||||||
guint scroll_id;
|
guint scroll_id;
|
||||||
guint expand_id;
|
guint expand_id;
|
||||||
+
|
+
|
||||||
+ gchar *drop_path;
|
+ char *direct_save_uri;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -82,7 +88,8 @@ static const GtkTargetEntry drag_types [
|
@@ -81,7 +88,8 @@ static const GtkTargetEntry drag_types [
|
||||||
/* prefer "_NETSCAPE_URL" over "text/uri-list" to satisfy web browsers. */
|
/* prefer "_NETSCAPE_URL" over "text/uri-list" to satisfy web browsers. */
|
||||||
{ NAUTILUS_ICON_DND_NETSCAPE_URL_TYPE, 0, NAUTILUS_ICON_DND_NETSCAPE_URL },
|
{ NAUTILUS_ICON_DND_NETSCAPE_URL_TYPE, 0, NAUTILUS_ICON_DND_NETSCAPE_URL },
|
||||||
{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
|
{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
|
||||||
@ -37,7 +43,30 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -408,6 +415,7 @@ get_drop_action (NautilusTreeViewDragDes
|
@@ -245,6 +253,12 @@ get_drag_data (NautilusTreeViewDragDest
|
||||||
|
target = gtk_drag_dest_find_target (GTK_WIDGET (dest->details->tree_view),
|
||||||
|
context,
|
||||||
|
NULL);
|
||||||
|
+ if (target == gdk_atom_intern (NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE, FALSE) &&
|
||||||
|
+ !dest->details->drop_occurred) {
|
||||||
|
+ dest->details->drag_type = NAUTILUS_ICON_DND_XDNDDIRECTSAVE;
|
||||||
|
+ dest->details->have_drag_data = TRUE;
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
gtk_drag_get_data (GTK_WIDGET (dest->details->tree_view),
|
||||||
|
context, target, time);
|
||||||
|
@@ -264,6 +278,9 @@ free_drag_data (NautilusTreeViewDragDest
|
||||||
|
nautilus_drag_destroy_selection_list (dest->details->drag_list);
|
||||||
|
dest->details->drag_list = NULL;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ g_free (dest->details->direct_save_uri);
|
||||||
|
+ dest->details->direct_save_uri = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
@@ -408,6 +425,7 @@ get_drop_action (NautilusTreeViewDragDes
|
||||||
return context->suggested_action;
|
return context->suggested_action;
|
||||||
|
|
||||||
case NAUTILUS_ICON_DND_TEXT:
|
case NAUTILUS_ICON_DND_TEXT:
|
||||||
@ -45,89 +74,138 @@
|
|||||||
return GDK_ACTION_COPY;
|
return GDK_ACTION_COPY;
|
||||||
|
|
||||||
case NAUTILUS_ICON_DND_KEYWORD:
|
case NAUTILUS_ICON_DND_KEYWORD:
|
||||||
@@ -438,6 +446,7 @@ drag_motion_callback (GtkWidget *widget,
|
@@ -718,6 +736,35 @@ receive_dropped_keyword (NautilusTreeVie
|
||||||
GtkTreeViewDropPosition pos;
|
g_free (drop_target_uri);
|
||||||
GdkWindow *bin_window;
|
}
|
||||||
guint action;
|
|
||||||
+ gchar *uri_path;
|
|
||||||
|
|
||||||
dest = NAUTILUS_TREE_VIEW_DRAG_DEST (data);
|
+static void
|
||||||
|
+receive_xds (NautilusTreeViewDragDest *dest,
|
||||||
@@ -464,13 +473,42 @@ drag_motion_callback (GtkWidget *widget,
|
+ GdkDragContext *context,
|
||||||
gtk_tree_view_get_drag_dest_row (GTK_TREE_VIEW (widget), &old_drop_path,
|
+ int x, int y)
|
||||||
NULL);
|
+{
|
||||||
|
+ GFile *location;
|
||||||
+
|
+
|
||||||
if (action) {
|
+ /* Indicate that we don't provide "F" fallback */
|
||||||
+
|
+ if (G_UNLIKELY (dest->details->drag_data->format == 8
|
||||||
+ /* XDS support: I need to save the drop path here, because I didn't
|
+ && dest->details->drag_data->length == 1
|
||||||
+ * succeeded to get it from the drag_drop_callback (x and y coordinates
|
+ && dest->details->drag_data->data[0] == 'F')) {
|
||||||
+ * passed to it do not match drop position, so I cannot get the target later) */
|
+ gdk_property_change (GDK_DRAWABLE (context->source_window),
|
||||||
+
|
+ gdk_atom_intern (NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE, FALSE),
|
||||||
+ uri_path = get_drop_target_uri_for_path (dest, drop_path);
|
+ gdk_atom_intern ("text/plain", FALSE), 8,
|
||||||
+
|
+ GDK_PROP_MODE_REPLACE, (const guchar *) "", 0);
|
||||||
+ if (uri_path != NULL) {
|
+ } else if (G_LIKELY (dest->details->drag_data->format == 8
|
||||||
+ if (dest->details->drop_path != NULL) {
|
+ && dest->details->drag_data->length == 1
|
||||||
+ /* A path is already in, free and replace */
|
+ && dest->details->drag_data->data[0] == 'S')) {
|
||||||
+ if (strcmp (uri_path, dest->details->drop_path) != 0) {
|
+ g_assert (dest->details->direct_save_uri != NULL);
|
||||||
+ g_free (dest->details->drop_path);
|
+ location = g_file_new_for_uri (dest->details->direct_save_uri);
|
||||||
+ dest->details->drop_path = g_strdup (uri_path);
|
+
|
||||||
+ }
|
+ nautilus_file_changes_queue_file_added (location);
|
||||||
+ } else {
|
+ nautilus_file_changes_consume_changes (TRUE);
|
||||||
+ /* No previous path is there */
|
+
|
||||||
+ dest->details->drop_path = g_strdup (uri_path);
|
+ g_object_unref (location);
|
||||||
+ }
|
+ }
|
||||||
+
|
+}
|
||||||
+ g_free (uri_path);
|
+
|
||||||
+
|
+
|
||||||
+ }
|
static gboolean
|
||||||
+
|
drag_data_received_callback (GtkWidget *widget,
|
||||||
+ /* End XDS support */
|
GdkDragContext *context,
|
||||||
+
|
@@ -767,6 +814,10 @@ drag_data_received_callback (GtkWidget *
|
||||||
set_drag_dest_row (dest, drop_path);
|
|
||||||
+
|
|
||||||
model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
|
|
||||||
if (drop_path == NULL || (old_drop_path != NULL &&
|
|
||||||
gtk_tree_path_compare (old_drop_path, drop_path) != 0)) {
|
|
||||||
remove_expand_timeout (dest);
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
if (dest->details->expand_id == 0 && drop_path != NULL) {
|
|
||||||
gtk_tree_model_get_iter (model, &drop_iter, drop_path);
|
|
||||||
if (gtk_tree_model_iter_has_child (model, &drop_iter)) {
|
|
||||||
@@ -767,6 +805,22 @@ drag_data_received_callback (GtkWidget *
|
|
||||||
receive_dropped_keyword (dest, context, x, y);
|
receive_dropped_keyword (dest, context, x, y);
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
break;
|
break;
|
||||||
+ case NAUTILUS_ICON_DND_XDNDDIRECTSAVE:
|
+ case NAUTILUS_ICON_DND_XDNDDIRECTSAVE:
|
||||||
+ /* Indicate that we don't provide "F" fallback */
|
+ receive_xds (dest, context, x, y);
|
||||||
+ if (G_UNLIKELY (dest->details->drag_data->format == 8
|
|
||||||
+ && dest->details->drag_data->length == 1
|
|
||||||
+ && dest->details->drag_data->data[0] == 'F')) {
|
|
||||||
+ gdk_property_change (GDK_DRAWABLE (context->source_window),
|
|
||||||
+ gdk_atom_intern (NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE, FALSE),
|
|
||||||
+ gdk_atom_intern ("text/plain", FALSE), 8,
|
|
||||||
+ GDK_PROP_MODE_REPLACE, (const guchar *) "", 0);
|
|
||||||
+ } else if (G_LIKELY (dest->details->drag_data->format == 8
|
|
||||||
+ && dest->details->drag_data->length == 1
|
|
||||||
+ && dest->details->drag_data->data[0] == 'S')) {
|
|
||||||
+ /* FIXME: XDS Successful... Do we need to tell the treeview to update itself? */
|
|
||||||
+ }
|
|
||||||
+ success = TRUE;
|
+ success = TRUE;
|
||||||
+ break;
|
+ break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest->details->drop_occurred = FALSE;
|
dest->details->drop_occurred = FALSE;
|
||||||
@@ -791,8 +845,71 @@ drag_drop_callback (GtkWidget *widget,
|
@@ -782,6 +833,79 @@ drag_data_received_callback (GtkWidget *
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static char *
|
||||||
|
+get_direct_save_filename (GdkDragContext *context)
|
||||||
|
+{
|
||||||
|
+ guchar *prop_text;
|
||||||
|
+ gint prop_len;
|
||||||
|
+
|
||||||
|
+ if (!gdk_property_get (context->source_window, gdk_atom_intern (NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE, FALSE),
|
||||||
|
+ gdk_atom_intern ("text/plain", FALSE), 0, 1024, FALSE, NULL, NULL,
|
||||||
|
+ &prop_len, &prop_text) && prop_text != NULL) {
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Zero-terminate the string */
|
||||||
|
+ prop_text = g_realloc (prop_text, prop_len + 1);
|
||||||
|
+ prop_text[prop_len] = '\0';
|
||||||
|
+
|
||||||
|
+ /* Verify that the file name provided by the source is valid */
|
||||||
|
+ if (*prop_text == '\0' ||
|
||||||
|
+ strchr ((const gchar *) prop_text, G_DIR_SEPARATOR) != NULL) {
|
||||||
|
+ nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
|
||||||
|
+ "Invalid filename provided by XDS drag site");
|
||||||
|
+ g_free (prop_text);
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return prop_text;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static gboolean
|
||||||
|
+set_direct_save_uri (NautilusTreeViewDragDest *dest,
|
||||||
|
+ GdkDragContext *context,
|
||||||
|
+ int x, int y)
|
||||||
|
+{
|
||||||
|
+ GFile *base, *child;
|
||||||
|
+ char *drop_uri;
|
||||||
|
+ char *filename, *uri;
|
||||||
|
+
|
||||||
|
+ g_assert (dest->details->direct_save_uri == NULL);
|
||||||
|
+
|
||||||
|
+ uri = NULL;
|
||||||
|
+
|
||||||
|
+ drop_uri = get_drop_target_uri_at_pos (dest, x, y);
|
||||||
|
+ if (drop_uri != NULL) {
|
||||||
|
+ filename = get_direct_save_filename (context);
|
||||||
|
+ if (filename != NULL) {
|
||||||
|
+ /* Resolve relative path */
|
||||||
|
+ base = g_file_new_for_uri (drop_uri);
|
||||||
|
+ child = g_file_get_child (base, filename);
|
||||||
|
+ uri = g_file_get_uri (child);
|
||||||
|
+
|
||||||
|
+ g_object_unref (base);
|
||||||
|
+ g_object_unref (child);
|
||||||
|
+
|
||||||
|
+ /* Change the property */
|
||||||
|
+ gdk_property_change (GDK_DRAWABLE (context->source_window),
|
||||||
|
+ gdk_atom_intern (NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE, FALSE),
|
||||||
|
+ gdk_atom_intern ("text/plain", FALSE), 8,
|
||||||
|
+ GDK_PROP_MODE_REPLACE, (const guchar *) uri,
|
||||||
|
+ strlen (uri));
|
||||||
|
+
|
||||||
|
+ dest->details->direct_save_uri = uri;
|
||||||
|
+ } else {
|
||||||
|
+ nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
|
||||||
|
+ "Invalid filename provided by XDS drag site");
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
|
||||||
|
+ "Could not retrieve XDS drop destination");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return uri != NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static gboolean
|
||||||
|
drag_drop_callback (GtkWidget *widget,
|
||||||
|
GdkDragContext *context,
|
||||||
|
@@ -791,8 +915,24 @@ drag_drop_callback (GtkWidget *widget,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
NautilusTreeViewDragDest *dest;
|
NautilusTreeViewDragDest *dest;
|
||||||
+ guint info;
|
+ guint info;
|
||||||
+ guchar *prop_text;
|
|
||||||
+ gint prop_len;
|
|
||||||
+ GFile *base, *child;
|
|
||||||
+ gchar *uri = NULL;
|
|
||||||
+ GdkAtom target;
|
+ GdkAtom target;
|
||||||
|
|
||||||
dest = NAUTILUS_TREE_VIEW_DRAG_DEST (data);
|
dest = NAUTILUS_TREE_VIEW_DRAG_DEST (data);
|
||||||
@ -135,69 +213,16 @@
|
|||||||
+ target = gtk_drag_dest_find_target (GTK_WIDGET (dest->details->tree_view),
|
+ target = gtk_drag_dest_find_target (GTK_WIDGET (dest->details->tree_view),
|
||||||
+ context,
|
+ context,
|
||||||
+ NULL);
|
+ NULL);
|
||||||
+
|
+ if (target == GDK_NONE) {
|
||||||
+ info = dest->details->drag_type;
|
|
||||||
+
|
|
||||||
+ if (G_UNLIKELY (target == GDK_NONE)) {
|
|
||||||
+ return FALSE;
|
+ return FALSE;
|
||||||
+ } else if (target != GDK_NONE) {
|
+ }
|
||||||
+ if (info == NAUTILUS_ICON_DND_XDNDDIRECTSAVE) {
|
|
||||||
+ if (gdk_property_get (context->source_window, gdk_atom_intern (NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE, FALSE),
|
|
||||||
+ gdk_atom_intern ("text/plain", FALSE), 0, 1024, FALSE, NULL, NULL,
|
|
||||||
+ &prop_len, &prop_text) && prop_text != NULL) {
|
|
||||||
+ /* Zero-terminate the string */
|
|
||||||
+ prop_text = g_realloc (prop_text, prop_len + 1);
|
|
||||||
+ prop_text[prop_len] = '\0';
|
|
||||||
+
|
+
|
||||||
+ /* Verify that the file name provided by the source is valid */
|
+ info = dest->details->drag_type;
|
||||||
+ if (G_LIKELY (*prop_text != '\0' && strchr ((const gchar *) prop_text, G_DIR_SEPARATOR) == NULL)) {
|
|
||||||
+
|
|
||||||
+ /* Retrieve drop target path */
|
|
||||||
+ if (dest->details->drop_path != NULL) {
|
|
||||||
+ /* Resolve relative path */
|
|
||||||
+ base = g_file_new_for_uri (dest->details->drop_path);
|
|
||||||
+ child = g_file_get_child (base, (const gchar *) prop_text);
|
|
||||||
+ uri = g_file_get_uri (child);
|
|
||||||
+ g_object_unref (base);
|
|
||||||
+ g_object_unref (child);
|
|
||||||
+ /* Change the property */
|
|
||||||
+ gdk_property_change (GDK_DRAWABLE (context->source_window),
|
|
||||||
+ gdk_atom_intern (NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE, FALSE),
|
|
||||||
+ gdk_atom_intern ("text/plain", FALSE), 8,
|
|
||||||
+ GDK_PROP_MODE_REPLACE, (const guchar *) uri,
|
|
||||||
+ strlen (uri));
|
|
||||||
+
|
+
|
||||||
+ /* Free memory */
|
+ if (info == NAUTILUS_ICON_DND_XDNDDIRECTSAVE &&
|
||||||
+ g_free (dest->details->drop_path);
|
+ !set_direct_save_uri (dest, context, x, y)) {
|
||||||
+ dest->details->drop_path = NULL;
|
+ return FALSE;
|
||||||
+ g_free (uri);
|
|
||||||
+ } else {
|
|
||||||
+ nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
|
|
||||||
+ "Could not retrieve XDS drag site ");
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ /* tell the user that the file name provided by the X Direct Save source is invalid */
|
|
||||||
+ nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
|
|
||||||
+ "Invalid filename provided by XDS drag site");
|
|
||||||
+ }
|
|
||||||
+ /* cleanup */
|
|
||||||
+ g_free (prop_text);
|
|
||||||
+ }
|
|
||||||
+ /* if uri == NULL, we didn't set the property */
|
|
||||||
+ if (G_UNLIKELY (uri == NULL))
|
|
||||||
+ return FALSE;
|
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
dest->details->drop_occurred = TRUE;
|
dest->details->drop_occurred = TRUE;
|
||||||
|
|
||||||
@@ -845,6 +962,9 @@ nautilus_tree_view_drag_dest_finalize (G
|
|
||||||
dest = NAUTILUS_TREE_VIEW_DRAG_DEST (object);
|
|
||||||
|
|
||||||
free_drag_data (dest);
|
|
||||||
+
|
|
||||||
+ if (dest->details->drop_path)
|
|
||||||
+ g_free (dest->details->drop_path);
|
|
||||||
|
|
||||||
g_free (dest->details);
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
Name: nautilus
|
Name: nautilus
|
||||||
Summary: Nautilus is a file manager for GNOME
|
Summary: Nautilus is a file manager for GNOME
|
||||||
Version: 2.24.1
|
Version: 2.24.1
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: User Interface/Desktops
|
Group: User Interface/Desktops
|
||||||
Source: http://download.gnome.org/sources/%{name}/2.24/%{name}-%{version}.tar.bz2
|
Source: http://download.gnome.org/sources/%{name}/2.24/%{name}-%{version}.tar.bz2
|
||||||
@ -138,7 +138,7 @@ for writing nautilus extensions.
|
|||||||
%patch7 -p1 -b .rtl-fix
|
%patch7 -p1 -b .rtl-fix
|
||||||
# %patch8 -p1 -b .hide-white-screen
|
# %patch8 -p1 -b .hide-white-screen
|
||||||
%patch10 -p0 -b .gvfs-desktop-key
|
%patch10 -p0 -b .gvfs-desktop-key
|
||||||
%patch15 -p1 -b .xds
|
%patch15 -p0 -b .xds
|
||||||
%patch17 -p0 -b .symlink
|
%patch17 -p0 -b .symlink
|
||||||
%patch18 -p0 -b .fallback-file-icon
|
%patch18 -p0 -b .fallback-file-icon
|
||||||
|
|
||||||
@ -269,6 +269,9 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Oct 27 2008 Tomas Bzatek <tbzatek@redhat.com> - 2.24.1-3
|
||||||
|
- Updated XDS support in tree view patch (sync with gnomebz #171655)
|
||||||
|
|
||||||
* Fri Oct 24 2008 Alexander Larsson <alexl@redhat.com> - 2.24.1-2
|
* Fri Oct 24 2008 Alexander Larsson <alexl@redhat.com> - 2.24.1-2
|
||||||
- Manually check for fallback file icon since we're not
|
- Manually check for fallback file icon since we're not
|
||||||
always returning that from gio anymore (from upstream)
|
always returning that from gio anymore (from upstream)
|
||||||
|
Loading…
Reference in New Issue
Block a user