#include "config.h"
#include "gtkcellrenderer.h"
+#include "gtkcellsizerequest.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtktreeprivate.h"
-#include "gtkalias.h"
+
+static void gtk_cell_renderer_init (GtkCellRenderer *cell);
+static void gtk_cell_renderer_class_init (GtkCellRendererClass *class);
static void gtk_cell_renderer_get_property (GObject *object,
guint param_id,
GValue *value,
static void set_cell_bg_color (GtkCellRenderer *cell,
GdkColor *color);
+/* Fallback GtkCellSizeRequest implementation to use remaining ->get_size() implementations */
+static void gtk_cell_renderer_cell_size_request_init (GtkCellSizeRequestIface *iface);
+static void gtk_cell_renderer_get_width (GtkCellSizeRequest *cell,
+ GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_cell_renderer_get_height (GtkCellSizeRequest *cell,
+ GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_cell_renderer_get_height_for_width (GtkCellSizeRequest *cell,
+ GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+static void gtk_cell_renderer_get_width_for_height (GtkCellSizeRequest *cell,
+ GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+
-#define GTK_CELL_RENDERER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_RENDERER, GtkCellRendererPrivate))
-typedef struct _GtkCellRendererPrivate GtkCellRendererPrivate;
struct _GtkCellRendererPrivate
{
+ gfloat xalign;
+ gfloat yalign;
+
+ gint width;
+ gint height;
+
+ guint16 xpad;
+ guint16 ypad;
+
+ guint mode : 2;
+ guint visible : 1;
+ guint is_expander : 1;
+ guint is_expanded : 1;
+ guint cell_background_set : 1;
+ guint sensitive : 1;
+ guint editing : 1;
+
GdkColor cell_background;
};
LAST_SIGNAL
};
-static guint cell_renderer_signals[LAST_SIGNAL] = { 0 };
+static guint cell_renderer_signals[LAST_SIGNAL] = { 0 };
+
+
+/* Do a manual _get_type() here to avoid a deadlock implementing
+ * the interface which we are a prerequisite of.
+ */
+GType
+gtk_cell_renderer_get_type (void)
+{
+ static GType cell_renderer_type = 0;
+
+ if (G_UNLIKELY (cell_renderer_type == 0))
+ {
+ const GTypeInfo cell_renderer_info =
+ {
+ sizeof (GtkCellRendererClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_cell_renderer_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_init */
+ sizeof (GtkCellRenderer),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_cell_renderer_init,
+ NULL, /* value_table */
+ };
+
+ const GInterfaceInfo cell_size_request_info =
+ {
+ (GInterfaceInitFunc) gtk_cell_renderer_cell_size_request_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL /* interface data */
+ };
+
+ cell_renderer_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkCellRenderer",
+ &cell_renderer_info, G_TYPE_FLAG_ABSTRACT);
+
+ g_type_add_interface_static (cell_renderer_type, GTK_TYPE_CELL_SIZE_REQUEST,
+ &cell_size_request_info) ;
+ }
+
+ return cell_renderer_type;
+}
-G_DEFINE_ABSTRACT_TYPE (GtkCellRenderer, gtk_cell_renderer, GTK_TYPE_OBJECT)
static void
gtk_cell_renderer_init (GtkCellRenderer *cell)
{
- cell->mode = GTK_CELL_RENDERER_MODE_INERT;
- cell->visible = TRUE;
- cell->width = -1;
- cell->height = -1;
- cell->xalign = 0.5;
- cell->yalign = 0.5;
- cell->xpad = 0;
- cell->ypad = 0;
- cell->sensitive = TRUE;
- cell->is_expander = FALSE;
- cell->is_expanded = FALSE;
- cell->editing = FALSE;
+ GtkCellRendererPrivate *priv;
+
+ cell->priv = G_TYPE_INSTANCE_GET_PRIVATE (cell,
+ GTK_TYPE_CELL_RENDERER,
+ GtkCellRendererPrivate);
+ priv = cell->priv;
+
+ priv->mode = GTK_CELL_RENDERER_MODE_INERT;
+ priv->visible = TRUE;
+ priv->width = -1;
+ priv->height = -1;
+ priv->xalign = 0.5;
+ priv->yalign = 0.5;
+ priv->xpad = 0;
+ priv->ypad = 0;
+ priv->sensitive = TRUE;
+ priv->is_expander = FALSE;
+ priv->is_expanded = FALSE;
+ priv->editing = FALSE;
}
static void
* @path: the path identifying the edited cell
*
* This signal gets emitted when a cell starts to be edited.
- * The indended use of this signal is to do special setup
+ * The intended use of this signal is to do special setup
* on @editable, e.g. adding a #GtkEntryCompletion or setting
* up additional columns in a #GtkComboBox.
*
P_("Cell background set"),
P_("Whether this tag affects the cell background color"));
- g_type_class_add_private (object_class, sizeof (GtkCellRendererPrivate));
+ g_type_class_add_private (class, sizeof (GtkCellRendererPrivate));
}
static void
GParamSpec *pspec)
{
GtkCellRenderer *cell = GTK_CELL_RENDERER (object);
- GtkCellRendererPrivate *priv = GTK_CELL_RENDERER_GET_PRIVATE (object);
+ GtkCellRendererPrivate *priv = cell->priv;
switch (param_id)
{
case PROP_MODE:
- g_value_set_enum (value, cell->mode);
+ g_value_set_enum (value, priv->mode);
break;
case PROP_VISIBLE:
- g_value_set_boolean (value, cell->visible);
+ g_value_set_boolean (value, priv->visible);
break;
case PROP_SENSITIVE:
- g_value_set_boolean (value, cell->sensitive);
+ g_value_set_boolean (value, priv->sensitive);
break;
case PROP_EDITING:
- g_value_set_boolean (value, cell->editing);
+ g_value_set_boolean (value, priv->editing);
break;
case PROP_XALIGN:
- g_value_set_float (value, cell->xalign);
+ g_value_set_float (value, priv->xalign);
break;
case PROP_YALIGN:
- g_value_set_float (value, cell->yalign);
+ g_value_set_float (value, priv->yalign);
break;
case PROP_XPAD:
- g_value_set_uint (value, cell->xpad);
+ g_value_set_uint (value, priv->xpad);
break;
case PROP_YPAD:
- g_value_set_uint (value, cell->ypad);
+ g_value_set_uint (value, priv->ypad);
break;
case PROP_WIDTH:
- g_value_set_int (value, cell->width);
+ g_value_set_int (value, priv->width);
break;
case PROP_HEIGHT:
- g_value_set_int (value, cell->height);
+ g_value_set_int (value, priv->height);
break;
case PROP_IS_EXPANDER:
- g_value_set_boolean (value, cell->is_expander);
+ g_value_set_boolean (value, priv->is_expander);
break;
case PROP_IS_EXPANDED:
- g_value_set_boolean (value, cell->is_expanded);
+ g_value_set_boolean (value, priv->is_expanded);
break;
case PROP_CELL_BACKGROUND_GDK:
{
}
break;
case PROP_CELL_BACKGROUND_SET:
- g_value_set_boolean (value, cell->cell_background_set);
+ g_value_set_boolean (value, priv->cell_background_set);
break;
case PROP_CELL_BACKGROUND:
default:
GParamSpec *pspec)
{
GtkCellRenderer *cell = GTK_CELL_RENDERER (object);
+ GtkCellRendererPrivate *priv = cell->priv;
switch (param_id)
{
case PROP_MODE:
- cell->mode = g_value_get_enum (value);
+ priv->mode = g_value_get_enum (value);
break;
case PROP_VISIBLE:
- cell->visible = g_value_get_boolean (value);
+ priv->visible = g_value_get_boolean (value);
break;
case PROP_SENSITIVE:
- cell->sensitive = g_value_get_boolean (value);
+ priv->sensitive = g_value_get_boolean (value);
break;
case PROP_EDITING:
- cell->editing = g_value_get_boolean (value);
+ priv->editing = g_value_get_boolean (value);
break;
case PROP_XALIGN:
- cell->xalign = g_value_get_float (value);
+ priv->xalign = g_value_get_float (value);
break;
case PROP_YALIGN:
- cell->yalign = g_value_get_float (value);
+ priv->yalign = g_value_get_float (value);
break;
case PROP_XPAD:
- cell->xpad = g_value_get_uint (value);
+ priv->xpad = g_value_get_uint (value);
break;
case PROP_YPAD:
- cell->ypad = g_value_get_uint (value);
+ priv->ypad = g_value_get_uint (value);
break;
case PROP_WIDTH:
- cell->width = g_value_get_int (value);
+ priv->width = g_value_get_int (value);
break;
case PROP_HEIGHT:
- cell->height = g_value_get_int (value);
+ priv->height = g_value_get_int (value);
break;
case PROP_IS_EXPANDER:
- cell->is_expander = g_value_get_boolean (value);
+ priv->is_expander = g_value_get_boolean (value);
break;
case PROP_IS_EXPANDED:
- cell->is_expanded = g_value_get_boolean (value);
+ priv->is_expanded = g_value_get_boolean (value);
break;
case PROP_CELL_BACKGROUND:
{
set_cell_bg_color (cell, g_value_get_boxed (value));
break;
case PROP_CELL_BACKGROUND_SET:
- cell->cell_background_set = g_value_get_boolean (value);
+ priv->cell_background_set = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
set_cell_bg_color (GtkCellRenderer *cell,
GdkColor *color)
{
- GtkCellRendererPrivate *priv = GTK_CELL_RENDERER_GET_PRIVATE (cell);
+ GtkCellRendererPrivate *priv = cell->priv;
if (color)
{
- if (!cell->cell_background_set)
+ if (!priv->cell_background_set)
{
- cell->cell_background_set = TRUE;
+ priv->cell_background_set = TRUE;
g_object_notify (G_OBJECT (cell), "cell-background-set");
}
}
else
{
- if (cell->cell_background_set)
+ if (priv->cell_background_set)
{
- cell->cell_background_set = FALSE;
+ priv->cell_background_set = FALSE;
g_object_notify (G_OBJECT (cell), "cell-background-set");
}
}
* gtk_cell_renderer_get_size:
* @cell: a #GtkCellRenderer
* @widget: the widget the renderer is rendering to
- * @cell_area: The area a cell 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
+ * @cell_area: (allow-none): The area a cell will be allocated, or %NULL
+ * @x_offset: (allow-none): location to return x offset of cell relative to @cell_area, or %NULL
+ * @y_offset: (allow-none): location to return y offset of 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
*
* Obtains the width and height needed to render the cell. Used by view
* widgets to determine the appropriate size for the cell_area passed to
*
* Please note that the values set in @width and @height, as well as those
* in @x_offset and @y_offset are inclusive of the xpad and ypad properties.
+ *
+ *
+ * Deprecated: 3.0: Use gtk_cell_size_request_get_size() instead.
**/
void
gtk_cell_renderer_get_size (GtkCellRenderer *cell,
gint *width,
gint *height)
{
- gint *real_width = width;
- gint *real_height = height;
+ GtkRequisition request;
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
- g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size != NULL);
- if (width && cell->width != -1)
- {
- real_width = NULL;
- *width = cell->width;
- }
- if (height && cell->height != -1)
- {
- real_height = NULL;
- *height = cell->height;
- }
+ gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (cell),
+ widget, &request, NULL);
- GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell,
- widget,
- (GdkRectangle *) cell_area,
- x_offset,
- y_offset,
- real_width,
- real_height);
+ if (width)
+ *width = request.width;
+
+ if (height)
+ *height = request.height;
+
+ if (cell_area)
+ _gtk_cell_renderer_calc_offset (cell, cell_area, gtk_widget_get_direction (widget),
+ request.width, request.height, x_offset, y_offset);
}
/**
GtkCellRendererState flags)
{
gboolean selected = FALSE;
- GtkCellRendererPrivate *priv = GTK_CELL_RENDERER_GET_PRIVATE (cell);
+ GtkCellRendererPrivate *priv = cell->priv;
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL);
selected = (flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED;
- if (cell->cell_background_set && !selected)
+ if (priv->cell_background_set && !selected)
{
cairo_t *cr = gdk_cairo_create (window);
const GdkRectangle *cell_area,
GtkCellRendererState flags)
{
+ GtkCellRendererPrivate *priv;
+
g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE);
- if (cell->mode != GTK_CELL_RENDERER_MODE_ACTIVATABLE)
+ priv = cell->priv;
+
+ if (priv->mode != GTK_CELL_RENDERER_MODE_ACTIVATABLE)
return FALSE;
if (GTK_CELL_RENDERER_GET_CLASS (cell)->activate == NULL)
GtkCellRendererState flags)
{
+ GtkCellRendererPrivate *priv;
GtkCellEditable *editable;
g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), NULL);
- if (cell->mode != GTK_CELL_RENDERER_MODE_EDITABLE)
+ priv = cell->priv;
+
+ if (priv->mode != GTK_CELL_RENDERER_MODE_EDITABLE)
return NULL;
if (GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing == NULL)
cell_renderer_signals[EDITING_STARTED], 0,
editable, path);
- cell->editing = TRUE;
+ priv->editing = TRUE;
return editable;
}
gint width,
gint height)
{
+ GtkCellRendererPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (width >= -1 && height >= -1);
- if ((width != cell->width) || (height != cell->height))
+ priv = cell->priv;
+
+ if ((width != priv->width) || (height != priv->height))
{
g_object_freeze_notify (G_OBJECT (cell));
- if (width != cell->width)
+ if (width != priv->width)
{
- cell->width = width;
+ priv->width = width;
g_object_notify (G_OBJECT (cell), "width");
}
- if (height != cell->height)
+ if (height != priv->height)
{
- cell->height = height;
+ priv->height = height;
g_object_notify (G_OBJECT (cell), "height");
}
/**
* gtk_cell_renderer_get_fixed_size:
* @cell: A #GtkCellRenderer
- * @width: location to fill in with the fixed width of the cell, or %NULL
- * @height: location to fill in with the fixed height of the cell, or %NULL
+ * @width: (allow-none): location to fill in with the fixed width of the cell, or %NULL
+ * @height: (allow-none): location to fill in with the fixed height of the cell, or %NULL
*
* Fills in @width and @height with the appropriate size of @cell.
**/
gint *width,
gint *height)
{
+ GtkCellRendererPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+ priv = cell->priv;
+
if (width)
- *width = cell->width;
+ *width = priv->width;
if (height)
- *height = cell->height;
+ *height = priv->height;
}
/**
gfloat xalign,
gfloat yalign)
{
+ GtkCellRendererPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (xalign >= 0.0 && xalign <= 1.0);
g_return_if_fail (yalign >= 0.0 && yalign <= 1.0);
- if ((xalign != cell->xalign) || (yalign != cell->yalign))
+ priv = cell->priv;
+
+ if ((xalign != priv->xalign) || (yalign != priv->yalign))
{
g_object_freeze_notify (G_OBJECT (cell));
- if (xalign != cell->xalign)
+ if (xalign != priv->xalign)
{
- cell->xalign = xalign;
+ priv->xalign = xalign;
g_object_notify (G_OBJECT (cell), "xalign");
}
- if (yalign != cell->yalign)
+ if (yalign != priv->yalign)
{
- cell->yalign = yalign;
+ priv->yalign = yalign;
g_object_notify (G_OBJECT (cell), "yalign");
}
/**
* gtk_cell_renderer_get_alignment:
* @cell: A #GtkCellRenderer
- * @xalign: location to fill in with the x alignment of the cell, or %NULL
- * @yalign: location to fill in with the y alignment of the cell, or %NULL
+ * @xalign: (allow-none): location to fill in with the x alignment of the cell, or %NULL
+ * @yalign: (allow-none): location to fill in with the y alignment of the cell, or %NULL
*
* Fills in @xalign and @yalign with the appropriate values of @cell.
*
gfloat *xalign,
gfloat *yalign)
{
+ GtkCellRendererPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+ priv = cell->priv;
+
if (xalign)
- *xalign = cell->xalign;
+ *xalign = priv->xalign;
if (yalign)
- *yalign = cell->yalign;
+ *yalign = priv->yalign;
}
/**
gint xpad,
gint ypad)
{
+ GtkCellRendererPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (xpad >= 0 && xpad >= 0);
- if ((xpad != cell->xpad) || (ypad != cell->ypad))
+ priv = cell->priv;
+
+ if ((xpad != priv->xpad) || (ypad != priv->ypad))
{
g_object_freeze_notify (G_OBJECT (cell));
- if (xpad != cell->xpad)
+ if (xpad != priv->xpad)
{
- cell->xpad = xpad;
+ priv->xpad = xpad;
g_object_notify (G_OBJECT (cell), "xpad");
}
- if (ypad != cell->ypad)
+ if (ypad != priv->ypad)
{
- cell->ypad = ypad;
+ priv->ypad = ypad;
g_object_notify (G_OBJECT (cell), "ypad");
}
/**
* gtk_cell_renderer_get_padding:
* @cell: A #GtkCellRenderer
- * @xpad: location to fill in with the x padding of the cell, or %NULL
- * @ypad: location to fill in with the y padding of the cell, or %NULL
+ * @xpad: (allow-none): location to fill in with the x padding of the cell, or %NULL
+ * @ypad: (allow-none): location to fill in with the y padding of the cell, or %NULL
*
* Fills in @xpad and @ypad with the appropriate values of @cell.
*
gint *xpad,
gint *ypad)
{
+ GtkCellRendererPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+ priv = cell->priv;
+
if (xpad)
- *xpad = cell->xpad;
+ *xpad = priv->xpad;
if (ypad)
- *ypad = cell->ypad;
+ *ypad = priv->ypad;
}
/**
gtk_cell_renderer_set_visible (GtkCellRenderer *cell,
gboolean visible)
{
+ GtkCellRendererPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
- if (cell->visible != visible)
+ priv = cell->priv;
+
+ if (priv->visible != visible)
{
- cell->visible = visible ? TRUE : FALSE;
+ priv->visible = visible ? TRUE : FALSE;
g_object_notify (G_OBJECT (cell), "visible");
}
}
*
* Returns the cell renderer's visibility.
*
+ * Returns: %TRUE if the cell renderer is visible
+ *
* Since: 2.18
- **/
+ */
gboolean
-gtk_cell_renderer_get_visible (GtkCellRenderer *cell)
+gtk_cell_renderer_get_visible (GtkCellRenderer *cell)
{
g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE);
- return cell->visible;
+ return cell->priv->visible;
}
/**
gtk_cell_renderer_set_sensitive (GtkCellRenderer *cell,
gboolean sensitive)
{
+ GtkCellRendererPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
- if (cell->sensitive != sensitive)
+ priv = cell->priv;
+
+ if (priv->sensitive != sensitive)
{
- cell->sensitive = sensitive ? TRUE : FALSE;
+ priv->sensitive = sensitive ? TRUE : FALSE;
g_object_notify (G_OBJECT (cell), "sensitive");
}
}
*
* Returns the cell renderer's sensitivity.
*
+ * Returns: %TRUE if the cell renderer is sensitive
+ *
* Since: 2.18
- **/
+ */
gboolean
-gtk_cell_renderer_get_sensitive (GtkCellRenderer *cell)
+gtk_cell_renderer_get_sensitive (GtkCellRenderer *cell)
{
g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE);
- return cell->sensitive;
-}
-
-/**
- * gtk_cell_renderer_editing_canceled:
- * @cell: A #GtkCellRenderer
- *
- * Causes the cell renderer to emit the #GtkCellRenderer::editing-canceled
- * signal.
- *
- * This function is for use only by implementations of cell renderers that
- * need to notify the client program that an editing process was canceled
- * and the changes were not committed.
- *
- * Since: 2.4
- * Deprecated: 2.6: Use gtk_cell_renderer_stop_editing() instead
- **/
-void
-gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell)
-{
- g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
-
- gtk_cell_renderer_stop_editing (cell, TRUE);
+ return cell->priv->sensitive;
}
/**
gtk_cell_renderer_stop_editing (GtkCellRenderer *cell,
gboolean canceled)
{
+ GtkCellRendererPrivate *priv;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
- if (cell->editing)
+ priv = cell->priv;
+
+ if (priv->editing)
{
- cell->editing = FALSE;
+ priv->editing = FALSE;
if (canceled)
g_signal_emit (cell, cell_renderer_signals[EDITING_CANCELED], 0);
}
}
-#define __GTK_CELL_RENDERER_C__
-#include "gtkaliasdef.c"
+static void
+gtk_cell_renderer_cell_size_request_init (GtkCellSizeRequestIface *iface)
+{
+ iface->get_width = gtk_cell_renderer_get_width;
+ iface->get_height = gtk_cell_renderer_get_height;
+
+ iface->get_width_for_height = gtk_cell_renderer_get_width_for_height;
+ iface->get_height_for_width = gtk_cell_renderer_get_height_for_width;
+}
+
+static void
+gtk_cell_renderer_get_desired_size (GtkCellSizeRequest *cell,
+ GtkWidget *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ GtkRequisition min_req;
+
+ /* Fallback on the old API to get the size. */
+ if (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size)
+ GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (GTK_CELL_RENDERER (cell), widget, NULL, NULL, NULL,
+ &min_req.width, &min_req.height);
+ else
+ {
+ min_req.width = 0;
+ min_req.height = 0;
+ }
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ if (minimum_size)
+ *minimum_size = min_req.width;
+
+ if (natural_size)
+ *natural_size = min_req.width;
+ }
+ else
+ {
+ if (minimum_size)
+ *minimum_size = min_req.height;
+
+ if (natural_size)
+ *natural_size = min_req.height;
+ }
+}
+
+static void
+gtk_cell_renderer_get_width (GtkCellSizeRequest *cell,
+ GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ gtk_cell_renderer_get_desired_size (cell, widget, GTK_ORIENTATION_HORIZONTAL,
+ minimum_size, natural_size);
+}
+
+static void
+gtk_cell_renderer_get_height (GtkCellSizeRequest *cell,
+ GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ gtk_cell_renderer_get_desired_size (cell, widget, GTK_ORIENTATION_VERTICAL,
+ minimum_size, natural_size);
+}
+
+
+static void
+gtk_cell_renderer_get_height_for_width (GtkCellSizeRequest *cell,
+ GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ /* Fall back on the height reported from ->get_size() */
+ gtk_cell_size_request_get_height (cell, widget, minimum_height, natural_height);
+}
+
+static void
+gtk_cell_renderer_get_width_for_height (GtkCellSizeRequest *cell,
+ GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ /* Fall back on the width reported from ->get_size() */
+ gtk_cell_size_request_get_width (cell, widget, minimum_width, natural_width);
+}
+
+/* An internal convenience function for some containers to peek at the
+ * cell alignment in a target allocation (used to draw focus and align
+ * cells in the icon view).
+ *
+ * Note this is only a trivial 'align * (allocation - request)' operation.
+ */
+void
+_gtk_cell_renderer_calc_offset (GtkCellRenderer *cell,
+ const GdkRectangle *cell_area,
+ GtkTextDirection direction,
+ gint width,
+ gint height,
+ gint *x_offset,
+ gint *y_offset)
+{
+ GtkCellRendererPrivate *priv;
+
+ g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+ g_return_if_fail (cell_area != NULL);
+ g_return_if_fail (x_offset || y_offset);
+
+ priv = cell->priv;
+
+ if (x_offset)
+ {
+ *x_offset = (((direction == GTK_TEXT_DIR_RTL) ?
+ (1.0 - priv->xalign) : priv->xalign) *
+ (cell_area->width - width));
+ *x_offset = MAX (*x_offset, 0);
+ }
+ if (y_offset)
+ {
+ *y_offset = (priv->yalign *
+ (cell_area->height - height));
+ *y_offset = MAX (*y_offset, 0);
+ }
+}