libegg r853 - in trunk: . libegg/toolpalette



Author: hasselmm
Date: Wed Jan 23 16:05:09 2008
New Revision: 853
URL: http://svn.gnome.org/viewvc/libegg?rev=853&view=rev

Log:
* libegg/toolpalette/eggtoolitemgroup.c,
libegg/toolpalette/eggtoolitemgroup.h: Allow position
of -1 for egg_tool_item_group_set_item_position().
* libegg/toolpalette/eggtoolpalette.c,
libegg/toolpalette/eggtoolpalette.h: Add targets and actions arguments
to egg_tool_palette_add_drag_dest(). Implement DnD for item groups.
Add egg_tool_palette_get_group_position(). Implement
egg_tool_palette_reorder_group(), and rename it to
egg_tool_palette_set_group_position().
* libegg/toolpalette/eggtoolpaletteprivate.h:
Rename _egg_tool_palette_item_set_drag_source()
to _egg_tool_palette_child_set_drag_source().
* libegg/toolpalette/testtoolpalette.c:
Support reordering of tool item groups.
* libegg/toolpalette/TODO: Updated.


Modified:
   trunk/ChangeLog
   trunk/libegg/toolpalette/TODO
   trunk/libegg/toolpalette/eggtoolitemgroup.c
   trunk/libegg/toolpalette/eggtoolitemgroup.h
   trunk/libegg/toolpalette/eggtoolpalette.c
   trunk/libegg/toolpalette/eggtoolpalette.h
   trunk/libegg/toolpalette/eggtoolpaletteprivate.h
   trunk/libegg/toolpalette/testtoolpalette.c

Modified: trunk/libegg/toolpalette/TODO
==============================================================================
--- trunk/libegg/toolpalette/TODO	(original)
+++ trunk/libegg/toolpalette/TODO	Wed Jan 23 16:05:09 2008
@@ -1,10 +1,10 @@
 EggToolPalette
 
- * implement stubs (g_return_if_reached)
  * implement natural-size interface
  * scroll to group, when expanding
  * support horizontal orientation
  * consider scrollbar size in size-request
+ * install position child properties
 
 GtkToolShell:
 

Modified: trunk/libegg/toolpalette/eggtoolitemgroup.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.c	(original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.c	Wed Jan 23 16:05:09 2008
@@ -862,7 +862,7 @@
   group->priv->items_length += 1;
 
   if (EGG_IS_TOOL_PALETTE (parent))
-    _egg_tool_palette_item_set_drag_source (GTK_WIDGET (item), parent);
+    _egg_tool_palette_child_set_drag_source (GTK_WIDGET (item), parent);
 
   gtk_widget_set_parent (GTK_WIDGET (item), GTK_WIDGET (group));
 }
@@ -870,7 +870,7 @@
 void
 egg_tool_item_group_set_item_position (EggToolItemGroup *group,
                                        GtkToolItem      *item,
-                                       guint             position)
+                                       gint              position)
 {
   gint old_position;
   gpointer src, dst;
@@ -881,18 +881,20 @@
 
   egg_tool_item_group_repack (group);
 
-  g_return_if_fail (position < group->priv->items_length);
+  g_return_if_fail (position >= -1);
+
+  if (-1 == position)
+    position = group->priv->items_length - 1;
+
+  g_return_if_fail ((guint) position < group->priv->items_length);
 
   if (item == group->priv->items[position])
     return;
 
   old_position = egg_tool_item_group_get_item_position (group, item);
-
   g_return_if_fail (old_position >= 0);
 
-g_print ("%s: old=%d, new=%d\n", G_STRFUNC, old_position, position);
-
-  if (position < (guint) old_position)
+  if (position < old_position)
     {
       dst = group->priv->items + position + 1;
       src = group->priv->items + position;

Modified: trunk/libegg/toolpalette/eggtoolitemgroup.h
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.h	(original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.h	Wed Jan 23 16:05:09 2008
@@ -65,7 +65,7 @@
                                                              gint              position);
 void                  egg_tool_item_group_set_item_position (EggToolItemGroup *group,
                                                              GtkToolItem      *item,
-                                                             guint             position);
+                                                             gint              position);
 gint                  egg_tool_item_group_get_item_position (EggToolItemGroup *group,
                                                              GtkToolItem      *item);
 

Modified: trunk/libegg/toolpalette/eggtoolpalette.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolpalette.c	(original)
+++ trunk/libegg/toolpalette/eggtoolpalette.c	Wed Jan 23 16:05:09 2008
@@ -64,13 +64,16 @@
 struct _EggToolPaletteDragData
 {
   EggToolPalette *palette;
-  GtkToolItem    *item;
+  GtkWidget      *item;
 };
 
-static GdkAtom dnd_target_atom = GDK_NONE;
+static GdkAtom dnd_target_atom_item = GDK_NONE;
+static GdkAtom dnd_target_atom_group = GDK_NONE;
+
 static GtkTargetEntry dnd_targets[] =
 {
   { "application/x-egg-tool-palette-item", GTK_TARGET_SAME_APP, 0 },
+  { "application/x-egg-tool-palette-group", GTK_TARGET_SAME_APP, 0 },
 };
 
 G_DEFINE_TYPE (EggToolPalette,
@@ -603,7 +606,8 @@
 
   g_type_class_add_private (cls, sizeof (EggToolPalettePrivate));
 
-  dnd_target_atom = gdk_atom_intern_static_string (dnd_targets[0].target);
+  dnd_target_atom_item = gdk_atom_intern_static_string (dnd_targets[0].target);
+  dnd_target_atom_group = gdk_atom_intern_static_string (dnd_targets[1].target);
 }
 
 GtkWidget*
@@ -664,15 +668,65 @@
 }
 
 void
-egg_tool_palette_reorder_group (EggToolPalette *palette,
-                                GtkWidget      *group,
-                                guint           position)
-{
+egg_tool_palette_set_group_position (EggToolPalette *palette,
+                                     GtkWidget      *group,
+                                     gint            position)
+{
+  gint old_position;
+  gpointer src, dst;
+  gsize len;
+
   g_return_if_fail (EGG_IS_TOOL_PALETTE (palette));
   g_return_if_fail (EGG_IS_TOOL_ITEM_GROUP (group));
-  g_return_if_fail (position < palette->priv->groups_length);
 
-  g_return_if_reached ();
+  egg_tool_palette_repack (palette);
+
+  g_return_if_fail (position >= -1);
+
+  if (-1 == position)
+    position = palette->priv->groups_length - 1;
+
+  g_return_if_fail ((guint) position < palette->priv->groups_length);
+
+  if (EGG_TOOL_ITEM_GROUP (group) == palette->priv->groups[position])
+    return;
+
+  old_position = egg_tool_palette_get_group_position (palette, group);
+  g_return_if_fail (old_position >= 0);
+
+  if (position < old_position)
+    {
+      dst = palette->priv->groups + position + 1;
+      src = palette->priv->groups + position;
+      len = old_position - position;
+    }
+  else
+    {
+      dst = palette->priv->groups + old_position;
+      src = palette->priv->groups + old_position + 1;
+      len = position - old_position;
+    }
+
+  memmove (dst, src, len * sizeof (*palette->priv->groups));
+  palette->priv->groups[position] = EGG_TOOL_ITEM_GROUP (group);
+
+  gtk_widget_queue_resize (GTK_WIDGET (palette));
+}
+
+gint
+egg_tool_palette_get_group_position (EggToolPalette *palette,
+                                     GtkWidget      *group)
+{
+  guint i;
+
+  g_return_val_if_fail (EGG_IS_TOOL_PALETTE (palette), -1);
+  g_return_val_if_fail (EGG_IS_TOOL_ITEM_GROUP (group), -1);
+
+  for (i = 0; i < palette->priv->groups_length; ++i)
+    if ((gpointer) group == palette->priv->groups[i])
+      return i;
+
+  return -1;
 }
 
 GtkToolItem*
@@ -726,7 +780,7 @@
   return NULL;
 }
 
-GtkToolItem*
+GtkWidget*
 egg_tool_palette_get_drag_item (EggToolPalette   *palette,
                                 GtkSelectionData *selection)
 {
@@ -737,12 +791,19 @@
 
   g_return_val_if_fail (selection->format == 8, NULL);
   g_return_val_if_fail (selection->length == sizeof (EggToolPaletteDragData), NULL);
-  g_return_val_if_fail (selection->target == dnd_target_atom, NULL);
+  g_return_val_if_fail (selection->target == dnd_target_atom_item ||
+                        selection->target == dnd_target_atom_group,
+                        NULL);
 
   data = (EggToolPaletteDragData*) selection->data;
 
   g_return_val_if_fail (data->palette == palette, NULL);
 
+  if (dnd_target_atom_item == selection->target)
+    g_return_val_if_fail (GTK_IS_TOOL_ITEM (data->item), NULL);
+  else if (dnd_target_atom_group == selection->target)
+    g_return_val_if_fail (EGG_IS_TOOL_ITEM_GROUP (data->item), NULL);
+
   return data->item;
 }
 
@@ -765,25 +826,33 @@
       if (!group)
         continue;
 
-      gtk_container_foreach (GTK_CONTAINER (group),
-                             _egg_tool_palette_item_set_drag_source,
-                             palette);
+      gtk_container_forall (GTK_CONTAINER (group),
+                            _egg_tool_palette_child_set_drag_source,
+                            palette);
     }
 }
 
 void
-egg_tool_palette_add_drag_dest (EggToolPalette  *palette,
-                                GtkWidget       *widget,
-                                GtkDestDefaults  flags)
+egg_tool_palette_add_drag_dest (EggToolPalette            *palette,
+                                GtkWidget                 *widget,
+                                GtkDestDefaults            flags,
+                                EggToolPaletteDragTargets  targets,
+                                GdkDragAction              actions)
 {
+  GtkTargetEntry entries[G_N_ELEMENTS (dnd_targets)];
+  gint n_entries = 0;
+
   g_return_if_fail (EGG_IS_TOOL_PALETTE (palette));
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
   egg_tool_palette_set_drag_source (palette);
 
-  gtk_drag_dest_set (widget, flags, dnd_targets,
-                     G_N_ELEMENTS (dnd_targets),
-                     GDK_ACTION_COPY);
+  if (targets & EGG_TOOL_PALETTE_DRAG_ITEMS)
+    entries[n_entries++] = dnd_targets[0];
+  if (targets & EGG_TOOL_PALETTE_DRAG_GROUPS)
+    entries[n_entries++] = dnd_targets[1];
+
+  gtk_drag_dest_set (widget, flags, entries, n_entries, actions);
 }
 
 void
@@ -796,13 +865,14 @@
   *item_size = palette->priv->item_size;
 }
 
-static GtkToolItem*
-egg_tool_palette_find_tool_item (GtkWidget *widget)
+static GtkWidget*
+egg_tool_palette_find_anchestor (GtkWidget *widget,
+                                 GType      type)
 {
   while (widget)
     {
-      if (GTK_IS_TOOL_ITEM (widget))
-        return GTK_TOOL_ITEM (widget);
+      if (G_TYPE_CHECK_INSTANCE_TYPE (widget, type))
+        return widget;
 
       widget = gtk_widget_get_parent (widget);
     }
@@ -818,12 +888,28 @@
                                      guint             time G_GNUC_UNUSED,
                                      gpointer          data)
 {
-  EggToolPaletteDragData drag_data = {
-    EGG_TOOL_PALETTE (data), NULL
-  };
+  EggToolPaletteDragData drag_data = { EGG_TOOL_PALETTE (data), NULL };
 
-  if (selection->target == dnd_target_atom)
-    drag_data.item = egg_tool_palette_find_tool_item (widget);
+  if (selection->target == dnd_target_atom_item)
+    drag_data.item = egg_tool_palette_find_anchestor (widget, GTK_TYPE_TOOL_ITEM);
+
+  if (drag_data.item)
+    gtk_selection_data_set (selection, selection->target, 8,
+                            (guchar*) &drag_data, sizeof (drag_data));
+}
+
+static void
+egg_tool_palette_child_drag_data_get (GtkWidget        *widget,
+                                      GdkDragContext   *context G_GNUC_UNUSED,
+                                      GtkSelectionData *selection,
+                                      guint             info G_GNUC_UNUSED,
+                                      guint             time G_GNUC_UNUSED,
+                                      gpointer          data)
+{
+  EggToolPaletteDragData drag_data = { EGG_TOOL_PALETTE (data), NULL };
+
+  if (selection->target == dnd_target_atom_group)
+    drag_data.item = egg_tool_palette_find_anchestor (widget, EGG_TYPE_TOOL_ITEM_GROUP);
 
   if (drag_data.item)
     gtk_selection_data_set (selection, selection->target, 8,
@@ -831,26 +917,38 @@
 }
 
 void
-_egg_tool_palette_item_set_drag_source (GtkWidget *widget,
-                                        gpointer   data)
+_egg_tool_palette_child_set_drag_source (GtkWidget *child,
+                                         gpointer   data)
 {
   EggToolPalette *palette = EGG_TOOL_PALETTE (data);
 
-  g_return_if_fail (GTK_IS_TOOL_ITEM (widget));
+  /* Check drag_source,
+   * to work properly when called from egg_tool_item_group_insert().
+   */
+  if (!palette->priv->drag_source)
+    return;
 
-  if (palette->priv->drag_source)
+  if (GTK_IS_TOOL_ITEM (child))
     {
-      /* Connect to child, instead of the item itself work arround bug 510377.
+      /* Connect to child instead of the item itself,
+       * to work arround bug 510377.
        */
-      GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
+      child = gtk_bin_get_child (GTK_BIN (child));
 
-      gtk_drag_source_set (child,
-                           GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
-                           dnd_targets, G_N_ELEMENTS (dnd_targets),
-                           GDK_ACTION_COPY);
+      gtk_drag_source_set (child, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                           &dnd_targets[0], 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
 
       g_signal_connect (child, "drag-data-get",
                         G_CALLBACK (egg_tool_palette_item_drag_data_get),
                         palette);
     }
+  else if (GTK_IS_BUTTON (child))
+    {
+      gtk_drag_source_set (child, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                           &dnd_targets[1], 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+
+      g_signal_connect (child, "drag-data-get",
+                        G_CALLBACK (egg_tool_palette_child_drag_data_get),
+                        palette);
+    }
 }

Modified: trunk/libegg/toolpalette/eggtoolpalette.h
==============================================================================
--- trunk/libegg/toolpalette/eggtoolpalette.h	(original)
+++ trunk/libegg/toolpalette/eggtoolpalette.h	Wed Jan 23 16:05:09 2008
@@ -39,6 +39,13 @@
 typedef struct _EggToolPaletteClass      EggToolPaletteClass;
 typedef struct _EggToolPalettePrivate    EggToolPalettePrivate;
 
+typedef enum /*< flags >*/
+{
+  EGG_TOOL_PALETTE_DRAG_ITEMS = (1 << 0),
+  EGG_TOOL_PALETTE_DRAG_GROUPS = (1 << 1),
+}
+EggToolPaletteDragTargets;
+
 struct _EggToolPalette
 {
   GtkContainer parent_instance;
@@ -54,37 +61,41 @@
                                   GtkAdjustment *vadjustment);
 };
 
-GType           egg_tool_palette_get_type        (void) G_GNUC_CONST;
-GtkWidget*      egg_tool_palette_new             (void);
+GType           egg_tool_palette_get_type           (void) G_GNUC_CONST;
+GtkWidget*      egg_tool_palette_new                (void);
 
-void            egg_tool_palette_reorder_group   (EggToolPalette   *palette,
-                                                  GtkWidget        *group,
-                                                  guint             position);
-
-void            egg_tool_palette_set_icon_size   (EggToolPalette   *palette,
-                                                  GtkIconSize       icon_size);
-void            egg_tool_palette_set_orientation (EggToolPalette   *palette,
-                                                  GtkOrientation    orientation);
-void            egg_tool_palette_set_style       (EggToolPalette   *palette,
-                                                  GtkToolbarStyle   style);
-
-GtkIconSize     egg_tool_palette_get_icon_size   (EggToolPalette   *palette);
-GtkOrientation  egg_tool_palette_get_orientation (EggToolPalette   *palette);
-GtkToolbarStyle egg_tool_palette_get_style       (EggToolPalette   *palette);
-
-GtkToolItem*    egg_tool_palette_get_drop_item   (EggToolPalette   *palette,
-                                                  gint              x,
-                                                  gint              y);
-GtkWidget*      egg_tool_palette_get_drop_group  (EggToolPalette   *palette,
-                                                  gint              x,
-                                                  gint              y);
-GtkToolItem*    egg_tool_palette_get_drag_item   (EggToolPalette   *palette,
-                                                  GtkSelectionData *selection);
-
-void            egg_tool_palette_set_drag_source (EggToolPalette   *palette);
-void            egg_tool_palette_add_drag_dest   (EggToolPalette   *palette,
-                                                  GtkWidget        *widget,
-                                                  GtkDestDefaults   flags);
+void            egg_tool_palette_set_group_position (EggToolPalette            *palette,
+                                                     GtkWidget                 *group,
+                                                     gint                       position);
+gint            egg_tool_palette_get_group_position (EggToolPalette            *palette,
+                                                     GtkWidget                 *group);
+
+void            egg_tool_palette_set_icon_size      (EggToolPalette            *palette,
+                                                     GtkIconSize                icon_size);
+void            egg_tool_palette_set_orientation    (EggToolPalette            *palette,
+                                                     GtkOrientation             orientation);
+void            egg_tool_palette_set_style          (EggToolPalette            *palette,
+                                                     GtkToolbarStyle            style);
+
+GtkIconSize     egg_tool_palette_get_icon_size      (EggToolPalette            *palette);
+GtkOrientation  egg_tool_palette_get_orientation    (EggToolPalette            *palette);
+GtkToolbarStyle egg_tool_palette_get_style          (EggToolPalette            *palette);
+
+GtkToolItem*    egg_tool_palette_get_drop_item      (EggToolPalette            *palette,
+                                                     gint                       x,
+                                                     gint                       y);
+GtkWidget*      egg_tool_palette_get_drop_group     (EggToolPalette            *palette,
+                                                     gint                       x,
+                                                     gint                       y);
+GtkWidget*      egg_tool_palette_get_drag_item      (EggToolPalette            *palette,
+                                                     GtkSelectionData          *selection);
+
+void            egg_tool_palette_set_drag_source    (EggToolPalette            *palette);
+void            egg_tool_palette_add_drag_dest      (EggToolPalette            *palette,
+                                                     GtkWidget                 *widget,
+                                                     GtkDestDefaults            flags,
+                                                     EggToolPaletteDragTargets  targets,
+                                                     GdkDragAction              actions);
 
 G_END_DECLS
 

Modified: trunk/libegg/toolpalette/eggtoolpaletteprivate.h
==============================================================================
--- trunk/libegg/toolpalette/eggtoolpaletteprivate.h	(original)
+++ trunk/libegg/toolpalette/eggtoolpaletteprivate.h	Wed Jan 23 16:05:09 2008
@@ -27,7 +27,7 @@
 
 void _egg_tool_palette_get_item_size           (EggToolPalette   *palette,
                                                 GtkRequisition   *item_size);
-void _egg_tool_palette_item_set_drag_source    (GtkWidget        *widget,
+void _egg_tool_palette_child_set_drag_source   (GtkWidget        *widget,
                                                 gpointer          data);
 
 void _egg_tool_item_group_item_size_request    (EggToolItemGroup *group,

Modified: trunk/libegg/toolpalette/testtoolpalette.c
==============================================================================
--- trunk/libegg/toolpalette/testtoolpalette.c	(original)
+++ trunk/libegg/toolpalette/testtoolpalette.c	Wed Jan 23 16:05:09 2008
@@ -102,6 +102,45 @@
 /*****************************/
 
 static void
+palette_drop_item (GtkToolItem      *drag_item,
+                   EggToolItemGroup *drop_group,
+                   gint              x,
+                   gint              y)
+{
+  GtkWidget *drag_group = gtk_widget_get_parent (GTK_WIDGET (drag_item));
+  GtkToolItem *drop_item = egg_tool_item_group_get_drop_item (drop_group, x, y);
+  gint drop_position = -1;
+
+  if (drop_item)
+    drop_position = egg_tool_item_group_get_item_position (EGG_TOOL_ITEM_GROUP (drop_group), drop_item);
+
+  if (EGG_TOOL_ITEM_GROUP (drag_group) != drop_group)
+    {
+      g_object_ref (drag_item);
+      gtk_container_remove (GTK_CONTAINER (drag_group), GTK_WIDGET (drag_item));
+      egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (drop_group),
+                                  drag_item, drop_position);
+      g_object_unref (drag_item);
+    }
+  else
+    egg_tool_item_group_set_item_position (EGG_TOOL_ITEM_GROUP (drop_group),
+                                           drag_item, drop_position);
+}
+
+static void
+palette_drop_group (EggToolPalette *palette,
+                    GtkWidget      *drag_group,
+                    GtkWidget      *drop_group)
+{
+  gint drop_position = -1;
+
+  if (drop_group)
+    drop_position = egg_tool_palette_get_group_position (palette, drop_group);
+
+  egg_tool_palette_set_group_position (palette, drag_group, drop_position);
+}
+
+static void
 palette_drag_data_received (GtkWidget        *widget,
                             GdkDragContext   *context,
                             gint              x,
@@ -112,41 +151,24 @@
                             gpointer          data G_GNUC_UNUSED)
 {
   GtkWidget *drag_palette = gtk_drag_get_source_widget (context);
-  GtkWidget *drag_group = NULL, *drop_group = NULL;
-  GtkToolItem *drag_item = NULL, *drop_item = NULL;
-  gint drop_position = -1;
+  GtkWidget *drag_item = NULL, *drop_group = NULL;
 
   while (drag_palette && !EGG_IS_TOOL_PALETTE (drag_palette))
     drag_palette = gtk_widget_get_parent (drag_palette);
 
   if (drag_palette)
-    drag_item = egg_tool_palette_get_drag_item (EGG_TOOL_PALETTE (drag_palette), selection);
-  if (drag_item)
-    drop_group = egg_tool_palette_get_drop_group (EGG_TOOL_PALETTE (widget), x, y);
-
-  if (drop_group)
     {
-      drop_item = egg_tool_item_group_get_drop_item (EGG_TOOL_ITEM_GROUP (drop_group),
-                                                     x - drop_group->allocation.x,
-                                                     y - drop_group->allocation.y);
-
-      if (drop_item)
-        drop_position = egg_tool_item_group_get_item_position (EGG_TOOL_ITEM_GROUP (drop_group), drop_item);
-
-      drag_group = gtk_widget_get_parent (GTK_WIDGET (drag_item));
-
-      if (drag_group != drop_group)
-        {
-          g_object_ref (drag_item);
-          gtk_container_remove (GTK_CONTAINER (drag_group), GTK_WIDGET (drag_item));
-          egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (drop_group),
-                                      drag_item, drop_position);
-          g_object_unref (drag_item);
-        }
-      else
-        egg_tool_item_group_set_item_position (EGG_TOOL_ITEM_GROUP (drop_group),
-                                               drag_item, drop_position);
+      drag_item = egg_tool_palette_get_drag_item (EGG_TOOL_PALETTE (drag_palette), selection);
+      drop_group = egg_tool_palette_get_drop_group (EGG_TOOL_PALETTE (widget), x, y);
     }
+
+  if (EGG_IS_TOOL_ITEM_GROUP (drag_item))
+    palette_drop_group (EGG_TOOL_PALETTE (drag_palette), drag_item, drop_group);
+  else if (GTK_IS_TOOL_ITEM (drag_item) && drop_group)
+    palette_drop_item (GTK_TOOL_ITEM (drag_item),
+                       EGG_TOOL_ITEM_GROUP (drop_group),
+                       x - GTK_WIDGET (drop_group)->allocation.x,
+                       y - GTK_WIDGET (drop_group)->allocation.y);
 }
 
 /********************************/
@@ -167,7 +189,7 @@
 
   GtkWidget *palette = gtk_drag_get_source_widget (context);
   CanvasItem *canvas_item = NULL;
-  GtkToolItem *tool_item = NULL;
+  GtkWidget *tool_item = NULL;
 
   while (palette && !EGG_IS_TOOL_PALETTE (palette))
     palette = gtk_widget_get_parent (palette);
@@ -240,7 +262,7 @@
   /* find the tool button, which is the source of this DnD operation */
 
   GtkWidget *palette = gtk_drag_get_source_widget (context);
-  GtkToolItem *tool_item = NULL;
+  GtkWidget *tool_item = NULL;
 
   while (palette && !EGG_IS_TOOL_PALETTE (palette))
     palette = gtk_widget_get_parent (palette);
@@ -561,7 +583,10 @@
                     G_CALLBACK (palette_drag_data_received),
                     NULL);
   egg_tool_palette_add_drag_dest (EGG_TOOL_PALETTE (palette),
-                                  palette, GTK_DEST_DEFAULT_ALL);
+                                  palette, GTK_DEST_DEFAULT_ALL,
+                                  EGG_TOOL_PALETTE_DRAG_ITEMS |
+                                  EGG_TOOL_PALETTE_DRAG_GROUPS,
+                                  GDK_ACTION_MOVE);
 
   /* ===== passive DnD dest ===== */
 
@@ -574,7 +599,9 @@
                     NULL);
 
   egg_tool_palette_add_drag_dest (EGG_TOOL_PALETTE (palette),
-                                  contents, GTK_DEST_DEFAULT_ALL);
+                                  contents, GTK_DEST_DEFAULT_ALL,
+                                  EGG_TOOL_PALETTE_DRAG_ITEMS,
+                                  GDK_ACTION_COPY);
 
   contents_scroller = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (contents_scroller),
@@ -599,7 +626,9 @@
                     NULL);
 
   egg_tool_palette_add_drag_dest (EGG_TOOL_PALETTE (palette),
-                                  contents, GTK_DEST_DEFAULT_HIGHLIGHT);
+                                  contents, GTK_DEST_DEFAULT_HIGHLIGHT,
+                                  EGG_TOOL_PALETTE_DRAG_ITEMS,
+                                  GDK_ACTION_COPY);
 
   contents_scroller = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (contents_scroller),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]