]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktreeviewcolumn.c
Fix #99593: Fix a memory leak when XmbLookupString returns XBufferOverflow
[~andy/gtk] / gtk / gtktreeviewcolumn.c
index 04a71daaf2acf58d63d7934ce00cb91e3983cff8..9bfd446621352de07468aaf23c51f717dd5ab8d1 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+#include <string.h>
 #include "gtktreeviewcolumn.h"
 #include "gtktreeview.h"
 #include "gtktreeprivate.h"
-#include "gtksignal.h"
 #include "gtkbutton.h"
 #include "gtkalignment.h"
 #include "gtklabel.h"
@@ -28,7 +28,6 @@
 #include "gtkmarshalers.h"
 #include "gtkarrow.h"
 #include "gtkintl.h"
-#include <string.h>
 
 enum
 {
@@ -64,9 +63,11 @@ struct _GtkTreeViewColumnCellInfo
   gpointer func_data;
   GtkDestroyNotify destroy;
   gint requested_width;
+  gint real_width;
   guint expand : 1;
   guint pack : 1;
   guint has_focus : 1;
+  guint in_editing_mode : 1;
 };
 
 /* Type methods */
@@ -84,7 +85,7 @@ static void gtk_tree_view_column_get_property                  (GObject
                                                                GParamSpec              *pspec);
 static void gtk_tree_view_column_finalize                      (GObject                 *object);
 
-/* Button handling code */ 
+/* Button handling code */
 static void gtk_tree_view_column_create_button                 (GtkTreeViewColumn       *tree_column);
 static void gtk_tree_view_column_update_button                 (GtkTreeViewColumn       *tree_column);
 
@@ -112,16 +113,24 @@ static void gtk_tree_view_column_set_attributesv               (GtkTreeViewColum
 static GtkTreeViewColumnCellInfo *gtk_tree_view_column_get_cell_info (GtkTreeViewColumn *tree_column,
                                                                      GtkCellRenderer   *cell_renderer);
 
-
+/* cell list manipulation */
+static GList *gtk_tree_view_column_cell_first                  (GtkTreeViewColumn      *tree_column);
+static GList *gtk_tree_view_column_cell_last                   (GtkTreeViewColumn      *tree_column);
+static GList *gtk_tree_view_column_cell_next                   (GtkTreeViewColumn      *tree_column,
+                                                               GList                  *current);
+static GList *gtk_tree_view_column_cell_prev                   (GtkTreeViewColumn      *tree_column,
+                                                               GList                  *current);
+static void gtk_tree_view_column_clear_attributes_by_info      (GtkTreeViewColumn      *tree_column,
+                                                               GtkTreeViewColumnCellInfo *info);
 
 static GtkObjectClass *parent_class = NULL;
 static guint tree_column_signals[LAST_SIGNAL] = { 0 };
 
 
-GtkType
+GType
 gtk_tree_view_column_get_type (void)
 {
-  static GtkType tree_column_type = 0;
+  static GType tree_column_type = 0;
 
   if (!tree_column_type)
     {
@@ -138,7 +147,9 @@ gtk_tree_view_column_get_type (void)
        (GInstanceInitFunc) gtk_tree_view_column_init,
       };
 
-      tree_column_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkTreeViewColumn", &tree_column_info, 0);
+      tree_column_type =
+       g_type_register_static (GTK_TYPE_OBJECT, "GtkTreeViewColumn",
+                               &tree_column_info, 0);
     }
 
   return tree_column_type;
@@ -161,12 +172,12 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
   
   tree_column_signals[CLICKED] =
     g_signal_new ("clicked",
-                  GTK_CLASS_TYPE (object_class),
+                  G_OBJECT_CLASS_TYPE (object_class),
                   G_SIGNAL_RUN_LAST,
                   G_STRUCT_OFFSET (GtkTreeViewColumnClass, clicked),
                   NULL, NULL,
                   _gtk_marshal_VOID__VOID,
-                  GTK_TYPE_NONE, 0);
+                  G_TYPE_NONE, 0);
 
   g_object_class_install_property (object_class,
                                    PROP_VISIBLE,
@@ -329,14 +340,24 @@ gtk_tree_view_column_finalize (GObject *object)
   for (list = tree_column->cell_list; list; list = list->next)
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
-      if (info->func_data && info->destroy)
-       (info->destroy) (info->func_data);
-      gtk_tree_view_column_clear_attributes (tree_column, info->cell);
-      g_object_unref (G_OBJECT (info->cell));
+
+      if (info->destroy)
+       {
+         GtkDestroyNotify d = info->destroy;
+
+         info->destroy = NULL;
+         d (info->func_data);
+       }
+      gtk_tree_view_column_clear_attributes_by_info (tree_column, info);
+      g_object_unref (info->cell);
       g_free (info);
     }
 
   g_free (tree_column->title);
+  g_list_free (tree_column->cell_list);
+
+  if (tree_column->child)
+    g_object_unref (G_OBJECT (tree_column->child));
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -539,13 +560,12 @@ gtk_tree_view_column_create_button (GtkTreeViewColumn *tree_column)
     gtk_widget_set_parent_window (tree_column->button, tree_view->priv->header_window);
   gtk_widget_set_parent (tree_column->button, GTK_WIDGET (tree_view));
 
-  g_signal_connect (G_OBJECT (tree_column->button), "event",
+  g_signal_connect (tree_column->button, "event",
                    G_CALLBACK (gtk_tree_view_column_button_event),
-                   (gpointer) tree_column);
-
-  g_signal_connect (G_OBJECT (tree_column->button), "clicked",
-                   (GtkSignalFunc) gtk_tree_view_column_button_clicked,
-                   (gpointer) tree_column);
+                   tree_column);
+  g_signal_connect (tree_column->button, "clicked",
+                   G_CALLBACK (gtk_tree_view_column_button_clicked),
+                   tree_column);
 
   tree_column->alignment = gtk_alignment_new (tree_column->xalign, 0.5, 0.0, 0.0);
 
@@ -560,9 +580,9 @@ gtk_tree_view_column_create_button (GtkTreeViewColumn *tree_column)
       gtk_widget_show (child);
     }
 
-  g_signal_connect (G_OBJECT (child), "mnemonic_activate",
+  g_signal_connect (child, "mnemonic_activate",
                    G_CALLBACK (gtk_tree_view_column_mnemonic_activate),
-                   (gpointer) tree_column);
+                   tree_column);
 
   if (tree_column->xalign <= 0.5)
     gtk_box_pack_end (GTK_BOX (hbox), tree_column->arrow, FALSE, FALSE, 0);
@@ -655,11 +675,11 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
       break;
     }
 
-  /* Put arrow on the right if the text is left-or-center justified,
-       * and on the left otherwise; do this by packing boxes, so flipping
-       * text direction will reverse things
-       */
-  gtk_widget_ref (arrow);
+  /* Put arrow on the right if the text is left-or-center justified, and on the
+   * left otherwise; do this by packing boxes, so flipping text direction will
+   * reverse things
+   */
+  g_object_ref (arrow);
   gtk_container_remove (GTK_CONTAINER (hbox), arrow);
 
   if (tree_column->xalign <= 0.5)
@@ -672,15 +692,15 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
       /* move it to the front */
       gtk_box_reorder_child (GTK_BOX (hbox), arrow, 0);
     }
-  gtk_widget_unref (arrow);
+  g_object_unref (arrow);
 
   if (tree_column->show_sort_indicator)
     gtk_widget_show (arrow);
   else
     gtk_widget_hide (arrow);
 
-  /* It's always safe to hide the button.  It isn't always safe to show it, as if you show it
-   * before it's realized, it'll get the wrong window. */
+  /* It's always safe to hide the button.  It isn't always safe to show it, as
+   * if you show it before it's realized, it'll get the wrong window. */
   if (tree_column->button &&
       tree_column->tree_view != NULL &&
       GTK_WIDGET_REALIZED (tree_column->tree_view))
@@ -799,7 +819,7 @@ gtk_tree_view_column_button_event (GtkWidget *widget,
 static void
 gtk_tree_view_column_button_clicked (GtkWidget *widget, gpointer data)
 {
-  g_signal_emit_by_name (G_OBJECT (data), "clicked");
+  g_signal_emit_by_name (data, "clicked");
 }
 
 static gboolean
@@ -811,17 +831,13 @@ gtk_tree_view_column_mnemonic_activate (GtkWidget *widget,
 
   g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (column), FALSE);
 
+  GTK_TREE_VIEW (column->tree_view)->priv->focus_column = column;
   if (column->clickable)
     gtk_button_clicked (GTK_BUTTON (column->button));
   else if (GTK_WIDGET_CAN_FOCUS (column->button))
     gtk_widget_grab_focus (column->button);
   else
-    {
-      GTK_TREE_VIEW (column->tree_view)->priv->focus_column = column;
-      GTK_TREE_VIEW_SET_FLAG (GTK_TREE_VIEW (column->tree_view),
-                             GTK_TREE_VIEW_DRAW_KEYFOCUS);
-      gtk_widget_grab_focus (column->tree_view);
-    }
+    gtk_widget_grab_focus (column->tree_view);
 
   return TRUE;
 }
@@ -916,10 +932,10 @@ gtk_tree_view_column_setup_sort_column_id_callback (GtkTreeViewColumn *tree_colu
       GtkSortType real_order;
 
       if (tree_column->sort_column_changed_signal == 0)
-       tree_column->sort_column_changed_signal =
-         g_signal_connect (G_OBJECT (model), "sort_column_changed",
-                            GTK_SIGNAL_FUNC (gtk_tree_view_model_sort_column_changed),
-                            tree_column);
+        tree_column->sort_column_changed_signal =
+         g_signal_connect (model, "sort_column_changed",
+                           G_CALLBACK (gtk_tree_view_model_sort_column_changed),
+                           tree_column);
       
       if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model),
                                                &real_sort_column_id,
@@ -969,8 +985,8 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column)
                     GDK_POINTER_MOTION_HINT_MASK |
                     GDK_KEY_PRESS_MASK);
   attributes_mask = GDK_WA_CURSOR | GDK_WA_X | GDK_WA_Y;
-  attr.cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
-
+  attr.cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (tree_view->priv->header_window),
+                                           GDK_SB_H_DOUBLE_ARROW);
   attr.y = 0;
   attr.width = TREE_VIEW_DRAG_WIDTH;
   attr.height = tree_view->priv->header_height;
@@ -997,6 +1013,18 @@ _gtk_tree_view_column_unrealize_button (GtkTreeViewColumn *column)
   column->window = NULL;
 }
 
+void
+_gtk_tree_view_column_unset_model (GtkTreeViewColumn *column,
+                                  GtkTreeModel      *old_model)
+{
+  if (column->sort_column_changed_signal)
+    {
+      g_signal_handler_disconnect (old_model,
+                                  column->sort_column_changed_signal);
+      column->sort_column_changed_signal = 0;
+    }
+}
+
 void
 _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
                                     GtkTreeView       *tree_view)
@@ -1007,9 +1035,9 @@ _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
   gtk_tree_view_column_create_button (column);
 
   column->property_changed_signal =
-         g_signal_connect_swapped (GTK_OBJECT (tree_view),
+         g_signal_connect_swapped (tree_view,
                                    "notify::model",
-                                   GTK_SIGNAL_FUNC (gtk_tree_view_column_setup_sort_column_id_callback),
+                                   G_CALLBACK (gtk_tree_view_column_setup_sort_column_id_callback),
                                    column);
 
   gtk_tree_view_column_setup_sort_column_id_callback (column);
@@ -1024,13 +1052,13 @@ _gtk_tree_view_column_unset_tree_view (GtkTreeViewColumn *column)
     }
   if (column->property_changed_signal)
     {
-      g_signal_handler_disconnect (G_OBJECT (column->tree_view), column->property_changed_signal);
+      g_signal_handler_disconnect (column->tree_view, column->property_changed_signal);
       column->property_changed_signal = 0;
     }
 
   if (column->sort_column_changed_signal)
     {
-      g_signal_handler_disconnect (G_OBJECT (gtk_tree_view_get_model (GTK_TREE_VIEW (column->tree_view))),
+      g_signal_handler_disconnect (gtk_tree_view_get_model (GTK_TREE_VIEW (column->tree_view)),
                                   column->sort_column_changed_signal);
       column->sort_column_changed_signal = 0;
     }
@@ -1039,6 +1067,69 @@ _gtk_tree_view_column_unset_tree_view (GtkTreeViewColumn *column)
   column->button = NULL;
 }
 
+gboolean
+_gtk_tree_view_column_has_editable_cell (GtkTreeViewColumn *column)
+{
+  GList *list;
+
+  for (list = column->cell_list; list; list = list->next)
+    if (((GtkTreeViewColumnCellInfo *)list->data)->cell->mode ==
+       GTK_CELL_RENDERER_MODE_EDITABLE)
+      return TRUE;
+
+  return FALSE;
+}
+
+/* gets cell being edited */
+GtkCellRenderer *
+_gtk_tree_view_column_get_edited_cell (GtkTreeViewColumn *column)
+{
+  GList *list;
+
+  for (list = column->cell_list; list; list = list->next)
+    if (((GtkTreeViewColumnCellInfo *)list->data)->in_editing_mode)
+      return ((GtkTreeViewColumnCellInfo *)list->data)->cell;
+
+  return NULL;
+}
+
+gint
+_gtk_tree_view_column_count_special_cells (GtkTreeViewColumn *column)
+{
+  gint i = 0;
+  GList *list;
+
+  for (list = column->cell_list; list; list = list->next)
+    {
+      GtkTreeViewColumnCellInfo *cellinfo = list->data;
+
+      if (cellinfo->cell->mode == GTK_CELL_RENDERER_MODE_EDITABLE ||
+         cellinfo->cell->mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE)
+       i++;
+    }
+
+  return i;
+}
+
+GtkCellRenderer *
+_gtk_tree_view_column_get_cell_at_pos (GtkTreeViewColumn *column,
+                                      gint               x)
+{
+  GList *list;
+  gint current_x = 0;
+
+  list = gtk_tree_view_column_cell_first (column);
+  for (; list; list = gtk_tree_view_column_cell_next (column, list))
+   {
+     GtkTreeViewColumnCellInfo *cellinfo = list->data;
+     if (current_x <= x && x <= current_x + cellinfo->real_width)
+       return cellinfo->cell;
+     current_x += cellinfo->real_width;
+   }
+
+  return NULL;
+}
+
 /* Public Functions */
 
 
@@ -1054,7 +1145,7 @@ gtk_tree_view_column_new (void)
 {
   GtkTreeViewColumn *tree_column;
 
-  tree_column = GTK_TREE_VIEW_COLUMN (gtk_type_new (GTK_TYPE_TREE_VIEW_COLUMN));
+  tree_column = g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, NULL);
 
   return tree_column;
 }
@@ -1069,6 +1160,22 @@ gtk_tree_view_column_new (void)
  * equivalent to calling gtk_tree_view_column_set_title(),
  * gtk_tree_view_column_pack_start(), and
  * gtk_tree_view_column_set_attributes() on the newly created #GtkTreeViewColumn.
+ *
+ * Here's a simple example:
+ * <informalexample><programlisting>
+ *  enum { TEXT_COLUMN, COLOR_COLUMN, N_COLUMNS };
+ *  ...
+ *  {
+ *    GtkTreeViewColumn *column;
+ *    GtkCellRenderer   *renderer = gtk_cell_renderer_text_new (<!-- -->);
+ *  
+ *    column = gtk_tree_view_column_new_with_attributes ("Title",
+ *                                                       renderer,
+ *                                                       "text", TEXT_COLUMN,
+ *                                                       "foreground", COLOR_COLUMN,
+ *                                                       NULL);
+ *  }
+ * </programlisting></informalexample>
  * 
  * Return value: A newly created #GtkTreeViewColumn.
  **/
@@ -1110,8 +1217,9 @@ gtk_tree_view_column_get_cell_info (GtkTreeViewColumn *tree_column,
  * @cell: The #GtkCellRenderer. 
  * @expand: %TRUE if @cell is to be given extra space allocated to box.
  *
- * Packs the @cell into the beginning column.  If @expand is %TRUE, then the
- * @cell is allocated a share of all available space that the @tree_column has.
+ * Packs the @cell into the beginning of the column. If @expand is FALSE, then
+ * the @cell is allocated no more space than it needs. Any unused space is divided
+ * evenly between cells for which @expand is TRUE.
  **/
 void
 gtk_tree_view_column_pack_start (GtkTreeViewColumn *tree_column,
@@ -1124,7 +1232,7 @@ gtk_tree_view_column_pack_start (GtkTreeViewColumn *tree_column,
   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
   g_return_if_fail (! gtk_tree_view_column_get_cell_info (tree_column, cell));
 
-  g_object_ref (G_OBJECT (cell));
+  g_object_ref (cell);
   gtk_object_sink (GTK_OBJECT (cell));
 
   cell_info = g_new0 (GtkTreeViewColumnCellInfo, 1);
@@ -1143,8 +1251,9 @@ gtk_tree_view_column_pack_start (GtkTreeViewColumn *tree_column,
  * @cell: The #GtkCellRenderer. 
  * @expand: %TRUE if @cell is to be given extra space allocated to box.
  *
- * Packs the @cell into the column.  If @expand is %TRUE, then the @cell is
- * allocated a share of all available space that the @tree_column has.
+ * Adds the @cell to end of the column. If @expand is FALSE, then the @cell
+ * is allocated no more space than it needs. Any unused space is divided
+ * evenly between cells for which @expand is TRUE.
  **/
 void
 gtk_tree_view_column_pack_end (GtkTreeViewColumn  *tree_column,
@@ -1157,10 +1266,10 @@ gtk_tree_view_column_pack_end (GtkTreeViewColumn  *tree_column,
   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
   g_return_if_fail (! gtk_tree_view_column_get_cell_info (tree_column, cell));
 
-  g_object_ref (G_OBJECT (cell));
+  g_object_ref (cell);
   gtk_object_sink (GTK_OBJECT (cell));
 
-  cell_info = g_new (GtkTreeViewColumnCellInfo, 1);
+  cell_info = g_new0 (GtkTreeViewColumnCellInfo, 1);
   cell_info->cell = cell;
   cell_info->expand = expand ? TRUE : FALSE;
   cell_info->pack = GTK_PACK_END;
@@ -1187,8 +1296,8 @@ gtk_tree_view_column_clear (GtkTreeViewColumn *tree_column)
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *)list->data;
 
-      g_object_unref (G_OBJECT (info->cell));
       gtk_tree_view_column_clear_attributes (tree_column, info->cell);
+      g_object_unref (info->cell);
       g_free (info);
     }
 
@@ -1333,13 +1442,13 @@ gtk_tree_view_column_set_cell_data_func (GtkTreeViewColumn   *tree_column,
 
   g_return_if_fail (info != NULL);
 
-  if (func == info->func &&
-      func_data == info->func_data &&
-      destroy == info->destroy)
-    return;
+  if (info->destroy)
+    {
+      GtkDestroyNotify d = info->destroy;
 
-  if (info->func_data && info->destroy)
-    (info->destroy) (info->func_data);
+      info->destroy = NULL;
+      d (info->func_data);
+    }
 
   info->func = func;
   info->func_data = func_data;
@@ -1363,12 +1472,21 @@ gtk_tree_view_column_clear_attributes (GtkTreeViewColumn *tree_column,
                                       GtkCellRenderer   *cell_renderer)
 {
   GtkTreeViewColumnCellInfo *info;
-  GSList *list;
 
   g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
   g_return_if_fail (GTK_IS_CELL_RENDERER (cell_renderer));
+
   info = gtk_tree_view_column_get_cell_info (tree_column, cell_renderer);
 
+  gtk_tree_view_column_clear_attributes_by_info (tree_column, info);
+}
+
+static void 
+gtk_tree_view_column_clear_attributes_by_info (GtkTreeViewColumn *tree_column,
+                                              GtkTreeViewColumnCellInfo *info)
+{
+  GSList *list;
+
   list = info->attributes;
 
   while (list && list->next)
@@ -1475,9 +1593,9 @@ gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column)
  * @resizable: %TRUE, if the column can be resized
  * 
  * If @resizable is %TRUE, then the user can explicitly resize the column by
- * grabbing the outer edge of the column button.  If the sizing mode of the
- * column is #GTK_TREE_VIEW_COLUMN_AUTOSIZE, then it is changed to
- * #GTK_TREE_VIEW_COLUMN_GROW_ONLY.
+ * grabbing the outer edge of the column button.  If resizable is TRUE and
+ * sizing mode of the column is #GTK_TREE_VIEW_COLUMN_AUTOSIZE, then the sizing
+ * mode is changed to #GTK_TREE_VIEW_COLUMN_GROW_ONLY.
  **/
 void
 gtk_tree_view_column_set_resizable (GtkTreeViewColumn *tree_column,
@@ -1591,9 +1709,10 @@ gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column)
  * @fixed_width: The size to set @tree_column to. Must be greater than 0.
  * 
  * Sets the size of the column in pixels.  This is meaningful only if the sizing
- * type is #GTK_TREE_VIEW_COLUMN_FIXED.  In this case, the value is discarded
- * as the size of the column is based on the calculated width of the column. The
- * width is clamped to the min/max width for the column.
+ * type is #GTK_TREE_VIEW_COLUMN_FIXED.  The size of the column is clamped to
+ * the min/max width for the column.  Please note that the min/max width of the
+ * column doesn't actually affect the "fixed_width" property of the widget, just
+ * the actual size when displayed.
  **/
 void
 gtk_tree_view_column_set_fixed_width (GtkTreeViewColumn *tree_column,
@@ -1602,9 +1721,6 @@ gtk_tree_view_column_set_fixed_width (GtkTreeViewColumn *tree_column,
   g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
   g_return_if_fail (fixed_width > 0);
 
-  if (tree_column->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
-    return;
-
   tree_column->fixed_width = fixed_width;
 
   if (tree_column->tree_view &&
@@ -1669,6 +1785,10 @@ gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column,
     }
   g_object_notify (G_OBJECT (tree_column), "min_width");
   g_object_thaw_notify (G_OBJECT (tree_column));
+
+  if (tree_column->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
+    _gtk_tree_view_column_autosize (GTK_TREE_VIEW (tree_column->tree_view),
+                                   tree_column);
 }
 
 /**
@@ -1725,6 +1845,10 @@ gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column,
     }
   g_object_notify (G_OBJECT (tree_column), "max_width");
   g_object_thaw_notify (G_OBJECT (tree_column));
+
+  if (tree_column->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
+    _gtk_tree_view_column_autosize (GTK_TREE_VIEW (tree_column->tree_view),
+                                   tree_column);
 }
 
 /**
@@ -1790,9 +1914,10 @@ gtk_tree_view_column_set_title (GtkTreeViewColumn *tree_column,
  * gtk_tree_view_column_get_title:
  * @tree_column: A #GtkTreeViewColumn.
  * 
- * Returns the title of the widget.  This value should not be modified.
+ * Returns the title of the widget.
  * 
- * Return value: the title of the column.
+ * Return value: the title of the column. This string should not be
+ * modified or freed.
  **/
 G_CONST_RETURN gchar *
 gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column)
@@ -1858,12 +1983,12 @@ gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
 
   if (widget)
     {
-      gtk_object_ref (GTK_OBJECT (widget));
+      g_object_ref (widget);
       gtk_object_sink (GTK_OBJECT (widget));
     }
 
   if (tree_column->child)      
-    gtk_object_unref (GTK_OBJECT (tree_column->child));
+    g_object_unref (tree_column->child);
 
   tree_column->child = widget;
   gtk_tree_view_column_update_button (tree_column);
@@ -1874,11 +1999,10 @@ gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
  * gtk_tree_view_column_get_widget:
  * @tree_column: A #GtkTreeViewColumn.
  * 
- * Returns the #GtkWidget in the button in the column header.  If a custom
- * widget has not been set, then this will be a #GtkAlignment with a #GtkLabel
- * in it.
+ * Returns the #GtkWidget in the button on the column header.  If a custom
+ * widget has not been set then %NULL is returned.
  * 
- * Return value: The #GtkWidget in the column header.
+ * Return value: The #GtkWidget in the column header, or %NULL
  **/
 GtkWidget *
 gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column)
@@ -1976,7 +2100,7 @@ gtk_tree_view_column_get_reorderable (GtkTreeViewColumn *tree_column)
  * gtk_tree_view_column_set_sort_column_id:
  * @tree_column: a #GtkTreeViewColumn
  * @sort_column_id: The @sort_column_id of the model to sort on.
- * 
+ *
  * Sets the logical @sort_column_id that this column sorts on when this column 
  * is selected for sorting.  Doing so makes the column header clickable.
  **/
@@ -1997,13 +2121,13 @@ gtk_tree_view_column_set_sort_column_id (GtkTreeViewColumn *tree_column,
     {
       if (tree_column->sort_clicked_signal)
        {
-         g_signal_handler_disconnect (G_OBJECT (tree_column), tree_column->sort_clicked_signal);
+         g_signal_handler_disconnect (tree_column, tree_column->sort_clicked_signal);
          tree_column->sort_clicked_signal = 0;
        }
 
       if (tree_column->sort_column_changed_signal)
        {
-         g_signal_handler_disconnect (G_OBJECT (tree_column), tree_column->sort_column_changed_signal);
+         g_signal_handler_disconnect (tree_column, tree_column->sort_column_changed_signal);
          tree_column->sort_column_changed_signal = 0;
        }
 
@@ -2015,7 +2139,7 @@ gtk_tree_view_column_set_sort_column_id (GtkTreeViewColumn *tree_column,
   gtk_tree_view_column_set_clickable (tree_column, TRUE);
 
   if (! tree_column->sort_clicked_signal)
-    tree_column->sort_clicked_signal = g_signal_connect (G_OBJECT (tree_column),
+    tree_column->sort_clicked_signal = g_signal_connect (tree_column,
                                                          "clicked",
                                                          G_CALLBACK (gtk_tree_view_column_sort),
                                                          NULL);
@@ -2028,7 +2152,8 @@ gtk_tree_view_column_set_sort_column_id (GtkTreeViewColumn *tree_column,
  * @tree_column: a #GtkTreeViewColumn
  *
  * Gets the logical @sort_column_id that the model sorts on when this
- * column is selected for sorting. See gtk_tree_view_column_set_sort_column_id().
+ * column is selected for sorting.
+ * See gtk_tree_view_column_set_sort_column_id().
  *
  * Return value: the current @sort_column_id for this column, or -1 if
  *               this column can't be used for sorting.
@@ -2139,9 +2264,9 @@ gtk_tree_view_column_get_sort_order      (GtkTreeViewColumn     *tree_column)
  * @is_expander: %TRUE, if the row has children
  * @is_expanded: %TRUE, if the row has visible children
  * 
- * Sets the cell renderer based on the @tree_model and @tree_node.  That is, for
+ * Sets the cell renderer based on the @tree_model and @iter.  That is, for
  * every attribute mapping in @tree_column, it will get a value from the set
- * column on the @tree_node, and use that value to set the attribute on the cell
+ * column on the @iter, and use that value to set the attribute on the cell
  * renderer.  This is used primarily by the #GtkTreeView.
  **/
 void
@@ -2191,9 +2316,9 @@ gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
 /**
  * gtk_tree_view_column_cell_get_size:
  * @tree_column: A #GtkTreeViewColumn.
- * @cell_area: The area a the column will be allocated, or %NULL
- * @x_offset: location to return x offset of cell relative to @cell_area, or %NULL
- * @y_offset: location to return y offset of cell relative to @cell_area, or %NULL
+ * @cell_area: The area a cell in the column will be allocated, or %NULL
+ * @x_offset: location to return x offset of cell relative to @cell_area, or %NULL
+ * @y_offset: location to return y offset of cell relative to @cell_area, or %NULL
  * @width: location to return width needed to render a cell, or %NULL
  * @height: location to return height needed to render a cell, or %NULL
  * 
@@ -2248,7 +2373,7 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
       info->requested_width = MAX (info->requested_width, new_width + focus_line_width * 2);
       if (width)
        * width += info->requested_width;
-      first_cell = TRUE;
+      first_cell = FALSE;
     }
 }
 
@@ -2256,37 +2381,81 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
  * code.  Rather than duplicate them, we put them together to keep the code in
  * one place
  */
-static void
-gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
-                                          GdkWindow         *window,
-                                          GdkRectangle      *background_area,
-                                          GdkRectangle      *cell_area,
-                                          GdkRectangle      *expose_area,
-                                          guint              flags,
-                                          gboolean           render,
-                                          GdkRectangle      *focus_rectangle)
+enum {
+  CELL_ACTION_RENDER,
+  CELL_ACTION_FOCUS,
+  CELL_ACTION_EVENT
+};
+
+static gboolean
+gtk_tree_view_column_cell_process_action (GtkTreeViewColumn  *tree_column,
+                                         GdkWindow          *window,
+                                         GdkRectangle       *background_area,
+                                         GdkRectangle       *cell_area,
+                                         guint               flags,
+                                         gint                action,
+                                         GdkRectangle       *expose_area,     /* RENDER */
+                                         GdkRectangle       *focus_rectangle, /* FOCUS  */
+                                         GtkCellEditable   **editable_widget, /* EVENT  */
+                                         GdkEvent           *event,           /* EVENT  */
+                                         gchar              *path_string)     /* EVENT  */
 {
   GList *list;
   GdkRectangle real_cell_area;
+  GdkRectangle real_background_area;
   gint expand_cell_count = 0;
   gint full_requested_width = 0;
   gint extra_space;
   gint min_x, min_y, max_x, max_y;
   gint focus_line_width;
+  gint dx;
+  gint special_cells;
 
   min_x = G_MAXINT;
   min_y = G_MAXINT;
   max_x = 0;
   max_y = 0;
 
-  real_cell_area = *cell_area;
+  special_cells = _gtk_tree_view_column_count_special_cells (tree_column);
+
+  if (special_cells > 1 && action == CELL_ACTION_FOCUS)
+    {
+      GtkTreeViewColumnCellInfo *info = NULL;
+      gboolean found_has_focus = FALSE;
+
+      /* one should have focus */
+      for (list = tree_column->cell_list; list; list = list->next)
+        {
+         info = list->data;
+         if (info && info->has_focus)
+           {
+             found_has_focus = TRUE;
+             break;
+           }
+       }
+
+      if (!found_has_focus)
+        {
+         /* give the first one focus */
+         info = gtk_tree_view_column_cell_first (tree_column)->data;
+         info->has_focus = TRUE;
+       }
+    }
 
   gtk_widget_style_get (GTK_WIDGET (tree_column->tree_view),
-                       "focus-line-width", &focus_line_width, NULL);
-  /* Find out how my extra space we have to allocate */
+                       "focus-line-width", &focus_line_width,
+                       NULL);
+
+  real_cell_area = *cell_area;
+  real_background_area = *background_area;
+  dx = real_cell_area.x - real_background_area.x - focus_line_width;
+
+  real_cell_area.x += focus_line_width;
+
+  /* Find out how many extra space we have to allocate */
   for (list = tree_column->cell_list; list; list = list->next)
     {
-      GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
+      GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *)list->data;
 
       if (! info->cell->visible)
        continue;
@@ -2296,10 +2465,13 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
       full_requested_width += info->requested_width;
     }
 
-  extra_space = cell_area->width - full_requested_width;
+  extra_space = background_area->width - full_requested_width;
   if (extra_space < 0)
     extra_space = 0;
+  else if (extra_space > 0 && expand_cell_count > 0)
+    extra_space /= expand_cell_count;
 
+  /* iterate list for GTK_PACK_START cells */
   for (list = tree_column->cell_list; list; list = list->next)
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
@@ -2310,20 +2482,24 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
       if (! info->cell->visible)
        continue;
 
-      real_cell_area.width = info->requested_width +
+      real_background_area.width = info->requested_width +
        (info->expand?extra_space:0);
-      real_cell_area.x += focus_line_width;
-      if (render)
+      info->real_width = real_background_area.width;
+
+      real_cell_area.width = real_background_area.width;
+      real_cell_area.width -= 2 * focus_line_width;
+
+      if (action == CELL_ACTION_RENDER)
        {
          gtk_cell_renderer_render (info->cell,
                                    window,
                                    tree_column->tree_view,
-                                   background_area,
+                                   &real_background_area,
                                    &real_cell_area,
                                    expose_area,
                                    flags);
        }
-      else
+      else if (action == CELL_ACTION_FOCUS)
        {
          gint x_offset, y_offset, width, height;
 
@@ -2333,17 +2509,100 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
                                      &x_offset, &y_offset,
                                      &width, &height);
 
-         if (min_x > (real_cell_area.x + x_offset))
-           min_x = real_cell_area.x + x_offset;
-         if (max_x < real_cell_area.x + x_offset + width)
-           max_x = real_cell_area.x + x_offset + width;
-         if (min_y > (real_cell_area.y + y_offset))
-           min_y = real_cell_area.y + y_offset;
-         if (max_y < real_cell_area.y + y_offset + height)
-           max_y = real_cell_area.y + y_offset + height;
+         if (special_cells > 1)
+           {
+             if (info->has_focus)
+               {
+                 min_x = real_cell_area.x + x_offset;
+                 max_x = min_x + width;
+                 min_y = real_cell_area.y + y_offset;
+                 max_y = min_y + height;
+               }
+           }
+         else
+           {
+             if (min_x > (real_cell_area.x + x_offset))
+               min_x = real_cell_area.x + x_offset;
+             if (max_x < real_cell_area.x + x_offset + width)
+               max_x = real_cell_area.x + x_offset + width;
+             if (min_y > (real_cell_area.y + y_offset))
+               min_y = real_cell_area.y + y_offset;
+             if (max_y < real_cell_area.y + y_offset + height)
+               max_y = real_cell_area.y + y_offset + height;
+           }
+       }
+      else if (action == CELL_ACTION_EVENT)
+       {
+         gboolean try_event = FALSE;
+
+         if (event)
+           {
+             if (special_cells == 1)
+               {
+                 /* only 1 activatable cell -> whole column can activate */
+                 if (cell_area->x <= ((GdkEventButton *)event)->x &&
+                     cell_area->x + cell_area->width > ((GdkEventButton *)event)->x)
+                   try_event = TRUE;
+               }
+             else if (real_cell_area.x <= ((GdkEventButton *)event)->x &&
+                 real_cell_area.x + real_cell_area.width > ((GdkEventButton *)event)->x)
+                 /* only activate cell if the user clicked on an individual
+                  * cell
+                  */
+               try_event = TRUE;
+           }
+         else if (special_cells > 1 && info->has_focus)
+           try_event = TRUE;
+         else if (special_cells == 1)
+           try_event = TRUE;
+
+         if (try_event)
+           {
+             gboolean visible, mode;
+
+             g_object_get (G_OBJECT (info->cell),
+                           "visible", &visible,
+                           "mode", &mode,
+                           NULL);
+             if (visible && mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE)
+               {
+                 if (gtk_cell_renderer_activate (info->cell,
+                                                 event,
+                                                 tree_column->tree_view,
+                                                 path_string,
+                                                 background_area,
+                                                 cell_area,
+                                                 flags))
+                   return TRUE;
+               }
+             else if (visible && mode == GTK_CELL_RENDERER_MODE_EDITABLE)
+               {
+                 *editable_widget =
+                   gtk_cell_renderer_start_editing (info->cell,
+                                                    event,
+                                                    tree_column->tree_view,
+                                                    path_string,
+                                                    background_area,
+                                                    cell_area,
+                                                    flags);
+
+                 if (*editable_widget != NULL)
+                   {
+                     g_return_val_if_fail (GTK_IS_CELL_EDITABLE (*editable_widget), FALSE);
+                     info->in_editing_mode = TRUE;
+                     gtk_tree_view_column_focus_cell (tree_column, info->cell);
+                     
+                     return TRUE;
+                   }
+               }
+           }
        }
-      real_cell_area.x += (info->requested_width + tree_column->spacing);
+
+      real_cell_area.x += (info->real_width + tree_column->spacing);
+      real_background_area.x += (info->real_width + tree_column->spacing);
     }
+
+  /* iterate list for PACK_END cells */
   for (list = g_list_last (tree_column->cell_list); list; list = list->prev)
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
@@ -2354,18 +2613,128 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
       if (! info->cell->visible)
        continue;
 
-      real_cell_area.width = info->requested_width +
+      real_background_area.width = info->requested_width +
        (info->expand?extra_space:0);
-      gtk_cell_renderer_render (info->cell,
-                               window,
-                               tree_column->tree_view,
-                               background_area,
-                               &real_cell_area,
-                               expose_area,
-                               flags);
-      real_cell_area.x += (info->requested_width + tree_column->spacing);
+      info->real_width = real_background_area.width;
+
+      real_cell_area.width = real_background_area.width;
+      real_cell_area.width -= 2 * focus_line_width;
+
+      if (action == CELL_ACTION_RENDER)
+       {
+         gtk_cell_renderer_render (info->cell,
+                                   window,
+                                   tree_column->tree_view,
+                                   &real_background_area,
+                                   &real_cell_area,
+                                   expose_area,
+                                   flags);
+       }
+      else if (action == CELL_ACTION_FOCUS)
+       {
+         gint x_offset, y_offset, width, height;
+
+         gtk_cell_renderer_get_size (info->cell,
+                                     tree_column->tree_view,
+                                     &real_cell_area,
+                                     &x_offset, &y_offset,
+                                     &width, &height);
+
+         if (special_cells > 1)
+           {
+             if (info->has_focus)
+               {
+                 min_x = real_cell_area.x + x_offset;
+                 max_x = min_x + width;
+                 min_y = real_cell_area.y + y_offset;
+                 max_y = min_y + height;
+               }
+           }
+         else
+           {
+             if (min_x > (real_cell_area.x + x_offset))
+               min_x = real_cell_area.x + x_offset;
+             if (max_x < real_cell_area.x + x_offset + width)
+               max_x = real_cell_area.x + x_offset + width;
+             if (min_y > (real_cell_area.y + y_offset))
+               min_y = real_cell_area.y + y_offset;
+             if (max_y < real_cell_area.y + y_offset + height)
+               max_y = real_cell_area.y + y_offset + height;
+           }
+       }
+      else if (action == CELL_ACTION_EVENT)
+        {
+         gboolean try_event = FALSE;
+
+         if (event)
+           {
+             if (special_cells == 1)
+               {
+                 /* only 1 activatable cell -> whole column can activate */
+                 if (cell_area->x <= ((GdkEventButton *)event)->x &&
+                     cell_area->x + cell_area->width > ((GdkEventButton *)event)->x)
+                   try_event = TRUE;
+               }
+             else if (real_cell_area.x <= ((GdkEventButton *)event)->x &&
+                 real_cell_area.x + real_cell_area.width > ((GdkEventButton *)event)->x)
+               /* only activate cell if the user clicked on an individual
+                * cell
+                */
+               try_event = TRUE;
+           }
+         else if (special_cells > 1 && info->has_focus)
+           try_event = TRUE;
+         else if (special_cells == 1)
+           try_event = TRUE;
+
+         if (try_event)
+           {
+             gboolean visible, mode;
+
+             g_object_get (G_OBJECT (info->cell),
+                           "visible", &visible,
+                           "mode", &mode,
+                           NULL);
+             if (visible && mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE)
+               {
+                 if (gtk_cell_renderer_activate (info->cell,
+                                                 event,
+                                                 tree_column->tree_view,
+                                                 path_string,
+                                                 background_area,
+                                                 cell_area,
+                                                 flags))
+                   return TRUE;
+               }
+             else if (visible && mode == GTK_CELL_RENDERER_MODE_EDITABLE)
+               {
+                 *editable_widget =
+                   gtk_cell_renderer_start_editing (info->cell,
+                                                    event,
+                                                    tree_column->tree_view,
+                                                    path_string,
+                                                    background_area,
+                                                    cell_area,
+                                                    flags);
+
+                 if (*editable_widget != NULL)
+                   {
+                     g_return_val_if_fail (GTK_IS_CELL_EDITABLE (*editable_widget), FALSE);
+                     info->in_editing_mode = TRUE;
+                     gtk_tree_view_column_focus_cell (tree_column, info->cell);
+
+                     return TRUE;
+                   }
+               }
+           }
+       }
+
+      real_cell_area.x += (info->real_width + tree_column->spacing);
+      real_background_area.x += (info->real_width + tree_column->spacing);
     }
-  if (! render)
+
+  /* fill focus_rectangle when required */
+  if (action == CELL_ACTION_FOCUS)
     {
       if (min_x >= max_x || min_y >= max_y)
        {
@@ -2381,6 +2750,8 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
          focus_rectangle->height = (max_y - min_y) + 2 * focus_line_width;
        }
     }
+
+  return FALSE;
 }
 
 /**
@@ -2408,14 +2779,14 @@ _gtk_tree_view_column_cell_render (GtkTreeViewColumn *tree_column,
   g_return_if_fail (cell_area != NULL);
   g_return_if_fail (expose_area != NULL);
 
-  gtk_tree_view_column_cell_render_or_focus (tree_column,
-                                            window,
-                                            background_area,
-                                            cell_area,
-                                            expose_area,
-                                            flags,
-                                            TRUE,
-                                            NULL);
+  gtk_tree_view_column_cell_process_action (tree_column,
+                                           window,
+                                           background_area,
+                                           cell_area,
+                                           flags,
+                                           CELL_ACTION_RENDER,
+                                           expose_area,
+                                           NULL, NULL, NULL, NULL);
 }
 
 gboolean
@@ -2427,52 +2798,232 @@ _gtk_tree_view_column_cell_event (GtkTreeViewColumn  *tree_column,
                                  GdkRectangle       *cell_area,
                                  guint               flags)
 {
-  gboolean visible, mode;
-
   g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), FALSE);
 
-  g_object_get (G_OBJECT (((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell),
-               "visible", &visible,
-               "mode", &mode,
-               NULL);
-  if (visible && mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE)
+  return gtk_tree_view_column_cell_process_action (tree_column,
+                                                  NULL,
+                                                  background_area,
+                                                  cell_area,
+                                                  flags,
+                                                  CELL_ACTION_EVENT,
+                                                  NULL, NULL,
+                                                  editable_widget,
+                                                  event,
+                                                  path_string);
+}
+
+/* cell list manipulation */
+static GList *
+gtk_tree_view_column_cell_first (GtkTreeViewColumn *tree_column)
+{
+  GList *list = tree_column->cell_list;
+
+  /* first GTK_PACK_START cell we find */
+  for ( ; list; list = list->next)
     {
-      if (gtk_cell_renderer_activate (((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell,
-                                     event,
-                                     tree_column->tree_view,
-                                     path_string,
-                                     background_area,
-                                     cell_area,
-                                     flags))
-       return TRUE;
+      GtkTreeViewColumnCellInfo *info = list->data;
+      if (info->pack == GTK_PACK_START)
+       return list;
     }
-  else if (visible && mode == GTK_CELL_RENDERER_MODE_EDITABLE)
+
+  /* hmm, else the *last* GTK_PACK_END cell */
+  list = g_list_last (tree_column->cell_list);
+
+  for ( ; list; list = list->prev)
     {
-      *editable_widget = gtk_cell_renderer_start_editing (((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell,
-                                                         event,
-                                                         tree_column->tree_view,
-                                                         path_string,
-                                                         background_area,
-                                                         cell_area,
-                                                         flags);
+      GtkTreeViewColumnCellInfo *info = list->data;
+      if (info->pack == GTK_PACK_END)
+       return list;
+    }
 
-      if (*editable_widget != NULL)
-       {
-         g_return_val_if_fail (GTK_IS_CELL_EDITABLE (*editable_widget), FALSE);
+  return NULL;
+}
 
-         return TRUE;
+static GList *
+gtk_tree_view_column_cell_last (GtkTreeViewColumn *tree_column)
+{
+  GList *list = tree_column->cell_list;
+
+  /* *first* GTK_PACK_END cell we find */
+  for ( ; list ; list = list->next)
+    {
+      GtkTreeViewColumnCellInfo *info = list->data;
+      if (info->pack == GTK_PACK_END)
+       return list;
+    }
+
+  /* hmm, else the last GTK_PACK_START cell */
+  list = g_list_last (tree_column->cell_list);
+
+  for ( ; list; list = list->prev)
+    {
+      GtkTreeViewColumnCellInfo *info = list->data;
+      if (info->pack == GTK_PACK_START)
+       return list;
+    }
+
+  return NULL;
+}
+
+static GList *
+gtk_tree_view_column_cell_next (GtkTreeViewColumn *tree_column,
+                               GList             *current)
+{
+  GList *list;
+  GtkTreeViewColumnCellInfo *info = current->data;
+
+  if (info->pack == GTK_PACK_START)
+    {
+      for (list = current->next; list; list = list->next)
+        {
+         GtkTreeViewColumnCellInfo *inf = list->data;
+         if (inf->pack == GTK_PACK_START)
+           return list;
+       }
+
+      /* out of GTK_PACK_START cells, get *last* GTK_PACK_END one */
+      list = g_list_last (tree_column->cell_list);
+      for (; list; list = list->prev)
+        {
+         GtkTreeViewColumnCellInfo *inf = list->data;
+         if (inf->pack == GTK_PACK_END)
+           return list;
        }
     }
-  return FALSE;
+
+  for (list = current->prev; list; list = list->prev)
+    {
+      GtkTreeViewColumnCellInfo *inf = list->data;
+      if (inf->pack == GTK_PACK_END)
+       return list;
+    }
+
+  return NULL;
 }
 
+static GList *
+gtk_tree_view_column_cell_prev (GtkTreeViewColumn *tree_column,
+                               GList             *current)
+{
+  GList *list;
+  GtkTreeViewColumnCellInfo *info = current->data;
+
+  if (info->pack == GTK_PACK_END)
+    {
+      for (list = current->next; list; list = list->next)
+        {
+         GtkTreeViewColumnCellInfo *inf = list->data;
+         if (inf->pack == GTK_PACK_END)
+           return list;
+       }
+
+      /* out of GTK_PACK_END, get last GTK_PACK_START one */
+      list = g_list_last (tree_column->cell_list);
+      for ( ; list; list = list->prev)
+        {
+         GtkTreeViewColumnCellInfo *inf = list->data;
+         if (inf->pack == GTK_PACK_START)
+           return list;
+       }
+    }
+
+  for (list = current->prev; list; list = list->prev)
+    {
+      GtkTreeViewColumnCellInfo *inf = list->data;
+      if (inf->pack == GTK_PACK_START)
+       return list;
+    }
+
+  return NULL;
+}
 
 gboolean
 _gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
-                                 gint               direction)
+                                 gint               direction,
+                                 gboolean           left,
+                                 gboolean           right)
 {
+  gint count;
+
+  count = _gtk_tree_view_column_count_special_cells (tree_column);
+
+  /* if we are the current focus column and have multiple editable cells,
+   * try to select the next one, else move the focus to the next column
+   */
   if (GTK_TREE_VIEW (tree_column->tree_view)->priv->focus_column == tree_column)
-    return FALSE;
+    {
+      if (count > 1)
+        {
+          GList *next, *prev;
+         GList *list = tree_column->cell_list;
+         GtkTreeViewColumnCellInfo *info = NULL;
+
+         /* find current focussed cell */
+         for ( ; list; list = list->next)
+           {
+             info = list->data;
+             if (info->has_focus)
+               break;
+           }
+
+         /* not a focussed cell in the focus column? */
+         if (!list || !info || !info->has_focus)
+           return FALSE;
+
+         next = gtk_tree_view_column_cell_next (tree_column, list);
+         prev = gtk_tree_view_column_cell_prev (tree_column, list);
+
+         info->has_focus = FALSE;
+         if (direction > 0 && next)
+           {
+             info = next->data;
+             info->has_focus = TRUE;
+             return TRUE;
+           }
+         else if (direction > 0 && !next && !right)
+           {
+             /* keep focus on latest cell */
+             info = gtk_tree_view_column_cell_last (tree_column)->data;
+             info->has_focus = TRUE;
+             return TRUE;
+           }
+         else if (direction < 0 && prev)
+           {
+             info = prev->data;
+             info->has_focus = TRUE;
+             return TRUE;
+           }
+         else if (direction < 0 && !prev && !left)
+           {
+             /* keep focus on first cell */
+             info = gtk_tree_view_column_cell_first (tree_column)->data;
+             info->has_focus = TRUE;
+             return TRUE;
+           }
+       }
+      return FALSE;
+    }
+
+  /* we get focus, if we have multiple editable cells, give the correct one
+   * focus
+   */
+  if (count > 1)
+    {
+      GList *list = tree_column->cell_list;
+
+      /* clear focus first */
+      for ( ; list ; list = list->next)
+        {
+         GtkTreeViewColumnCellInfo *info = list->data;
+         if (info->has_focus)
+           info->has_focus = FALSE;
+       }
+
+      if (direction > 0)
+       ((GtkTreeViewColumnCellInfo *)gtk_tree_view_column_cell_first (tree_column)->data)->has_focus = TRUE;
+      else if (direction < 0)
+       ((GtkTreeViewColumnCellInfo *)gtk_tree_view_column_cell_last (tree_column)->data)->has_focus = TRUE;
+    }
   return TRUE;
 }
 
@@ -2510,14 +3061,15 @@ _gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn       *tree_column,
   else
     {
       GdkRectangle focus_rectangle;
-      gtk_tree_view_column_cell_render_or_focus (tree_column,
-                                                window,
-                                                background_area,
-                                                cell_area,
-                                                expose_area,
-                                                flags,
-                                                FALSE,
-                                                &focus_rectangle);
+      gtk_tree_view_column_cell_process_action (tree_column,
+                                               window,
+                                               background_area,
+                                               cell_area,
+                                               flags,
+                                               CELL_ACTION_FOCUS,
+                                               expose_area,
+                                               &focus_rectangle,
+                                               NULL, NULL, NULL);
 
       cell_state = flags & GTK_CELL_RENDERER_SELECTED ? GTK_STATE_SELECTED :
              (flags & GTK_CELL_RENDERER_PRELIT ? GTK_STATE_PRELIGHT :
@@ -2550,6 +3102,8 @@ gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column)
 {
   GList *list;
 
+  g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), FALSE);
+
   for (list = tree_column->cell_list; list; list = list->next)
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
@@ -2561,6 +3115,53 @@ gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column)
   return FALSE;
 }
 
+/**
+ * gtk_tree_view_column_focus_cell:
+ * @tree_column: A #GtkTreeViewColumn
+ * @cell: A #GtkCellRenderer
+ *
+ * Sets the current keyboard focus to be at @cell, if the column contains
+ * 2 or more editable and activatable cells.
+ **/
+void
+gtk_tree_view_column_focus_cell (GtkTreeViewColumn *tree_column,
+                                GtkCellRenderer   *cell)
+{
+  GList *list;
+  gboolean found_cell = FALSE;
+
+  g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
+  g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+
+  if (_gtk_tree_view_column_count_special_cells (tree_column) < 2)
+    return;
+
+  for (list = tree_column->cell_list; list; list = list->next)
+    {
+      GtkTreeViewColumnCellInfo *info = list->data;
+
+      if (info->cell == cell)
+        {
+         info->has_focus = TRUE;
+         found_cell = TRUE;
+         break;
+       }
+    }
+
+  if (found_cell)
+    {
+      for (list = tree_column->cell_list; list; list = list->next)
+        {
+         GtkTreeViewColumnCellInfo *info = list->data;
+
+         if (info->cell != cell)
+           info->has_focus = FALSE;
+        }
+
+      /* FIXME: redraw? */
+    }
+}
+
 void
 _gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column,
                                      gboolean           install_handler)
@@ -2601,7 +3202,102 @@ _gtk_tree_view_column_start_editing (GtkTreeViewColumn *tree_column,
 void
 _gtk_tree_view_column_stop_editing (GtkTreeViewColumn *tree_column)
 {
+  GList *list;
+
   g_return_if_fail (tree_column->editable_widget != NULL);
 
   tree_column->editable_widget = NULL;
+  for (list = tree_column->cell_list; list; list = list->next)
+    ((GtkTreeViewColumnCellInfo *)list->data)->in_editing_mode = FALSE;
+}
+
+void
+_gtk_tree_view_column_get_neighbor_sizes (GtkTreeViewColumn *column,
+                                         GtkCellRenderer   *cell,
+                                         gint              *left,
+                                         gint              *right)
+{
+  GList *list;
+
+  if (left)
+    {
+      *left = 0;
+      list = gtk_tree_view_column_cell_first (column);
+
+      for (; list; list = gtk_tree_view_column_cell_next (column, list))
+        {
+         GtkTreeViewColumnCellInfo *info =
+           (GtkTreeViewColumnCellInfo *)list->data;
+
+         if (info->cell == cell)
+           break;
+
+         *left += info->real_width;
+       }
+    }
+
+  if (right)
+    {
+      GList *next;
+
+      *right = 0;
+      list = gtk_tree_view_column_cell_first (column);
+
+      for (; list; list = gtk_tree_view_column_cell_next (column, list))
+        {
+         GtkTreeViewColumnCellInfo *info =
+           (GtkTreeViewColumnCellInfo *)list->data;
+
+         if (info->cell == cell)
+           break;
+       }
+
+      /* skip cell */
+      next = gtk_tree_view_column_cell_next (column, list);
+      if (list && next)
+        {
+         list = next;
+         for ( ; list; list = gtk_tree_view_column_cell_next (column, list))
+           {
+             GtkTreeViewColumnCellInfo *info =
+               (GtkTreeViewColumnCellInfo *)list->data;
+
+             *right += info->real_width;
+           }
+       }
+    }
+}
+
+gboolean
+gtk_tree_view_column_cell_get_position (GtkTreeViewColumn *tree_column,
+                                       GtkCellRenderer   *cell_renderer,
+                                       gint              *start_pos,
+                                       gint              *width)
+{
+  GList *list;
+  gint current_x = 0;
+  gboolean found_cell = FALSE;
+  GtkTreeViewColumnCellInfo *cellinfo;
+
+  list = gtk_tree_view_column_cell_first (tree_column);
+  for (; list; list = gtk_tree_view_column_cell_next (tree_column, list))
+    {
+      cellinfo = list->data;
+      if (cellinfo->cell == cell_renderer)
+        {
+          found_cell = TRUE;
+          break;
+        }
+      current_x += cellinfo->real_width;
+    }
+
+  if (found_cell)
+    {
+      if (start_pos)
+        *start_pos = current_x;
+      if (width)
+        *width = cellinfo->real_width;
+    }
+
+  return found_cell;
 }