]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkiconview.c
Replace a lot of idle and timeout calls by the new gdk_threads api.
[~andy/gtk] / gtk / gtkiconview.c
index 34988467465aca639aba3f532f86f25466a8df5c..45280f63c4e38ec2d13dacb0f77072094e71432e 100644 (file)
@@ -74,6 +74,7 @@ struct _GtkIconViewItem
 
   guint selected : 1;
   guint selected_before_rubberbanding : 1;
+
 };
 
 typedef struct _GtkIconViewCellInfo GtkIconViewCellInfo;
@@ -172,6 +173,12 @@ struct _GtkIconViewPrivate
   GtkTreeRowReference *dest_item;
   GtkIconViewDropPosition dest_pos;
 
+  /* scroll to */
+  GtkTreeRowReference *scroll_to_path;
+  gfloat scroll_to_row_align;
+  gfloat scroll_to_col_align;
+  guint scroll_to_use_align : 1;
+
   guint source_set : 1;
   guint dest_set : 1;
   guint reorderable : 1;
@@ -215,7 +222,6 @@ enum
 };
 
 /* GObject vfuncs */
-static void             gtk_icon_view_class_init                (GtkIconViewClass   *klass);
 static void             gtk_icon_view_cell_layout_init          (GtkCellLayoutIface *iface);
 static void             gtk_icon_view_finalize                  (GObject            *object);
 static void             gtk_icon_view_set_property              (GObject            *object,
@@ -233,6 +239,10 @@ static void             gtk_icon_view_destroy                   (GtkObject
 /* GtkWidget vfuncs */
 static void             gtk_icon_view_realize                   (GtkWidget          *widget);
 static void             gtk_icon_view_unrealize                 (GtkWidget          *widget);
+static void             gtk_icon_view_style_set                 (GtkWidget        *widget,
+                                                                GtkStyle         *previous_style);
+static void             gtk_icon_view_state_changed             (GtkWidget        *widget,
+                                                                GtkStateType      previous_state);
 static void             gtk_icon_view_size_request              (GtkWidget          *widget,
                                                                 GtkRequisition     *requisition);
 static void             gtk_icon_view_size_allocate             (GtkWidget          *widget,
@@ -434,7 +444,7 @@ static guint icon_view_signals[LAST_SIGNAL] = { 0 };
 
 G_DEFINE_TYPE_WITH_CODE (GtkIconView, gtk_icon_view, GTK_TYPE_CONTAINER,
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT,
-                                               gtk_icon_view_cell_layout_init));
+                                               gtk_icon_view_cell_layout_init))
 
 static void
 gtk_icon_view_class_init (GtkIconViewClass *klass)
@@ -462,6 +472,8 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
   
   widget_class->realize = gtk_icon_view_realize;
   widget_class->unrealize = gtk_icon_view_unrealize;
+  widget_class->style_set = gtk_icon_view_style_set;
+  widget_class->get_accessible = gtk_icon_view_get_accessible;
   widget_class->size_request = gtk_icon_view_size_request;
   widget_class->size_allocate = gtk_icon_view_size_allocate;
   widget_class->expose_event = gtk_icon_view_expose;
@@ -476,7 +488,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
   widget_class->drag_motion = gtk_icon_view_drag_motion;
   widget_class->drag_drop = gtk_icon_view_drag_drop;
   widget_class->drag_data_received = gtk_icon_view_drag_data_received;
-  widget_class->get_accessible = gtk_icon_view_get_accessible;
+  widget_class->state_changed = gtk_icon_view_state_changed;
 
   container_class->remove = gtk_icon_view_remove;
   container_class->forall = gtk_icon_view_forall;
@@ -591,7 +603,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
   
 
   /**
-   * GtkIconView::item-width:
+   * GtkIconView:item-width:
    *
    * The item-width property specifies the width to use for each item. 
    * If it is set to -1, the icon view will automatically determine a 
@@ -608,7 +620,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                                                     GTK_PARAM_READWRITE));  
 
   /**
-   * GtkIconView::spacing:
+   * GtkIconView:spacing:
    *
    * The spacing property specifies the space which is inserted between
    * the cells (i.e. the icon and the text) of an item.
@@ -624,7 +636,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                                                     GTK_PARAM_READWRITE));
 
   /**
-   * GtkIconView::row-spacing:
+   * GtkIconView:row-spacing:
    *
    * The row-spacing property specifies the space which is inserted between
    * the rows of the icon view.
@@ -640,7 +652,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                                                     GTK_PARAM_READWRITE));
 
   /**
-   * GtkIconView::column-spacing:
+   * GtkIconView:column-spacing:
    *
    * The column-spacing property specifies the space which is inserted between
    * the columns of the icon view.
@@ -651,12 +663,12 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                                    PROP_COLUMN_SPACING,
                                    g_param_spec_int ("column-spacing",
                                                     P_("Column Spacing"),
-                                                    P_("Space which is inserted between grid column"),
+                                                    P_("Space which is inserted between grid columns"),
                                                     0, G_MAXINT, 6,
                                                     GTK_PARAM_READWRITE));
 
   /**
-   * GtkIconView::margin:
+   * GtkIconView:margin:
    *
    * The margin property specifies the space which is inserted 
    * at the edges of the icon view.
@@ -673,7 +685,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
 
 
   /**
-   * GtkIconView::orientation:
+   * GtkIconView:orientation:
    *
    * The orientation property specifies how the cells (i.e. the icon and 
    * the text) of the item are positioned relative to each other.
@@ -690,7 +702,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                                                      GTK_PARAM_READWRITE));
 
   /**
-   * GtkIconView:orientation:
+   * GtkIconView:reorderable:
    *
    * The reorderable property specifies if the items can be reordered
    * by DND.
@@ -723,7 +735,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
 
   /* Signals */
   widget_class->set_scroll_adjustments_signal =
-    g_signal_new ("set_scroll_adjustments",
+    g_signal_new (I_("set_scroll_adjustments"),
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GtkIconViewClass, set_scroll_adjustments),
@@ -733,7 +745,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
 
   icon_view_signals[ITEM_ACTIVATED] =
-    g_signal_new ("item_activated",
+    g_signal_new (I_("item_activated"),
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GtkIconViewClass, item_activated),
@@ -743,7 +755,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  GTK_TYPE_TREE_PATH);
 
   icon_view_signals[SELECTION_CHANGED] =
-    g_signal_new ("selection_changed",
+    g_signal_new (I_("selection-changed"),
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_FIRST,
                  G_STRUCT_OFFSET (GtkIconViewClass, selection_changed),
@@ -752,7 +764,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  G_TYPE_NONE, 0);
   
   icon_view_signals[SELECT_ALL] =
-    g_signal_new ("select_all",
+    g_signal_new (I_("select_all"),
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET (GtkIconViewClass, select_all),
@@ -761,7 +773,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  G_TYPE_NONE, 0);
   
   icon_view_signals[UNSELECT_ALL] =
-    g_signal_new ("unselect_all",
+    g_signal_new (I_("unselect_all"),
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET (GtkIconViewClass, unselect_all),
@@ -770,7 +782,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  G_TYPE_NONE, 0);
 
   icon_view_signals[SELECT_CURSOR_ITEM] =
-    g_signal_new ("select_cursor_item",
+    g_signal_new (I_("select_cursor_item"),
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET (GtkIconViewClass, select_cursor_item),
@@ -779,7 +791,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  G_TYPE_NONE, 0);
 
   icon_view_signals[TOGGLE_CURSOR_ITEM] =
-    g_signal_new ("toggle_cursor_item",
+    g_signal_new (I_("toggle_cursor_item"),
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET (GtkIconViewClass, toggle_cursor_item),
@@ -788,7 +800,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  G_TYPE_NONE, 0);
 
   icon_view_signals[ACTIVATE_CURSOR_ITEM] =
-    g_signal_new ("activate_cursor_item",
+    g_signal_new (I_("activate_cursor_item"),
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET (GtkIconViewClass, activate_cursor_item),
@@ -797,7 +809,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  G_TYPE_BOOLEAN, 0);
   
   icon_view_signals[MOVE_CURSOR] =
-    g_signal_new ("move_cursor",
+    g_signal_new (I_("move_cursor"),
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET (GtkIconViewClass, move_cursor),
@@ -808,14 +820,21 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
                  G_TYPE_INT);
 
   /* Key bindings */
-  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK, "select_all", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "unselect_all", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_CONTROL_MASK, "toggle_cursor_item", 0);
-
-  gtk_binding_entry_add_signal (binding_set, GDK_space, 0, "activate_cursor_item", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "activate_cursor_item", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_ISO_Enter, 0, "activate_cursor_item", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "activate_cursor_item", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK, 
+                               "select_all", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK, 
+                               "unselect_all", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_CONTROL_MASK, 
+                               "toggle_cursor_item", 0);
+
+  gtk_binding_entry_add_signal (binding_set, GDK_space, 0, 
+                               "activate_cursor_item", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, 
+                               "activate_cursor_item", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_ISO_Enter, 0, 
+                               "activate_cursor_item", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, 
+                               "activate_cursor_item", 0);
 
   gtk_icon_view_add_move_binding (binding_set, GDK_Up, 0,
                                  GTK_MOVEMENT_DISPLAY_LINES, -1);
@@ -923,9 +942,30 @@ gtk_icon_view_destroy (GtkObject *object)
   gtk_icon_view_set_model (icon_view, NULL);
   
   if (icon_view->priv->layout_idle_id != 0)
-    g_source_remove (icon_view->priv->layout_idle_id);
+    {
+      g_source_remove (icon_view->priv->layout_idle_id);
+      icon_view->priv->layout_idle_id = 0;
+    }
+
+  if (icon_view->priv->scroll_to_path != NULL)
+    {
+      gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
+      icon_view->priv->scroll_to_path = NULL;
+    }
 
   remove_scroll_timeout (icon_view);
+
+  if (icon_view->priv->hadjustment != NULL)
+    {
+      g_object_unref (icon_view->priv->hadjustment);
+      icon_view->priv->hadjustment = NULL;
+    }
+
+  if (icon_view->priv->vadjustment != NULL)
+    {
+      g_object_unref (icon_view->priv->vadjustment);
+      icon_view->priv->vadjustment = NULL;
+    }
   
   (* GTK_OBJECT_CLASS (gtk_icon_view_parent_class)->destroy) (object);
 }
@@ -1083,6 +1123,7 @@ gtk_icon_view_realize (GtkWidget *widget)
 
   widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
                                   &attributes, attributes_mask);
+  gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
   gdk_window_set_user_data (widget->window, widget);
 
   /* Make the window for the icon view */
@@ -1105,7 +1146,6 @@ gtk_icon_view_realize (GtkWidget *widget)
 
   widget->style = gtk_style_attach (widget->style, widget->window);
   gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
-  gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
 
   gdk_window_show (icon_view->priv->bin_window);
 }
@@ -1126,6 +1166,40 @@ gtk_icon_view_unrealize (GtkWidget *widget)
     (* GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->unrealize) (widget);
 }
 
+static void
+gtk_icon_view_state_changed (GtkWidget      *widget,
+                            GtkStateType    previous_state)
+{
+  GtkIconView *icon_view = GTK_ICON_VIEW (widget);
+
+  if (GTK_WIDGET_REALIZED (widget))
+    {
+      gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
+      gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
+    }
+
+  gtk_widget_queue_draw (widget);
+}
+
+static void
+gtk_icon_view_style_set (GtkWidget *widget,
+                        GtkStyle *previous_style)
+{
+  GtkIconView *icon_view;
+
+  g_return_if_fail (GTK_IS_ICON_VIEW (widget));
+
+  icon_view = GTK_ICON_VIEW (widget);
+
+  if (GTK_WIDGET_REALIZED (widget))
+    {
+      gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
+      gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
+    }
+
+  gtk_widget_queue_resize (widget);
+}
+
 static void
 gtk_icon_view_size_request (GtkWidget      *widget,
                            GtkRequisition *requisition)
@@ -1229,8 +1303,25 @@ gtk_icon_view_size_allocate (GtkWidget      *widget,
   if (vadjustment->value > vadjustment->upper - vadjustment->page_size)
     gtk_adjustment_set_value (vadjustment, MAX (0, vadjustment->upper - vadjustment->page_size));
 
-  gtk_adjustment_changed (hadjustment);
-  gtk_adjustment_changed (vadjustment);
+  if (GTK_WIDGET_REALIZED (widget) &&
+      icon_view->priv->scroll_to_path)
+    {
+      GtkTreePath *path;
+      path = gtk_tree_row_reference_get_path (icon_view->priv->scroll_to_path);
+      gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
+      icon_view->priv->scroll_to_path = NULL;
+
+      gtk_icon_view_scroll_to_path (icon_view, path,
+                                   icon_view->priv->scroll_to_use_align,
+                                   icon_view->priv->scroll_to_row_align,
+                                   icon_view->priv->scroll_to_col_align);
+      gtk_tree_path_free (path);
+    }
+  else
+    {
+      gtk_adjustment_changed (hadjustment);
+      gtk_adjustment_changed (vadjustment);
+    }
 }
 
 static gboolean
@@ -1370,8 +1461,6 @@ rubberband_scroll_timeout (gpointer data)
   GtkIconView *icon_view;
   gdouble value;
 
-  GDK_THREADS_ENTER ();
-  
   icon_view = data;
 
   value = MIN (icon_view->priv->vadjustment->value +
@@ -1383,8 +1472,6 @@ rubberband_scroll_timeout (gpointer data)
 
   gtk_icon_view_update_rubberband (icon_view);
   
-  GDK_THREADS_LEAVE ();
-
   return TRUE;
 }
 
@@ -1419,7 +1506,7 @@ gtk_icon_view_motion (GtkWidget      *widget,
          icon_view->priv->event_last_y = event->y;
 
          if (icon_view->priv->scroll_timeout_id == 0)
-           icon_view->priv->scroll_timeout_id = g_timeout_add (30, rubberband_scroll_timeout, 
+           icon_view->priv->scroll_timeout_id = gdk_threads_add_timeout (30, rubberband_scroll_timeout, 
                                                                icon_view);
        }
       else 
@@ -1610,7 +1697,7 @@ gtk_icon_view_start_editing (GtkIconView         *icon_view,
 
       /* FIXME ugly special case */ 
       if (GTK_IS_ENTRY (editable) || GTK_IS_COMBO_BOX (editable))
-       g_object_set (editable, "has_frame", TRUE, NULL);
+       g_object_set (editable, "has-frame", TRUE, NULL);
 
       /* the rest corresponds to tree_view_real_start_editing... */
       icon_view->priv->edited_item = item;
@@ -1680,7 +1767,7 @@ gtk_icon_view_stop_editing (GtkIconView *icon_view,
  * gtk_icon_view_set_cursor:
  * @icon_view: A #GtkIconView
  * @path: A #GtkTreePath
- * @cell: A #GtkCellRenderer or %NULL
+ * @cell: 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
@@ -1701,7 +1788,7 @@ gtk_icon_view_set_cursor (GtkIconView     *icon_view,
                          GtkCellRenderer *cell,
                          gboolean         start_editing)
 {
-  GtkIconViewItem *item;
+  GtkIconViewItem *item = NULL;
   GtkIconViewCellInfo *info =  NULL;
   GList *l;
   gint i, cell_pos;
@@ -1711,31 +1798,34 @@ gtk_icon_view_set_cursor (GtkIconView     *icon_view,
   g_return_if_fail (cell == NULL || GTK_IS_CELL_RENDERER (cell));
 
   gtk_icon_view_stop_editing (icon_view, TRUE);
-  
-  item = g_list_nth (icon_view->priv->items,
-                    gtk_tree_path_get_indices(path)[0])->data;
+
+  if (gtk_tree_path_get_depth (path) == 1)
+    item = g_list_nth_data (icon_view->priv->items,
+                           gtk_tree_path_get_indices(path)[0]);
   
   if (!item)
     return;
-  
+
   cell_pos = -1;
   for (l = icon_view->priv->cell_list, i = 0; l; l = l->next, i++)
     {
       info = l->data;
-
+      
       if (info->cell == cell)
        {
          cell_pos = i;
          break;
        }
-
+         
       info = NULL;
     }
+  
+  g_return_if_fail (cell == NULL || info != NULL);
 
   gtk_icon_view_set_cursor_item (icon_view, item, cell_pos);
-  gtk_icon_view_scroll_to_item (icon_view, item);
-
-  if (start_editing)
+  gtk_icon_view_scroll_to_path (icon_view, path, FALSE, 0.0, 0.0);
+  
+  if (info && start_editing)
     gtk_icon_view_start_editing (icon_view, item, info, NULL);
 }
 
@@ -1923,6 +2013,7 @@ gtk_icon_view_button_press (GtkWidget      *widget,
        }
 
       icon_view->priv->last_single_clicked = NULL;
+      icon_view->priv->pressed_button = -1;
     }
   
   if (dirty)
@@ -2175,8 +2266,7 @@ gtk_icon_view_set_adjustments (GtkIconView   *icon_view,
   if (icon_view->priv->hadjustment != hadj)
     {
       icon_view->priv->hadjustment = hadj;
-      g_object_ref (icon_view->priv->hadjustment);
-      gtk_object_sink (GTK_OBJECT (icon_view->priv->hadjustment));
+      g_object_ref_sink (icon_view->priv->hadjustment);
 
       g_signal_connect (icon_view->priv->hadjustment, "value_changed",
                        G_CALLBACK (gtk_icon_view_adjustment_changed),
@@ -2187,8 +2277,7 @@ gtk_icon_view_set_adjustments (GtkIconView   *icon_view,
   if (icon_view->priv->vadjustment != vadj)
     {
       icon_view->priv->vadjustment = vadj;
-      g_object_ref (icon_view->priv->vadjustment);
-      gtk_object_sink (GTK_OBJECT (icon_view->priv->vadjustment));
+      g_object_ref_sink (icon_view->priv->vadjustment);
 
       g_signal_connect (icon_view->priv->vadjustment, "value_changed",
                        G_CALLBACK (gtk_icon_view_adjustment_changed),
@@ -2316,7 +2405,6 @@ gtk_icon_view_layout_single_row (GtkIconView *icon_view,
                                 gint        *maximum_width)
 {
   gint focus_width;
-  gint spacing;
   gint x, current_width;
   GList *items, *last_item;
   gint col;
@@ -2337,8 +2425,6 @@ gtk_icon_view_layout_single_row (GtkIconView *icon_view,
                        "focus-line-width", &focus_width,
                        NULL);
 
-  spacing = icon_view->priv->spacing;
-
   x += icon_view->priv->margin + focus_width;
   current_width += 2 * (icon_view->priv->margin + focus_width);
 
@@ -2436,6 +2522,12 @@ gtk_icon_view_layout (GtkIconView *icon_view)
   gint row;
   gint item_width;
 
+  if (icon_view->priv->layout_idle_id != 0)
+    {
+      g_source_remove (icon_view->priv->layout_idle_id);
+      icon_view->priv->layout_idle_id = 0;
+    }
+  
   if (icon_view->priv->model == NULL)
     return;
 
@@ -2467,32 +2559,38 @@ gtk_icon_view_layout (GtkIconView *icon_view)
   while (icons != NULL);
 
   if (maximum_width != icon_view->priv->width)
-    {
-      icon_view->priv->width = maximum_width;
-    }
+    icon_view->priv->width = maximum_width;
+
   y += icon_view->priv->margin;
   
   if (y != icon_view->priv->height)
-    {
-      icon_view->priv->height = y;
-    }
+    icon_view->priv->height = y;
 
-  gtk_icon_view_set_adjustment_upper (icon_view->priv->hadjustment, icon_view->priv->width);
-  gtk_icon_view_set_adjustment_upper (icon_view->priv->vadjustment, icon_view->priv->height);
+  gtk_icon_view_set_adjustment_upper (icon_view->priv->hadjustment, 
+                                     icon_view->priv->width);
+  gtk_icon_view_set_adjustment_upper (icon_view->priv->vadjustment, 
+                                     icon_view->priv->height);
 
   if (GTK_WIDGET_REALIZED (icon_view))
-    {
-      gdk_window_resize (icon_view->priv->bin_window,
-                        MAX (icon_view->priv->width, widget->allocation.width),
-                        MAX (icon_view->priv->height, widget->allocation.height));
-    }
+    gdk_window_resize (icon_view->priv->bin_window,
+                      MAX (icon_view->priv->width, widget->allocation.width),
+                      MAX (icon_view->priv->height, widget->allocation.height));
 
-  if (icon_view->priv->layout_idle_id != 0)
+  if (icon_view->priv->scroll_to_path)
     {
-      g_source_remove (icon_view->priv->layout_idle_id);
-      icon_view->priv->layout_idle_id = 0;
-    }
+      GtkTreePath *path;
 
+      path = gtk_tree_row_reference_get_path (icon_view->priv->scroll_to_path);
+      gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
+      icon_view->priv->scroll_to_path = NULL;
+      
+      gtk_icon_view_scroll_to_path (icon_view, path,
+                                   icon_view->priv->scroll_to_use_align,
+                                   icon_view->priv->scroll_to_row_align,
+                                   icon_view->priv->scroll_to_col_align);
+      gtk_tree_path_free (path);
+    }
+  
   gtk_widget_queue_draw (GTK_WIDGET (icon_view));
 }
 
@@ -2539,8 +2637,7 @@ adjust_wrap_width (GtkIconView     *icon_view,
   GtkIconViewCellInfo *pixbuf_info;
   gint pixbuf_width, wrap_width;
       
-  if (icon_view->priv->item_width < 0 &&
-      icon_view->priv->text_cell != -1 &&
+  if (icon_view->priv->text_cell != -1 &&
       icon_view->priv->pixbuf_cell != -1)
     {
       text_info = g_list_nth_data (icon_view->priv->cell_list,
@@ -2555,7 +2652,7 @@ adjust_wrap_width (GtkIconView     *icon_view,
                                  NULL);
          
       if (item->width == -1)
-       wrap_width = pixbuf_width;
+       wrap_width = MAX (2 * pixbuf_width, 50);
       else if (icon_view->priv->orientation == GTK_ORIENTATION_VERTICAL)
        wrap_width = item->width;
       else
@@ -2605,7 +2702,7 @@ gtk_icon_view_calculate_item_size (GtkIconView     *icon_view,
                                  NULL, NULL, NULL,
                                  &item->box[info->position].width, 
                                  &item->box[info->position].height);
-      
+
       if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
        {
          item->width += item->box[info->position].width 
@@ -2658,40 +2755,45 @@ gtk_icon_view_calculate_item_size2 (GtkIconView     *icon_view,
          continue;
 
        if (!info->cell->visible)
-        continue;
-
-      if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
-       {
-         cell_area.width = item->box[i].width;
-         cell_area.height = item->height;
-       }
-      else
-       {
-         cell_area.width = item->width;
-         cell_area.height = max_height[i];
-       }
-
-      gtk_cell_renderer_get_size (info->cell, GTK_WIDGET (icon_view), 
-                                 &cell_area,
-                                 &item->box[i].x, &item->box[i].y,
-                                 &item->box[i].width, &item->box[i].height);
-      item->box[i].x += cell_area.x;
-      item->box[i].y += cell_area.y;
-
-      if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
-       {
-         item->before[i] = item->box[i].x - cell_area.x;
-         item->after[i] = cell_area.width - item->box[i].width - item->before[i];
-         cell_area.x += cell_area.width + spacing;
-       }
-      else
-       {
-         item->before[i] = item->box[i].y - cell_area.y;
-         item->after[i] = cell_area.height - item->box[i].height - item->before[i];
-         cell_area.y += cell_area.height + spacing;
-       }
-    }
+         continue;
 
+       if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+         {
+           cell_area.width = item->box[info->position].width;
+           cell_area.height = item->height;
+         }
+       else
+         {
+           cell_area.width = item->width;
+           cell_area.height = max_height[i];
+         }
+       
+       gtk_cell_renderer_get_size (info->cell, GTK_WIDGET (icon_view), 
+                                   &cell_area,
+                                   &item->box[info->position].x, &item->box[info->position].y,
+                                   &item->box[info->position].width, &item->box[info->position].height);
+       
+       item->box[info->position].x += cell_area.x;
+       item->box[info->position].y += cell_area.y;
+       if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+         {
+           item->before[info->position] = item->box[info->position].x - cell_area.x;
+           item->after[info->position] = cell_area.width - item->box[info->position].width - item->before[info->position];
+           cell_area.x += cell_area.width + spacing;
+         }
+       else
+         {
+           if (item->box[info->position].width > item->width)
+             {
+               item->width = item->box[info->position].width;
+               cell_area.width = item->width;
+             }
+           item->before[info->position] = item->box[info->position].y - cell_area.y;
+           item->after[info->position] = cell_area.height - item->box[info->position].height - item->before[info->position];
+           cell_area.y += cell_area.height + spacing;
+         }
+      }
+  
   if (rtl && icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       for (i = 0; i < icon_view->priv->n_cells; i++)
@@ -2727,12 +2829,11 @@ gtk_icon_view_paint_item (GtkIconView     *icon_view,
                          gboolean         draw_focus)
 {
   gint focus_width, focus_pad;
-  gint spacing, padding;
+  gint padding;
   GdkRectangle cell_area, box;
   GList *l;
   gint i;
   GtkStateType state;
-  gboolean rtl;
   GtkCellRendererState flags;
       
   if (icon_view->priv->model == NULL)
@@ -2740,14 +2841,11 @@ gtk_icon_view_paint_item (GtkIconView     *icon_view,
   
   gtk_icon_view_set_cell_data (icon_view, item);
 
-  rtl = gtk_widget_get_direction (GTK_WIDGET (icon_view)) == GTK_TEXT_DIR_RTL;
-  
   gtk_widget_style_get (GTK_WIDGET (icon_view),
                        "focus-line-width", &focus_width,
                        "focus-padding", &focus_pad,
                        NULL);
   
-  spacing = icon_view->priv->spacing;
   padding = focus_width; 
   
   if (item->selected)
@@ -2814,7 +2912,7 @@ gtk_icon_view_paint_item (GtkIconView     *icon_view,
                          cell_area.width, cell_area.height);
 
       gtk_icon_view_get_cell_box (icon_view, item, info, &box);
-
+         
       gdk_draw_rectangle (drawable,
                          GTK_WIDGET (icon_view)->style->black_gc,
                          FALSE,
@@ -2965,16 +3063,12 @@ layout_callback (gpointer user_data)
 {
   GtkIconView *icon_view;
 
-  GDK_THREADS_ENTER ();
-
   icon_view = GTK_ICON_VIEW (user_data);
   
   icon_view->priv->layout_idle_id = 0;
 
   gtk_icon_view_layout (icon_view);
   
-  GDK_THREADS_LEAVE();
-
   return FALSE;
 }
 
@@ -2984,7 +3078,7 @@ gtk_icon_view_queue_layout (GtkIconView *icon_view)
   if (icon_view->priv->layout_idle_id != 0)
     return;
 
-  icon_view->priv->layout_idle_id = g_idle_add (layout_callback, icon_view);
+  icon_view->priv->layout_idle_id = gdk_threads_add_idle (layout_callback, icon_view);
 }
 
 static void
@@ -3060,8 +3154,8 @@ gtk_icon_view_get_item_at_coords (GtkIconView          *icon_view,
     {
       GtkIconViewItem *item = items->data;
 
-      if (x >= item->x - icon_view->priv->row_spacing/2 && x <= item->x + item->width + icon_view->priv->row_spacing/2 &&
-         y >= item->y - icon_view->priv->column_spacing/2 && y <= item->y + item->height + icon_view->priv->column_spacing/2)
+      if (x >= item->x - icon_view->priv->column_spacing/2 && x <= item->x + item->width + icon_view->priv->column_spacing/2 &&
+         y >= item->y - icon_view->priv->row_spacing/2 && y <= item->y + item->height + icon_view->priv->row_spacing/2)
        {
          if (only_in_cell || cell_at_pos)
            {
@@ -3195,7 +3289,7 @@ gtk_icon_view_row_inserted (GtkTreeModel *model,
                            GtkTreeIter  *iter,
                            gpointer      data)
 {
-  gint length, index;
+  gint index;
   GtkIconViewItem *item;
   gboolean iters_persist;
   GtkIconView *icon_view;
@@ -3205,7 +3299,6 @@ gtk_icon_view_row_inserted (GtkTreeModel *model,
 
   iters_persist = gtk_tree_model_get_flags (icon_view->priv->model) & GTK_TREE_MODEL_ITERS_PERSIST;
   
-  length = gtk_tree_model_iter_n_children (model, NULL);
   index = gtk_tree_path_get_indices(path)[0];
 
   item = gtk_icon_view_item_new ();
@@ -3231,6 +3324,8 @@ gtk_icon_view_row_inserted (GtkTreeModel *model,
     }
     
   verify_items (icon_view);
+
+  gtk_icon_view_queue_layout (icon_view);
 }
 
 static void
@@ -3273,10 +3368,10 @@ gtk_icon_view_row_deleted (GtkTreeModel *model,
   
   icon_view->priv->items = g_list_delete_link (icon_view->priv->items, list);
 
-  gtk_icon_view_queue_layout (icon_view);
-
   verify_items (icon_view);  
   
+  gtk_icon_view_queue_layout (icon_view);
+
   if (emit)
     g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0);
 }
@@ -3368,7 +3463,7 @@ gtk_icon_view_add_move_binding (GtkBindingSet  *binding_set,
 {
   
   gtk_binding_entry_add_signal (binding_set, keyval, modmask,
-                                "move_cursor", 2,
+                                I_("move_cursor"), 2,
                                 G_TYPE_ENUM, step,
                                 G_TYPE_INT, count);
 
@@ -3693,7 +3788,10 @@ gtk_icon_view_move_cursor_up_down (GtkIconView *icon_view,
     }
 
   if (!item)
-    return;
+    {
+      gtk_widget_error_bell (GTK_WIDGET (icon_view));
+      return;
+    }
 
   if (icon_view->priv->ctrl_pressed ||
       !icon_view->priv->shift_pressed ||
@@ -3744,6 +3842,9 @@ gtk_icon_view_move_cursor_page_up_down (GtkIconView *icon_view,
                                   icon_view->priv->cursor_item,
                                   count);
 
+  if (item == icon_view->priv->cursor_item)
+    gtk_widget_error_bell (GTK_WIDGET (icon_view));
+
   if (!item)
     return;
 
@@ -3812,7 +3913,10 @@ gtk_icon_view_move_cursor_left_right (GtkIconView *icon_view,
     }
 
   if (!item)
-    return;
+    {
+      gtk_widget_error_bell (GTK_WIDGET (icon_view));
+      return;
+    }
 
   if (icon_view->priv->ctrl_pressed ||
       !icon_view->priv->shift_pressed ||
@@ -3855,6 +3959,9 @@ gtk_icon_view_move_cursor_start_end (GtkIconView *icon_view,
   
   item = list ? list->data : NULL;
 
+  if (item == icon_view->priv->cursor_item)
+    gtk_widget_error_bell (GTK_WIDGET (icon_view));
+
   if (!item)
     return;
 
@@ -3887,21 +3994,22 @@ gtk_icon_view_move_cursor_start_end (GtkIconView *icon_view,
  * @path: The path of the item to move to.
  * @use_align: whether to use alignment arguments, or %FALSE.
  * @row_align: The vertical alignment of the item specified by @path.
- * @col_align: The horizontal alignment of the item specified by @column.
+ * @col_align: The horizontal alignment of the item specified by @path.
  *
  * Moves the alignments of @icon_view to the position specified by @path.  
- * @row_align determines where the row is placed, and @col_align determines where 
- * @column is placed.  Both are expected to be between 0.0 and 1.0. 
- * 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means center.
+ * @row_align determines where the row is placed, and @col_align determines 
+ * where @column is placed.  Both are expected to be between 0.0 and 1.0. 
+ * 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means 
+ * center.
  *
  * If @use_align is %FALSE, then the alignment arguments are ignored, and the
  * tree does the minimum amount of work to scroll the item onto the screen.
  * This means that the item will be scrolled to the edge closest to its current
  * position.  If the item is currently visible on the screen, nothing is done.
  *
- * This function only works if the model is set, and @path is a valid row on the
- * model.  If the model changes before the @tree_view is realized, the centered
- * path will be modified to reflect this change.
+ * This function only works if the model is set, and @path is a valid row on 
+ * the model. If the model changes before the @icon_view is realized, the 
+ * centered path will be modified to reflect this change.
  *
  * Since: 2.8
  **/
@@ -3912,22 +4020,37 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
                              gfloat       row_align,
                              gfloat       col_align)
 {
-  GtkIconViewItem *item;
+  GtkIconViewItem *item = NULL;
 
   g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
   g_return_if_fail (path != NULL);
   g_return_if_fail (row_align >= 0.0 && row_align <= 1.0);
   g_return_if_fail (col_align >= 0.0 && col_align <= 1.0);
+
+  if (gtk_tree_path_get_depth (path) > 0)
+    item = g_list_nth_data (icon_view->priv->items,
+                           gtk_tree_path_get_indices(path)[0]);
   
-  item = g_list_nth (icon_view->priv->items,
-                    gtk_tree_path_get_indices(path)[0])->data;
-  
-  if (!item)
-    return;
-  
+  if (!GTK_WIDGET_REALIZED (icon_view) || !item || item->width < 0)
+    {
+      if (icon_view->priv->scroll_to_path)
+       gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
+
+      icon_view->priv->scroll_to_path = NULL;
+
+      if (path)
+       icon_view->priv->scroll_to_path = gtk_tree_row_reference_new_proxy (G_OBJECT (icon_view), icon_view->priv->model, path);
+
+      icon_view->priv->scroll_to_use_align = use_align;
+      icon_view->priv->scroll_to_row_align = row_align;
+      icon_view->priv->scroll_to_col_align = col_align;
+
+      return;
+    }
+
   if (use_align)
     {
-      gint x, y, width, height;
+      gint x, y;
       gint focus_width;
       gfloat offset, value;
 
@@ -3955,7 +4078,7 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
       gtk_adjustment_changed (icon_view->priv->vadjustment);
     }
   else
-    gtk_icon_view_scroll_to_item (icon_view, item);    
+    gtk_icon_view_scroll_to_item (icon_view, item);
 }
 
 
@@ -3973,7 +4096,7 @@ gtk_icon_view_scroll_to_item (GtkIconView     *icon_view,
   gdk_drawable_get_size (GDK_DRAWABLE (icon_view->priv->bin_window), 
                         &width, &height);
   gdk_window_get_position (icon_view->priv->bin_window, &x, &y);
-
+  
   if (y + item->y - focus_width < 0)
     gtk_adjustment_set_value (icon_view->priv->vadjustment, 
                              icon_view->priv->vadjustment->value + y + item->y - focus_width);
@@ -4106,8 +4229,7 @@ gtk_icon_view_cell_layout_pack_start (GtkCellLayout   *layout,
   g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
   g_return_if_fail (!gtk_icon_view_get_cell_info (icon_view, renderer));
 
-  g_object_ref (renderer);
-  gtk_object_sink (GTK_OBJECT (renderer));
+  g_object_ref_sink (renderer);
 
   info = g_new0 (GtkIconViewCellInfo, 1);
   info->cell = renderer;
@@ -4130,8 +4252,7 @@ gtk_icon_view_cell_layout_pack_end (GtkCellLayout   *layout,
   g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
   g_return_if_fail (!gtk_icon_view_get_cell_info (icon_view, renderer));
 
-  g_object_ref (renderer);
-  gtk_object_sink (GTK_OBJECT (renderer));
+  g_object_ref_sink (renderer);
 
   info = g_new0 (GtkIconViewCellInfo, 1);
   info->cell = renderer;
@@ -4383,6 +4504,8 @@ gtk_icon_view_get_item_at_pos (GtkIconView      *icon_view,
  * Sets @start_path and @end_path to be the first and last visible path. 
  * Note that there may be invisible paths in between.
  * 
+ * Both paths should be freed with gtk_tree_path_free() after use.
+ * 
  * Return value: %TRUE, if valid paths were placed in @start_path and @end_path
  *
  * Since: 2.8
@@ -4394,7 +4517,6 @@ gtk_icon_view_get_visible_range (GtkIconView  *icon_view,
 {
   gint start_index = -1;
   gint end_index = -1;
-  GtkIconViewItem *item;
   GList *icons;
 
   g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), FALSE);
@@ -4526,6 +4648,12 @@ gtk_icon_view_set_model (GtkIconView *icon_view,
   if (icon_view->priv->model == model)
     return;
 
+  if (icon_view->priv->scroll_to_path)
+    {
+      gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
+      icon_view->priv->scroll_to_path = NULL;
+    }
+
   gtk_icon_view_stop_editing (icon_view, TRUE);
 
   if (model)
@@ -4651,10 +4779,13 @@ update_text_cell (GtkIconView *icon_view)
     {
       if (icon_view->priv->text_cell != -1)
        {
+         if (icon_view->priv->pixbuf_cell > icon_view->priv->text_cell)
+           icon_view->priv->pixbuf_cell--;
+
          info = g_list_nth_data (icon_view->priv->cell_list, 
                                  icon_view->priv->text_cell);
          
-         g_list_remove (icon_view->priv->cell_list, info);
+         icon_view->priv->cell_list = g_list_remove (icon_view->priv->cell_list, info);
          
          free_cell_info (info);
          
@@ -4695,15 +4826,15 @@ update_text_cell (GtkIconView *icon_view)
 
       if (icon_view->priv->orientation == GTK_ORIENTATION_VERTICAL)
        g_object_set (info->cell,
-                     "wrap_mode", PANGO_WRAP_CHAR,
-                     "wrap_width", icon_view->priv->item_width,
+                     "wrap-mode", PANGO_WRAP_CHAR,
+                     "wrap-width", icon_view->priv->item_width,
                      "xalign", 0.5,
                      "yalign", 0.0,
                      NULL);
       else
        g_object_set (info->cell,
-                     "wrap_mode", PANGO_WRAP_CHAR,
-                     "wrap_width", icon_view->priv->item_width,
+                     "wrap-mode", PANGO_WRAP_CHAR,
+                     "wrap-width", icon_view->priv->item_width,
                      "xalign", 0.0,
                      "yalign", 0.0,
                      NULL);
@@ -4721,10 +4852,13 @@ update_pixbuf_cell (GtkIconView *icon_view)
     {
       if (icon_view->priv->pixbuf_cell != -1)
        {
+         if (icon_view->priv->text_cell > icon_view->priv->pixbuf_cell)
+           icon_view->priv->text_cell--;
+
          info = g_list_nth_data (icon_view->priv->cell_list, 
                                  icon_view->priv->pixbuf_cell);
          
-         g_list_remove (icon_view->priv->cell_list, info);
+         icon_view->priv->cell_list = g_list_remove (icon_view->priv->cell_list, info);
          
          free_cell_info (info);
          
@@ -4760,13 +4894,13 @@ update_pixbuf_cell (GtkIconView *icon_view)
 
        if (icon_view->priv->orientation == GTK_ORIENTATION_VERTICAL)
          g_object_set (info->cell,
-                       "follow_state", TRUE, 
+                       "follow-state", TRUE, 
                        "xalign", 0.5,
                        "yalign", 1.0,
                        NULL);
        else
          g_object_set (info->cell,
-                       "follow_state", TRUE, 
+                       "follow-state", TRUE, 
                        "xalign", 0.0,
                        "yalign", 0.0,
                        NULL);
@@ -4972,17 +5106,18 @@ void
 gtk_icon_view_select_path (GtkIconView *icon_view,
                           GtkTreePath *path)
 {
-  GList *l;
+  GtkIconViewItem *item = NULL;
 
   g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
   g_return_if_fail (icon_view->priv->model != NULL);
   g_return_if_fail (path != NULL);
 
-  l = g_list_nth (icon_view->priv->items,
-                 gtk_tree_path_get_indices(path)[0]);
+  if (gtk_tree_path_get_depth (path) > 0)
+    item = g_list_nth_data (icon_view->priv->items,
+                           gtk_tree_path_get_indices(path)[0]);
 
-  if (l != NULL)
-    gtk_icon_view_select_item (icon_view, l->data);
+  if (item)
+    gtk_icon_view_select_item (icon_view, item);
 }
 
 /**
@@ -5004,8 +5139,8 @@ gtk_icon_view_unselect_path (GtkIconView *icon_view,
   g_return_if_fail (icon_view->priv->model != NULL);
   g_return_if_fail (path != NULL);
 
-  item = g_list_nth (icon_view->priv->items,
-                    gtk_tree_path_get_indices(path)[0])->data;
+  item = g_list_nth_data (icon_view->priv->items,
+                         gtk_tree_path_get_indices(path)[0]);
 
   if (!item)
     return;
@@ -5121,7 +5256,7 @@ gtk_icon_view_unselect_all (GtkIconView *icon_view)
  * @path: A #GtkTreePath to check selection on.
  * 
  * Returns %TRUE if the icon pointed to by @path is currently
- * selected. If @icon does not point to a valid location, %FALSE is returned.
+ * selected. If @path does not point to a valid location, %FALSE is returned.
  * 
  * Return value: %TRUE if @path is selected.
  *
@@ -5137,8 +5272,8 @@ gtk_icon_view_path_is_selected (GtkIconView *icon_view,
   g_return_val_if_fail (icon_view->priv->model != NULL, FALSE);
   g_return_val_if_fail (path != NULL, FALSE);
   
-  item = g_list_nth (icon_view->priv->items,
-                    gtk_tree_path_get_indices(path)[0])->data;
+  item = g_list_nth_data (icon_view->priv->items,
+                         gtk_tree_path_get_indices(path)[0]);
 
   if (!item)
     return FALSE;
@@ -5509,7 +5644,7 @@ set_status_pending (GdkDragContext *context,
                     GdkDragAction   suggested_action)
 {
   g_object_set_data (G_OBJECT (context),
-                     "gtk-icon-view-status-pending",
+                     I_("gtk-icon-view-status-pending"),
                      GINT_TO_POINTER (suggested_action));
 }
 
@@ -5557,12 +5692,12 @@ set_source_row (GdkDragContext *context,
 {
   if (source_row)
     g_object_set_data_full (G_OBJECT (context),
-                           "gtk-icon-view-source-row",
+                           I_("gtk-icon-view-source-row"),
                            gtk_tree_row_reference_new (model, source_row),
                            (GDestroyNotify) gtk_tree_row_reference_free);
   else
     g_object_set_data_full (G_OBJECT (context),
-                           "gtk-icon-view-source-row",
+                           I_("gtk-icon-view-source-row"),
                            NULL, NULL);
 }
 
@@ -5607,7 +5742,7 @@ set_dest_row (GdkDragContext *context,
   if (!dest_row)
     {
       g_object_set_data_full (G_OBJECT (context),
-                             "gtk-icon-view-dest-row",
+                             I_("gtk-icon-view-dest-row"),
                              NULL, NULL);
       return;
     }
@@ -5618,7 +5753,7 @@ set_dest_row (GdkDragContext *context,
   dr->empty_view_drop = empty_view_drop;
   dr->drop_append_mode = drop_append_mode;
   g_object_set_data_full (G_OBJECT (context),
-                          "gtk-icon-view-dest-row",
+                          I_("gtk-icon-view-dest-row"),
                           dr, (GDestroyNotify) dest_row_free);
 }
 
@@ -5725,12 +5860,8 @@ drag_scroll_timeout (gpointer data)
 {
   GtkIconView *icon_view = GTK_ICON_VIEW (data);
 
-  GDK_THREADS_ENTER ();
-
   gtk_icon_view_autoscroll (icon_view);
 
-  GDK_THREADS_LEAVE ();
-
   return TRUE;
 }
 
@@ -6036,7 +6167,7 @@ gtk_icon_view_drag_data_get (GtkWidget        *widget,
     goto done;
 
   /* If drag_data_get does nothing, try providing row data. */
-  if (selection_data->target == gdk_atom_intern ("GTK_TREE_MODEL_ROW", FALSE))
+  if (selection_data->target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW"))
     gtk_tree_set_row_drag_data (selection_data,
                                model,
                                source_row);
@@ -6101,7 +6232,6 @@ gtk_icon_view_drag_motion (GtkWidget      *widget,
                           guint           time)
 {
   GtkTreePath *path = NULL;
-  GtkTreeModel *model;
   GtkIconViewDropPosition pos;
   GtkIconView *icon_view;
   GdkDragAction suggested_action = 0;
@@ -6116,7 +6246,6 @@ gtk_icon_view_drag_motion (GtkWidget      *widget,
   gtk_icon_view_get_drag_dest_item (icon_view, &path, &pos);
 
   /* we only know this *after* set_desination_row */
-  model = gtk_icon_view_get_model (icon_view);
   empty = icon_view->priv->empty_view_drop;
 
   if (path == NULL && !empty)
@@ -6129,10 +6258,10 @@ gtk_icon_view_drag_motion (GtkWidget      *widget,
       if (icon_view->priv->scroll_timeout_id == 0)
        {
          icon_view->priv->scroll_timeout_id =
-           g_timeout_add (50, drag_scroll_timeout, icon_view);
+           gdk_threads_add_timeout (50, drag_scroll_timeout, icon_view);
        }
 
-      if (target == gdk_atom_intern ("GTK_TREE_MODEL_ROW", FALSE))
+      if (target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW"))
         {
           /* Request data so we can use the source row when
            * determining whether to accept the drop
@@ -6334,7 +6463,7 @@ gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
  * @icon_view: a #GtkIconView
  * @targets: the table of targets that the drag will support
  * @n_targets: the number of items in @targets
- * @actions: the bitmask of possible actions for a drag from this
+ * @actions: the bitmask of possible actions for a drag to this
  *    widget
  * 
  * Turns @icon_view into a drop destination for automatic DND.
@@ -6410,7 +6539,7 @@ 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.
- * @pos: Specifies whether to drop, relative to the item
+ * @pos: Specifies where to drop, relative to the item
  * 
  * Sets the item that is highlighted for feedback.
  *
@@ -6499,7 +6628,7 @@ gtk_icon_view_get_drag_dest_item (GtkIconView              *icon_view,
  * @icon_view: a #GtkIconView
  * @drag_x: the position to determine the destination item for
  * @drag_y: the position to determine the destination item for
- * @path: Return location for the path of the highlighted item, or %NULL.
+ * @path: Return location for the path of the item, or %NULL.
  * @pos: Return location for the drop position, or %NULL
  * 
  * Determines the destination item for a given position.
@@ -6581,8 +6710,14 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
   gint index;
   GdkRectangle area;
 
+  g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), NULL);
+  g_return_val_if_fail (path != NULL, NULL);
+
   widget = GTK_WIDGET (icon_view);
 
+  if (!GTK_WIDGET_REALIZED (widget))
+    return NULL;
+
   index = gtk_tree_path_get_indices (path)[0];
 
   for (l = icon_view->priv->items; l; l = l->next) 
@@ -6634,7 +6769,7 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
  *
  * Return value: %TRUE if the list can be reordered.
  *
- * Since: 3.8
+ * Since: 2.8
  **/
 gboolean
 gtk_icon_view_get_reorderable (GtkIconView *icon_view)
@@ -6764,8 +6899,6 @@ gtk_icon_view_item_accessible_idle_do_action (gpointer data)
   GtkIconView *icon_view;
   GtkTreePath *path;
 
-  GDK_THREADS_ENTER ();
-
   item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (data);
   item->action_idle_handler = 0;
 
@@ -6777,8 +6910,6 @@ gtk_icon_view_item_accessible_idle_do_action (gpointer data)
       gtk_tree_path_free (path);
     }
 
-  GDK_THREADS_LEAVE ();
-
   return FALSE;
 }
 
@@ -6787,7 +6918,6 @@ gtk_icon_view_item_accessible_action_do_action (AtkAction *action,
                                                 gint       i)
 {
   GtkIconViewItemAccessible *item;
-  GtkIconView *icon_view;
 
   if (i < 0 || i >= LAST_ACTION) 
     return FALSE;
@@ -6800,13 +6930,11 @@ gtk_icon_view_item_accessible_action_do_action (AtkAction *action,
   if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT))
     return FALSE;
 
-  icon_view = GTK_ICON_VIEW (item->widget);
-
   switch (i)
     {
     case ACTION_ACTIVATE:
       if (!item->action_idle_handler)
-        item->action_idle_handler = g_idle_add (gtk_icon_view_item_accessible_idle_do_action, item);
+        item->action_idle_handler = gdk_threads_add_idle (gtk_icon_view_item_accessible_idle_do_action, item);
       break;
     default:
       g_assert_not_reached ();
@@ -7065,6 +7193,7 @@ gtk_icon_view_item_accessible_text_get_character_at_offset (AtkText *text,
   return unichar;
 }
 
+#if 0
 static void
 get_pango_text_offsets (PangoLayout     *layout,
                         GtkTextBuffer   *buffer,
@@ -7187,6 +7316,7 @@ get_pango_text_offsets (PangoLayout     *layout,
   gtk_text_buffer_get_iter_at_offset (buffer, start_iter, *start_offset);
   gtk_text_buffer_get_iter_at_offset (buffer, end_iter, *end_offset);
 }
+#endif
 
 static gchar*
 gtk_icon_view_item_accessible_text_get_text_before_offset (AtkText         *text,
@@ -7198,7 +7328,9 @@ gtk_icon_view_item_accessible_text_get_text_before_offset (AtkText         *text
   GtkIconViewItemAccessible *item;
   GtkTextIter start, end;
   GtkTextBuffer *buffer;
+#if 0
   GtkIconView *icon_view;
+#endif
 
   item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text);
 
@@ -7273,8 +7405,8 @@ gtk_icon_view_item_accessible_text_get_text_before_offset (AtkText         *text
       break;
    case ATK_TEXT_BOUNDARY_LINE_START:
    case ATK_TEXT_BOUNDARY_LINE_END:
-      icon_view = GTK_ICON_VIEW (item->widget);
 #if 0
+      icon_view = GTK_ICON_VIEW (item->widget);
       /* FIXME we probably have to use GailTextCell to salvage this */
       gtk_icon_view_update_item_text (icon_view, item->item);
       get_pango_text_offsets (icon_view->priv->layout,
@@ -7306,7 +7438,9 @@ gtk_icon_view_item_accessible_text_get_text_at_offset (AtkText         *text,
   GtkIconViewItemAccessible *item;
   GtkTextIter start, end;
   GtkTextBuffer *buffer;
+#if 0
   GtkIconView *icon_view;
+#endif
 
   item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text);
 
@@ -7379,8 +7513,8 @@ gtk_icon_view_item_accessible_text_get_text_at_offset (AtkText         *text,
       break;
    case ATK_TEXT_BOUNDARY_LINE_START:
    case ATK_TEXT_BOUNDARY_LINE_END:
-      icon_view = GTK_ICON_VIEW (item->widget);
 #if 0
+      icon_view = GTK_ICON_VIEW (item->widget);
       /* FIXME we probably have to use GailTextCell to salvage this */
       gtk_icon_view_update_item_text (icon_view, item->item);
       get_pango_text_offsets (icon_view->priv->layout,
@@ -7413,7 +7547,9 @@ gtk_icon_view_item_accessible_text_get_text_after_offset (AtkText         *text,
   GtkIconViewItemAccessible *item;
   GtkTextIter start, end;
   GtkTextBuffer *buffer;
+#if 0
   GtkIconView *icon_view;
+#endif
 
   item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text);
 
@@ -7493,8 +7629,8 @@ gtk_icon_view_item_accessible_text_get_text_after_offset (AtkText         *text,
       break;
    case ATK_TEXT_BOUNDARY_LINE_START:
    case ATK_TEXT_BOUNDARY_LINE_END:
-      icon_view = GTK_ICON_VIEW (item->widget);
 #if 0
+      icon_view = GTK_ICON_VIEW (item->widget);
       /* FIXME we probably have to use GailTextCell to salvage this */
       gtk_icon_view_update_item_text (icon_view, item->item);
       get_pango_text_offsets (icon_view->priv->layout,
@@ -7541,10 +7677,12 @@ gtk_icon_view_item_accessible_text_get_character_extents (AtkText      *text,
                                                           AtkCoordType coord_type)
 {
   GtkIconViewItemAccessible *item;
+#if 0
   GtkIconView *icon_view;
   PangoRectangle char_rect;
   const gchar *item_text;
   gint index;
+#endif
 
   item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text);
 
@@ -7554,8 +7692,8 @@ gtk_icon_view_item_accessible_text_get_character_extents (AtkText      *text,
   if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT))
     return;
 
-  icon_view = GTK_ICON_VIEW (item->widget);
 #if 0
+  icon_view = GTK_ICON_VIEW (item->widget);
       /* FIXME we probably have to use GailTextCell to salvage this */
   gtk_icon_view_update_item_text (icon_view, item->item);
   item_text = pango_layout_get_text (icon_view->priv->layout);
@@ -7579,11 +7717,13 @@ gtk_icon_view_item_accessible_text_get_offset_at_point (AtkText      *text,
                                                         AtkCoordType coord_type)
 {
   GtkIconViewItemAccessible *item;
+  gint offset = 0;
+#if 0
   GtkIconView *icon_view;
   const gchar *item_text;
   gint index;
-  gint offset;
   gint l_x, l_y;
+#endif
 
   item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text);
 
@@ -7593,8 +7733,8 @@ gtk_icon_view_item_accessible_text_get_offset_at_point (AtkText      *text,
   if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT))
     return -1;
 
-  icon_view = GTK_ICON_VIEW (item->widget);
 #if 0
+  icon_view = GTK_ICON_VIEW (item->widget);
       /* FIXME we probably have to use GailTextCell to salvage this */
   gtk_icon_view_update_item_text (icon_view, item->item);
   atk_component_get_position (ATK_COMPONENT (text), &l_x, &l_y, coord_type);
@@ -7948,7 +8088,7 @@ gtk_icon_view_item_accessible_get_type (void)
 
   if (!type)
     {
-      static const GTypeInfo tinfo =
+      const GTypeInfo tinfo =
       {
         sizeof (GtkIconViewItemAccessibleClass),
         (GBaseInitFunc) NULL, /* base init */
@@ -7988,7 +8128,7 @@ gtk_icon_view_item_accessible_get_type (void)
       };
 
       type = g_type_register_static (ATK_TYPE_OBJECT,
-                                     "GtkIconViewItemAccessible", &tinfo, 0);
+                                     I_("GtkIconViewItemAccessible"), &tinfo, 0);
       g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
                                    &atk_component_info);
       g_type_add_interface_static (type, ATK_TYPE_ACTION,
@@ -8270,7 +8410,7 @@ gtk_icon_view_accessible_model_row_changed (GtkTreeModel *tree_model,
   AtkObject *atk_obj;
 
   atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
-  g_signal_emit_by_name (atk_obj, "visible-data-changed");
+  g_signal_emit_by_name (atk_obj, "visible_data_changed");
 
   return;
 }
@@ -8395,27 +8535,22 @@ gtk_icon_view_accessible_model_rows_reordered (GtkTreeModel *tree_model,
 {
   GtkIconViewAccessiblePrivate *priv;
   GtkIconViewItemAccessibleInfo *info;
-  GtkIconViewAccessible *view;
   GtkIconView *icon_view;
   GtkIconViewItemAccessible *item;
   GList *items;
-  GList *tmp_list;
   AtkObject *atk_obj;
 
   atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
   icon_view = GTK_ICON_VIEW (user_data);
-  view = GTK_ICON_VIEW_ACCESSIBLE (atk_obj);
   priv = gtk_icon_view_accessible_get_priv (atk_obj);
 
   items = priv->items;
-  tmp_list = NULL;
   while (items)
     {
       info = items->data;
       item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
       info->index = new_order[info->index];
-      tmp_list = g_list_nth (icon_view->priv->items, info->index);
-      item->item = tmp_list->data;
+      item->item = g_list_nth_data (icon_view->priv->items, info->index);
       items = items->next;
     }
   priv->items = g_list_sort (priv->items, 
@@ -8443,16 +8578,16 @@ gtk_icon_view_accessible_connect_model_signals (GtkIconView *icon_view)
   GObject *obj;
 
   obj = G_OBJECT (icon_view->priv->model);
-  g_signal_connect_data (obj, "row-changed",
+  g_signal_connect_data (obj, "row_changed",
                          (GCallback) gtk_icon_view_accessible_model_row_changed,
                          icon_view, NULL, 0);
-  g_signal_connect_data (obj, "row-inserted",
+  g_signal_connect_data (obj, "row_inserted",
                          (GCallback) gtk_icon_view_accessible_model_row_inserted, 
                          icon_view, NULL, G_CONNECT_AFTER);
-  g_signal_connect_data (obj, "row-deleted",
+  g_signal_connect_data (obj, "row_deleted",
                          (GCallback) gtk_icon_view_accessible_model_row_deleted, 
                          icon_view, NULL, G_CONNECT_AFTER);
-  g_signal_connect_data (obj, "rows-reordered",
+  g_signal_connect_data (obj, "rows_reordered",
                          (GCallback) gtk_icon_view_accessible_model_rows_reordered, 
                          icon_view, NULL, G_CONNECT_AFTER);
 }
@@ -8482,14 +8617,12 @@ gtk_icon_view_accessible_notify_gtk (GObject *obj,
   GtkIconView *icon_view;
   GtkWidget *widget;
   AtkObject *atk_obj;
-  GtkIconViewAccessible *view;
   GtkIconViewAccessiblePrivate *priv;
 
   if (strcmp (pspec->name, "model") == 0)
     {
       widget = GTK_WIDGET (obj); 
       atk_obj = gtk_widget_get_accessible (widget);
-      view = GTK_ICON_VIEW_ACCESSIBLE (atk_obj);
       priv = gtk_icon_view_accessible_get_priv (atk_obj);
       if (priv->model)
         {
@@ -8682,7 +8815,6 @@ gtk_icon_view_accessible_add_selection (AtkSelection *selection,
   GtkWidget *widget;
   GtkIconView *icon_view;
   GtkIconViewItem *item;
-  GList *l;
 
   widget = GTK_ACCESSIBLE (selection)->widget;
   if (widget == NULL)
@@ -8690,11 +8822,11 @@ gtk_icon_view_accessible_add_selection (AtkSelection *selection,
 
   icon_view = GTK_ICON_VIEW (widget);
 
-  l = g_list_nth (icon_view->priv->items, i);
-  if (!l)
+  item = g_list_nth_data (icon_view->priv->items, i);
+
+  if (!item)
     return FALSE;
 
-  item = l->data;
   gtk_icon_view_select_item (icon_view, item);
 
   return TRUE;
@@ -8785,18 +8917,16 @@ gtk_icon_view_accessible_is_child_selected (AtkSelection *selection,
   GtkWidget *widget;
   GtkIconView *icon_view;
   GtkIconViewItem *item;
-  GList *l;
 
   widget = GTK_ACCESSIBLE (selection)->widget;
   if (widget == NULL)
     return FALSE;
 
   icon_view = GTK_ICON_VIEW (widget);
-  l = g_list_nth (icon_view->priv->items, i);
-  if (!l)
-    return FALSE;
 
-  item = l->data;
+  item = g_list_nth_data (icon_view->priv->items, i);
+  if (!item)
+    return FALSE;
 
   return item->selected;
 }
@@ -8963,7 +9093,7 @@ gtk_icon_view_accessible_factory_get_type (void)
 
   if (!type)
     {
-      static const GTypeInfo tinfo =
+      const GTypeInfo tinfo =
       {
         sizeof (AtkObjectFactoryClass),
         NULL,           /* base_init */