]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktreeviewcolumn.c
new function (gtk_tree_view_column_create_button): use g_signal_* instead
[~andy/gtk] / gtk / gtktreeviewcolumn.c
index 18a33630871e24e238dabd60c7865ff5a5342bfe..6e67316cd9526f5d4901271025a0fec87987381d 100644 (file)
@@ -25,6 +25,7 @@
 #include "gtkalignment.h"
 #include "gtklabel.h"
 #include "gtkhbox.h"
+#include "gtkmarshalers.h"
 #include "gtkarrow.h"
 #include "gtkintl.h"
 #include <string.h>
@@ -33,6 +34,7 @@ enum
 {
   PROP_0,
   PROP_VISIBLE,
+  PROP_RESIZABLE,
   PROP_WIDTH,
   PROP_SIZING,
   PROP_FIXED_WIDTH,
@@ -90,10 +92,11 @@ static void gtk_tree_view_column_update_button                 (GtkTreeViewColum
 static gint gtk_tree_view_column_button_event                  (GtkWidget               *widget,
                                                                GdkEvent                *event,
                                                                gpointer                 data);
-static void gtk_tree_view_column_button_realize                (GtkWidget               *widget,
-                                                               gpointer                 data);
 static void gtk_tree_view_column_button_clicked                (GtkWidget               *widget,
                                                                gpointer                 data);
+static gboolean gtk_tree_view_column_mnemonic_activate         (GtkWidget *widget,
+                                                               gboolean   group_cycling,
+                                                               gpointer   data);
 
 /* Property handlers */
 static void gtk_tree_view_model_sort_column_changed            (GtkTreeSortable         *sortable,
@@ -162,7 +165,7 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
                   G_SIGNAL_RUN_LAST,
                   G_STRUCT_OFFSET (GtkTreeViewColumnClass, clicked),
                   NULL, NULL,
-                  gtk_marshal_VOID__VOID,
+                  _gtk_marshal_VOID__VOID,
                   GTK_TYPE_NONE, 0);
 
   g_object_class_install_property (object_class,
@@ -173,6 +176,14 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
                                                          TRUE,
                                                          G_PARAM_READABLE | G_PARAM_WRITABLE));
   
+  g_object_class_install_property (object_class,
+                                   PROP_RESIZABLE,
+                                   g_param_spec_boolean ("resizable",
+                                                        _("Resizable"),
+                                                        _("Column is user-resizable"),
+                                                         FALSE,
+                                                         G_PARAM_READABLE | G_PARAM_WRITABLE));
+  
   g_object_class_install_property (object_class,
                                    PROP_WIDTH,
                                    g_param_spec_int ("width",
@@ -292,8 +303,10 @@ gtk_tree_view_column_init (GtkTreeViewColumn *tree_column)
   tree_column->requested_width = -1;
   tree_column->min_width = -1;
   tree_column->max_width = -1;
+  tree_column->resized_width = 0;
   tree_column->column_type = GTK_TREE_VIEW_COLUMN_GROW_ONLY;
   tree_column->visible = TRUE;
+  tree_column->resizable = FALSE;
   tree_column->clickable = FALSE;
   tree_column->dirty = TRUE;
   tree_column->sort_order = GTK_SORT_ASCENDING;
@@ -304,6 +317,7 @@ gtk_tree_view_column_init (GtkTreeViewColumn *tree_column)
   tree_column->sort_column_id = -1;
   tree_column->reorderable = FALSE;
   tree_column->maybe_reordered = FALSE;
+  tree_column->use_resized_width = FALSE;
 }
 
 static void
@@ -344,6 +358,11 @@ gtk_tree_view_column_set_property (GObject         *object,
                                         g_value_get_boolean (value));
       break;
 
+    case PROP_RESIZABLE:
+      gtk_tree_view_column_set_resizable (tree_column,
+                                         g_value_get_boolean (value));
+      break;
+
     case PROP_SIZING:
       gtk_tree_view_column_set_sizing (tree_column,
                                        g_value_get_enum (value));
@@ -422,6 +441,11 @@ gtk_tree_view_column_get_property (GObject         *object,
                            gtk_tree_view_column_get_visible (tree_column));
       break;
 
+    case PROP_RESIZABLE:
+      g_value_set_boolean (value,
+                           gtk_tree_view_column_get_resizable (tree_column));
+      break;
+
     case PROP_WIDTH:
       g_value_set_int (value,
                        gtk_tree_view_column_get_width (tree_column));
@@ -507,24 +531,21 @@ gtk_tree_view_column_create_button (GtkTreeViewColumn *tree_column)
 
   gtk_widget_push_composite_child ();
   tree_column->button = gtk_button_new ();
+  gtk_widget_add_events (tree_column->button, GDK_POINTER_MOTION_MASK);
   gtk_widget_pop_composite_child ();
 
   /* make sure we own a reference to it as well. */
   if (tree_view->priv->header_window)
     gtk_widget_set_parent_window (tree_column->button, tree_view->priv->header_window);
   gtk_widget_set_parent (tree_column->button, GTK_WIDGET (tree_view));
-  
-  gtk_signal_connect (GTK_OBJECT (tree_column->button), "realize",
-                     (GtkSignalFunc) gtk_tree_view_column_button_realize,
-                     NULL);
 
-  gtk_signal_connect (GTK_OBJECT (tree_column->button), "event",
-                     (GtkSignalFunc) gtk_tree_view_column_button_event,
-                     (gpointer) tree_column);
-  
-  gtk_signal_connect (GTK_OBJECT (tree_column->button), "clicked",
-                     (GtkSignalFunc) gtk_tree_view_column_button_clicked,
-                     (gpointer) tree_column);
+  g_signal_connect (G_OBJECT (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->alignment = gtk_alignment_new (tree_column->xalign, 0.5, 0.0, 0.0);
 
@@ -539,6 +560,10 @@ gtk_tree_view_column_create_button (GtkTreeViewColumn *tree_column)
       gtk_widget_show (child);
     }
 
+  g_signal_connect (G_OBJECT (child), "mnemonic_activate",
+                   G_CALLBACK (gtk_tree_view_column_mnemonic_activate),
+                   (gpointer) tree_column);
+
   if (tree_column->xalign <= 0.5)
     gtk_box_pack_end (GTK_BOX (hbox), tree_column->arrow, FALSE, FALSE, 0);
   else
@@ -604,11 +629,11 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
       g_return_if_fail (GTK_IS_LABEL (current_child));
 
       if (tree_column->title)
-       gtk_label_set_text (GTK_LABEL (current_child),
-                           tree_column->title);
+       gtk_label_set_text_with_mnemonic (GTK_LABEL (current_child),
+                                         tree_column->title);
       else
-       gtk_label_set_text (GTK_LABEL (current_child),
-                           "");
+       gtk_label_set_text_with_mnemonic (GTK_LABEL (current_child),
+                                         "");
     }
 
   switch (tree_column->sort_order)
@@ -665,7 +690,7 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
          gtk_widget_show_now (tree_column->button);
          if (tree_column->window)
            {
-             if (tree_column->column_type == GTK_TREE_VIEW_COLUMN_RESIZABLE)
+             if (tree_column->resizable)
                {
                  gdk_window_show (tree_column->window);
                  gdk_window_raise (tree_column->window);
@@ -695,11 +720,17 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
        {
          GtkWidget *toplevel = gtk_widget_get_toplevel (tree_column->tree_view);
          if (GTK_WIDGET_TOPLEVEL (toplevel))
-           gtk_window_set_focus (GTK_WINDOW (toplevel), NULL);
+           {
+             gtk_window_set_focus (GTK_WINDOW (toplevel), NULL);
+           }
        }
     }
+  /* Queue a resize on the assumption that we always want to catch all changes
+   * and columns don't change all that often.
+   */
+  if (GTK_WIDGET_REALIZED (tree_column->tree_view))
+     gtk_widget_queue_resize (tree_column->tree_view);
 
-  gtk_tree_view_column_cell_set_dirty (tree_column);
 }
 
 /* Button signal handlers
@@ -738,6 +769,10 @@ gtk_tree_view_column_button_event (GtkWidget *widget,
                                 (gint) ((GdkEventMotion *)event)->y)))
     {
       column->maybe_reordered = FALSE;
+      /* this is to change our drag_x to be relative to
+       * tree_view->priv->bin_window, instead of our window.
+       */
+      column->drag_x -= column->button->allocation.x;
       _gtk_tree_view_column_start_drag (GTK_TREE_VIEW (column->tree_view), column);
       return TRUE;
     }
@@ -760,11 +795,6 @@ gtk_tree_view_column_button_event (GtkWidget *widget,
   return FALSE;
 }
 
-static void
-gtk_tree_view_column_button_realize (GtkWidget *widget, gpointer data)
-{
-  gdk_window_set_events (widget->window, gdk_window_get_events (widget->window) | GDK_POINTER_MOTION_MASK);
-}
 
 static void
 gtk_tree_view_column_button_clicked (GtkWidget *widget, gpointer data)
@@ -772,9 +802,33 @@ gtk_tree_view_column_button_clicked (GtkWidget *widget, gpointer data)
   g_signal_emit_by_name (G_OBJECT (data), "clicked");
 }
 
+static gboolean
+gtk_tree_view_column_mnemonic_activate (GtkWidget *widget,
+                                       gboolean   group_cycling,
+                                       gpointer   data)
+{
+  GtkTreeViewColumn *column = (GtkTreeViewColumn *)data;
+
+  g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (column), FALSE);
+
+  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);
+    }
+
+  return TRUE;
+}
+
 static void
 gtk_tree_view_model_sort_column_changed (GtkTreeSortable   *sortable,
-                                         GtkTreeViewColumn *column)
+                                        GtkTreeViewColumn *column)
 {
   gint sort_column_id;
   GtkSortType order;
@@ -916,7 +970,6 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column)
                     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);
-  tree_view->priv->cursor_drag = attr.cursor;
 
   attr.y = 0;
   attr.width = TREE_VIEW_DRAG_WIDTH;
@@ -929,6 +982,8 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column)
   gdk_window_set_user_data (column->window, tree_view);
 
   gtk_tree_view_column_update_button (column);
+
+  gdk_cursor_unref (attr.cursor);
 }
 
 void
@@ -984,29 +1039,6 @@ _gtk_tree_view_column_unset_tree_view (GtkTreeViewColumn *column)
   column->button = NULL;
 }
 
-void
-_gtk_tree_view_column_set_width (GtkTreeViewColumn *tree_column,
-                                gint               width)
-{
-  if (tree_column->min_width != -1 &&
-      width <= tree_column->min_width)
-    width = tree_column->min_width;
-  else if (tree_column->max_width != -1 &&
-           width > tree_column->max_width)
-    width = tree_column->max_width;
-  
-  if (tree_column->width == width)
-    return;
-  
-  tree_column->width = width;
-
-  g_object_notify (G_OBJECT (tree_column), "width");
-
-  if (tree_column->tree_view != NULL)
-    gtk_widget_queue_resize (tree_column->tree_view);
-
-}
-
 /* Public Functions */
 
 
@@ -1031,12 +1063,12 @@ gtk_tree_view_column_new (void)
  * gtk_tree_view_column_new_with_attributes:
  * @title: The title to set the header to.
  * @cell: The #GtkCellRenderer.
- * @Varargs: A NULL terminated list of attributes.
+ * @Varargs: A %NULL-terminated list of attributes.
  * 
  * Creates a new #GtkTreeViewColumn with a number of default values.  This is
- * 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.
+ * 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.
  * 
  * Return value: A newly created #GtkTreeViewColumn.
  **/
@@ -1075,8 +1107,8 @@ gtk_tree_view_column_get_cell_info (GtkTreeViewColumn *tree_column,
 /**
  * gtk_tree_view_column_pack_start:
  * @tree_column: A #GtkTreeViewColumn.
- * @cell: The #GtkCellRenderer, 
- * @expand: TRUE if @cell is to be given extra space allocated to box.
+ * @cell: The #GtkCellRenderer. 
+ * @expand: %TRUE if @cell is to be given extra space allocated to box.
  * 
  **/
 void
@@ -1128,6 +1160,12 @@ gtk_tree_view_column_pack_end (GtkTreeViewColumn  *tree_column,
 }
 
 
+/**
+ * gtk_tree_view_column_clear:
+ * @tree_column: A #GtkTreeViewColumn
+ * 
+ * Unsets all the mappings on all renderers on the @tree_column.
+ **/
 void
 gtk_tree_view_column_clear (GtkTreeViewColumn *tree_column)
 {
@@ -1147,6 +1185,15 @@ gtk_tree_view_column_clear (GtkTreeViewColumn *tree_column)
   tree_column->cell_list = NULL;
 }
 
+/**
+ * gtk_tree_view_column_get_cell_renderers:
+ * @tree_column: A #GtkTreeViewColumn
+ * 
+ * Returns a newly-allocated #GList of all the cell renderers in the column, 
+ * in no particular order.  The list must be freed with g_list_free().
+ * 
+ * Return value: A list of #GtkCellRenderers
+ **/
 GList *
 gtk_tree_view_column_get_cell_renderers (GtkTreeViewColumn *tree_column)
 {
@@ -1194,7 +1241,7 @@ gtk_tree_view_column_add_attribute (GtkTreeViewColumn *tree_column,
   info->attributes = g_slist_prepend (info->attributes, g_strdup (attribute));
 
   if (tree_column->tree_view)
-    gtk_tree_view_column_cell_set_dirty (tree_column);
+    _gtk_tree_view_column_cell_set_dirty (tree_column, TRUE);
 
 }
 
@@ -1222,11 +1269,11 @@ gtk_tree_view_column_set_attributesv (GtkTreeViewColumn *tree_column,
  * gtk_tree_view_column_set_attributes:
  * @tree_column: A #GtkTreeViewColumn.
  * @cell_renderer: the #GtkCellRenderer we're setting the attributes of
- * @Varargs: A NULL terminated listing of attributes.
+ * @Varargs: A %NULL-terminated list of attributes.
  * 
  * Sets the attributes in the list as the attributes of @tree_column.
  * The attributes should be in attribute/column order, as in
- * @gtk_tree_view_column_add_attribute. All existing attributes
+ * gtk_tree_view_column_add_attribute(). All existing attributes
  * are removed, and replaced with the new attributes.
  **/
 void
@@ -1257,7 +1304,7 @@ gtk_tree_view_column_set_attributes (GtkTreeViewColumn *tree_column,
  * Sets the #GtkTreeViewColumnFunc to use for the column.  This
  * function is used instead of the standard attributes mapping for
  * setting the column value, and should set the value of @tree_column's
- * cell renderer as appropriate.  @func may be NULL to remove an
+ * cell renderer as appropriate.  @func may be %NULL to remove an
  * older one.
  **/
 void
@@ -1288,14 +1335,14 @@ gtk_tree_view_column_set_cell_data_func (GtkTreeViewColumn   *tree_column,
   info->destroy = destroy;
 
   if (tree_column->tree_view)
-    gtk_tree_view_column_cell_set_dirty (tree_column);
+    _gtk_tree_view_column_cell_set_dirty (tree_column, TRUE);
 }
 
 
 /**
  * gtk_tree_view_column_clear_attributes:
  * @tree_column: a #GtkTreeViewColumn
- *@cell_renderer: a #GtkCellRenderer to clear the attribute mapping on.
+ * @cell_renderer: a #GtkCellRenderer to clear the attribute mapping on.
  * 
  * Clears all existing attributes previously set with
  * gtk_tree_view_column_set_attributes().
@@ -1322,7 +1369,7 @@ gtk_tree_view_column_clear_attributes (GtkTreeViewColumn *tree_column,
   info->attributes = NULL;
 
   if (tree_column->tree_view)
-    gtk_tree_view_column_cell_set_dirty (tree_column);
+    _gtk_tree_view_column_cell_set_dirty (tree_column, TRUE);
 }
 
 
@@ -1346,7 +1393,7 @@ gtk_tree_view_column_set_spacing (GtkTreeViewColumn *tree_column,
 
   tree_column->spacing = spacing;
   if (tree_column->tree_view)
-    gtk_tree_view_column_cell_set_dirty (tree_column);
+    _gtk_tree_view_column_cell_set_dirty (tree_column, TRUE);
 }
 
 /**
@@ -1354,6 +1401,8 @@ gtk_tree_view_column_set_spacing (GtkTreeViewColumn *tree_column,
  * @tree_column: A #GtkTreeViewColumn.
  * 
  * Returns the spacing of @tree_column.
+ * 
+ * Return value: the spacing of @tree_column.
  **/
 gint
 gtk_tree_view_column_get_spacing (GtkTreeViewColumn *tree_column)
@@ -1368,7 +1417,7 @@ gtk_tree_view_column_get_spacing (GtkTreeViewColumn *tree_column)
 /**
  * gtk_tree_view_column_set_visible:
  * @tree_column: A #GtkTreeViewColumn.
- * @visible: TRUE if the @tree_column is visible.
+ * @visible: %TRUE if the @tree_column is visible.
  * 
  * Sets the visibility of @tree_column.
  **/
@@ -1393,7 +1442,7 @@ gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column,
  * gtk_tree_view_column_get_visible:
  * @tree_column: A #GtkTreeViewColumn.
  * 
- * Returns TRUE if @tree_column is visible.
+ * Returns %TRUE if @tree_column is visible.
  * 
  * Return value: whether the column is visible or not.  If it is visible, then
  * the tree will show the column.
@@ -1406,6 +1455,36 @@ gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column)
   return tree_column->visible;
 }
 
+void
+gtk_tree_view_column_set_resizable (GtkTreeViewColumn *tree_column,
+                                   gboolean           resizable)
+{
+  g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
+
+  resizable = !! resizable;
+
+  if (tree_column->resizable == resizable)
+    return;
+
+  tree_column->resizable = resizable;
+
+  if (resizable && tree_column->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
+    gtk_tree_view_column_set_sizing (tree_column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+
+  gtk_tree_view_column_update_button (tree_column);
+
+  g_object_notify (G_OBJECT (tree_column), "resizable");
+}
+
+gboolean
+gtk_tree_view_column_get_resizable (GtkTreeViewColumn *tree_column)
+{
+  g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), FALSE);
+
+  return tree_column->resizable;
+}
+
+
 /**
  * gtk_tree_view_column_set_sizing:
  * @tree_column: A #GtkTreeViewColumn.
@@ -1422,16 +1501,23 @@ gtk_tree_view_column_set_sizing (GtkTreeViewColumn       *tree_column,
   if (type == tree_column->column_type)
     return;
 
+  if (type == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
+    gtk_tree_view_column_set_resizable (tree_column, FALSE);
+
+#if 0
+  /* I was clearly on crack when I wrote this.  I'm not sure what's supposed to
+   * be below so I'll leave it until I figure it out.
+   */
   if (tree_column->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE &&
       tree_column->requested_width != -1)
     {
       gtk_tree_view_column_set_sizing (tree_column, tree_column->requested_width);
     }
+#endif
   tree_column->column_type = type;
 
   gtk_tree_view_column_update_button (tree_column);
 
-  if (type != GTK_TREE_VIEW_COLUMN_AUTOSIZE)
   g_object_notify (G_OBJECT (tree_column), "sizing");
 }
 
@@ -1455,9 +1541,9 @@ gtk_tree_view_column_get_sizing (GtkTreeViewColumn *tree_column)
  * gtk_tree_view_column_get_width:
  * @tree_column: A #GtkTreeViewColumn.
  * 
- * Returns the current size of the @tree_column in pixels.
+ * Returns the current size of @tree_column in pixels.
  * 
- * Return value: The current width of the @tree_column.
+ * Return value: The current width of @tree_column.
  **/
 gint
 gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column)
@@ -1470,7 +1556,7 @@ gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column)
 /**
  * gtk_tree_view_column_set_fixed_width:
  * @tree_column: A #GtkTreeViewColumn.
- * @fixed_width: The size to set the @tree_column to. Must be greater than 0.
+ * @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
@@ -1488,16 +1574,23 @@ gtk_tree_view_column_set_fixed_width (GtkTreeViewColumn *tree_column,
     return;
 
   tree_column->fixed_width = fixed_width;
-  tree_column->requested_width = fixed_width;
-  _gtk_tree_view_column_set_width (tree_column, fixed_width);
+
+  if (tree_column->tree_view &&
+      GTK_WIDGET_REALIZED (tree_column->tree_view) &&
+      tree_column->column_type == GTK_TREE_VIEW_COLUMN_FIXED)
+    {
+      gtk_widget_queue_resize (tree_column->tree_view);
+    }
+
+  g_object_notify (G_OBJECT (tree_column), "fixed_width");
 }
 
 /**
  * gtk_tree_view_column_get_fixed_width:
  * @tree_column: a #GtkTreeViewColumn
  * 
- * Gets the fixed width of the column.  This value is only meaning may not be the
- * actual width of the column on the screen, just what is requested.
+ * Gets the fixed width of the column.  This value is only meaning may not be
+ * the actual width of the column on the screen, just what is requested.
  * 
  * Return value: the fixed width of the column
  **/
@@ -1521,42 +1614,29 @@ void
 gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column,
                                    gint               min_width)
 {
-  gint real_min_width;
-
   g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
   g_return_if_fail (min_width >= -1);
 
   if (min_width == tree_column->min_width)
     return;
 
-  if (tree_column->tree_view == NULL)
-    {
-      tree_column->min_width = min_width;
-      return;
-    }
-
-  real_min_width = (tree_column->min_width == -1) ?
-    tree_column->button->requisition.width : tree_column->min_width;
-
-  /* We want to queue a resize if the either the old min_size or the
-   * new min_size determined the size of the column */
-  if (GTK_WIDGET_REALIZED (tree_column->tree_view))
+  if (tree_column->visible &&
+      tree_column->tree_view != NULL &&
+      GTK_WIDGET_REALIZED (tree_column->tree_view))
     {
-      if ((tree_column->min_width > tree_column->width) ||
-         (tree_column->min_width == -1 &&
-          tree_column->button->requisition.width > tree_column->width) ||
-         (min_width > tree_column->width) ||
-         (min_width == -1 &&
-          tree_column->button->requisition.width > tree_column->width))
+      if (min_width > tree_column->width)
        gtk_widget_queue_resize (tree_column->tree_view);
     }
 
-  if (tree_column->max_width != -1 && tree_column->max_width < real_min_width)
-    tree_column->max_width = real_min_width;
-
   tree_column->min_width = min_width;
-
+  g_object_freeze_notify (G_OBJECT (tree_column));
+  if (tree_column->max_width != -1 && tree_column->max_width < min_width)
+    {
+      tree_column->max_width = min_width;
+      g_object_notify (G_OBJECT (tree_column), "max_width");
+    }
   g_object_notify (G_OBJECT (tree_column), "min_width");
+  g_object_thaw_notify (G_OBJECT (tree_column));
 }
 
 /**
@@ -1584,41 +1664,35 @@ gtk_tree_view_column_get_min_width (GtkTreeViewColumn *tree_column)
  * Sets the maximum width of the @tree_column.  If @max_width is -1, then the
  * maximum width is unset.  Note, the column can actually be wider than max
  * width if it's the last column in a view.  In this case, the column expands to
- * fill the view.
+ * fill any extra space.
  **/
 void
 gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column,
                                    gint               max_width)
 {
-  gint real_max_width;
-
   g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
   g_return_if_fail (max_width >= -1);
 
   if (max_width == tree_column->max_width)
     return;
 
-  if (tree_column->tree_view == NULL)
+  if (tree_column->visible &&
+      tree_column->tree_view != NULL &&
+      GTK_WIDGET_REALIZED (tree_column->tree_view))
     {
-      tree_column->max_width = max_width;
-      return;
+      if (max_width != -1 && max_width < tree_column->width)
+       gtk_widget_queue_resize (tree_column->tree_view);
     }
 
-  real_max_width = tree_column->max_width == -1 ?
-    tree_column->button->requisition.width : tree_column->max_width;
-
-  if (tree_column->tree_view &&
-      GTK_WIDGET_REALIZED (tree_column->tree_view) &&
-      ((tree_column->max_width < tree_column->width) ||
-       (max_width != -1 && max_width < tree_column->width)))
-    gtk_widget_queue_resize (tree_column->tree_view);
-
   tree_column->max_width = max_width;
-
-  if (real_max_width > max_width)
-    tree_column->max_width = max_width;
-
+  g_object_freeze_notify (G_OBJECT (tree_column));
+  if (max_width != -1 && max_width < tree_column->min_width)
+    {
+      tree_column->min_width = max_width;
+      g_object_notify (G_OBJECT (tree_column), "min_width");
+    }
   g_object_notify (G_OBJECT (tree_column), "max_width");
+  g_object_thaw_notify (G_OBJECT (tree_column));
 }
 
 /**
@@ -1643,7 +1717,7 @@ gtk_tree_view_column_get_max_width (GtkTreeViewColumn *tree_column)
  * @tree_column: a #GtkTreeViewColumn
  * 
  * Emits the "clicked" signal on the column.  This function will only work if
- * the user could have conceivably clicked on the button.
+ * @tree_column is clickable.
  **/
 void
 gtk_tree_view_column_clicked (GtkTreeViewColumn *tree_column)
@@ -1699,9 +1773,9 @@ gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column)
 /**
  * gtk_tree_view_column_set_clickable:
  * @tree_column: A #GtkTreeViewColumn.
- * @clickable: TRUE if the header is active.
+ * @clickable: %TRUE if the header is active.
  * 
- * Sets the header to be active if @active is TRUE.  When the header is active,
+ * Sets the header to be active if @active is %TRUE.  When the header is active,
  * then it can take keyboard focus, and can be clicked.
  **/
 void
@@ -1710,10 +1784,11 @@ gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column,
 {
   g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
 
-  if (tree_column->clickable == (clickable?TRUE:FALSE))
+  clickable = !! clickable;
+  if (tree_column->clickable == clickable)
     return;
 
-  tree_column->clickable = (clickable?TRUE:FALSE);
+  tree_column->clickable = clickable;
   gtk_tree_view_column_update_button (tree_column);
   g_object_notify (G_OBJECT (tree_column), "clickable");
 }
@@ -1724,7 +1799,7 @@ gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column,
  * 
  * Returns %TRUE if the user can click on the header for the column.
  * 
- * Return value: whether the user can click the column header
+ * Return value: %TRUE if user can click the column header.
  **/
 gboolean
 gtk_tree_view_column_get_clickable (GtkTreeViewColumn *tree_column)
@@ -1737,9 +1812,9 @@ gtk_tree_view_column_get_clickable (GtkTreeViewColumn *tree_column)
 /**
  * gtk_tree_view_column_set_widget:
  * @tree_column: A #GtkTreeViewColumn.
- * @widget: A child #GtkWidget, or NULL.
+ * @widget: A child #GtkWidget, or %NULL.
  * 
- * Sets the widget in the header to be @widget.  If widget is NULL, then the
+ * Sets the widget in the header to be @widget.  If widget is %NULL, then the
  * header button is set with a #GtkLabel set to the title of @tree_column.
  **/
 void
@@ -1852,10 +1927,10 @@ 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.
+ * @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.
+ * 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.
  **/
 void
 gtk_tree_view_column_set_sort_column_id (GtkTreeViewColumn *tree_column,
@@ -1904,10 +1979,10 @@ gtk_tree_view_column_set_sort_column_id (GtkTreeViewColumn *tree_column,
  * gtk_tree_view_column_get_sort_column_id:
  * @tree_column: a #GtkTreeViewColumn
  *
- * Gets the logical sort_column_id that the model sorts on when this
- * coumn is selected for sorting. See gtk_tree_view_column_set_sort_column_id().
+ * 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().
  *
- * Return value: the current sort_column_id for this column, or -1 if
+ * Return value: the current @sort_column_id for this column, or -1 if
  *               this column can't be used for sorting.
  **/
 gint
@@ -1966,16 +2041,17 @@ gtk_tree_view_column_get_sort_indicator  (GtkTreeViewColumn     *tree_column)
  * @tree_column: a #GtkTreeViewColumn
  * @order: sort order that the sort indicator should indicate
  *
- * Changes the appearance of the sort indicator. (This <emphasis>does
- * not</emphasis> actually sort the model.  Use
+ * Changes the appearance of the sort indicator. 
+ * 
+ * This <emphasis>does not</emphasis> actually sort the model.  Use
  * gtk_tree_view_column_set_sort_column_id() if you want automatic sorting
  * support.  This function is primarily for custom sorting behavior, and should
- * be used in conjunction with #gtk_tree_sortable_set_sort_column() to do
- * that. For custom models, the mechanism will vary. The sort indicator changes
- * direction to indicate normal sort or reverse sort. Note that you must have
- * the sort indicator enabled to see anything when calling this function; see
- * gtk_tree_view_column_set_sort_indicator().
+ * be used in conjunction with gtk_tree_sortable_set_sort_column() to do
+ * that. For custom models, the mechanism will vary. 
  * 
+ * The sort indicator changes direction to indicate normal sort or reverse sort.
+ * Note that you must have the sort indicator enabled to see anything when 
+ * calling this function; see gtk_tree_view_column_set_sort_indicator().
  **/
 void
 gtk_tree_view_column_set_sort_order      (GtkTreeViewColumn     *tree_column,
@@ -2012,13 +2088,13 @@ gtk_tree_view_column_get_sort_order      (GtkTreeViewColumn     *tree_column)
  * @tree_column: A #GtkTreeViewColumn.
  * @tree_model: The #GtkTreeModel to to get the cell renderers attributes from.
  * @iter: The #GtkTreeIter to to get the cell renderer's attributes from.
- * @is_expander: TRUE, if the row has children
- * @is_expanded: TRUE, if the row has visible children
+ * @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
  * 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
- * renderer.  This is used primarily by the GtkTreeView.
+ * renderer.  This is used primarily by the #GtkTreeView.
  **/
 void
 gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
@@ -2074,7 +2150,7 @@ gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
  * @height: location to return height needed to render a cell, or %NULL
  * 
  * Obtains the width and height needed to render the column.  This is used
- * primarily by the GtkTreeView.
+ * primarily by the #GtkTreeView.
  **/
 void
 gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
@@ -2086,6 +2162,7 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
 {
   GList *list;
   gboolean first_cell = TRUE;
+  gint focus_line_width;
 
   g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
 
@@ -2094,6 +2171,8 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
   if (width)
     * width = 0;
 
+  gtk_widget_style_get (tree_column->tree_view, "focus-line-width", &focus_line_width, NULL);
+  
   for (list = tree_column->cell_list; list; list = list->next)
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
@@ -2117,8 +2196,8 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
                                  &new_height);
 
       if (height)
-       * height = MAX (*height, new_height);
-      info->requested_width = MAX (info->requested_width, new_width);
+       * height = MAX (*height, new_height + focus_line_width * 2);
+      info->requested_width = MAX (info->requested_width, new_width + focus_line_width * 2);
       if (width)
        * width += info->requested_width;
       first_cell = TRUE;
@@ -2145,6 +2224,7 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
   gint full_requested_width = 0;
   gint extra_space;
   gint min_x, min_y, max_x, max_y;
+  gint focus_line_width;
 
   min_x = G_MAXINT;
   min_y = G_MAXINT;
@@ -2153,14 +2233,14 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
 
   real_cell_area = *cell_area;
 
+  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 */
   for (list = tree_column->cell_list; list; list = list->next)
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
-      gboolean visible;
 
-      g_object_get (info->cell, "visible", &visible, NULL);
-      if (visible == FALSE)
+      if (! info->cell->visible)
        continue;
 
       if (info->expand == TRUE)
@@ -2175,17 +2255,16 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
   for (list = tree_column->cell_list; list; list = list->next)
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
-      gboolean visible;
 
       if (info->pack == GTK_PACK_END)
        continue;
 
-      g_object_get (info->cell, "visible", &visible, NULL);
-      if (visible == FALSE)
+      if (! info->cell->visible)
        continue;
 
       real_cell_area.width = info->requested_width +
        (info->expand?extra_space:0);
+      real_cell_area.x += focus_line_width;
       if (render)
        {
          gtk_cell_renderer_render (info->cell,
@@ -2220,13 +2299,11 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
   for (list = g_list_last (tree_column->cell_list); list; list = list->prev)
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
-      gboolean visible;
 
       if (info->pack == GTK_PACK_START)
        continue;
 
-      g_object_get (info->cell, "visible", &visible, NULL);
-      if (visible == FALSE)
+      if (! info->cell->visible)
        continue;
 
       real_cell_area.width = info->requested_width +
@@ -2245,17 +2322,17 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
       if (min_x >= max_x || min_y >= max_y)
        {
          *focus_rectangle = *cell_area;
-         focus_rectangle->x -= 1;
-         focus_rectangle->y -= 1;
-         focus_rectangle->width += 2;
-         focus_rectangle->height += 2;
+         focus_rectangle->x -= focus_line_width;
+         focus_rectangle->y -= focus_line_width;
+         focus_rectangle->width += 2 * focus_line_width;
+         focus_rectangle->height += 2 * focus_line_width;
        }
       else
        {
-         focus_rectangle->x = min_x - 1;
-         focus_rectangle->y = min_y - 1;
-         focus_rectangle->width = (max_x - min_x) + 2;
-         focus_rectangle->height = (max_y - min_y) + 2;
+         focus_rectangle->x = min_x - focus_line_width;
+         focus_rectangle->y = min_y - focus_line_width;
+         focus_rectangle->width = (max_x - min_x) + 2 * focus_line_width;
+         focus_rectangle->height = (max_y - min_y) + 2 * focus_line_width;
        }
     }
 }
@@ -2270,15 +2347,15 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
  * @flags: flags that affect rendering
  * 
  * Renders the cell contained by #tree_column. This is used primarily by the
- * GtkTreeView.
+ * #GtkTreeView.
  **/
 void
-gtk_tree_view_column_cell_render (GtkTreeViewColumn *tree_column,
-                                 GdkWindow         *window,
-                                 GdkRectangle      *background_area,
-                                 GdkRectangle      *cell_area,
-                                 GdkRectangle      *expose_area,
-                                 guint              flags)
+_gtk_tree_view_column_cell_render (GtkTreeViewColumn *tree_column,
+                                  GdkWindow         *window,
+                                  GdkRectangle      *background_area,
+                                  GdkRectangle      *cell_area,
+                                  GdkRectangle      *expose_area,
+                                  guint              flags)
 {
   g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
   g_return_if_fail (background_area != NULL);
@@ -2345,8 +2422,8 @@ _gtk_tree_view_column_cell_event (GtkTreeViewColumn  *tree_column,
 
 
 gboolean
-gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
-                                gint               direction)
+_gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
+                                 gint               direction)
 {
   if (GTK_TREE_VIEW (tree_column->tree_view)->priv->focus_column == tree_column)
     return FALSE;
@@ -2354,29 +2431,35 @@ gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
 }
 
 void
-gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn       *tree_column,
-                                     GdkWindow               *window,
-                                     GdkRectangle            *background_area,
-                                     GdkRectangle            *cell_area,
-                                     GdkRectangle            *expose_area,
-                                     guint                    flags)
-{
+_gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn       *tree_column,
+                                      GdkWindow               *window,
+                                      GdkRectangle            *background_area,
+                                      GdkRectangle            *cell_area,
+                                      GdkRectangle            *expose_area,
+                                      guint                    flags)
+{
+  gint focus_line_width;
+  GtkStateType cell_state;
+  
   g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
+  gtk_widget_style_get (GTK_WIDGET (tree_column->tree_view),
+                       "focus-line-width", &focus_line_width, NULL);
   if (tree_column->editable_widget)
     {
       /* This function is only called on the editable row when editing.
        */
-
+#if 0
       gtk_paint_focus (tree_column->tree_view->style,
                       window,
+                      GTK_WIDGET_STATE (tree_column->tree_view),
                       NULL,
                       tree_column->tree_view,
                       "treeview",
-                      cell_area->x - 1,
-                      cell_area->y - 1,
-                      cell_area->width + 2 - 1,
-                      cell_area->height + 2 - 1);
-      
+                      cell_area->x - focus_line_width,
+                      cell_area->y - focus_line_width,
+                      cell_area->width + 2 * focus_line_width,
+                      cell_area->height + 2 * focus_line_width);
+#endif      
     }
   else
     {
@@ -2389,16 +2472,20 @@ gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn       *tree_column,
                                                 flags,
                                                 FALSE,
                                                 &focus_rectangle);
-      
+
+      cell_state = flags & GTK_CELL_RENDERER_SELECTED ? GTK_STATE_SELECTED :
+             (flags & GTK_CELL_RENDERER_PRELIT ? GTK_STATE_PRELIGHT :
+             (flags & GTK_CELL_RENDERER_INSENSITIVE ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL));
       gtk_paint_focus (tree_column->tree_view->style,
                       window,
+                      cell_state,
                       NULL,
                       tree_column->tree_view,
                       "treeview",
                       focus_rectangle.x,
                       focus_rectangle.y,
-                      focus_rectangle.width - 1,
-                      focus_rectangle.height - 1);
+                      focus_rectangle.width,
+                      focus_rectangle.height);
     }
 }
 
@@ -2410,11 +2497,8 @@ gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column)
   for (list = tree_column->cell_list; list; list = list->next)
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
-      gboolean visible;
-
-      g_object_get (G_OBJECT (info->cell), "visible", &visible, NULL);
 
-      if (visible)
+      if (info->cell->visible)
        return TRUE;
     }
 
@@ -2422,7 +2506,8 @@ gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column)
 }
 
 void
-gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column)
+_gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column,
+                                     gboolean           install_handler)
 {
   GList *list;
 
@@ -2433,9 +2518,19 @@ gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column)
       info->requested_width = 0;
     }
   tree_column->dirty = TRUE;
+  tree_column->resized_width = MAX (tree_column->requested_width, tree_column->button_request);
+  tree_column->requested_width = -1;
+  tree_column->width = 0;
 
-  if (tree_column->tree_view)
-    gtk_widget_queue_resize (tree_column->tree_view);
+  if (tree_column->tree_view &&
+      GTK_WIDGET_REALIZED (tree_column->tree_view))
+    {
+      if (install_handler)
+       _gtk_tree_view_install_mark_rows_col_dirty (GTK_TREE_VIEW (tree_column->tree_view));
+      else
+       GTK_TREE_VIEW (tree_column->tree_view)->priv->mark_rows_col_dirty = TRUE;
+      gtk_widget_queue_resize (tree_column->tree_view);
+    }
 }
 
 void