[Xfce4-commits] [xfce/xfdesktop] 03/03: Enable drag&drop popup menu for local actions

noreply at xfce.org noreply at xfce.org
Mon Mar 2 14:25:06 CET 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfdesktop.

commit 7cfdcad6490b635aaa98a6807eed2b7aec1f529d
Author: Thaddaeus Tintenfisch <thad.fisch at gmail.com>
Date:   Sun Feb 22 19:49:12 2015 +0100

    Enable drag&drop popup menu for local actions
    
    Signed-off-by: Eric Koegel <eric.koegel at gmail.com>
---
 src/xfdesktop-file-icon-manager.c |   14 +++++++-------
 src/xfdesktop-file-icon-manager.h |    8 ++++++++
 src/xfdesktop-icon-view.c         |   29 +++++++++++++++++++++++++++--
 src/xfdesktop-regular-file-icon.c |    2 +-
 src/xfdesktop-special-file-icon.c |    4 ++--
 src/xfdesktop-volume-icon.c       |    2 +-
 6 files changed, 46 insertions(+), 13 deletions(-)

diff --git a/src/xfdesktop-file-icon-manager.c b/src/xfdesktop-file-icon-manager.c
index 39c75af..2077a42 100644
--- a/src/xfdesktop-file-icon-manager.c
+++ b/src/xfdesktop-file-icon-manager.c
@@ -3384,13 +3384,13 @@ static void xfdesktop_dnd_item_cancel(GtkWidget *item, GdkDragAction *action)
  * Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>
  * Copyright (c) 2009-2011 Jannis Pohlmann <jannis at xfce.org>
  **/
-static void xfdesktop_dnd_menu (XfdesktopIconViewManager *manager,
-                                XfdesktopIcon *drop_icon,
-                                GdkDragContext *context,
-                                GdkDragAction *action,
-                                gint16 row,
-                                gint16 col,
-                                guint time_)
+void xfdesktop_dnd_menu (XfdesktopIconViewManager *manager,
+                         XfdesktopIcon *drop_icon,
+                         GdkDragContext *context,
+                         GdkDragAction *action,
+                         gint16 row,
+                         gint16 col,
+                         guint time_)
 {
     static GdkDragAction    actions[] = { GDK_ACTION_COPY, GDK_ACTION_MOVE, GDK_ACTION_LINK };
     static const gchar      *action_names[] = { N_ ("Copy _Here") , N_ ("_Move Here") , N_ ("_Link Here") };
diff --git a/src/xfdesktop-file-icon-manager.h b/src/xfdesktop-file-icon-manager.h
index 5a4fece..7dce281 100644
--- a/src/xfdesktop-file-icon-manager.h
+++ b/src/xfdesktop-file-icon-manager.h
@@ -67,6 +67,14 @@ gboolean xfdesktop_file_icon_manager_get_cached_icon_position(
                                                     gint16 *row,
                                                     gint16 *col);
 
+void xfdesktop_dnd_menu (XfdesktopIconViewManager *manager,
+                         XfdesktopIcon *drop_icon,
+                         GdkDragContext *context,
+                         GdkDragAction *action,
+                         gint16 row,
+                         gint16 col,
+                         guint time_);
+
 G_END_DECLS
 
 #endif  /* __XFDESKTOP_FILE_ICON_MANAGER_H__ */
diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index 1710898..5be473d 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -1479,10 +1479,11 @@ xfdesktop_icon_view_drag_motion(GtkWidget *widget,
         GdkDragAction allowed_actions = gdk_drag_context_get_actions(context);
 
         if(is_local_drag) {  /* #2 */
-            /* check to make sure we aren't just hovering over ourself */
             GList *l;
             gint16 sel_row, sel_col;
+            gboolean action_ask = FALSE;
             
+            /* check to make sure we aren't just hovering over ourself */
             for(l = icon_view->priv->selected_icons; l; l = l->next) {
                 XfdesktopIcon *sel_icon = l->data;
                 if(xfdesktop_icon_get_position(sel_icon, &sel_row, &sel_col)
@@ -1492,10 +1493,21 @@ xfdesktop_icon_view_drag_motion(GtkWidget *widget,
                 }
             }
             
+            if(allowed_actions & GDK_ACTION_ASK)
+                action_ask = TRUE;
+
             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);
+
+            /* check if drag&drop menu should be triggered */
+            if(action_ask) {
+                if(allowed_actions == (GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK)) {
+                    allowed_actions |= GDK_ACTION_ASK;
+                    our_action = GDK_ACTION_ASK;
+                }
+            }
         } else {  /* #4 */
             allowed_actions &= xfdesktop_icon_get_allowed_drop_actions(icon_on_dest, NULL);
 
@@ -1567,12 +1579,25 @@ xfdesktop_icon_view_drag_drop(GtkWidget *widget,
     
     if(target == gdk_atom_intern("XFDESKTOP_ICON", FALSE)) {
         if(icon_on_dest) {
+            GdkDragAction action;
             gboolean ret = FALSE;
             
+            action = gdk_drag_context_get_selected_action(context);
+
+            if(action == GDK_ACTION_ASK) {
+                xfdesktop_dnd_menu(icon_view->priv->manager, icon_on_dest,
+                                   context, &action, row, col, time_);
+
+                if(action == 0) {
+                    gtk_drag_finish(context, FALSE, FALSE, time_);
+                    return;
+                }
+            }
+
             for(l = icon_view->priv->selected_icons; l; l = l->next) {
                 if(xfdesktop_icon_do_drop_dest(icon_on_dest,
                                                XFDESKTOP_ICON(l->data),
-                                               gdk_drag_context_get_selected_action(context)))
+                                               action))
                 {
                     ret = TRUE;
                 }
diff --git a/src/xfdesktop-regular-file-icon.c b/src/xfdesktop-regular-file-icon.c
index 3ce9b3e..e2fd49b 100644
--- a/src/xfdesktop-regular-file-icon.c
+++ b/src/xfdesktop-regular-file-icon.c
@@ -649,7 +649,7 @@ xfdesktop_regular_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
         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;
+            return GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK;
         }
     } else {
         if(xfdesktop_file_utils_file_is_executable(info)) {
diff --git a/src/xfdesktop-special-file-icon.c b/src/xfdesktop-special-file-icon.c
index 6578f7f..4c85b57 100644
--- a/src/xfdesktop-special-file-icon.c
+++ b/src/xfdesktop-special-file-icon.c
@@ -355,8 +355,8 @@ xfdesktop_special_file_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
             if(g_file_info_get_attribute_boolean(info,
                                                  G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
             {
-                XF_DEBUG("can move, copy and link");
-                actions = GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK;
+                XF_DEBUG("can move, copy, link and ask");
+                actions = GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK;
                 if(suggested_action)
                     *suggested_action = GDK_ACTION_MOVE;
             }
diff --git a/src/xfdesktop-volume-icon.c b/src/xfdesktop-volume-icon.c
index 00631f2..fe462d6 100644
--- a/src/xfdesktop-volume-icon.c
+++ b/src/xfdesktop-volume-icon.c
@@ -375,7 +375,7 @@ xfdesktop_volume_icon_get_allowed_drop_actions(XfdesktopIcon *icon,
             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;
+                return GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK;
             }
         }
     }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list