]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkiconview.c
Deprecate flag macros for toplevel, state, no window and composite child
[~andy/gtk] / gtk / gtkiconview.c
index dcab923dc69811107ece05ea83e086570e68f9b6..9a47509f937514f1c91054b1a709f69fd3235e45 100644 (file)
@@ -149,6 +149,7 @@ struct _GtkIconViewPrivate
   gint row_spacing;
   gint column_spacing;
   gint margin;
+  gint item_padding;
 
   gint text_column;
   gint markup_column;
@@ -165,10 +166,7 @@ struct _GtkIconViewPrivate
   gint press_start_x;
   gint press_start_y;
 
-  GtkTargetList *source_targets;
   GdkDragAction source_actions;
-
-  GtkTargetList *dest_targets;
   GdkDragAction dest_actions;
 
   GtkTreeRowReference *dest_item;
@@ -186,7 +184,9 @@ struct _GtkIconViewPrivate
   guint empty_view_drop :1;
 
   guint ctrl_pressed : 1;
-  guint shift_pressed : 1;  
+  guint shift_pressed : 1;
+
+  guint draw_focus : 1;
 };
 
 /* Signals */
@@ -220,7 +220,8 @@ enum
   PROP_COLUMN_SPACING,
   PROP_MARGIN,
   PROP_REORDERABLE,
-  PROP_TOOLTIP_COLUMN
+  PROP_TOOLTIP_COLUMN,
+  PROP_ITEM_PADDING
 };
 
 /* GObject vfuncs */
@@ -448,8 +449,6 @@ static gboolean gtk_icon_view_maybe_begin_drag   (GtkIconView             *icon_
                                                  GdkEventMotion          *event);
 
 static void     remove_scroll_timeout            (GtkIconView *icon_view);
-static void     clear_dest_info                  (GtkIconView *icon_view);
-static void     clear_source_info                (GtkIconView *icon_view);
 
 static void     adjust_wrap_width                (GtkIconView     *icon_view,
                                                  GtkIconViewItem *item);
@@ -716,7 +715,6 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                                                     0, G_MAXINT, 6,
                                                     GTK_PARAM_READWRITE));
 
-
   /**
    * GtkIconView:orientation:
    *
@@ -760,6 +758,22 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                                                        -1,
                                                        GTK_PARAM_READWRITE));
 
+  /**
+   * GtkIconView:item-padding:
+   *
+   * The item-padding property specifies the padding around each
+   * of the icon view's item.
+   *
+   * Since: 2.18
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_ITEM_PADDING,
+                                   g_param_spec_int ("item-padding",
+                                                    P_("Item Padding"),
+                                                    P_("Padding around icon view items"),
+                                                    0, G_MAXINT, 6,
+                                                    GTK_PARAM_READWRITE));
+
 
 
   /* Style properties */
@@ -779,6 +793,15 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                                                                GTK_PARAM_READABLE));
 
   /* Signals */
+  /**
+   * GtkIconView::set-scroll-adjustments
+   * @horizontal: the horizontal #GtkAdjustment
+   * @vertical: the vertical #GtkAdjustment
+   *
+   * Set the scroll adjustments for the icon view. Usually scrolled containers
+   * like #GtkScrolledWindow will emit this signal to connect two instances
+   * of #GtkScrollbar to the scroll directions of the #GtkIconView.
+   */
   widget_class->set_scroll_adjustments_signal =
     g_signal_new (I_("set-scroll-adjustments"),
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -789,6 +812,17 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  G_TYPE_NONE, 2,
                  GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
 
+  /**
+   * GtkIconView::item-activated:
+   * @iconview: the object on which the signal is emitted
+   * @path: the #GtkTreePath for the activated item
+   *
+   * The ::item-activated signal is emitted when the method
+   * gtk_icon_view_item_activated() is called or the user double 
+   * clicks an item. It is also emitted when a non-editable item
+   * is selected and one of the keys: Space, Return or Enter is
+   * pressed.
+   */
   icon_view_signals[ITEM_ACTIVATED] =
     g_signal_new (I_("item-activated"),
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -799,6 +833,13 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  G_TYPE_NONE, 1,
                  GTK_TYPE_TREE_PATH);
 
+  /**
+   * GtkIconView::selection-changed:
+   * @iconview: the object on which the signal is emitted
+   *
+   * The ::selection-changed signal is emitted when the selection
+   * (i.e. the set of selected items) changes.
+   */
   icon_view_signals[SELECTION_CHANGED] =
     g_signal_new (I_("selection-changed"),
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -808,6 +849,19 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  g_cclosure_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);
   
+  /**
+   * GtkIconView::select-all:
+   * @iconview: the object on which the signal is emitted
+   *
+   * A <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user selects all items.
+   *
+   * Applications should not connect to it, but may emit it with
+   * g_signal_emit_by_name() if they need to control selection
+   * programmatically.
+   * 
+   * The default binding for this signal is Ctrl-a.
+   */
   icon_view_signals[SELECT_ALL] =
     g_signal_new (I_("select-all"),
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -817,6 +871,19 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  g_cclosure_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);
   
+  /**
+   * GtkIconView::unselect-all:
+   * @iconview: the object on which the signal is emitted
+   *
+   * A <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user unselects all items.
+   *
+   * Applications should not connect to it, but may emit it with
+   * g_signal_emit_by_name() if they need to control selection
+   * programmatically.
+   * 
+   * The default binding for this signal is Ctrl-Shift-a. 
+   */
   icon_view_signals[UNSELECT_ALL] =
     g_signal_new (I_("unselect-all"),
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -826,6 +893,20 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  g_cclosure_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);
 
+  /**
+   * GtkIconView::select-cursor-item:
+   * @iconview: the object on which the signal is emitted
+   *
+   * A <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user selects the item that is currently
+   * focused.
+   *
+   * Applications should not connect to it, but may emit it with
+   * g_signal_emit_by_name() if they need to control selection
+   * programmatically.
+   * 
+   * There is no default binding for this signal.
+   */
   icon_view_signals[SELECT_CURSOR_ITEM] =
     g_signal_new (I_("select-cursor-item"),
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -835,6 +916,21 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  g_cclosure_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);
 
+  /**
+   * GtkIconView::toggle-cursor-item:
+   * @iconview: the object on which the signal is emitted
+   *
+   * A <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user toggles whether the currently
+   * focused item is selected or not. The exact effect of this 
+   * depend on the selection mode.
+   *
+   * Applications should not connect to it, but may emit it with
+   * g_signal_emit_by_name() if they need to control selection
+   * programmatically.
+   * 
+   * There is no default binding for this signal is Ctrl-Space.
+   */
   icon_view_signals[TOGGLE_CURSOR_ITEM] =
     g_signal_new (I_("toggle-cursor-item"),
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -844,6 +940,20 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  g_cclosure_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);
 
+  /**
+   * GtkIconView::activate-cursor-item:
+   * @iconview: the object on which the signal is emitted
+   *
+   * A <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user activates the currently 
+   * focused item. 
+   *
+   * Applications should not connect to it, but may emit it with
+   * g_signal_emit_by_name() if they need to control activation
+   * programmatically.
+   * 
+   * The default bindings for this signal are Space, Return and Enter.
+   */
   icon_view_signals[ACTIVATE_CURSOR_ITEM] =
     g_signal_new (I_("activate-cursor-item"),
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -853,6 +963,30 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  _gtk_marshal_BOOLEAN__VOID,
                  G_TYPE_BOOLEAN, 0);
   
+  /**
+   * GtkIconView::move-cursor:
+   * @iconview: the object which received the signal
+   * @step: the granularity of the move, as a #GtkMovementStep
+   * @count: the number of @step units to move
+   *
+   * The ::move-cursor signal is a
+   * <link linkend="keybinding-signals">keybinding signal</link>
+   * which gets emitted when the user initiates a cursor movement.
+   *
+   * Applications should not connect to it, but may emit it with
+   * g_signal_emit_by_name() if they need to control the cursor
+   * programmatically.
+   *
+   * The default bindings for this signal include
+   * <itemizedlist>
+   * <listitem>Arrow keys which move by individual steps</listitem>
+   * <listitem>Home/End keys which move to the first/last item</listitem>
+   * <listitem>PageUp/PageDown which move by "pages"</listitem>
+   * </itemizedlist>
+   *
+   * All of these will extend the selection when combined with
+   * the Shift modifier.
+   */
   icon_view_signals[MOVE_CURSOR] =
     g_signal_new (I_("move-cursor"),
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -988,6 +1122,9 @@ gtk_icon_view_init (GtkIconView *icon_view)
   icon_view->priv->row_spacing = 6;
   icon_view->priv->column_spacing = 6;
   icon_view->priv->margin = 6;
+  icon_view->priv->item_padding = 6;
+
+  icon_view->priv->draw_focus = TRUE;
 }
 
 static void
@@ -1027,10 +1164,7 @@ gtk_icon_view_destroy (GtkObject *object)
       icon_view->priv->vadjustment = NULL;
     }
   
-  clear_dest_info (icon_view);
-  clear_source_info (icon_view);
-
-  (* GTK_OBJECT_CLASS (gtk_icon_view_parent_class)->destroy) (object);
+  GTK_OBJECT_CLASS (gtk_icon_view_parent_class)->destroy (object);
 }
 
 /* GObject methods */
@@ -1039,7 +1173,7 @@ gtk_icon_view_finalize (GObject *object)
 {
   gtk_icon_view_cell_layout_clear (GTK_CELL_LAYOUT (object));
 
-  (* G_OBJECT_CLASS (gtk_icon_view_parent_class)->finalize) (object);
+  G_OBJECT_CLASS (gtk_icon_view_parent_class)->finalize (object);
 }
 
 
@@ -1099,6 +1233,10 @@ gtk_icon_view_set_property (GObject      *object,
       gtk_icon_view_set_tooltip_column (icon_view, g_value_get_int (value));
       break;
 
+    case PROP_ITEM_PADDING:
+      gtk_icon_view_set_item_padding (icon_view, g_value_get_int (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1160,6 +1298,10 @@ gtk_icon_view_get_property (GObject      *object,
       g_value_set_int (value, icon_view->priv->tooltip_column);
       break;
 
+    case PROP_ITEM_PADDING:
+      g_value_set_int (value, icon_view->priv->item_padding);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1231,9 +1373,7 @@ gtk_icon_view_unrealize (GtkWidget *widget)
   gdk_window_destroy (icon_view->priv->bin_window);
   icon_view->priv->bin_window = NULL;
 
-  /* GtkWidget::unrealize destroys children and widget->window */
-  if (GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->unrealize)
-    (* GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->unrealize) (widget);
+  GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->unrealize (widget);
 }
 
 static void
@@ -1303,10 +1443,10 @@ gtk_icon_view_allocate_children (GtkIconView *icon_view)
       /* totally ignore our child's requisition */
       if (child->cell < 0)
        {
-         allocation.x = child->item->x;
-         allocation.y = child->item->y;
-         allocation.width = child->item->width;
-         allocation.height = child->item->height;
+         allocation.x = child->item->x + icon_view->priv->item_padding;
+         allocation.y = child->item->y + icon_view->priv->item_padding;
+         allocation.width = child->item->width - icon_view->priv->item_padding * 2;
+         allocation.height = child->item->height - icon_view->priv->item_padding * 2;
        }
       else
        {
@@ -1356,7 +1496,7 @@ gtk_icon_view_size_allocate (GtkWidget      *widget,
   hadjustment->upper = MAX (allocation->width, icon_view->priv->width);
 
   if (hadjustment->value > hadjustment->upper - hadjustment->page_size)
-    gtk_adjustment_set_value (hadjustment, hadjustment->upper - hadjustment->page_size);
+    gtk_adjustment_set_value (hadjustment, MAX (0, hadjustment->upper - hadjustment->page_size));
 
   vadjustment->page_size = allocation->height;
   vadjustment->page_increment = allocation->height * 0.9;
@@ -1365,7 +1505,7 @@ gtk_icon_view_size_allocate (GtkWidget      *widget,
   vadjustment->upper = MAX (allocation->height, icon_view->priv->height);
 
   if (vadjustment->value > vadjustment->upper - vadjustment->page_size)
-    gtk_adjustment_set_value (vadjustment, vadjustment->upper - vadjustment->page_size);
+    gtk_adjustment_set_value (vadjustment, MAX (0, vadjustment->upper - vadjustment->page_size));
 
   if (GTK_WIDGET_REALIZED (widget) &&
       icon_view->priv->scroll_to_path)
@@ -1405,6 +1545,11 @@ gtk_icon_view_expose (GtkWidget *widget,
   if (expose->window != icon_view->priv->bin_window)
     return FALSE;
 
+  /* If a layout has been scheduled, do it now so that all
+   * cell view items have valid sizes before we proceed. */
+  if (icon_view->priv->layout_idle_id != 0)
+    gtk_icon_view_layout (icon_view);
+
   cr = gdk_cairo_create (icon_view->priv->bin_window);
   cairo_set_line_width (cr, 1.);
 
@@ -1433,7 +1578,8 @@ gtk_icon_view_expose (GtkWidget *widget,
       
       gtk_icon_view_paint_item (icon_view, cr, item, &expose->area, 
                                icon_view->priv->bin_window,
-                               item->x, item->y, TRUE); 
+                               item->x, item->y,
+                               icon_view->priv->draw_focus); 
  
       if (dest_index == item->index)
        dest_item = item;
@@ -1514,7 +1660,7 @@ gtk_icon_view_expose (GtkWidget *widget,
 
   cairo_destroy (cr);
 
-  (* GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->expose_event) (widget, expose);
+  GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->expose_event (widget, expose);
 
   return TRUE;
 }
@@ -1522,11 +1668,17 @@ gtk_icon_view_expose (GtkWidget *widget,
 static gboolean
 rubberband_scroll_timeout (gpointer data)
 {
-  GtkIconView *icon_view = data;
+  GtkIconView *icon_view;
+  gdouble value;
+
+  icon_view = data;
 
-  gtk_adjustment_set_value (icon_view->priv->vadjustment,
-                            icon_view->priv->vadjustment->value +
-                            icon_view->priv->scroll_value_diff);
+  value = MIN (icon_view->priv->vadjustment->value +
+              icon_view->priv->scroll_value_diff,
+              icon_view->priv->vadjustment->upper -
+              icon_view->priv->vadjustment->page_size);
+
+  gtk_adjustment_set_value (icon_view->priv->vadjustment, value);
 
   gtk_icon_view_update_rubberband (icon_view);
   
@@ -1772,10 +1924,6 @@ gtk_icon_view_start_editing (GtkIconView         *icon_view,
                                                  0);
       g_free (path_string);      
 
-      /* FIXME ugly special case */ 
-      if (GTK_IS_ENTRY (editable) || GTK_IS_COMBO_BOX (editable))
-       g_object_set (editable, "has-frame", TRUE, NULL);
-
       /* the rest corresponds to tree_view_real_start_editing... */
       icon_view->priv->edited_item = item;
       icon_view->priv->editable = editable;
@@ -1786,7 +1934,7 @@ gtk_icon_view_start_editing (GtkIconView         *icon_view,
       gtk_cell_editable_start_editing (GTK_CELL_EDITABLE (editable), 
                                       (GdkEvent *)event);
       gtk_widget_grab_focus (GTK_WIDGET (editable));
-      g_signal_connect (editable, "remove_widget",
+      g_signal_connect (editable, "remove-widget",
                        G_CALLBACK (gtk_icon_view_remove_widget), 
                        icon_view);
 
@@ -1844,11 +1992,11 @@ gtk_icon_view_stop_editing (GtkIconView *icon_view,
  * gtk_icon_view_set_cursor:
  * @icon_view: A #GtkIconView
  * @path: A #GtkTreePath
- * @cell: One of the cell renderers of @icon_view, or %NULL
+ * @cell: (allow-none): One of the cell renderers of @icon_view, or %NULL
  * @start_editing: %TRUE if the specified cell should start being edited.
  *
  * Sets the current keyboard focus to be at @path, and selects it.  This is
- * useful when you want to focus the user's attention on a particular item.  
+ * useful when you want to focus the user's attention on a particular item.
  * If @cell is not %NULL, then focus is given to the cell specified by 
  * it. Additionally, if @start_editing is %TRUE, then editing should be 
  * started in the specified cell.  
@@ -1967,7 +2115,7 @@ gtk_icon_view_button_press (GtkWidget      *widget,
   GtkIconViewCellInfo *info = NULL;
   gboolean dirty = FALSE;
   GtkCellRendererMode mode;
-  gint cursor_cell;
+  gint cursor_cell = -1;
 
   icon_view = GTK_ICON_VIEW (widget);
 
@@ -1981,18 +2129,25 @@ gtk_icon_view_button_press (GtkWidget      *widget,
     {
       item = gtk_icon_view_get_item_at_coords (icon_view, 
                                               event->x, event->y,
-                                              TRUE,
-                                              &info);      
-      if (item != NULL)
+                                              FALSE,
+                                              &info);    
+
+      /*
+       * We consider only the the cells' area as the item area if the
+       * item is not selected, but if it *is* selected, the complete
+       * selection rectangle is considered to be part of the item.
+       */
+      if (item != NULL && (info != NULL || item->selected))
        {
-         g_object_get (info->cell, "mode", &mode, NULL);
-         
-         if (mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE ||
-             mode == GTK_CELL_RENDERER_MODE_EDITABLE)
-           cursor_cell = g_list_index (icon_view->priv->cell_list, info);
-         else
-           cursor_cell = -1;
-         
+         if (info != NULL)
+           {
+             g_object_get (info->cell, "mode", &mode, NULL);
+
+             if (mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE ||
+                 mode == GTK_CELL_RENDERER_MODE_EDITABLE)
+               cursor_cell = g_list_index (icon_view->priv->cell_list, info);
+           }
+
          gtk_icon_view_scroll_to_item (icon_view, item);
          
          if (icon_view->priv->selection_mode == GTK_SELECTION_NONE)
@@ -2025,14 +2180,11 @@ gtk_icon_view_button_press (GtkWidget      *widget,
                }
              else
                {
-                 if (!item->selected)
-                   {
-                     gtk_icon_view_unselect_all_internal (icon_view);
-                     
-                     item->selected = TRUE;
-                     gtk_icon_view_queue_draw_item (icon_view, item);
-                     dirty = TRUE;
-                   }
+                 gtk_icon_view_unselect_all_internal (icon_view);
+
+                 item->selected = TRUE;
+                 gtk_icon_view_queue_draw_item (icon_view, item);
+                 dirty = TRUE;
                }
              gtk_icon_view_set_cursor_item (icon_view, item, cursor_cell);
              icon_view->priv->anchor_item = item;
@@ -2051,13 +2203,16 @@ gtk_icon_view_button_press (GtkWidget      *widget,
 
          /* cancel the current editing, if it exists */
          gtk_icon_view_stop_editing (icon_view, TRUE);
-         
-         if (mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE)
-           gtk_icon_view_item_activate_cell (icon_view, item, info, 
-                                             (GdkEvent *)event);
-         else if (mode == GTK_CELL_RENDERER_MODE_EDITABLE)
-           gtk_icon_view_start_editing (icon_view, item, info, 
-                                        (GdkEvent *)event);      
+
+         if (info != NULL)
+           {
+             if (mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE)
+               gtk_icon_view_item_activate_cell (icon_view, item, info, 
+                                                 (GdkEvent *)event);
+             else if (mode == GTK_CELL_RENDERER_MODE_EDITABLE)
+               gtk_icon_view_start_editing (icon_view, item, info, 
+                                            (GdkEvent *)event);
+           }
        }
       else
        {
@@ -2071,13 +2226,15 @@ gtk_icon_view_button_press (GtkWidget      *widget,
            gtk_icon_view_start_rubberbanding (icon_view, event->x, event->y);
        }
 
+      /* don't draw keyboard focus around an clicked-on item */
+      icon_view->priv->draw_focus = FALSE;
     }
 
   if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
     {
       item = gtk_icon_view_get_item_at_coords (icon_view,
                                               event->x, event->y,
-                                              TRUE,
+                                              FALSE,
                                               NULL);
 
       if (item && item == icon_view->priv->last_single_clicked)
@@ -2131,7 +2288,7 @@ gtk_icon_view_key_press (GtkWidget      *widget,
       return TRUE;
     }
 
-  return (* GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->key_press_event) (widget, event);
+  return GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->key_press_event (widget, event);
 }
 
 static gboolean
@@ -2143,7 +2300,7 @@ gtk_icon_view_key_release (GtkWidget      *widget,
   if (icon_view->priv->doing_rubberband)
     return TRUE;
 
-  return (* GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->key_press_event) (widget, event);
+  return GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->key_press_event (widget, event);
 }
 
 static void
@@ -2562,7 +2719,7 @@ gtk_icon_view_layout_single_row (GtkIconView *icon_view,
       current_width += icon_view->priv->column_spacing + 2 * focus_width;
 
       item->y = *y + focus_width;
-      item->x = rtl ? GTK_WIDGET (icon_view)->allocation.width - item->width - x : x;
+      item->x = x;
 
       x = current_width - (icon_view->priv->margin + focus_width); 
 
@@ -2586,14 +2743,17 @@ gtk_icon_view_layout_single_row (GtkIconView *icon_view,
     {
       GtkIconViewItem *item = items->data;
 
+      if (rtl)
+       {
+         item->x = *maximum_width - item->width - item->x;
+         item->col = col - 1 - item->col;
+       }
+
       gtk_icon_view_calculate_item_size2 (icon_view, item, max_height);
 
       /* We may want to readjust the new y coordinate. */
       if (item->y + item->height + focus_width + icon_view->priv->row_spacing > *y)
        *y = item->y + item->height + focus_width + icon_view->priv->row_spacing;
-
-      if (rtl)
-       item->col = col - 1 - item->col;
     }
 
   g_free (max_height);
@@ -2728,16 +2888,16 @@ gtk_icon_view_get_cell_area (GtkIconView         *icon_view,
   if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       cell_area->x = item->box[info->position].x - item->before[info->position];
-      cell_area->y = item->y;
+      cell_area->y = item->y + icon_view->priv->item_padding;
       cell_area->width = item->box[info->position].width + 
        item->before[info->position] + item->after[info->position];
-      cell_area->height = item->height;
+      cell_area->height = item->height - icon_view->priv->item_padding * 2;
     }
   else
     {
-      cell_area->x = item->x;
+      cell_area->x = item->x + icon_view->priv->item_padding;
       cell_area->y = item->box[info->position].y - item->before[info->position];
-      cell_area->width = item->width;
+      cell_area->width = item->width - icon_view->priv->item_padding * 2;
       cell_area->height = item->box[info->position].height + 
        item->before[info->position] + item->after[info->position];
     }
@@ -2786,17 +2946,16 @@ adjust_wrap_width (GtkIconView     *icon_view,
       else
        item_width = item->width;
 
-      if (item->width == -1)
-        {
-         if (item_width > 0)
-           wrap_width = item_width - pixbuf_width - icon_view->priv->spacing;
-         else
-           wrap_width = MAX (2 * pixbuf_width, 50);
-       }
-      else if (icon_view->priv->orientation == GTK_ORIENTATION_VERTICAL)
-       wrap_width = item_width;
-      else
-       wrap_width = item_width - pixbuf_width - icon_view->priv->spacing;
+      if (icon_view->priv->orientation == GTK_ORIENTATION_VERTICAL)
+        wrap_width = item_width;
+      else {
+        if (item->width == -1 && item_width <= 0)
+          wrap_width = MAX (2 * pixbuf_width, 50);
+        else
+          wrap_width = item_width - pixbuf_width - icon_view->priv->spacing;
+        }
+
+      wrap_width -= icon_view->priv->item_padding * 2;
 
       g_object_set (text_info->cell, "wrap-width", wrap_width, NULL);
       g_object_set (text_info->cell, "width", wrap_width, NULL);
@@ -2856,6 +3015,9 @@ gtk_icon_view_calculate_item_size (GtkIconView     *icon_view,
          item->height += item->box[info->position].height + (info->position > 0 ? spacing : 0);
        }
     }
+
+  item->width += icon_view->priv->item_padding * 2;
+  item->height += icon_view->priv->item_padding * 2;
 }
 
 static void
@@ -2884,8 +3046,8 @@ gtk_icon_view_calculate_item_size2 (GtkIconView     *icon_view,
        item->height += max_height[i] + (i > 0 ? spacing : 0);
     }
 
-  cell_area.x = item->x;
-  cell_area.y = item->y;
+  cell_area.x = item->x + icon_view->priv->item_padding;
+  cell_area.y = item->y + icon_view->priv->item_padding;
       
   for (k = 0; k < 2; k++)
     for (l = icon_view->priv->cell_list, i = 0; l; l = l->next, i++)
@@ -2900,12 +3062,19 @@ gtk_icon_view_calculate_item_size2 (GtkIconView     *icon_view,
 
        if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
          {
+            /* We should not subtract icon_view->priv->item_padding from item->height,
+             * because item->height is recalculated above using
+             * max_height which does not contain item padding.
+             */
            cell_area.width = item->box[info->position].width;
            cell_area.height = item->height;
          }
        else
          {
-           cell_area.width = item->width;
+            /* item->width is not recalculated and thus needs to be
+             * corrected for the padding.
+             */
+           cell_area.width = item->width - 2 * icon_view->priv->item_padding;
            cell_area.height = max_height[i];
          }
        
@@ -2924,9 +3093,9 @@ gtk_icon_view_calculate_item_size2 (GtkIconView     *icon_view,
          }
        else
          {
-           if (item->box[info->position].width > item->width)
+           if (item->box[info->position].width > item->width - icon_view->priv->item_padding * 2)
              {
-               item->width = item->box[info->position].width;
+               item->width = item->box[info->position].width + icon_view->priv->item_padding * 2;
                cell_area.width = item->width;
              }
            item->before[info->position] = item->box[info->position].y - cell_area.y;
@@ -2942,7 +3111,9 @@ gtk_icon_view_calculate_item_size2 (GtkIconView     *icon_view,
          item->box[i].x = item->x + item->width - 
            (item->box[i].x + item->box[i].width - item->x);
        }      
-    }  
+    }
+
+  item->height += icon_view->priv->item_padding * 2;
 }
 
 static void
@@ -3011,28 +3182,17 @@ gtk_icon_view_paint_item (GtkIconView     *icon_view,
 #endif
 
   if (item->selected)
-    for (l = icon_view->priv->cell_list; l; l = l->next)
-      {
-       GtkIconViewCellInfo *info = (GtkIconViewCellInfo *)l->data;
-       
-       if (!info->cell->visible)
-         continue;
-       
-       gtk_icon_view_get_cell_box (icon_view, item, info, &box);
-
-       /* FIXME we hardwire background drawing behind text
-        * cell renderers here 
-        */
-       if (GTK_IS_CELL_RENDERER_TEXT (info->cell))
-         {
-           gdk_cairo_set_source_color (cr, &GTK_WIDGET (icon_view)->style->base[state]);
-           cairo_rectangle (cr,
-                            x - item->x + box.x, 
-                            y - item->y + box.y,
-                            box.width, box.height);
-           cairo_fill (cr);
-         }
-      }
+    {
+      gtk_paint_flat_box (GTK_WIDGET (icon_view)->style,
+                         (GdkWindow *) drawable,
+                         GTK_STATE_SELECTED,
+                         GTK_SHADOW_NONE,
+                         area,
+                         GTK_WIDGET (icon_view),
+                         "icon_view_item",
+                         x, y,
+                         item->width, item->height);
+    }
   
   for (l = icon_view->priv->cell_list; l; l = l->next)
     {
@@ -3068,42 +3228,57 @@ gtk_icon_view_paint_item (GtkIconView     *icon_view,
                                drawable,
                                GTK_WIDGET (icon_view),
                                &cell_area, &cell_area, area, flags);
-      
     }
 
-  /* FIXME where to draw the focus with generic cell renderers ? */
-  if (draw_focus && 
+  if (draw_focus &&
       GTK_WIDGET_HAS_FOCUS (icon_view) &&
       item == icon_view->priv->cursor_item)
-    for (l = icon_view->priv->cell_list, i = 0; l; l = l->next, i++)
-      {
-       GtkIconViewCellInfo *info = (GtkIconViewCellInfo *)l->data;
-       
-       if (!info->cell->visible)
-         continue;
-       
-       if (icon_view->priv->cursor_cell < 0 &&
-           (info->cell->mode != GTK_CELL_RENDERER_MODE_INERT ||
-            GTK_IS_CELL_RENDERER_TEXT (info->cell)))
-         icon_view->priv->cursor_cell = i;
-       
-       if (i == icon_view->priv->cursor_cell)
-         {
-           gtk_icon_view_get_cell_box (icon_view, item, info, &box);
-
-           gtk_paint_focus (GTK_WIDGET (icon_view)->style,
-                            drawable,
-                            GTK_STATE_NORMAL,
-                            area,
-                            GTK_WIDGET (icon_view),
-                            "icon_view",
-                            x - item->x + box.x - padding,
-                            y - item->y + box.y - padding,
-                            box.width + 2 * padding,
-                            box.height + 2 * padding);
-           break;
-         }
-      }
+    {
+      for (l = icon_view->priv->cell_list, i = 0; l; l = l->next, i++)
+        {
+          GtkIconViewCellInfo *info = (GtkIconViewCellInfo *)l->data;
+
+          if (!info->cell->visible)
+            continue;
+
+          /* If found a editable/activatable cell, draw focus on it. */
+          if (icon_view->priv->cursor_cell < 0 &&
+              info->cell->mode != GTK_CELL_RENDERER_MODE_INERT)
+            icon_view->priv->cursor_cell = i;
+
+          gtk_icon_view_get_cell_box (icon_view, item, info, &box);
+
+          if (i == icon_view->priv->cursor_cell)
+            {
+              gtk_paint_focus (GTK_WIDGET (icon_view)->style,
+                               drawable,
+                               GTK_STATE_NORMAL,
+                               area,
+                               GTK_WIDGET (icon_view),
+                               "icon_view",
+                               x - item->x + box.x - padding,
+                               y - item->y + box.y - padding,
+                               box.width + 2 * padding,
+                               box.height + 2 * padding);
+              break;
+            }
+        }
+
+      /* If there are no editable/activatable cells, draw focus 
+       * around the whole item.
+       */
+      if (icon_view->priv->cursor_cell < 0)
+        gtk_paint_focus (GTK_WIDGET (icon_view)->style,
+                         drawable,
+                         GTK_STATE_NORMAL,
+                         area,
+                         GTK_WIDGET (icon_view),
+                         "icon_view",
+                         x - padding,
+                         y - padding,
+                         item->width + 2 * padding,
+                         item->height + 2 * padding);
+    }
 }
 
 static void
@@ -3299,6 +3474,9 @@ gtk_icon_view_get_item_at_coords (GtkIconView          *icon_view,
   GList *items, *l;
   GdkRectangle box;
 
+  if (cell_at_pos)
+    *cell_at_pos = NULL;
+
   for (items = icon_view->priv->items; items; items = items->next)
     {
       GtkIconViewItem *item = items->data;
@@ -3313,12 +3491,12 @@ gtk_icon_view_get_item_at_coords (GtkIconView          *icon_view,
              for (l = icon_view->priv->cell_list; l; l = l->next)
                {
                  GtkIconViewCellInfo *info = (GtkIconViewCellInfo *)l->data;
-                 
+
                  if (!info->cell->visible)
                    continue;
-                 
+
                  gtk_icon_view_get_cell_box (icon_view, item, info, &box);
-                 
+
                  if ((x >= box.x && x <= box.x + box.width &&
                       y >= box.y && y <= box.y + box.height) ||
                      (x >= box.x  &&
@@ -3328,16 +3506,13 @@ gtk_icon_view_get_item_at_coords (GtkIconView          *icon_view,
                    {
                      if (cell_at_pos)
                        *cell_at_pos = info;
-                     
+
                      return item;
                    }
                }
 
              if (only_in_cell)
                return NULL;
-             
-             if (cell_at_pos)
-               *cell_at_pos = NULL;
            }
 
          return item;
@@ -3688,6 +3863,8 @@ gtk_icon_view_real_move_cursor (GtkIconView     *icon_view,
   icon_view->priv->ctrl_pressed = FALSE;
   icon_view->priv->shift_pressed = FALSE;
 
+  icon_view->priv->draw_focus = TRUE;
+
   return TRUE;
 }
 
@@ -3726,7 +3903,6 @@ find_cell (GtkIconView     *icon_view,
 {
   gint n_focusable;
   gint *focusable;
-  gint first_text;
   gint current;
   gint i, k;
   GList *l;
@@ -3739,7 +3915,6 @@ find_cell (GtkIconView     *icon_view,
   focusable = g_new0 (gint, icon_view->priv->n_cells);
   n_focusable = 0;
 
-  first_text = 0;
   current = 0;
   for (k = 0; k < 2; k++)
     for (l = icon_view->priv->cell_list, i = 0; l; l = l->next, i++)
@@ -3751,9 +3926,6 @@ find_cell (GtkIconView     *icon_view,
        
        if (!info->cell->visible)
          continue;
-       
-       if (GTK_IS_CELL_RENDERER_TEXT (info->cell))
-         first_text = i;
 
        if (info->cell->mode != GTK_CELL_RENDERER_MODE_INERT)
          {
@@ -3767,7 +3939,10 @@ find_cell (GtkIconView     *icon_view,
       }
   
   if (n_focusable == 0)
-    focusable[n_focusable++] = first_text;
+    {
+      g_free (focusable);
+      return -1;
+    }
 
   if (cell < 0)
     {
@@ -4204,7 +4379,7 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
     {
       gint x, y;
       gint focus_width;
-      gfloat offset;
+      gfloat offset, value;
 
       gtk_widget_style_get (GTK_WIDGET (icon_view),
                            "focus-line-width", &focus_width,
@@ -4214,15 +4389,17 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
       
       offset =  y + item->y - focus_width - 
        row_align * (GTK_WIDGET (icon_view)->allocation.height - item->height);
-
-      gtk_adjustment_set_value (icon_view->priv->vadjustment,
-                                icon_view->priv->vadjustment->value + offset);
+      value = CLAMP (icon_view->priv->vadjustment->value + offset, 
+                    icon_view->priv->vadjustment->lower,
+                    icon_view->priv->vadjustment->upper - icon_view->priv->vadjustment->page_size);
+      gtk_adjustment_set_value (icon_view->priv->vadjustment, value);
 
       offset = x + item->x - focus_width - 
        col_align * (GTK_WIDGET (icon_view)->allocation.width - item->width);
-
-      gtk_adjustment_set_value (icon_view->priv->hadjustment,
-                                icon_view->priv->hadjustment->value + offset);
+      value = CLAMP (icon_view->priv->hadjustment->value + offset, 
+                    icon_view->priv->hadjustment->lower,
+                    icon_view->priv->hadjustment->upper - icon_view->priv->hadjustment->page_size);
+      gtk_adjustment_set_value (icon_view->priv->hadjustment, value);
 
       gtk_adjustment_changed (icon_view->priv->hadjustment);
       gtk_adjustment_changed (icon_view->priv->vadjustment);
@@ -4704,6 +4881,7 @@ gtk_icon_view_get_item_at_pos (GtkIconView      *icon_view,
  * @path: a #GtkTreePath
  * 
  * Sets the tip area of @tooltip to be the area covered by the item at @path.
+ * See also gtk_icon_view_set_tooltip_column() for a simpler alternative.
  * See also gtk_tooltip_set_tip_area().
  * 
  * Since: 2.12
@@ -4729,6 +4907,8 @@ gtk_icon_view_set_tooltip_item (GtkIconView     *icon_view,
  * Sets the tip area of @tooltip to the area which @cell occupies in
  * the item pointed to by @path. See also gtk_tooltip_set_tip_area().
  *
+ * See also gtk_icon_view_set_tooltip_column() for a simpler alternative.
+ *
  * Since: 2.12
  */
 void
@@ -5086,10 +5266,10 @@ gtk_icon_view_get_selection_mode (GtkIconView *icon_view)
 /**
  * gtk_icon_view_set_model:
  * @icon_view: A #GtkIconView.
- * @model: The model.
+ * @model: (allow-none): The model.
  *
- * Sets the model for a #GtkIconView.  
- * If the @icon_view already has a model set, it will remove 
+ * Sets the model for a #GtkIconView.
+ * If the @icon_view already has a model set, it will remove
  * it before setting the new model.  If @model is %NULL, then
  * it will unset the old model.
  *
@@ -5351,13 +5531,11 @@ update_pixbuf_cell (GtkIconView *icon_view)
 
        if (icon_view->priv->orientation == GTK_ORIENTATION_VERTICAL)
          g_object_set (info->cell,
-                       "follow-state", TRUE, 
                        "xalign", 0.5,
                        "yalign", 1.0,
                        NULL);
        else
          g_object_set (info->cell,
-                       "follow-state", TRUE, 
                        "xalign", 0.0,
                        "yalign", 0.0,
                        NULL);
@@ -5616,11 +5794,11 @@ gtk_icon_view_unselect_path (GtkIconView *icon_view,
  *
  * To free the return value, use:
  * |[
- * g_list_foreach (list, gtk_tree_path_free, NULL);
+ * g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
  * g_list_free (list);
  * ]|
  *
- * Return value: A #GList containing a #GtkTreePath for each selected row.
+ * Return value: (element-type GtkTreePath) (transfer full): A #GList containing a #GtkTreePath for each selected row.
  *
  * Since: 2.6
  **/
@@ -6091,6 +6269,51 @@ gtk_icon_view_get_margin (GtkIconView *icon_view)
   return icon_view->priv->margin;
 }
 
+/**
+ * gtk_icon_view_set_item_padding:
+ * @icon_view: a #GtkIconView
+ * @item_padding: the item padding
+ *
+ * Sets the #GtkIconView:item-padding property which specifies the padding
+ * around each of the icon view's items.
+ *
+ * Since: 2.18
+ */
+void
+gtk_icon_view_set_item_padding (GtkIconView *icon_view,
+                               gint         item_padding)
+{
+  g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
+  
+  if (icon_view->priv->item_padding != item_padding)
+    {
+      icon_view->priv->item_padding = item_padding;
+
+      gtk_icon_view_stop_editing (icon_view, TRUE);
+      gtk_icon_view_invalidate_sizes (icon_view);
+      gtk_icon_view_queue_layout (icon_view);
+      
+      g_object_notify (G_OBJECT (icon_view), "item-padding");
+    }  
+}
+
+/**
+ * gtk_icon_view_get_item_padding:
+ * @icon_view: a #GtkIconView
+ * 
+ * Returns the value of the ::item-padding property.
+ * 
+ * Return value: the padding around items
+ *
+ * Since: 2.18
+ */
+gint
+gtk_icon_view_get_item_padding (GtkIconView *icon_view)
+{
+  g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), -1);
+
+  return icon_view->priv->item_padding;
+}
 
 /* Get/set whether drag_motion requested the drag data and
  * drag_data_received should thus not actually insert the data,
@@ -6122,26 +6345,6 @@ unset_reorderable (GtkIconView *icon_view)
     }
 }
 
-static void
-clear_source_info (GtkIconView *icon_view)
-{
-  if (icon_view->priv->source_targets)
-    gtk_target_list_unref (icon_view->priv->source_targets);
-  icon_view->priv->source_targets = NULL;
-
-  icon_view->priv->source_set = FALSE;
-}
-
-static void
-clear_dest_info (GtkIconView *icon_view)
-{
-  if (icon_view->priv->dest_targets)
-    gtk_target_list_unref (icon_view->priv->dest_targets);
-  icon_view->priv->dest_targets = NULL;
-
-  icon_view->priv->dest_set = FALSE;
-}
-
 static void
 set_source_row (GdkDragContext *context,
                 GtkTreeModel   *model,
@@ -6281,6 +6484,7 @@ gtk_icon_view_autoscroll (GtkIconView *icon_view)
 {
   gint px, py, x, y, width, height;
   gint hoffset, voffset;
+  gfloat value;
 
   gdk_window_get_pointer (GTK_WIDGET (icon_view)->window, &px, &py, NULL);
   gdk_window_get_geometry (GTK_WIDGET (icon_view)->window, &x, &y, &width, &height, NULL);
@@ -6295,12 +6499,19 @@ gtk_icon_view_autoscroll (GtkIconView *icon_view)
     hoffset = MAX (px - (x + width - 2 * SCROLL_EDGE_SIZE), 0);
 
   if (voffset != 0)
-    gtk_adjustment_set_value (icon_view->priv->vadjustment,
-                              icon_view->priv->vadjustment->value + voffset);
-
+    {
+      value = CLAMP (icon_view->priv->vadjustment->value + voffset, 
+                    icon_view->priv->vadjustment->lower,
+                    icon_view->priv->vadjustment->upper - icon_view->priv->vadjustment->page_size);
+      gtk_adjustment_set_value (icon_view->priv->vadjustment, value);
+    }
   if (hoffset != 0)
-    gtk_adjustment_set_value (icon_view->priv->hadjustment,
-                              icon_view->priv->hadjustment->value + hoffset);
+    {
+      value = CLAMP (icon_view->priv->hadjustment->value + hoffset, 
+                    icon_view->priv->hadjustment->lower,
+                    icon_view->priv->hadjustment->upper - icon_view->priv->hadjustment->page_size);
+      gtk_adjustment_set_value (icon_view->priv->hadjustment, value);
+    }
 }
 
 
@@ -6350,7 +6561,8 @@ set_destination (GtkIconView    *icon_view,
       return FALSE; /* no longer a drop site */
     }
 
-  *target = gtk_drag_dest_find_target (widget, context, icon_view->priv->dest_targets);
+  *target = gtk_drag_dest_find_target (widget, context,
+                                       gtk_drag_dest_get_target_list (widget));
   if (*target == GDK_NONE)
     return FALSE;
 
@@ -6470,6 +6682,7 @@ static gboolean
 gtk_icon_view_maybe_begin_drag (GtkIconView    *icon_view,
                                GdkEventMotion *event)
 {
+  GtkWidget *widget = GTK_WIDGET (icon_view);
   GdkDragContext *context;
   GtkTreePath *path = NULL;
   gint button;
@@ -6516,8 +6729,8 @@ gtk_icon_view_maybe_begin_drag (GtkIconView    *icon_view,
   
   retval = TRUE;
 
-  context = gtk_drag_begin (GTK_WIDGET (icon_view),
-                            icon_view->priv->source_targets,
+  context = gtk_drag_begin (widget,
+                            gtk_drag_source_get_target_list (widget),
                             icon_view->priv->source_actions,
                             button,
                             (GdkEvent*)event);
@@ -6596,7 +6809,7 @@ gtk_icon_view_drag_data_get (GtkWidget        *widget,
   if (model == NULL)
     return;
 
-  if (!icon_view->priv->dest_set)
+  if (!icon_view->priv->source_set)
     return;
 
   source_row = get_source_row (context);
@@ -6636,10 +6849,10 @@ gtk_icon_view_drag_data_delete (GtkWidget      *widget,
   icon_view = GTK_ICON_VIEW (widget);
   model = gtk_icon_view_get_model (icon_view);
 
-  if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_SOURCE, "drag_data_delete"))
+  if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_SOURCE, "drag-data-delete"))
     return;
 
-  if (!icon_view->priv->dest_set)
+  if (!icon_view->priv->source_set)
     return;
 
   source_row = get_source_row (context);
@@ -6753,7 +6966,7 @@ gtk_icon_view_drag_drop (GtkWidget      *widget,
   if (!icon_view->priv->dest_set)
     return FALSE;
 
-  if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drag_drop"))
+  if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drag-drop"))
     return FALSE;
 
   if (!set_destination (icon_view, context, x, y, &suggested_action, &target))
@@ -6806,7 +7019,7 @@ gtk_icon_view_drag_data_received (GtkWidget        *widget,
   icon_view = GTK_ICON_VIEW (widget);  
   model = gtk_icon_view_get_model (icon_view);
 
-  if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drag_data_received"))
+  if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drag-data-received"))
     return;
 
   if (!icon_view->priv->dest_set)
@@ -6881,8 +7094,9 @@ gtk_icon_view_drag_data_received (GtkWidget        *widget,
  * @n_targets: the number of items in @targets
  * @actions: the bitmask of possible actions for a drag from this
  *    widget
- * 
- * Turns @icon_view into a drag source for automatic DND.
+ *
+ * Turns @icon_view into a drag source for automatic DND. Calling this
+ * method sets #GtkIconView:reorderable to %FALSE.
  *
  * Since: 2.8
  **/
@@ -6895,11 +7109,9 @@ gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
 {
   g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
 
-  gtk_drag_source_set (GTK_WIDGET (icon_view), 0, NULL, 0, actions);
+  gtk_drag_source_set (GTK_WIDGET (icon_view), 0, targets, n_targets, actions);
 
-  clear_source_info (icon_view);
   icon_view->priv->start_button_mask = start_button_mask;
-  icon_view->priv->source_targets = gtk_target_list_new (targets, n_targets);
   icon_view->priv->source_actions = actions;
 
   icon_view->priv->source_set = TRUE;
@@ -6914,8 +7126,9 @@ gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
  * @n_targets: the number of items in @targets
  * @actions: the bitmask of possible actions for a drag to this
  *    widget
- * 
- * Turns @icon_view into a drop destination for automatic DND.
+ *
+ * Turns @icon_view into a drop destination for automatic DND. Calling this
+ * method sets #GtkIconView:reorderable to %FALSE.
  *
  * Since: 2.8
  **/
@@ -6927,11 +7140,8 @@ gtk_icon_view_enable_model_drag_dest (GtkIconView          *icon_view,
 {
   g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
 
-  gtk_drag_dest_set (GTK_WIDGET (icon_view), 0, NULL, 0, actions);
+  gtk_drag_dest_set (GTK_WIDGET (icon_view), 0, targets, n_targets, actions);
 
-  clear_dest_info (icon_view);
-
-  icon_view->priv->dest_targets = gtk_target_list_new (targets, n_targets);
   icon_view->priv->dest_actions = actions;
 
   icon_view->priv->dest_set = TRUE;
@@ -6943,7 +7153,8 @@ gtk_icon_view_enable_model_drag_dest (GtkIconView          *icon_view,
  * gtk_icon_view_unset_model_drag_source:
  * @icon_view: a #GtkIconView
  * 
- * Undoes the effect of gtk_icon_view_enable_model_drag_source().
+ * Undoes the effect of gtk_icon_view_enable_model_drag_source(). Calling this
+ * method sets #GtkIconView:reorderable to %FALSE.
  *
  * Since: 2.8
  **/
@@ -6955,7 +7166,7 @@ gtk_icon_view_unset_model_drag_source (GtkIconView *icon_view)
   if (icon_view->priv->source_set)
     {
       gtk_drag_source_unset (GTK_WIDGET (icon_view));
-      clear_source_info (icon_view);
+      icon_view->priv->source_set = FALSE;
     }
 
   unset_reorderable (icon_view);
@@ -6965,7 +7176,8 @@ gtk_icon_view_unset_model_drag_source (GtkIconView *icon_view)
  * gtk_icon_view_unset_model_drag_dest:
  * @icon_view: a #GtkIconView
  * 
- * Undoes the effect of gtk_icon_view_enable_model_drag_dest().
+ * Undoes the effect of gtk_icon_view_enable_model_drag_dest(). Calling this
+ * method sets #GtkIconView:reorderable to %FALSE.
  *
  * Since: 2.8
  **/
@@ -6977,7 +7189,7 @@ gtk_icon_view_unset_model_drag_dest (GtkIconView *icon_view)
   if (icon_view->priv->dest_set)
     {
       gtk_drag_dest_unset (GTK_WIDGET (icon_view));
-      clear_dest_info (icon_view);
+      icon_view->priv->dest_set = FALSE;
     }
 
   unset_reorderable (icon_view);
@@ -6987,9 +7199,9 @@ gtk_icon_view_unset_model_drag_dest (GtkIconView *icon_view)
 /**
  * gtk_icon_view_set_drag_dest_item:
  * @icon_view: a #GtkIconView
- * @path: The path of the item to highlight, or %NULL.
+ * @path: (allow-none): The path of the item to highlight, or %NULL.
  * @pos: Specifies where to drop, relative to the item
- * 
+ *
  * Sets the item that is highlighted for feedback.
  *
  * Since: 2.8
@@ -7018,7 +7230,7 @@ gtk_icon_view_set_drag_dest_item (GtkIconView              *icon_view,
   
   /* special case a drop on an empty model */
   icon_view->priv->empty_view_drop = FALSE;
-  if (pos == GTK_TREE_VIEW_DROP_BEFORE && path
+  if (pos == GTK_ICON_VIEW_DROP_ABOVE && path
       && gtk_tree_path_get_depth (path) == 1
       && gtk_tree_path_get_indices (path)[0] == 0)
     {
@@ -7243,7 +7455,9 @@ static const GtkTargetEntry item_targets[] = {
  * #GtkTreeStore and #GtkListStore support these.  If @reorderable is %TRUE, then
  * the user can reorder the model by dragging and dropping rows.  The
  * developer can listen to these changes by connecting to the model's
- * row_inserted and row_deleted signals.
+ * row_inserted and row_deleted signals. The reordering is implemented by setting up
+ * the icon view as a drag source and destination. Therefore, drag and
+ * drop can not be used in a reorderable view for any other purpose.
  *
  * This function does not give you any degree of control over the order -- any
  * reordering is allowed.  If more control is needed, you should probably
@@ -7474,7 +7688,7 @@ gtk_icon_view_item_accessible_image_set_image_description (AtkImage    *image,
   item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (image);
 
   g_free (item->image_description);
-  item->image_description = g_strdup (item->image_description);
+  item->image_description = g_strdup (description);
 
   return TRUE;
 }
@@ -8273,7 +8487,7 @@ gtk_icon_view_item_accessible_grab_focus (AtkComponent *component)
   gtk_widget_grab_focus (item->widget);
   gtk_icon_view_set_cursor_item (GTK_ICON_VIEW (item->widget), item->item, -1);
   toplevel = gtk_widget_get_toplevel (GTK_WIDGET (item->widget));
-  if (GTK_WIDGET_TOPLEVEL (toplevel))
+  if (gtk_widget_is_toplevel (toplevel))
     gtk_window_present (GTK_WINDOW (toplevel));
 
   return TRUE;
@@ -8554,25 +8768,25 @@ gtk_icon_view_item_accessible_get_type (void)
         NULL /* value table */
       };
 
-      static const GInterfaceInfo atk_component_info =
+      const GInterfaceInfo atk_component_info =
       {
         (GInterfaceInitFunc) atk_component_item_interface_init,
         (GInterfaceFinalizeFunc) NULL,
         NULL
       };
-      static const GInterfaceInfo atk_action_info =
+      const GInterfaceInfo atk_action_info =
       {
         (GInterfaceInitFunc) atk_action_item_interface_init,
         (GInterfaceFinalizeFunc) NULL,
         NULL
       };
-      static const GInterfaceInfo atk_image_info =
+      const GInterfaceInfo atk_image_info =
       {
         (GInterfaceInitFunc) atk_image_item_interface_init,
         (GInterfaceFinalizeFunc) NULL,
         NULL
       };
-      static const GInterfaceInfo atk_text_info =
+      const GInterfaceInfo atk_text_info =
       {
         (GInterfaceInitFunc) atk_text_item_interface_init,
         (GInterfaceFinalizeFunc) NULL,
@@ -8863,11 +9077,44 @@ static void
 gtk_icon_view_accessible_model_row_changed (GtkTreeModel *tree_model,
                                             GtkTreePath  *path,
                                             GtkTreeIter  *iter,
-                                            gpointer     user_data)
+                                            gpointer      user_data)
 {
   AtkObject *atk_obj;
+  gint index;
+  GtkWidget *widget;
+  GtkIconView *icon_view;
+  GtkIconViewItem *item;
+  GtkIconViewAccessible *a11y_view;
+  GtkIconViewItemAccessible *a11y_item;
+  const gchar *name;
+  gchar *text;
 
   atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
+  a11y_view = GTK_ICON_VIEW_ACCESSIBLE (atk_obj);
+  index = gtk_tree_path_get_indices(path)[0];
+  a11y_item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (
+      gtk_icon_view_accessible_find_child (atk_obj, index));
+
+  if (a11y_item)
+    {
+      widget = GTK_ACCESSIBLE (atk_obj)->widget;
+      icon_view = GTK_ICON_VIEW (widget);
+      item = a11y_item->item;
+
+      name = gtk_icon_view_item_accessible_get_name (ATK_OBJECT (a11y_item));
+
+      if (!name || strcmp (name, "") == 0)
+        {
+          gtk_icon_view_set_cell_data (icon_view, item);
+          text = get_text (icon_view, item);
+          if (text)
+            {
+              gtk_text_buffer_set_text (a11y_item->text_buffer, text, -1);
+              g_free (text);
+            }
+        }
+    }
+
   g_signal_emit_by_name (atk_obj, "visible-data-changed");
 
   return;
@@ -8994,20 +9241,29 @@ gtk_icon_view_accessible_model_rows_reordered (GtkTreeModel *tree_model,
   GtkIconViewItemAccessible *item;
   GList *items;
   AtkObject *atk_obj;
+  gint *order;
+  gint length, i;
 
   atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
   icon_view = GTK_ICON_VIEW (user_data);
   priv = gtk_icon_view_accessible_get_priv (atk_obj);
 
+  length = gtk_tree_model_iter_n_children (tree_model, NULL);
+
+  order = g_new (gint, length);
+  for (i = 0; i < length; i++)
+    order [new_order[i]] = i;
+
   items = priv->items;
   while (items)
     {
       info = items->data;
       item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
-      info->index = new_order[info->index];
+      info->index = order[info->index];
       item->item = g_list_nth_data (icon_view->priv->items, info->index);
       items = items->next;
     }
+  g_free (order);
   priv->items = g_list_sort (priv->items, 
                              (GCompareFunc)gtk_icon_view_accessible_item_compare);
 
@@ -9455,7 +9711,7 @@ gtk_icon_view_accessible_get_type (void)
 
   if (!type)
     {
-      static GTypeInfo tinfo =
+      GTypeInfo tinfo =
       {
         0, /* class size */
         (GBaseInitFunc) NULL, /* base init */
@@ -9468,13 +9724,13 @@ gtk_icon_view_accessible_get_type (void)
         (GInstanceInitFunc) NULL, /* instance init */
         NULL /* value table */
       };
-      static const GInterfaceInfo atk_component_info =
+      const GInterfaceInfo atk_component_info =
       {
         (GInterfaceInitFunc) atk_component_interface_init,
         (GInterfaceFinalizeFunc) NULL,
         NULL
       };
-      static const GInterfaceInfo atk_selection_info = 
+      const GInterfaceInfo atk_selection_info =
       {
         (GInterfaceInitFunc) gtk_icon_view_accessible_selection_interface_init,
         (GInterfaceFinalizeFunc) NULL,
@@ -9598,7 +9854,7 @@ gtk_icon_view_get_accessible (GtkWidget *widget)
                                       gtk_icon_view_accessible_factory_get_type ());
       first_time = FALSE;
     } 
-  return (* GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->get_accessible) (widget);
+  return GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->get_accessible (widget);
 }
 
 static gboolean