[Xfce4-commits] <thunar:jannis/new-shortcuts-pane> Move DND to ThunarShortcutGroup, start with creating shortcuts via DND.

Jannis Pohlmann noreply at xfce.org
Tue Jan 24 02:52:02 CET 2012


Updating branch refs/heads/jannis/new-shortcuts-pane
         to 8c9570cf8750b06e547e197d39f1608e7724f66f (commit)
       from 0941a545ebea71dd0b6c6272bd188760b5b87827 (commit)

commit 8c9570cf8750b06e547e197d39f1608e7724f66f
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Tue Jan 24 01:46:53 2012 +0000

    Move DND to ThunarShortcutGroup, start with creating shortcuts via DND.
    
    The empty spot indicator for text/uri-list should really just be a thin
    line, not a huge empty block.

 TODO                           |   14 ++
 thunar/thunar-shortcut-group.c |  204 +++++++++++++++++++++++--
 thunar/thunar-shortcut.c       |  324 ++++++----------------------------------
 thunar/thunar-shortcut.h       |    8 +-
 4 files changed, 256 insertions(+), 294 deletions(-)

diff --git a/TODO b/TODO
index 7547d2a..c5f677e 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,17 @@
+Branch jannis/new-shortcuts-pane
+================================
+
+ - Reordering shortcuts may not change the order or position of immutable
+   shortcuts. That still needs to be implemented in ThunarShortcutGroup.
+
+ - Dragging a URI to the new shortcuts pane must either cause an empty
+   spot indicator to show up or must indicate possible drop actions on
+   the current shortcut. The latter already works, the empty spot
+   indicator still needs to be implemented.
+
+ -
+
+
 Important for Thunar 1.2
 ========================
 
diff --git a/thunar/thunar-shortcut-group.c b/thunar/thunar-shortcut-group.c
index c00d15e..28b0230 100644
--- a/thunar/thunar-shortcut-group.c
+++ b/thunar/thunar-shortcut-group.c
@@ -1,6 +1,6 @@
 /* vi:set et ai sw=2 sts=2 ts=2: */
 /*-
- * Copyright (c) 2011 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2011-2012 Jannis Pohlmann <jannis at xfce.org>
  *
  * This program is free software; you can redistribute it and/or 
  * modify it under the terms of the GNU General Public License as
@@ -27,9 +27,11 @@
 
 #include <gtk/gtk.h>
 
+#include <thunar/thunar-dnd.h>
 #include <thunar/thunar-enum-types.h>
 #include <thunar/thunar-private.h>
 #include <thunar/thunar-shortcut-group.h>
+#include <thunar/thunar-shortcut.h>
 
 
 
@@ -95,6 +97,8 @@ static void     thunar_shortcut_group_expand_style_set     (ThunarShortcutGroup
                                                             GtkWidget              *expander);
 static void     thunar_shortcut_group_apply_indentation    (ThunarShortcutGroup    *group,
                                                             ThunarShortcut         *shortcut);
+static void     thunar_shortcut_group_drag_highlight       (ThunarShortcutGroup    *group,
+                                                            ThunarShortcut         *shortcut);
 static gboolean thunar_shortcut_group_find_child_by_coords (ThunarShortcutGroup    *group,
                                                             gint                    x,
                                                             gint                    y,
@@ -128,6 +132,7 @@ struct _ThunarShortcutGroup
 
   guint              drop_data_ready : 1;
   guint              drop_occurred : 1;
+  GList             *drop_file_list;
 
   GtkWidget         *drag_shortcut;
   GdkPixmap         *drag_snapshot;
@@ -440,11 +445,19 @@ thunar_shortcut_group_drag_data_received (GtkWidget        *widget,
                                           GdkDragContext   *context,
                                           gint              x,
                                           gint              y,
-                                          GtkSelectionData *data,
+                                          GtkSelectionData *selection_data,
                                           guint             info,
                                           guint             timestamp)
 {
   ThunarShortcutGroup *group = THUNAR_SHORTCUT_GROUP (widget);
+  ThunarShortcut      *shortcut;
+  GtkAllocation        allocation;
+  ThunarFile          *file;
+  GdkDragAction        action = 0;
+  GdkDragAction        actions = 0;
+  GtkWidget           *child = NULL;
+  gboolean             success = FALSE;
+  gint                 child_index;
 
   _thunar_return_if_fail (THUNAR_IS_SHORTCUT_GROUP (widget));
   _thunar_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
@@ -454,11 +467,82 @@ thunar_shortcut_group_drag_data_received (GtkWidget        *widget,
       /* only read data if we don't have it yet */
       if (!group->drop_data_ready)
         {
+          /* extract the URI list from the selection data (if valid) */
+          if (info == THUNAR_DND_TARGET_TEXT_URI_LIST
+              && selection_data->format == 8
+              && selection_data->length > 0)
+            {
+              group->drop_file_list =
+                thunar_g_file_list_new_from_string ((const gchar *) selection_data->data);
+            }
+
+          /* reset the state */
+          group->drop_data_ready = TRUE;
         }
 
       if (group->drop_occurred)
         {
+          /* reset the drop state */
           group->drop_occurred = FALSE;
+
+          /* translate the y coordinate so that it is relative to the parent */
+          gtk_widget_get_allocation (widget, &allocation);
+          y = y + allocation.y;
+
+          /* find the shortcut we are currently hovering */
+          if (!thunar_shortcut_group_find_child_by_coords (group, x, y,
+                                                           &child,
+                                                           &child_index))
+            {
+              return;
+            }
+
+          /* if we are hovering a shortcut, show an empty spot indicator */
+          if (THUNAR_IS_SHORTCUT (child))
+            {
+              shortcut = THUNAR_SHORTCUT (child);
+
+              /* determine the drop actions */
+              actions = thunar_shortcut_compute_drop_actions (shortcut,
+                                                              group->drop_file_list,
+                                                              context,
+                                                              &action);
+
+              /* check whether the actions are supported */
+              if ((actions & (GDK_ACTION_COPY
+                              | GDK_ACTION_MOVE
+                              | GDK_ACTION_LINK)) != 0)
+                {
+                  file = thunar_shortcut_get_file (shortcut);
+
+                  /* if necessary, ask the user what he wants to do */
+                  if (action == GDK_ACTION_ASK)
+                    {
+                      action = thunar_dnd_ask (widget,
+                                               file,
+                                               group->drop_file_list,
+                                               timestamp,
+                                               actions);
+                    }
+
+                  /* if we have a drop action, perform it now */
+                  if (action != 0)
+                    {
+                      success = thunar_dnd_perform (widget,
+                                                    file,
+                                                    group->drop_file_list,
+                                                    action,
+                                                    NULL);
+                    }
+                }
+
+
+              /* disable highlighting and release the drag data */
+              thunar_shortcut_group_drag_leave (widget, context, timestamp);
+
+              /* tell the peer that we handled the copy */
+              gtk_drag_finish (context, success, FALSE, timestamp);
+            }
         }
     }
 }
@@ -497,6 +581,16 @@ thunar_shortcut_group_drag_drop (GtkWidget      *widget,
 
       return TRUE;
     }
+  else if (target == gdk_atom_intern_static_string ("text/uri-list"))
+    {
+      /* set the state so that drag_data_received knows that it needs to drop now */
+      group->drop_occurred = TRUE;
+
+      /* request the drag data from the source and perform the drop */
+      gtk_drag_get_data (widget, context, target, timestamp);
+
+      return TRUE;
+    }
   else
     {
       /* we cannot handle the drop */
@@ -521,7 +615,7 @@ thunar_shortcut_group_drag_end (GtkWidget      *widget,
 
       group->drag_shortcut = NULL;
     }
-  
+
   if (group->drag_snapshot != NULL)
     {
       g_object_unref (group->drag_snapshot);
@@ -544,15 +638,18 @@ thunar_shortcut_group_drag_leave (GtkWidget      *widget,
   _thunar_return_if_fail (THUNAR_IS_SHORTCUT_GROUP (widget));
   _thunar_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
 
-#if 0
+  thunar_shortcut_group_drag_highlight (group, NULL);
+
   /* reset DND state information */
   if (group->drop_data_ready)
     {
+      thunar_g_file_list_free (group->drop_file_list);
+      group->drop_file_list = NULL;
+
       group->drop_data_ready = FALSE;
       group->drop_occurred = FALSE;
       group->drag_shortcut = NULL;
     }
-#endif
 
   /* hide the empty spot indicator */
   gtk_widget_hide (group->empty_spot);
@@ -644,18 +741,72 @@ thunar_shortcut_group_drag_motion (GtkWidget      *widget,
 
       /* allow reordering */
       actions = GDK_ACTION_MOVE;
-      
     }
   else if (target == gdk_atom_intern_static_string ("text/uri-list"))
     {
-      /* request the drop data on demand */
-      if (!group->drop_data_ready)
+      /* translate the y coordinate so that it is relative to the parent */
+      gtk_widget_get_allocation (widget, &allocation);
+      y = y + allocation.y;
+
+      /* find the shortcut we are currently hovering */
+      if (!thunar_shortcut_group_find_child_by_coords (group, x, y,
+                                                       &child,
+                                                       &child_index))
         {
-          /* request the drop data from the source */
-          gtk_drag_get_data (widget, context, target, timestamp);
+          gdk_drag_status (context, 0, timestamp);
+          return TRUE;
         }
-      else
+
+      /* if we are hovering a shortcut, show an empty spot indicator */
+      if (THUNAR_IS_SHORTCUT (child))
         {
+          gtk_widget_get_allocation (child, &allocation);
+
+          /* only allow DND into the shortcut if we're 1/6th inside */
+          if (y > (allocation.y + allocation.height / 6)
+              && y < (allocation.y + (allocation.height * 5) / 6))
+            {
+              thunar_shortcut_group_drag_highlight (group, THUNAR_SHORTCUT (child));
+
+              /* request the drop data on demand */
+              if (!group->drop_data_ready)
+                {
+                  /* request the drop data from the source */
+                  gtk_drag_get_data (widget, context, target, timestamp);
+                }
+              else
+                {
+                  /* check whether we have any files at all */
+                  if (group->drop_file_list != NULL)
+                    {
+                      thunar_shortcut_compute_drop_actions (THUNAR_SHORTCUT (child),
+                                                            group->drop_file_list,
+                                                            context,
+                                                            &actions);
+                    }
+                }
+            }
+          else
+            {
+              thunar_shortcut_group_drag_highlight (group, NULL);
+
+              /* add the empty spot indicator to the shortcuts container */
+              if (gtk_widget_get_parent (group->empty_spot) == NULL)
+                {
+                  gtk_box_pack_start (GTK_BOX (group->shortcuts),
+                                      group->empty_spot,
+                                      FALSE, TRUE, 0);
+                }
+
+              /* show the empty spot indicator before/after the hovered shortcut,
+               * depending on where exactly the drag motion happened */
+              if (y > allocation.y + allocation.height / 2)
+                child_index += 1;
+              gtk_box_reorder_child (GTK_BOX (group->shortcuts),
+                                     group->empty_spot,
+                                     child_index);
+              gtk_widget_show (group->empty_spot);
+            }
         }
     }
   else
@@ -754,7 +905,7 @@ thunar_shortcut_group_expand_style_set (ThunarShortcutGroup *group,
   _thunar_return_if_fail (THUNAR_IS_SHORTCUT_GROUP (group));
   _thunar_return_if_fail (GTK_IS_EXPANDER (expander));
   _thunar_return_if_fail (expander == GTK_WIDGET (group));
-  
+
   children = gtk_container_get_children (GTK_CONTAINER (group->shortcuts));
 
   for (iter = children; iter != NULL; iter = iter->next)
@@ -794,6 +945,34 @@ thunar_shortcut_group_apply_indentation (ThunarShortcutGroup *group,
 
 
 
+static void
+thunar_shortcut_group_drag_highlight (ThunarShortcutGroup *group,
+                                      ThunarShortcut      *shortcut)
+{
+  GList *children;
+  GList *iter;
+
+  _thunar_return_if_fail (THUNAR_IS_SHORTCUT_GROUP (group));
+  _thunar_return_if_fail (shortcut == NULL || THUNAR_IS_SHORTCUT (shortcut));
+
+  children = gtk_container_get_children (GTK_CONTAINER (group->shortcuts));
+
+  for (iter = children; iter != NULL; iter = iter->next)
+    {
+      if (!THUNAR_IS_SHORTCUT (iter->data))
+        continue;
+
+      if (THUNAR_SHORTCUT (iter->data) == shortcut)
+        thunar_shortcut_set_drag_highlight (THUNAR_SHORTCUT (iter->data), TRUE);
+      else
+        thunar_shortcut_set_drag_highlight (THUNAR_SHORTCUT (iter->data), FALSE);
+    }
+
+  g_list_free (children);
+}
+
+
+
 static gboolean
 thunar_shortcut_group_find_child_by_coords (ThunarShortcutGroup *group,
                                             gint                 x,
@@ -1014,7 +1193,6 @@ thunar_shortcut_group_unselect_shortcuts (ThunarShortcutGroup *group,
         {
           gtk_widget_set_state (GTK_WIDGET (shortcut), GTK_STATE_NORMAL);
         }
-      
     }
 
   g_list_free (children);
diff --git a/thunar/thunar-shortcut.c b/thunar/thunar-shortcut.c
index 5417b36..a73863f 100644
--- a/thunar/thunar-shortcut.c
+++ b/thunar/thunar-shortcut.c
@@ -99,29 +99,6 @@ static gboolean      thunar_shortcut_button_press_event      (GtkWidget
                                                               GdkEventButton     *event);
 static gboolean      thunar_shortcut_button_release_event    (GtkWidget          *widget,
                                                               GdkEventButton     *event);
-static void          thunar_shortcut_drag_data_received      (GtkWidget          *widget,
-                                                              GdkDragContext     *context,
-                                                              gint                x,
-                                                              gint                y,
-                                                              GtkSelectionData   *selection_data,
-                                                              guint               info,
-                                                              guint               timestamp);
-static gboolean      thunar_shortcut_drag_drop               (GtkWidget          *widget,
-                                                              GdkDragContext     *context,
-                                                              gint                x,
-                                                              gint                y,
-                                                              guint               timestamp);
-static void          thunar_shortcut_drag_leave              (GtkWidget          *widget,
-                                                              GdkDragContext     *context,
-                                                              guint               timestamp);
-static gboolean      thunar_shortcut_drag_motion             (GtkWidget          *widget,
-                                                              GdkDragContext     *context,
-                                                              gint                x,
-                                                              gint                y,
-                                                              guint               timestamp);
-static GdkDragAction thunar_shortcut_compute_drop_actions    (ThunarShortcut     *shortcut,
-                                                              GdkDragContext     *context,
-                                                              GdkDragAction      *suggested_action);
 static gboolean      thunar_shortcut_key_press_event         (GtkWidget          *widget,
                                                               GdkEventKey        *event);
 static gboolean      thunar_shortcut_enter_notify_event      (GtkWidget          *widget,
@@ -230,9 +207,6 @@ struct _ThunarShortcut
   ThunarShortcutState state;
 
   guint               drag_highlight : 1;
-  guint               drop_occurred : 1;
-  guint               drop_data_ready : 1;
-  GList              *drop_file_list;
 
   gint                pressed_button;
 };
@@ -246,11 +220,6 @@ G_DEFINE_TYPE_WITH_CODE (ThunarShortcut, thunar_shortcut, GTK_TYPE_EVENT_BOX,
 
 static guint shortcut_signals[LAST_SIGNAL];
 
-static const GtkTargetEntry drop_targets[] =
-{
-  { "text/uri-list", 0, THUNAR_DND_TARGET_TEXT_URI_LIST },
-};
-
 
 
 static void
@@ -271,10 +240,6 @@ thunar_shortcut_class_init (ThunarShortcutClass *klass)
   gtkwidget_class = GTK_WIDGET_CLASS (klass);
   gtkwidget_class->button_press_event = thunar_shortcut_button_press_event;
   gtkwidget_class->button_release_event = thunar_shortcut_button_release_event;
-  gtkwidget_class->drag_data_received = thunar_shortcut_drag_data_received;
-  gtkwidget_class->drag_drop = thunar_shortcut_drag_drop;
-  gtkwidget_class->drag_leave = thunar_shortcut_drag_leave;
-  gtkwidget_class->drag_motion = thunar_shortcut_drag_motion;
   gtkwidget_class->key_press_event = thunar_shortcut_key_press_event;
   gtkwidget_class->enter_notify_event = thunar_shortcut_enter_notify_event;
   gtkwidget_class->leave_notify_event = thunar_shortcut_leave_notify_event;
@@ -504,16 +469,6 @@ thunar_shortcut_init (ThunarShortcut *shortcut)
   shortcut->preferences = thunar_preferences_get ();
   exo_binding_new (G_OBJECT (shortcut->preferences), "shortcuts-icon-size",
                    G_OBJECT (shortcut), "icon-size");
-
-  /* set up drop support for the shortcut */
-  gtk_drag_dest_set (GTK_WIDGET (shortcut), 0,
-                     drop_targets, G_N_ELEMENTS (drop_targets),
-                     GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
-
-  /* reset drop information */
-  shortcut->drop_occurred = FALSE;
-  shortcut->drop_data_ready = FALSE;
-  shortcut->drop_file_list = NULL;
 }
 
 
@@ -802,241 +757,6 @@ thunar_shortcut_button_release_event (GtkWidget      *widget,
 
 
 
-static void
-thunar_shortcut_drag_data_received (GtkWidget        *widget,
-                                    GdkDragContext   *context,
-                                    gint              x,
-                                    gint              y,
-                                    GtkSelectionData *selection_data,
-                                    guint             info,
-                                    guint             timestamp)
-{
-  ThunarShortcut *shortcut = THUNAR_SHORTCUT (widget);
-  GdkDragAction   actions;
-  GdkDragAction   action;
-  gboolean        success = FALSE;
-
-  _thunar_return_if_fail (THUNAR_IS_SHORTCUT (widget));
-  _thunar_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
-
-  /* check if we don't already know the drop data */
-  if (!shortcut->drop_data_ready)
-    {
-      /* extract the URI list from the selection data (if valid) */
-      if (info == THUNAR_DND_TARGET_TEXT_URI_LIST
-          && selection_data->format == 8
-          && selection_data->length > 0)
-        {
-          shortcut->drop_file_list = 
-            thunar_g_file_list_new_from_string ((const gchar *) selection_data->data);
-        }
-
-      /* reset the state */
-      shortcut->drop_data_ready = TRUE;
-    }
-
-  /* check if the data was dropped */
-  if (shortcut->drop_occurred)
-    {
-      /* reset the drop state */
-      shortcut->drop_occurred = FALSE;
-
-      /* make sure we only handle text/uri-list */
-      if (info == THUNAR_DND_TARGET_TEXT_URI_LIST)
-        {
-          if (shortcut->file != NULL)
-            {
-              /* determine the drop actions */
-              actions = thunar_shortcut_compute_drop_actions (shortcut, context, 
-                                                              &action);
-
-              /* check whether the actions are supported */
-              if ((actions & (GDK_ACTION_COPY
-                              | GDK_ACTION_MOVE 
-                              | GDK_ACTION_LINK)) != 0)
-                {
-                  /* if necessary, ask the user what he wants to do */
-                  if (action == GDK_ACTION_ASK)
-                    {
-                      action = thunar_dnd_ask (widget,
-                                               shortcut->file,
-                                               shortcut->drop_file_list,
-                                               timestamp,
-                                               actions);
-                    }
-
-                  /* if we have a drop action, perform it now */
-                  if (action != 0)
-                    {
-                      success = thunar_dnd_perform (widget,
-                                                    shortcut->file,
-                                                    shortcut->drop_file_list,
-                                                    action,
-                                                    NULL);
-                    }
-                }
-            }
-
-          /* disable highlighting and release the drag data */
-          thunar_shortcut_drag_leave (widget, context, timestamp);
-
-          /* tell the peer that we handled the copy */
-          gtk_drag_finish (context, success, FALSE, timestamp);
-        }
-    }
-  else
-    {
-      gdk_drag_status (context, 0, timestamp);
-    }
-}
-
-
-
-static gboolean
-thunar_shortcut_drag_drop (GtkWidget      *widget,
-                           GdkDragContext *context,
-                           gint            x,
-                           gint            y,
-                           guint           timestamp)
-{
-  ThunarShortcut *shortcut = THUNAR_SHORTCUT (widget);
-  GdkAtom         target;
-
-  _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT (widget), FALSE);
-  _thunar_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), FALSE);
-
-  target = gtk_drag_dest_find_target (widget, context, NULL);
-  if (target == gdk_atom_intern_static_string ("text/uri-list"))
-    {
-      /* set the state so that drag_data_received knows that it needs to drop now */
-      shortcut->drop_occurred = TRUE;
-
-      /* request the drag data from the source and perform the drop */
-      gtk_drag_get_data (widget, context, target, timestamp);
-
-      return TRUE;
-    }
-  else
-    {
-      /* we cannot handle the drop */
-      return FALSE;
-    }
-}
-
-
-
-static void
-thunar_shortcut_drag_leave (GtkWidget      *widget,
-                            GdkDragContext *context,
-                            guint           timestamp)
-{
-  ThunarShortcut *shortcut = THUNAR_SHORTCUT (widget);
-
-  _thunar_return_if_fail (THUNAR_IS_SHORTCUT (widget));
-  _thunar_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
-
-  /* reset highlighting */
-  shortcut->drag_highlight = FALSE;
-
-  /* reset the "drop data ready" status and free the file list */
-  if (shortcut->drop_data_ready)
-    {
-      thunar_g_file_list_free (shortcut->drop_file_list);
-      shortcut->drop_file_list = NULL;
-      shortcut->drop_data_ready = FALSE;
-    }
-
-  /* schedule a repaint to make sure the shortcut is no longer highlighted */
-  gtk_widget_queue_draw (widget);
-
-  /* call the parent's handler */
-  if (GTK_WIDGET_CLASS (thunar_shortcut_parent_class)->drag_leave != NULL)
-    (*GTK_WIDGET_CLASS (thunar_shortcut_parent_class)->drag_leave) (widget, context, timestamp);
-}
-
-
-
-static gboolean
-thunar_shortcut_drag_motion (GtkWidget      *widget,
-                             GdkDragContext *context,
-                             gint            x,
-                             gint            y,
-                             guint           timestamp)
-{
-  ThunarShortcut *shortcut = THUNAR_SHORTCUT (widget);
-  GdkDragAction   actions;
-  GdkAtom         target;
-
-  _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT (widget), FALSE);
-  _thunar_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), FALSE);
-
-  /* determine the drag target */
-  target = gtk_drag_dest_find_target (widget, context, NULL);
-
-  /* abort if the target is unsupported */
-  if (target != gdk_atom_intern_static_string ("text/uri-list"))
-    {
-      /* unsupported target, can't handle it, sorry */
-      return FALSE;
-    }
-
-  /* request the drop data on-demand (if we don't have it yet) */
-  if (!shortcut->drop_data_ready)
-    {
-      /* request the drag data from the source */
-      gtk_drag_get_data (widget, context, target, timestamp);
-      return TRUE;
-    }
-  else
-    {
-      /* check whether we have any files at all */
-      if (shortcut->drop_file_list != NULL)
-        thunar_shortcut_compute_drop_actions (shortcut, context, &actions);
-    }
-
-  /* tell Gdk whether we can drop here */
-  gdk_drag_status (context, actions, timestamp);
-
-  /* highlight the shortcut */
-  shortcut->drag_highlight = TRUE;
-  gtk_widget_queue_draw (widget);
-
-  return TRUE;
-}
-
-
-
-static GdkDragAction
-thunar_shortcut_compute_drop_actions (ThunarShortcut *shortcut,
-                                      GdkDragContext *context,
-                                      GdkDragAction  *suggested_action)
-{
-  GdkDragAction actions;
-
-  _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT (shortcut), 0);
-  _thunar_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
-
-  if (shortcut->file != NULL)
-    {
-      actions = thunar_file_accepts_drop (shortcut->file,
-                                          shortcut->drop_file_list,
-                                          context,
-                                          suggested_action);
-    }
-  else
-    {
-      /* we know nothing about the file, just report back that dropping
-       * here is impossible */
-      actions = 0;
-      if (suggested_action != NULL)
-        *suggested_action = 0;
-    }
-
-  return actions;
-}
-
-
-
 static gboolean
 thunar_shortcut_key_press_event (GtkWidget   *widget,
                                  GdkEventKey *event)
@@ -2784,3 +2504,47 @@ thunar_shortcut_get_display_name (ThunarShortcut *shortcut)
 
   return label;
 }
+
+
+
+GdkDragAction
+thunar_shortcut_compute_drop_actions (ThunarShortcut *shortcut,
+                                      GList          *drop_file_list,
+                                      GdkDragContext *context,
+                                      GdkDragAction  *suggested_action)
+{
+  GdkDragAction actions;
+
+  _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT (shortcut), 0);
+  _thunar_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
+
+  if (shortcut->file != NULL)
+    {
+      actions = thunar_file_accepts_drop (shortcut->file,
+                                          drop_file_list,
+                                          context,
+                                          suggested_action);
+    }
+  else
+    {
+      /* we know nothing about the file, just report back that dropping
+       * here is impossible */
+      actions = 0;
+      if (suggested_action != NULL)
+        *suggested_action = 0;
+    }
+
+  return actions;
+}
+
+
+
+void
+thunar_shortcut_set_drag_highlight (ThunarShortcut *shortcut,
+                                    gboolean        highlight)
+{
+  _thunar_return_if_fail (THUNAR_IS_SHORTCUT (shortcut));
+  
+  shortcut->drag_highlight = !!highlight;
+  gtk_widget_queue_draw (GTK_WIDGET (shortcut));
+}
diff --git a/thunar/thunar-shortcut.h b/thunar/thunar-shortcut.h
index 7986abb..e55c63c 100644
--- a/thunar/thunar-shortcut.h
+++ b/thunar/thunar-shortcut.h
@@ -1,6 +1,6 @@
 /* vi:set et ai sw=2 sts=2 ts=2: */
 /*-
- * Copyright (c) 2011 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2011-2012 Jannis Pohlmann <jannis at xfce.org>
  *
  * This program is free software; you can redistribute it and/or 
  * modify it under the terms of the GNU General Public License as
@@ -93,6 +93,12 @@ gboolean           thunar_shortcut_matches_file          (ThunarShortcut    *sho
 gboolean           thunar_shortcut_matches_location      (ThunarShortcut    *shortcut,
                                                           GFile             *location);
 const gchar       *thunar_shortcut_get_display_name      (ThunarShortcut    *shortcut);
+GdkDragAction      thunar_shortcut_compute_drop_actions  (ThunarShortcut    *shortcut,
+                                                          GList             *drop_file_list,
+                                                          GdkDragContext    *context,
+                                                          GdkDragAction     *suggested_action);
+void               thunar_shortcut_set_drag_highlight    (ThunarShortcut    *shortcut,
+                                                          gboolean           highlight);
 
 G_END_DECLS
 


More information about the Xfce4-commits mailing list