[Xfce4-commits] [xfce/xfdesktop] 02/19: Fix HTTP URL performance issue / wrong action proposed
noreply at xfce.org
noreply at xfce.org
Sun Nov 9 15:36:44 CET 2014
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch xfce-4.10
in repository xfce/xfdesktop.
commit 27b81befc1a6d12767822dbde3534beab2db81f3
Author: Dennis Tomas <den.t at gmx.de>
Date: Sat Apr 20 13:21:45 2013 +0300
Fix HTTP URL performance issue / wrong action proposed
- only check "file" URLs for move/copy
- adding an optional output parameter "suggested_action" to the
icon's allowed_drop_actions()
The suggested actions are:
folder: move if writable else none
volume: copy if writable else none
file: copy (run) if executable else none
trash: move
Signed-off-by: Eric Koegel <eric.koegel at gmail.com>
Resolve conflicts for 4.10 backport.
Conflicts:
src/xfdesktop-icon-view.c
---
src/xfdesktop-file-icon-manager.c | 32 ++++++++++++++++++++++---------
src/xfdesktop-icon-view.c | 38 +++++++++++++++++++++++++------------
src/xfdesktop-icon.c | 12 ++++++++----
src/xfdesktop-icon.h | 5 +++--
src/xfdesktop-regular-file-icon.c | 23 +++++++++++++++++-----
src/xfdesktop-special-file-icon.c | 15 ++++++++++++---
src/xfdesktop-volume-icon.c | 16 ++++++++++++----
7 files changed, 102 insertions(+), 39 deletions(-)
diff --git a/src/xfdesktop-file-icon-manager.c b/src/xfdesktop-file-icon-manager.c
index 9f42699..1503f0b 100644
--- a/src/xfdesktop-file-icon-manager.c
+++ b/src/xfdesktop-file-icon-manager.c
@@ -3227,31 +3227,45 @@ xfdesktop_file_icon_manager_propose_drop_action(XfdesktopIconViewManager *manage
file_icon = XFDESKTOP_FILE_ICON(drop_icon);
tfile = xfdesktop_file_icon_peek_file(file_icon);
tinfo = xfdesktop_file_icon_peek_file_info(file_icon);
- }
- if(tfile && !g_file_has_uri_scheme(tfile, "file")) {
- return action;
+ /* if it's a volume, but we don't have |tinfo|, this just isn't
+ * going to work */
+ if(!tinfo && XFDESKTOP_IS_VOLUME_ICON(drop_icon)) {
+ return 0;
+ }
+
+ if(tfile && !g_file_has_uri_scheme(tfile, "file")) {
+ return action;
+ }
+
+ if(tinfo && g_file_info_get_file_type(tinfo) != G_FILE_TYPE_DIRECTORY) {
+ return action;
+ }
}
file_list = xfdesktop_file_utils_file_list_from_string((const gchar *)gtk_selection_data_get_data(data));
if(file_list) {
GFile *base_dest_file = NULL;
- gboolean dest_is_volume = (drop_icon
- && XFDESKTOP_IS_VOLUME_ICON(drop_icon));
- /* if it's a volume, but we don't have |tinfo|, this just isn't
- * going to work */
- if(!tinfo && dest_is_volume) {
+ /* source must be local file */
+ if(!g_file_has_uri_scheme(file_list->data, "file")) {
xfdesktop_file_utils_file_list_free(file_list);
return action;
}
- if(tinfo && g_file_info_get_file_type(tinfo) == G_FILE_TYPE_DIRECTORY) {
+ if(tinfo) {
base_dest_file = g_object_ref(tfile);
} else {
base_dest_file = g_object_ref(fmanager->priv->folder);
}
+ /* dropping on ourselves? */
+ if(g_strcmp0(g_file_get_uri(file_list->data), g_file_get_uri(base_dest_file)) == 0) {
+ g_object_unref(base_dest_file);
+ xfdesktop_file_utils_file_list_free(file_list);
+ return 0;
+ }
+
/* Determine if we should move/copy by checking if the files
* are on the same filesystem and are writable by the user.
*/
diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index b40c800..d6bc63c 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -1382,7 +1382,7 @@ xfdesktop_icon_view_drag_motion(GtkWidget *widget,
icon_on_dest = xfdesktop_icon_view_icon_in_cell(icon_view, hover_row,
hover_col);
if(icon_on_dest) {
- if(!xfdesktop_icon_get_allowed_drop_actions(icon_on_dest))
+ if(!xfdesktop_icon_get_allowed_drop_actions(icon_on_dest, NULL))
return FALSE;
} else if(!xfdesktop_grid_is_free_position(icon_view, hover_row, hover_col))
return FALSE;
@@ -1402,7 +1402,7 @@ xfdesktop_icon_view_drag_motion(GtkWidget *widget,
else /* #3 */
our_action = gdk_drag_context_get_suggested_action(context);
} else {
- /* start with all available actions */
+ /* start with all available actions (may be filtered by modifier keys) */
GdkDragAction allowed_actions = context->actions;
if(is_local_drag) { /* #2 */
@@ -1421,18 +1421,30 @@ xfdesktop_icon_view_drag_motion(GtkWidget *widget,
}
allowed_actions &= xfdesktop_icon_get_allowed_drag_actions(icon_view->priv->cursor);
+
+ /* for local drags, let the dest icon decide */
+ allowed_actions &= xfdesktop_icon_get_allowed_drop_actions(icon_on_dest, &our_action);
+ } else { /* #4 */
+ allowed_actions &= xfdesktop_icon_get_allowed_drop_actions(icon_on_dest, NULL);
+
+ /* for foreign drags, take the action suggested by the source */
+ our_action = gdk_drag_context_get_suggested_action(context);
}
-
+
/* #2 or #4 */
- allowed_actions &= xfdesktop_icon_get_allowed_drop_actions(icon_on_dest);
- /* priority: move, copy, link */
- if(allowed_actions & GDK_ACTION_MOVE)
- our_action = GDK_ACTION_MOVE;
- else if(allowed_actions & GDK_ACTION_COPY)
- our_action = GDK_ACTION_COPY;
- else if(allowed_actions & GDK_ACTION_LINK)
- our_action = GDK_ACTION_LINK;
+ /* fallback actions if the suggested action is not allowed,
+ * priority: move, copy, link */
+ if(!(our_action & allowed_actions)) {
+ if(allowed_actions & GDK_ACTION_MOVE)
+ our_action = GDK_ACTION_MOVE;
+ else if(allowed_actions & GDK_ACTION_COPY)
+ our_action = GDK_ACTION_COPY;
+ else if(allowed_actions & GDK_ACTION_LINK)
+ our_action = GDK_ACTION_LINK;
+ else
+ our_action = 0;
+ }
}
/* allow the drag dest to override the selected action based on the drag data */
@@ -1440,6 +1452,8 @@ xfdesktop_icon_view_drag_motion(GtkWidget *widget,
icon_view->priv->hover_col = hover_col;
icon_view->priv->proposed_drop_action = our_action;
icon_view->priv->dropped = FALSE;
+ g_object_set_data(G_OBJECT(context), "--xfdesktop-icon-view-drop-icon",
+ icon_on_dest);
gtk_drag_get_data(widget, context, target, time_);
/* the actual call to gdk_drag_status() is deferred to
@@ -1618,7 +1632,7 @@ xfdesktop_icon_view_drag_data_received(GtkWidget *widget,
context, row, col, data,
info, time_);
} else {
- /* FIXME: cannot use x and y here, for they doen't seem to have any
+ /* FIXME: cannot use x and y here, for they don't seem to have any
* meaningful value */
GdkDragAction action = icon_view->priv->proposed_drop_action;
diff --git a/src/xfdesktop-icon.c b/src/xfdesktop-icon.c
index 38c1538..ffe3d2f 100644
--- a/src/xfdesktop-icon.c
+++ b/src/xfdesktop-icon.c
@@ -221,7 +221,8 @@ xfdesktop_icon_get_allowed_drag_actions(XfdesktopIcon *icon)
/*< optional; drops aren't allowed if not provided >*/
GdkDragAction
-xfdesktop_icon_get_allowed_drop_actions(XfdesktopIcon *icon)
+xfdesktop_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
+ GdkDragAction *suggested_action)
{
XfdesktopIconClass *klass;
@@ -229,10 +230,13 @@ xfdesktop_icon_get_allowed_drop_actions(XfdesktopIcon *icon)
klass = XFDESKTOP_ICON_GET_CLASS(icon);
- if(!klass->get_allowed_drop_actions)
+ if(!klass->get_allowed_drop_actions) {
+ if(suggested_action)
+ *suggested_action = 0;
return 0;
-
- return klass->get_allowed_drop_actions(icon);
+ }
+
+ return klass->get_allowed_drop_actions(icon, suggested_action);
}
/*< optional; required if get_allowed_drop_actions() can return nonzero >*/
diff --git a/src/xfdesktop-icon.h b/src/xfdesktop-icon.h
index e42261e..5b750fd 100644
--- a/src/xfdesktop-icon.h
+++ b/src/xfdesktop-icon.h
@@ -68,7 +68,7 @@ struct _XfdesktopIconClass
GdkDragAction (*get_allowed_drag_actions)(XfdesktopIcon *icon);
- GdkDragAction (*get_allowed_drop_actions)(XfdesktopIcon *icon);
+ GdkDragAction (*get_allowed_drop_actions)(XfdesktopIcon *icon, GdkDragAction *suggested_action);
gboolean (*do_drop_dest)(XfdesktopIcon *icon, XfdesktopIcon *src_icon, GdkDragAction action);
G_CONST_RETURN gchar *(*peek_tooltip)(XfdesktopIcon *icon);
@@ -98,7 +98,8 @@ gboolean xfdesktop_icon_get_position(XfdesktopIcon *icon,
GdkDragAction xfdesktop_icon_get_allowed_drag_actions(XfdesktopIcon *icon);
-GdkDragAction xfdesktop_icon_get_allowed_drop_actions(XfdesktopIcon *icon);
+GdkDragAction xfdesktop_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
+ GdkDragAction *suggested_action);
gboolean xfdesktop_icon_do_drop_dest(XfdesktopIcon *icon,
XfdesktopIcon *src_icon,
GdkDragAction action);
diff --git a/src/xfdesktop-regular-file-icon.c b/src/xfdesktop-regular-file-icon.c
index 6e4b71d..a247a43 100644
--- a/src/xfdesktop-regular-file-icon.c
+++ b/src/xfdesktop-regular-file-icon.c
@@ -80,7 +80,8 @@ static GdkPixbuf *xfdesktop_regular_file_icon_peek_pixbuf(XfdesktopIcon *icon,
static G_CONST_RETURN gchar *xfdesktop_regular_file_icon_peek_label(XfdesktopIcon *icon);
static G_CONST_RETURN gchar *xfdesktop_regular_file_icon_peek_tooltip(XfdesktopIcon *icon);
static GdkDragAction xfdesktop_regular_file_icon_get_allowed_drag_actions(XfdesktopIcon *icon);
-static GdkDragAction xfdesktop_regular_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon);
+static GdkDragAction xfdesktop_regular_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
+ GdkDragAction *suggested_action);
static gboolean xfdesktop_regular_file_icon_do_drop_dest(XfdesktopIcon *icon,
XfdesktopIcon *src_icon,
GdkDragAction action);
@@ -411,24 +412,36 @@ xfdesktop_regular_file_icon_get_allowed_drag_actions(XfdesktopIcon *icon)
}
static GdkDragAction
-xfdesktop_regular_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon)
+xfdesktop_regular_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
+ GdkDragAction *suggested_action)
{
GFileInfo *info = xfdesktop_file_icon_peek_file_info(XFDESKTOP_FILE_ICON(icon));
- if(!info)
+ if(!info) {
+ if(suggested_action)
+ *suggested_action = 0;
return 0;
+ }
/* if it's executable we can 'copy'. if it's a folder we can do anything
* if it's writable. */
if(g_file_info_get_file_type(info) == G_FILE_TYPE_DIRECTORY) {
- if(g_file_info_get_attribute_boolean(info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
+ if(g_file_info_get_attribute_boolean(info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) {
+ if(suggested_action)
+ *suggested_action = GDK_ACTION_MOVE;
return GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK;
+ }
} else {
if(xfdesktop_file_utils_file_is_executable(info)) {
+ if(suggested_action)
+ *suggested_action = GDK_ACTION_COPY;
return GDK_ACTION_COPY;
}
}
+ if(suggested_action)
+ *suggested_action = 0;
+
return 0;
}
@@ -446,7 +459,7 @@ xfdesktop_regular_file_icon_do_drop_dest(XfdesktopIcon *icon,
DBG("entering");
g_return_val_if_fail(regular_file_icon && src_file_icon, FALSE);
- g_return_val_if_fail(xfdesktop_regular_file_icon_get_allowed_drop_actions(icon) != 0,
+ g_return_val_if_fail(xfdesktop_regular_file_icon_get_allowed_drop_actions(icon, NULL) != 0,
FALSE);
src_file = xfdesktop_file_icon_peek_file(src_file_icon);
diff --git a/src/xfdesktop-special-file-icon.c b/src/xfdesktop-special-file-icon.c
index db4b7bc..955263c 100644
--- a/src/xfdesktop-special-file-icon.c
+++ b/src/xfdesktop-special-file-icon.c
@@ -75,7 +75,8 @@ static GdkPixbuf *xfdesktop_special_file_icon_peek_pixbuf(XfdesktopIcon *icon,
static G_CONST_RETURN gchar *xfdesktop_special_file_icon_peek_label(XfdesktopIcon *icon);
static G_CONST_RETURN gchar *xfdesktop_special_file_icon_peek_tooltip(XfdesktopIcon *icon);
static GdkDragAction xfdesktop_special_file_icon_get_allowed_drag_actions(XfdesktopIcon *icon);
-static GdkDragAction xfdesktop_special_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon);
+static GdkDragAction xfdesktop_special_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
+ GdkDragAction *suggested_action);
static gboolean xfdesktop_special_file_icon_do_drop_dest(XfdesktopIcon *icon,
XfdesktopIcon *src_icon,
GdkDragAction action);
@@ -305,7 +306,8 @@ xfdesktop_special_file_icon_get_allowed_drag_actions(XfdesktopIcon *icon)
}
static GdkDragAction
-xfdesktop_special_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon)
+xfdesktop_special_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
+ GdkDragAction *suggested_action)
{
XfdesktopSpecialFileIcon *special_file_icon = XFDESKTOP_SPECIAL_FILE_ICON(icon);
GFileInfo *info;
@@ -319,13 +321,20 @@ xfdesktop_special_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon)
{
DBG("can move, copy and link");
actions = GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK;
+ if(suggested_action)
+ *suggested_action = GDK_ACTION_MOVE;
}
}
} else {
DBG("can move");
actions = GDK_ACTION_MOVE; /* everything else is just silly */
+ if(suggested_action)
+ *suggested_action = GDK_ACTION_MOVE;
}
+ if(suggested_action)
+ *suggested_action = 0;
+
return actions;
}
@@ -344,7 +353,7 @@ xfdesktop_special_file_icon_do_drop_dest(XfdesktopIcon *icon,
DBG("entering");
g_return_val_if_fail(special_file_icon && src_file_icon, FALSE);
- g_return_val_if_fail(xfdesktop_special_file_icon_get_allowed_drop_actions(icon),
+ g_return_val_if_fail(xfdesktop_special_file_icon_get_allowed_drop_actions(icon, NULL),
FALSE);
src_file = xfdesktop_file_icon_peek_file(src_file_icon);
diff --git a/src/xfdesktop-volume-icon.c b/src/xfdesktop-volume-icon.c
index 115ae51..4500aa8 100644
--- a/src/xfdesktop-volume-icon.c
+++ b/src/xfdesktop-volume-icon.c
@@ -81,7 +81,8 @@ static GdkPixbuf *xfdesktop_volume_icon_peek_pixbuf(XfdesktopIcon *icon,
static G_CONST_RETURN gchar *xfdesktop_volume_icon_peek_label(XfdesktopIcon *icon);
static G_CONST_RETURN gchar *xfdesktop_volume_icon_peek_tooltip(XfdesktopIcon *icon);
static GdkDragAction xfdesktop_volume_icon_get_allowed_drag_actions(XfdesktopIcon *icon);
-static GdkDragAction xfdesktop_volume_icon_get_allowed_drop_actions(XfdesktopIcon *icon);
+static GdkDragAction xfdesktop_volume_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
+ GdkDragAction *suggested_action);
static gboolean xfdesktop_volume_icon_do_drop_dest(XfdesktopIcon *icon,
XfdesktopIcon *src_icon,
GdkDragAction action);
@@ -328,7 +329,8 @@ xfdesktop_volume_icon_get_allowed_drag_actions(XfdesktopIcon *icon)
}
static GdkDragAction
-xfdesktop_volume_icon_get_allowed_drop_actions(XfdesktopIcon *icon)
+xfdesktop_volume_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
+ GdkDragAction *suggested_action)
{
/* if not mounted, it doesn't really make sense to allow any operations
* here. if mounted, we should allow everything if it's writable. */
@@ -339,10 +341,16 @@ xfdesktop_volume_icon_get_allowed_drop_actions(XfdesktopIcon *icon)
if(xfdesktop_volume_icon_is_mounted(icon)) {
GFileInfo *info = xfdesktop_file_icon_peek_file_info(XFDESKTOP_FILE_ICON(icon));
if(info) {
- if(g_file_info_get_attribute_boolean(info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
+ if(g_file_info_get_attribute_boolean(info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) {
+ if(suggested_action)
+ *suggested_action = GDK_ACTION_COPY;
return GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK;
+ }
}
}
+
+ if(suggested_action)
+ *suggested_action = 0;
return 0;
}
@@ -362,7 +370,7 @@ xfdesktop_volume_icon_do_drop_dest(XfdesktopIcon *icon,
DBG("entering");
g_return_val_if_fail(volume_icon && src_file_icon, FALSE);
- g_return_val_if_fail(xfdesktop_volume_icon_get_allowed_drop_actions(icon),
+ g_return_val_if_fail(xfdesktop_volume_icon_get_allowed_drop_actions(icon, NULL),
FALSE);
src_file = xfdesktop_file_icon_peek_file(src_file_icon);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list