#include "gtkbutton.h"
#include "gtkalignment.h"
#include "gtklabel.h"
-#include "gtkhbox.h"
+#include "gtkbox.h"
#include "gtkmarshalers.h"
#include "gtkarrow.h"
#include "gtkcellareacontext.h"
#include "gtkcellareabox.h"
#include "gtkprivate.h"
#include "gtkintl.h"
+#include "gtktypebuiltins.h"
/**
GObjectConstructParam *construct_properties);
/* GtkCellLayout implementation */
+static void gtk_tree_view_column_ensure_cell_area (GtkTreeViewColumn *column,
+ GtkCellArea *cell_area);
+
static GtkCellArea *gtk_tree_view_column_cell_layout_get_area (GtkCellLayout *cell_layout);
/* Button handling code */
/* Sizing fields */
/* see gtk+/doc/tree-column-sizing.txt for more information on them */
GtkTreeViewColumnSizing column_type;
- gint requested_width;
+ gint padding;
gint resized_width;
+ gint x_offset;
gint width;
gint fixed_width;
gint min_width;
PROP_0,
PROP_VISIBLE,
PROP_RESIZABLE,
+ PROP_X_OFFSET,
PROP_WIDTH,
PROP_SPACING,
PROP_SIZING,
FALSE,
GTK_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_X_OFFSET,
+ g_param_spec_int ("x-offset",
+ P_("X position"),
+ P_("Current X position of the column"),
+ -G_MAXINT,
+ G_MAXINT,
+ 0,
+ GTK_PARAM_READABLE));
+
g_object_class_install_property (object_class,
PROP_WIDTH,
g_param_spec_int ("width",
*
* The #GtkCellArea used to layout cell renderers for this column.
*
+ * If no area is specified when creating the tree view column with gtk_tree_view_column_new_with_area()
+ * a horizontally oriented #GtkCellAreaBox will be used.
+ *
* Since: 3.0
*/
g_object_class_install_property (object_class,
priv->button = NULL;
priv->xalign = 0.0;
priv->width = 0;
- priv->requested_width = -1;
+ priv->padding = -1;
priv->min_width = -1;
priv->max_width = -1;
priv->resized_width = 0;
}
static GObject *
-gtk_tree_view_column_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+gtk_tree_view_column_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GtkTreeViewColumn *tree_column;
- GtkTreeViewColumnPrivate *priv;
GObject *object;
object = G_OBJECT_CLASS (gtk_tree_view_column_parent_class)->constructor
(type, n_construct_properties, construct_properties);
tree_column = (GtkTreeViewColumn *) object;
- priv = tree_column->priv;
-
- if (!priv->cell_area)
- {
- priv->cell_area = gtk_cell_area_box_new ();
- g_object_ref_sink (priv->cell_area);
- }
- gtk_cell_area_set_style_detail (priv->cell_area, "treeview");
-
- priv->add_editable_signal =
- g_signal_connect (priv->cell_area, "add-editable",
- G_CALLBACK (gtk_tree_view_column_add_editable_callback),
- tree_column);
- priv->remove_editable_signal =
- g_signal_connect (priv->cell_area, "remove-editable",
- G_CALLBACK (gtk_tree_view_column_remove_editable_callback),
- tree_column);
-
- priv->cell_area_context = gtk_cell_area_create_context (priv->cell_area);
-
- priv->context_changed_signal =
- g_signal_connect (priv->cell_area_context, "notify",
- G_CALLBACK (gtk_tree_view_column_context_changed), tree_column);
+ gtk_tree_view_column_ensure_cell_area (tree_column, NULL);
return object;
}
GtkTreeViewColumn *tree_column = (GtkTreeViewColumn *) object;
GtkTreeViewColumnPrivate *priv = tree_column->priv;
+ /* Remove this column from its treeview,
+ * in case this column is destroyed before its treeview.
+ */
+ if (priv->tree_view)
+ gtk_tree_view_remove_column (GTK_TREE_VIEW (priv->tree_view), tree_column);
+
if (priv->cell_area_context)
{
g_signal_handler_disconnect (priv->cell_area_context,
priv->add_editable_signal);
g_signal_handler_disconnect (priv->cell_area,
priv->remove_editable_signal);
-
+
g_object_unref (priv->cell_area);
priv->cell_area = NULL;
priv->add_editable_signal = 0;
area = g_value_get_object (value);
if (area)
- tree_column->priv->cell_area = g_object_ref_sink (area);
+ {
+ if (tree_column->priv->cell_area != NULL)
+ {
+ g_warning ("cell-area has already been set, ignoring construct property");
+ g_object_ref_sink (area);
+ g_object_unref (area);
+ }
+ else
+ gtk_tree_view_column_ensure_cell_area (tree_column, area);
+ }
break;
-
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
gtk_tree_view_column_get_resizable (tree_column));
break;
+ case PROP_X_OFFSET:
+ g_value_set_int (value,
+ gtk_tree_view_column_get_x_offset (tree_column));
+ break;
+
case PROP_WIDTH:
g_value_set_int (value,
gtk_tree_view_column_get_width (tree_column));
/* Implementation of GtkCellLayout interface
*/
+
+static void
+gtk_tree_view_column_ensure_cell_area (GtkTreeViewColumn *column,
+ GtkCellArea *cell_area)
+{
+ GtkTreeViewColumnPrivate *priv = column->priv;
+
+ if (priv->cell_area)
+ return;
+
+ if (cell_area)
+ priv->cell_area = cell_area;
+ else
+ priv->cell_area = gtk_cell_area_box_new ();
+
+ g_object_ref_sink (priv->cell_area);
+
+ priv->add_editable_signal =
+ g_signal_connect (priv->cell_area, "add-editable",
+ G_CALLBACK (gtk_tree_view_column_add_editable_callback),
+ column);
+ priv->remove_editable_signal =
+ g_signal_connect (priv->cell_area, "remove-editable",
+ G_CALLBACK (gtk_tree_view_column_remove_editable_callback),
+ column);
+
+ priv->cell_area_context = gtk_cell_area_create_context (priv->cell_area);
+
+ priv->context_changed_signal =
+ g_signal_connect (priv->cell_area_context, "notify",
+ G_CALLBACK (gtk_tree_view_column_context_changed),
+ column);
+}
+
static GtkCellArea *
gtk_tree_view_column_cell_layout_get_area (GtkCellLayout *cell_layout)
{
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (cell_layout);
GtkTreeViewColumnPrivate *priv = column->priv;
+ if (G_UNLIKELY (!priv->cell_area))
+ gtk_tree_view_column_ensure_cell_area (column, NULL);
+
return priv->cell_area;
}
{
if (priv->visible)
{
- gtk_widget_show_now (priv->button);
+ if (gdk_window_is_visible (_gtk_tree_view_get_header_window (GTK_TREE_VIEW (priv->tree_view))))
+ gtk_widget_show_now (priv->button);
+
if (priv->window)
{
if (priv->resizable)
GParamSpec *pspec,
GtkTreeViewColumn *tree_column)
{
+ /* Here we want the column re-requested if the underlying context was
+ * actually reset for any reason, this can happen if the underlying
+ * area/cell configuration changes (i.e. cell packing properties
+ * or cell spacing and the like)
+ *
+ * Note that we block this handler while requesting for sizes
+ * so there is no need to check for the new context size being -1,
+ * we also block the handler when explicitly resetting the context
+ * so as to avoid some infinite stack recursion.
+ */
if (!strcmp (pspec->name, "minimum-width") ||
!strcmp (pspec->name, "natural-width") ||
!strcmp (pspec->name, "minimum-height") ||
!strcmp (pspec->name, "natural-height"))
- {
- /* XXX We want to do something specific if the size actually got cleared
- * or if it just grew a little bit because of a data change and we
- * are in GROW_ONLY mode.
- */
- _gtk_tree_view_column_cell_set_dirty (tree_column, TRUE);
- }
+ _gtk_tree_view_column_cell_set_dirty (tree_column, TRUE);
}
static void
g_return_if_fail (_gtk_tree_view_get_header_window (tree_view) != NULL);
gtk_widget_set_parent_window (priv->button, _gtk_tree_view_get_header_window (tree_view));
- if (priv->visible)
- gtk_widget_show (priv->button);
-
attr.window_type = GDK_WINDOW_CHILD;
attr.wclass = GDK_INPUT_ONLY;
attr.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view));
gtk_tree_view_column_update_button (column);
- gdk_cursor_unref (attr.cursor);
+ g_object_unref (attr.cursor);
}
void
return gtk_cell_area_get_edited_cell (priv->cell_area);
}
+GtkCellRenderer *
+_gtk_tree_view_column_get_cell_at_pos (GtkTreeViewColumn *column,
+ GdkRectangle *cell_area,
+ GdkRectangle *background_area,
+ gint x,
+ gint y)
+{
+ GtkCellRenderer *match = NULL;
+ GtkTreeViewColumnPrivate *priv = column->priv;
+
+ /* If (x, y) is outside of the background area, immediately return */
+ if (x < background_area->x ||
+ x > background_area->x + background_area->width ||
+ y < background_area->y ||
+ y > background_area->y + background_area->height)
+ return NULL;
+
+ /* If (x, y) is inside the background area, clamp it to the cell_area
+ * so that a cell is still returned. The main reason for doing this
+ * (on the x axis) is for handling clicks in the indentation area
+ * (either at the left or right depending on RTL setting). Another
+ * reason is for handling clicks on the area where the focus rectangle
+ * is drawn (this is outside of cell area), this manifests itself
+ * mainly when a large setting is used for focus-line-width.
+ */
+ if (x < cell_area->x)
+ x = cell_area->x;
+ else if (x > cell_area->x + cell_area->width)
+ x = cell_area->x + cell_area->width;
+
+ if (y < cell_area->y)
+ y = cell_area->y;
+ else if (y > cell_area->y + cell_area->height)
+ y = cell_area->y + cell_area->height;
+
+ match = gtk_cell_area_get_cell_at_position (priv->cell_area,
+ priv->cell_area_context,
+ priv->tree_view,
+ cell_area,
+ x, y,
+ NULL);
+
+ return match;
+}
+
+gboolean
+_gtk_tree_view_column_is_blank_at_pos (GtkTreeViewColumn *column,
+ GdkRectangle *cell_area,
+ GdkRectangle *background_area,
+ gint x,
+ gint y)
+{
+ GtkCellRenderer *match;
+ GdkRectangle cell_alloc, aligned_area, inner_area;
+ GtkTreeViewColumnPrivate *priv = column->priv;
+
+ match = _gtk_tree_view_column_get_cell_at_pos (column,
+ cell_area,
+ background_area,
+ x, y);
+ if (!match)
+ return FALSE;
+
+ gtk_cell_area_get_cell_allocation (priv->cell_area,
+ priv->cell_area_context,
+ priv->tree_view,
+ match,
+ cell_area,
+ &cell_alloc);
+
+ gtk_cell_area_inner_cell_area (priv->cell_area, priv->tree_view,
+ &cell_alloc, &inner_area);
+ gtk_cell_renderer_get_aligned_area (match, priv->tree_view, 0,
+ &inner_area, &aligned_area);
+
+ if (x < aligned_area.x ||
+ x > aligned_area.x + aligned_area.width ||
+ y < aligned_area.y ||
+ y > aligned_area.y + aligned_area.height)
+ return TRUE;
+
+ return FALSE;
+}
+
/* Public Functions */
}
/**
- * 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.
+ * gtk_tree_view_column_new_with_area:
+ * @area: the #GtkCellArea that the newly created column should use to layout cells.
+ *
+ * Creates a new #GtkTreeViewColumn using @area to render its cells.
*
- * Creates a new #GtkTreeViewColumn with a number of default values. This is
- * equivalent to calling gtk_tree_view_column_set_title(),
+ * Return value: A newly created #GtkTreeViewColumn.
+ *
+ * Since: 3.0
+ */
+GtkTreeViewColumn *
+gtk_tree_view_column_new_with_area (GtkCellArea *area)
+{
+ GtkTreeViewColumn *tree_column;
+
+ tree_column = g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, "cell-area", area, NULL);
+
+ return tree_column;
+}
+
+
+/**
+ * gtk_tree_view_column_new_with_attributes:
+ * @title: The title to set the header to
+ * @cell: The #GtkCellRenderer
+ * @...: 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.
*
/**
* gtk_tree_view_column_set_attributes:
- * @tree_column: A #GtkTreeViewColumn.
+ * @tree_column: A #GtkTreeViewColumn
* @cell_renderer: the #GtkCellRenderer we're setting the attributes of
- * @Varargs: A %NULL-terminated list of attributes.
- *
+ * @...: 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
* are removed, and replaced with the new attributes.
- **/
+ */
void
gtk_tree_view_column_set_attributes (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer,
* gtk_tree_view_column_set_cell_data_func:
* @tree_column: A #GtkTreeViewColumn
* @cell_renderer: A #GtkCellRenderer
- * @func: The #GtkTreeViewColumnFunc to use.
+ * @func: (allow-none): The #GtkTreeViewColumnFunc to use.
* @func_data: The user data for @func.
* @destroy: The destroy notification for @func_data
*
* @visible: %TRUE if the @tree_column is visible.
*
* Sets the visibility of @tree_column.
- **/
+ */
void
gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column,
- gboolean visible)
+ gboolean visible)
{
GtkTreeViewColumnPrivate *priv;
priv = tree_column->priv;
visible = !! visible;
-
+
if (priv->visible == visible)
return;
if (priv->visible)
_gtk_tree_view_column_cell_set_dirty (tree_column, TRUE);
+ if (priv->tree_view)
+ _gtk_tree_view_reset_header_styles (GTK_TREE_VIEW (priv->tree_view));
+
gtk_tree_view_column_update_button (tree_column);
g_object_notify (G_OBJECT (tree_column), "visible");
}
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 (priv->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE &&
- priv->requested_width != -1)
- {
- gtk_tree_view_column_set_sizing (tree_column, priv->requested_width);
- }
-#endif
priv->column_type = type;
gtk_tree_view_column_update_button (tree_column);
return tree_column->priv->width;
}
+/**
+ * gtk_tree_view_column_get_x_offset:
+ * @tree_column: A #GtkTreeViewColumn.
+ *
+ * Returns the current X offset of @tree_column in pixels.
+ *
+ * Return value: The current X offset of @tree_column.
+ *
+ * Since: 3.2
+ */
+gint
+gtk_tree_view_column_get_x_offset (GtkTreeViewColumn *tree_column)
+{
+ g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), 0);
+
+ return tree_column->priv->x_offset;
+}
+
gint
_gtk_tree_view_column_request_width (GtkTreeViewColumn *tree_column)
{
else if (gtk_tree_view_get_headers_visible (GTK_TREE_VIEW (priv->tree_view)))
{
gint button_request;
+ gint requested_width;
+
+ gtk_cell_area_context_get_preferred_width (priv->cell_area_context, &requested_width, NULL);
+ requested_width += priv->padding;
gtk_widget_get_preferred_width (priv->button, &button_request, NULL);
- real_requested_width = MAX (priv->requested_width, button_request);
+ real_requested_width = MAX (requested_width, button_request);
}
else
{
- real_requested_width = priv->requested_width;
+ gint requested_width;
+
+ gtk_cell_area_context_get_preferred_width (priv->cell_area_context, &requested_width, NULL);
+ requested_width += priv->padding;
+
+ real_requested_width = requested_width;
if (real_requested_width < 0)
real_requested_width = 0;
}
void
_gtk_tree_view_column_allocate (GtkTreeViewColumn *tree_column,
int x_offset,
- int width,
- int cell_width)
+ int width)
{
GtkTreeViewColumnPrivate *priv;
- GtkAllocation allocation;
gboolean rtl;
+ GtkAllocation allocation = { 0, 0, 0, 0 };
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
priv = tree_column->priv;
+ if (priv->width != width)
+ gtk_widget_queue_draw (priv->tree_view);
+
+ priv->x_offset = x_offset;
priv->width = width;
- gtk_cell_area_context_allocate (priv->cell_area_context, cell_width, -1);
+ gtk_cell_area_context_allocate (priv->cell_area_context, priv->width - priv->padding, -1);
- allocation.x = x_offset;
- allocation.y = 0;
- allocation.width = width;
- allocation.height = _gtk_tree_view_get_header_height (GTK_TREE_VIEW (priv->tree_view));
+ if (gtk_tree_view_get_headers_visible (GTK_TREE_VIEW (priv->tree_view)))
+ {
+ allocation.x = x_offset;
+ allocation.y = 0;
+ allocation.width = width;
+ allocation.height = _gtk_tree_view_get_header_height (GTK_TREE_VIEW (priv->tree_view));
- gtk_widget_size_allocate (priv->button, &allocation);
+ gtk_widget_size_allocate (priv->button, &allocation);
+ }
if (priv->window)
{
TREE_VIEW_DRAG_WIDTH, allocation.height);
}
+ g_object_notify (G_OBJECT (tree_column), "x-offset");
g_object_notify (G_OBJECT (tree_column), "width");
}
* Return value: the title of the column. This string should not be
* modified or freed.
**/
-G_CONST_RETURN gchar *
+const gchar *
gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column)
{
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), NULL);
* gtk_tree_view_column_cell_get_size:
* @tree_column: A #GtkTreeViewColumn.
* @cell_area: (allow-none): The area a cell in the column will be allocated, or %NULL
- * @x_offset: (allow-none): location to return x offset of a cell relative to @cell_area, or %NULL
- * @y_offset: (allow-none): location to return y offset of a cell relative to @cell_area, or %NULL
- * @width: (allow-none): location to return width needed to render a cell, or %NULL
- * @height: (allow-none): location to return height needed to render a cell, or %NULL
+ * @x_offset: (out) (allow-none): location to return x offset of a cell relative to @cell_area, or %NULL
+ * @y_offset: (out) (allow-none): location to return y offset of a cell relative to @cell_area, or %NULL
+ * @width: (out) (allow-none): location to return width needed to render a cell, or %NULL
+ * @height: (out) (allow-none): 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.
gboolean
_gtk_tree_view_column_cell_event (GtkTreeViewColumn *tree_column,
- GtkCellEditable **editable_widget,
GdkEvent *event,
- gchar *path_string,
- const GdkRectangle *background_area,
const GdkRectangle *cell_area,
guint flags)
{
priv = tree_column->priv;
- /* FIXME: Should we pass background area here as well?
- * What will happen to the path_string and editable widget
- * variables?
- *
- * Answer, No dont pass background area... editable widgets
- * grab the pointer and keyboard so the treeview doesnt
- * recieve these events while editable widgets are editing.
- *
- * Also it's important that gtk_cell_area_apply_attributes be
- * called before passing the event to the cell (maybe we need to
- * instead use the path_string here to apply the attributes ?,
- * if the attributes are applied, the underlying CellArea knows
- * the path string, which is expected when handling events).
- */
return gtk_cell_area_event (priv->cell_area,
priv->cell_area_context,
priv->tree_view,
flags);
}
-void
-_gtk_tree_view_column_get_focus_area (GtkTreeViewColumn *tree_column,
- const GdkRectangle *background_area,
- const GdkRectangle *cell_area,
- GdkRectangle *focus_area)
-{
- /* FIXME */
-#if 0
- gtk_tree_view_column_cell_process_action (tree_column,
- NULL,
- background_area,
- cell_area,
- 0,
- CELL_ACTION_FOCUS,
- focus_area,
- NULL, NULL, NULL);
-#endif
-}
-
-
-gboolean
-_gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
- gint count,
- gboolean left,
- gboolean right)
-{
- gboolean rtl;
- GtkDirectionType direction = 0;
- GtkTreeViewColumnPrivate *priv = tree_column->priv;
-
- rtl = gtk_widget_get_direction (priv->tree_view) == GTK_TEXT_DIR_RTL;
-
- switch (count)
- {
- case -1:
- direction = GTK_DIR_LEFT;
- break;
-
- case 1:
- direction = GTK_DIR_RIGHT;
- break;
- }
-
- /* 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_get_focus_column (GTK_TREE_VIEW (priv->tree_view)) == tree_column)
- {
- if (gtk_cell_area_focus (priv->cell_area, direction))
- /* Focus stays in this column, so we are done */
- return TRUE;
-
- /* FIXME: RTL support for the following: */
- if (count == -1 && !left)
- {
- direction = GTK_DIR_RIGHT;
- gtk_cell_area_focus (priv->cell_area, direction);
- }
- else if (count == 1 && !right)
- {
- direction = GTK_DIR_LEFT;
- gtk_cell_area_focus (priv->cell_area, direction);
- }
-
- return FALSE;
- }
-
- return gtk_cell_area_focus (priv->cell_area, direction);
-}
-
/**
* gtk_tree_view_column_cell_is_visible:
* @tree_column: A #GtkTreeViewColumn
GtkTreeViewColumnPrivate *priv = tree_column->priv;
priv->dirty = TRUE;
- priv->requested_width = -1;
+ priv->padding = 0;
priv->width = 0;
+ /* Issue a manual reset on the context to have all
+ * sizes re-requested for the context.
+ */
+ g_signal_handler_block (priv->cell_area_context,
+ priv->context_changed_signal);
+ gtk_cell_area_context_reset (priv->cell_area_context);
+ g_signal_handler_unblock (priv->cell_area_context,
+ priv->context_changed_signal);
+
if (priv->tree_view &&
gtk_widget_get_realized (priv->tree_view))
{
* gtk_tree_view_column_cell_get_position:
* @tree_column: a #GtkTreeViewColumn
* @cell_renderer: a #GtkCellRenderer
- * @start_pos: return location for the horizontal position of @cell within
- * @tree_column, may be %NULL
- * @width: return location for the width of @cell, may be %NULL
+ * @x_offset: (out) (allow-none): return location for the horizontal
+ * position of @cell within @tree_column, may be %NULL
+ * @width: (out) (allow-none): return location for the width of @cell,
+ * may be %NULL
*
* Obtains the horizontal position and size of a cell in a column. If the
* cell is not found in the column, @start_pos and @width are not changed and
gboolean
gtk_tree_view_column_cell_get_position (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer,
- gint *start_pos,
+ gint *x_offset,
gint *width)
{
GtkTreeViewColumnPrivate *priv;
- GdkRectangle zero_cell_area = { 0, };
+ GdkRectangle cell_area;
GdkRectangle allocation;
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), FALSE);
priv = tree_column->priv;
- /* FIXME: Could use a boolean return value for invalid cells */
+ if (! gtk_cell_area_has_renderer (priv->cell_area, cell_renderer))
+ return FALSE;
+
+ gtk_tree_view_get_background_area (GTK_TREE_VIEW (priv->tree_view),
+ NULL, tree_column, &cell_area);
+
gtk_cell_area_get_cell_allocation (priv->cell_area,
priv->cell_area_context,
priv->tree_view,
cell_renderer,
- &zero_cell_area,
+ &cell_area,
&allocation);
- if (start_pos)
- *start_pos = allocation.x;
+ if (x_offset)
+ *x_offset = allocation.x - cell_area.x;
+
if (width)
*width = allocation.width;
}
void
-_gtk_tree_view_column_set_requested_width (GtkTreeViewColumn *column,
- gint width)
+_gtk_tree_view_column_push_padding (GtkTreeViewColumn *column,
+ gint padding)
{
- column->priv->requested_width = width;
+ column->priv->padding = MAX (column->priv->padding, padding);
}
gint
_gtk_tree_view_column_get_requested_width (GtkTreeViewColumn *column)
{
- return column->priv->requested_width;
+ gint requested_width;
+
+ gtk_cell_area_context_get_preferred_width (column->priv->cell_area_context, &requested_width, NULL);
+
+ return requested_width + column->priv->padding;
}
+
void
_gtk_tree_view_column_set_resized_width (GtkTreeViewColumn *column,
gint width)