* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* size requests and allocations for a given row of data.
*
* Usually users dont have to interact with the #GtkCellArea directly
- * unless they are implementing a cell layouting widget themselves.
+ * unless they are implementing a cell-layouting widget themselves.
*
* <refsect2 id="cell-area-geometry-management">
* <title>Requesting area sizes</title>
* size of an area for an arbitrary number of #GtkTreeModel rows.
*
* When requesting the size of a cell area one needs to calculate
- * the size for a handful of rows, this will be done differently by
+ * the size for a handful of rows, and this will be done differently by
* different layouting widgets. For instance a #GtkTreeViewColumn
* always lines up the areas from top to bottom while a #GtkIconView
* on the other hand might enforce that all areas received the same
*
* The #GtkCellAreaContext is an opaque object specific to the
* #GtkCellArea which created it (see gtk_cell_area_create_context()).
- * The owning cell layouting widget can create as many contexts as
+ * The owning cell-layouting widget can create as many contexts as
* it wishes to calculate sizes of rows which should receive the
* same size in at least one orientation (horizontally or vertically),
- * however it's important that the same #GtkCellAreaContext which
+ * However, it's important that the same #GtkCellAreaContext which
* was used to request the sizes for a given #GtkTreeModel row be
* used when rendering or processing events for that row.
*
* </example>
* Note that in this example it's not important to observe the
* returned minimum and natural width of the area for each row
- * unless the cell layouting object is actually interested in the
+ * unless the cell-layouting object is actually interested in the
* widths of individual rows. The overall width is however stored
* in the accompanying #GtkCellAreaContext object and can be consulted
* at any time.
* Requesting the height for width (or width for height) of an area is
* a similar task except in this case the #GtkCellAreaContext does not
* store the data (actually, it does not know how much space the layouting
- * widget plans to allocate it for every row, it's up to the layouting
+ * widget plans to allocate it for every row. It's up to the layouting
* widget to render each row of data with the appropriate height and
* width which was requested by the #GtkCellArea).
*
* call to #GtkWidgetClass.get_preferred_height_for_width(). Returning
* a perfect height for width that is larger than the screen area is
* inconsequential since after the layouting receives an allocation
- * from a scrolled window it simply continues to drive the the scrollbar
+ * from a scrolled window it simply continues to drive the scrollbar
* values while more and more height is required for the row heights
* that are calculated in the background.
* </para>
* </example>
* Note that the cached height in this example really depends on how
* the layouting widget works. The layouting widget might decide to
- * give every row it's minimum or natural height or, if the model content
+ * give every row its minimum or natural height or, if the model content
* is expected to fit inside the layouting widget without scrolling, it
* would make sense to calculate the allocation for each row at
- * #GtkWidget.size_allocate() time using gtk_distribute_natural_allocation().
+ * #GtkWidget::size-allocate time using gtk_distribute_natural_allocation().
* </para>
* </refsect2>
* <refsect2 id="cell-area-events-and-focus">
* for #GtkWidgets. This provides some general interfaces for defining
* the relationship cell areas have with their cells. For instance in a
* #GtkCellAreaBox a cell might "expand" and receive extra space when
- * the area is allocated more than it's full natural request, or a cell
+ * the area is allocated more than its full natural request, or a cell
* might be configured to "align" with adjacent rows which were requested
* and rendered with the same #GtkCellAreaContext.
*
GParamSpec *pspec);
/* GtkCellAreaClass */
+static void gtk_cell_area_real_add (GtkCellArea *area,
+ GtkCellRenderer *renderer);
+static void gtk_cell_area_real_remove (GtkCellArea *area,
+ GtkCellRenderer *renderer);
+static void gtk_cell_area_real_foreach (GtkCellArea *area,
+ GtkCellCallback callback,
+ gpointer callback_data);
+static void gtk_cell_area_real_foreach_alloc (GtkCellArea *area,
+ GtkCellAreaContext *context,
+ GtkWidget *widget,
+ const GdkRectangle *cell_area,
+ const GdkRectangle *background_area,
+ GtkCellAllocCallback callback,
+ gpointer callback_data);
static gint gtk_cell_area_real_event (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
GtkTreeIter *iter,
gboolean is_expander,
gboolean is_expanded);
+
+static GtkCellAreaContext *gtk_cell_area_real_create_context (GtkCellArea *area);
+static GtkCellAreaContext *gtk_cell_area_real_copy_context (GtkCellArea *area,
+ GtkCellAreaContext *context);
+static GtkSizeRequestMode gtk_cell_area_real_get_request_mode (GtkCellArea *area);
+static void gtk_cell_area_real_get_preferred_width (GtkCellArea *area,
+ GtkCellAreaContext *context,
+ GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static void gtk_cell_area_real_get_preferred_height (GtkCellArea *area,
+ GtkCellAreaContext *context,
+ GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
static void gtk_cell_area_real_get_preferred_height_for_width (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
const GdkRectangle *cell_area,
GtkCellRendererState flags,
gboolean edit_only);
+static gboolean gtk_cell_area_real_focus (GtkCellArea *area,
+ GtkDirectionType direction);
/* GtkCellLayoutIface */
static void gtk_cell_area_cell_layout_init (GtkCellLayoutIface *iface);
GtkCellLayoutDataFunc func;
gpointer data;
GDestroyNotify destroy;
+ GtkCellLayout *proxy;
} CellInfo;
static CellInfo *cell_info_new (GtkCellLayoutDataFunc func,
/* Tracking which cells are focus siblings of focusable cells */
GHashTable *focus_siblings;
-
- /* Detail string to pass to gtk_paint_*() functions */
- gchar *style_detail;
};
enum {
object_class->set_property = gtk_cell_area_set_property;
/* general */
- class->add = NULL;
- class->remove = NULL;
- class->foreach = NULL;
+ class->add = gtk_cell_area_real_add;
+ class->remove = gtk_cell_area_real_remove;
+ class->foreach = gtk_cell_area_real_foreach;
+ class->foreach_alloc = gtk_cell_area_real_foreach_alloc;
class->event = gtk_cell_area_real_event;
class->render = gtk_cell_area_real_render;
class->apply_attributes = gtk_cell_area_real_apply_attributes;
/* geometry */
- class->create_context = NULL;
- class->get_request_mode = NULL;
- class->get_preferred_width = NULL;
- class->get_preferred_height = NULL;
+ class->create_context = gtk_cell_area_real_create_context;
+ class->copy_context = gtk_cell_area_real_copy_context;
+ class->get_request_mode = gtk_cell_area_real_get_request_mode;
+ class->get_preferred_width = gtk_cell_area_real_get_preferred_width;
+ class->get_preferred_height = gtk_cell_area_real_get_preferred_height;
class->get_preferred_height_for_width = gtk_cell_area_real_get_preferred_height_for_width;
class->get_preferred_width_for_height = gtk_cell_area_real_get_preferred_width_for_height;
/* focus */
class->is_activatable = gtk_cell_area_real_is_activatable;
class->activate = gtk_cell_area_real_activate;
- class->focus = NULL;
+ class->focus = gtk_cell_area_real_focus;
/* Signals */
/**
GTK_TYPE_TREE_ITER,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
+ g_signal_set_va_marshaller (cell_area_signals[SIGNAL_APPLY_ATTRIBUTES], G_TYPE_FROM_CLASS (class),
+ _gtk_marshal_VOID__OBJECT_BOXED_BOOLEAN_BOOLEANv);
/**
* GtkCellArea::add-editable:
* @path: the #GtkTreePath string this edit was initiated for
*
* Indicates that editing has started on @renderer and that @editable
- * should be added to the owning cell layouting widget at @cell_area.
+ * should be added to the owning cell-layouting widget at @cell_area.
*
* Since: 3.0
*/
* @editable: the #GtkCellEditable widget to remove
*
* Indicates that editing finished on @renderer and that @editable
- * should be removed from the owning cell layouting widget.
+ * should be removed from the owning cell-layouting widget.
*
* Since: 3.0
*/
("edit-widget",
P_("Edit Widget"),
P_("The widget currently editing the edited cell"),
- GTK_TYPE_CELL_RENDERER,
+ GTK_TYPE_CELL_EDITABLE,
G_PARAM_READABLE));
/* Pool for Cell Properties */
/*************************************************************
* GtkCellAreaClass *
*************************************************************/
+static void
+gtk_cell_area_real_add (GtkCellArea *area,
+ GtkCellRenderer *renderer)
+{
+ g_warning ("GtkCellAreaClass::add not implemented for `%s'",
+ g_type_name (G_TYPE_FROM_INSTANCE (area)));
+}
+
+static void
+gtk_cell_area_real_remove (GtkCellArea *area,
+ GtkCellRenderer *renderer)
+{
+ g_warning ("GtkCellAreaClass::remove not implemented for `%s'",
+ g_type_name (G_TYPE_FROM_INSTANCE (area)));
+}
+
+static void
+gtk_cell_area_real_foreach (GtkCellArea *area,
+ GtkCellCallback callback,
+ gpointer callback_data)
+{
+ g_warning ("GtkCellAreaClass::foreach not implemented for `%s'",
+ g_type_name (G_TYPE_FROM_INSTANCE (area)));
+}
+
+static void
+gtk_cell_area_real_foreach_alloc (GtkCellArea *area,
+ GtkCellAreaContext *context,
+ GtkWidget *widget,
+ const GdkRectangle *cell_area,
+ const GdkRectangle *background_area,
+ GtkCellAllocCallback callback,
+ gpointer callback_data)
+{
+ g_warning ("GtkCellAreaClass::foreach_alloc not implemented for `%s'",
+ g_type_name (G_TYPE_FROM_INSTANCE (area)));
+}
+
static gint
gtk_cell_area_real_event (GtkCellArea *area,
GtkCellAreaContext *context,
{
GdkEventButton *button_event = (GdkEventButton *)event;
- if (button_event->button == 1)
+ if (button_event->button == GDK_BUTTON_PRIMARY)
{
GtkCellRenderer *renderer = NULL;
GtkCellRenderer *focus_renderer;
gdk_rectangle_union (&data->focus_rect, &cell_focus, &data->focus_rect);
}
}
- else
- flags &= ~GTK_CELL_RENDERER_FOCUSED;
gtk_cell_renderer_render (renderer, data->cr, data->widget,
cell_background, &inner_area, flags);
if (gtk_cell_area_get_edited_cell (area))
render_data.paint_focus = FALSE;
+ if (!gtk_widget_has_visible_focus (widget))
+ render_data.paint_focus = FALSE;
+
/* If no cell can activate but the caller wants focus painted,
* then we paint focus around all cells */
if ((flags & GTK_CELL_RENDERER_FOCUSED) != 0 && paint_focus &&
render_data.focus_rect.width != 0 &&
render_data.focus_rect.height != 0)
{
- GtkStateType renderer_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));
+ GtkStyleContext *style_context;
+ GtkStateFlags renderer_state = 0;
+
+ style_context = gtk_widget_get_style_context (widget);
+ gtk_style_context_save (style_context);
+
+ renderer_state = gtk_cell_renderer_get_state (NULL, widget, flags);
+ gtk_style_context_set_state (style_context, renderer_state);
cairo_save (cr);
gdk_cairo_rectangle (cr, background_area);
cairo_clip (cr);
- gtk_paint_focus (gtk_widget_get_style (widget), cr,
- renderer_state, widget,
- gtk_cell_area_get_style_detail (area),
- render_data.focus_rect.x, render_data.focus_rect.y,
- render_data.focus_rect.width, render_data.focus_rect.height);
+ gtk_render_focus (style_context, cr,
+ render_data.focus_rect.x, render_data.focus_rect.y,
+ render_data.focus_rect.width, render_data.focus_rect.height);
+ gtk_style_context_restore (style_context);
cairo_restore (cr);
}
}
{
CellAttribute *attribute;
GSList *list;
- GValue value = { 0, };
+ GValue value = G_VALUE_INIT;
gboolean is_expander;
gboolean is_expanded;
/* Call any GtkCellLayoutDataFunc that may have been set by the user
*/
if (info->func)
- info->func (GTK_CELL_LAYOUT (data->area), renderer,
- data->model, data->iter, info->data);
+ info->func (info->proxy ? info->proxy : GTK_CELL_LAYOUT (data->area), renderer,
+ data->model, data->iter, info->data);
g_object_thaw_notify (G_OBJECT (renderer));
}
gtk_tree_path_free (path);
}
+static GtkCellAreaContext *
+gtk_cell_area_real_create_context (GtkCellArea *area)
+{
+ g_warning ("GtkCellAreaClass::create_context not implemented for `%s'",
+ g_type_name (G_TYPE_FROM_INSTANCE (area)));
+
+ return NULL;
+}
+
+static GtkCellAreaContext *
+gtk_cell_area_real_copy_context (GtkCellArea *area,
+ GtkCellAreaContext *context)
+{
+ g_warning ("GtkCellAreaClass::copy_context not implemented for `%s'",
+ g_type_name (G_TYPE_FROM_INSTANCE (area)));
+
+ return NULL;
+}
+
+static GtkSizeRequestMode
+gtk_cell_area_real_get_request_mode (GtkCellArea *area)
+{
+ /* By default cell areas are height-for-width. */
+ return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
+}
+
+static void
+gtk_cell_area_real_get_preferred_width (GtkCellArea *area,
+ GtkCellAreaContext *context,
+ GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ g_warning ("GtkCellAreaClass::get_preferred_width not implemented for `%s'",
+ g_type_name (G_TYPE_FROM_INSTANCE (area)));
+}
+
+static void
+gtk_cell_area_real_get_preferred_height (GtkCellArea *area,
+ GtkCellAreaContext *context,
+ GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ g_warning ("GtkCellAreaClass::get_preferred_height not implemented for `%s'",
+ g_type_name (G_TYPE_FROM_INSTANCE (area)));
+}
+
static void
gtk_cell_area_real_get_preferred_height_for_width (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
- gint width,
+ gint width,
gint *minimum_height,
gint *natural_height)
{
/* If the area doesnt do height-for-width, fallback on base preferred height */
- GTK_CELL_AREA_GET_CLASS (area)->get_preferred_width (area, context, widget, minimum_height, natural_height);
+ GTK_CELL_AREA_GET_CLASS (area)->get_preferred_height (area, context, widget, minimum_height, natural_height);
}
static void
return FALSE;
}
+static gboolean
+gtk_cell_area_real_focus (GtkCellArea *area,
+ GtkDirectionType direction)
+{
+ g_warning ("GtkCellAreaClass::focus not implemented for `%s'",
+ g_type_name (G_TYPE_FROM_INSTANCE (area)));
+ return FALSE;
+}
+
/*************************************************************
* GtkCellLayoutIface *
*************************************************************/
gpointer func_data,
GDestroyNotify destroy)
{
- GtkCellArea *area = GTK_CELL_AREA (cell_layout);
- GtkCellAreaPrivate *priv = area->priv;
- CellInfo *info;
-
- info = g_hash_table_lookup (priv->cell_info, renderer);
-
- if (info)
- {
- if (info->destroy && info->data)
- info->destroy (info->data);
+ GtkCellArea *area = GTK_CELL_AREA (cell_layout);
- if (func)
- {
- info->func = func;
- info->data = func_data;
- info->destroy = destroy;
- }
- else
- {
- info->func = NULL;
- info->data = NULL;
- info->destroy = NULL;
- }
- }
- else
- {
- info = cell_info_new (func, func_data, destroy);
-
- g_hash_table_insert (priv->cell_info, renderer, info);
- }
+ _gtk_cell_area_set_cell_data_func_with_proxy (area, renderer, (GFunc)func, func_data, destroy, NULL);
}
static void
gtk_cell_area_add (GtkCellArea *area,
GtkCellRenderer *renderer)
{
- GtkCellAreaClass *class;
-
g_return_if_fail (GTK_IS_CELL_AREA (area));
g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
- class = GTK_CELL_AREA_GET_CLASS (area);
-
- if (class->add)
- class->add (area, renderer);
- else
- g_warning ("GtkCellAreaClass::add not implemented for `%s'",
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
+ GTK_CELL_AREA_GET_CLASS (area)->add (area, renderer);
}
/**
gtk_cell_area_remove (GtkCellArea *area,
GtkCellRenderer *renderer)
{
- GtkCellAreaClass *class;
GtkCellAreaPrivate *priv;
GList *renderers, *l;
g_return_if_fail (GTK_IS_CELL_AREA (area));
g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
- class = GTK_CELL_AREA_GET_CLASS (area);
priv = area->priv;
/* Remove any custom attributes and custom cell data func here first */
g_list_free (renderers);
- if (class->remove)
- class->remove (area, renderer);
- else
- g_warning ("GtkCellAreaClass::remove not implemented for `%s'",
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
+ GTK_CELL_AREA_GET_CLASS (area)->remove (area, renderer);
}
static gboolean
/**
* gtk_cell_area_foreach:
* @area: a #GtkCellArea
- * @callback: the #GtkCellCallback to call
+ * @callback: (scope call): the #GtkCellCallback to call
* @callback_data: user provided data pointer
*
* Calls @callback for every #GtkCellRenderer in @area.
GtkCellCallback callback,
gpointer callback_data)
{
- GtkCellAreaClass *class;
-
g_return_if_fail (GTK_IS_CELL_AREA (area));
g_return_if_fail (callback != NULL);
- class = GTK_CELL_AREA_GET_CLASS (area);
-
- if (class->foreach)
- class->foreach (area, callback, callback_data);
- else
- g_warning ("GtkCellAreaClass::foreach not implemented for `%s'",
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
+ GTK_CELL_AREA_GET_CLASS (area)->foreach (area, callback, callback_data);
}
/**
* @widget: the #GtkWidget that @area is rendering to
* @cell_area: the @widget relative coordinates and size for @area
* @background_area: the @widget relative coordinates of the background area
- * @callback: the #GtkCellAllocCallback to call
+ * @callback: (scope call): the #GtkCellAllocCallback to call
* @callback_data: user provided data pointer
*
* Calls @callback for every #GtkCellRenderer in @area with the
GtkCellAllocCallback callback,
gpointer callback_data)
{
- GtkCellAreaClass *class;
-
g_return_if_fail (GTK_IS_CELL_AREA (area));
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (cell_area != NULL);
g_return_if_fail (callback != NULL);
- class = GTK_CELL_AREA_GET_CLASS (area);
-
- if (class->foreach_alloc)
- class->foreach_alloc (area, context, widget, cell_area, background_area, callback, callback_data);
- else
- g_warning ("GtkCellAreaClass::foreach_alloc not implemented for `%s'",
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
+ GTK_CELL_AREA_GET_CLASS (area)->foreach_alloc (area, context, widget,
+ cell_area, background_area,
+ callback, callback_data);
}
/**
g_type_name (G_TYPE_FROM_INSTANCE (area)));
}
-/**
- * gtk_cell_area_set_style_detail:
- * @area: a #GtkCellArea
- * @detail: the #GtkStyle detail string to set
- *
- * Sets the detail string used in any gtk_paint_*() functions
- * used by @area.
- *
- * Since: 3.0
- */
-void
-gtk_cell_area_set_style_detail (GtkCellArea *area,
- const gchar *detail)
-{
- GtkCellAreaPrivate *priv;
-
- g_return_if_fail (GTK_IS_CELL_AREA (area));
-
- priv = area->priv;
-
- if (g_strcmp0 (priv->style_detail, detail) != 0)
- {
- g_free (priv->style_detail);
- priv->style_detail = g_strdup (detail);
- }
-}
-
-/**
- * gtk_cell_area_get_style_detail:
- * @area: a #GtkCellArea
- *
- * Gets the detail string used in any gtk_paint_*() functions
- * used by @area.
- *
- * Return value: the detail string, the string belongs to the area and should not be freed.
- *
- * Since: 3.0
- */
-G_CONST_RETURN gchar *
-gtk_cell_area_get_style_detail (GtkCellArea *area)
-{
- GtkCellAreaPrivate *priv;
-
- g_return_val_if_fail (GTK_IS_CELL_AREA (area), NULL);
-
- priv = area->priv;
-
- return priv->style_detail;
-}
-
static gboolean
get_cell_allocation (GtkCellRenderer *renderer,
const GdkRectangle *cell_area,
* Gets the #GtkCellRenderer at @x and @y coordinates inside @area and optionally
* returns the full cell allocation for it inside @cell_area.
*
- * Return value: the #GtkCellRenderer at @x and @y.
+ * Return value: (transfer none): the #GtkCellRenderer at @x and @y.
*
* Since: 3.0
*/
GtkCellAreaContext *
gtk_cell_area_create_context (GtkCellArea *area)
{
- GtkCellAreaClass *class;
-
g_return_val_if_fail (GTK_IS_CELL_AREA (area), NULL);
- class = GTK_CELL_AREA_GET_CLASS (area);
-
- if (class->create_context)
- return class->create_context (area);
-
- g_warning ("GtkCellAreaClass::create_context not implemented for `%s'",
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
-
- return NULL;
+ return GTK_CELL_AREA_GET_CLASS (area)->create_context (area);
}
/**
gtk_cell_area_copy_context (GtkCellArea *area,
GtkCellAreaContext *context)
{
- GtkCellAreaClass *class;
-
g_return_val_if_fail (GTK_IS_CELL_AREA (area), NULL);
g_return_val_if_fail (GTK_IS_CELL_AREA_CONTEXT (context), NULL);
- class = GTK_CELL_AREA_GET_CLASS (area);
-
- if (class->copy_context)
- return class->copy_context (area, context);
-
- g_warning ("GtkCellAreaClass::copy_context not implemented for `%s'",
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
-
- return NULL;
+ return GTK_CELL_AREA_GET_CLASS (area)->copy_context (area, context);
}
/**
GtkSizeRequestMode
gtk_cell_area_get_request_mode (GtkCellArea *area)
{
- GtkCellAreaClass *class;
-
g_return_val_if_fail (GTK_IS_CELL_AREA (area),
GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH);
- class = GTK_CELL_AREA_GET_CLASS (area);
-
- if (class->get_request_mode)
- return class->get_request_mode (area);
-
- g_warning ("GtkCellAreaClass::get_request_mode not implemented for `%s'",
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
-
- return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
+ return GTK_CELL_AREA_GET_CLASS (area)->get_request_mode (area);
}
/**
*
* Retrieves a cell area's initial minimum and natural width.
*
- * @area will store some geometrical information in @context along the way,
- * when requesting sizes over an arbitrary number of rows, its not important
+ * @area will store some geometrical information in @context along the way;
+ * when requesting sizes over an arbitrary number of rows, it's not important
* to check the @minimum_width and @natural_width of this call but rather to
* consult gtk_cell_area_context_get_preferred_width() after a series of
* requests.
gint *minimum_width,
gint *natural_width)
{
- GtkCellAreaClass *class;
-
g_return_if_fail (GTK_IS_CELL_AREA (area));
g_return_if_fail (GTK_IS_WIDGET (widget));
- class = GTK_CELL_AREA_GET_CLASS (area);
-
- if (class->get_preferred_width)
- class->get_preferred_width (area, context, widget, minimum_width, natural_width);
- else
- g_warning ("GtkCellAreaClass::get_preferred_width not implemented for `%s'",
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
+ GTK_CELL_AREA_GET_CLASS (area)->get_preferred_width (area, context, widget,
+ minimum_width, natural_width);
}
/**
* the specified @width.
*
* @area stores some geometrical information in @context along the way
- * while calling gtk_cell_area_get_preferred_width(), it's important to
+ * while calling gtk_cell_area_get_preferred_width(). It's important to
* perform a series of gtk_cell_area_get_preferred_width() requests with
* @context first and then call gtk_cell_area_get_preferred_height_for_width()
* on each cell area individually to get the height for width of each
*
* Retrieves a cell area's initial minimum and natural height.
*
- * @area will store some geometrical information in @context along the way,
- * when requesting sizes over an arbitrary number of rows, its not important
+ * @area will store some geometrical information in @context along the way;
+ * when requesting sizes over an arbitrary number of rows, it's not important
* to check the @minimum_height and @natural_height of this call but rather to
* consult gtk_cell_area_context_get_preferred_height() after a series of
* requests.
gint *minimum_height,
gint *natural_height)
{
- GtkCellAreaClass *class;
-
g_return_if_fail (GTK_IS_CELL_AREA (area));
g_return_if_fail (GTK_IS_WIDGET (widget));
- class = GTK_CELL_AREA_GET_CLASS (area);
-
- if (class->get_preferred_height)
- class->get_preferred_height (area, context, widget, minimum_height, natural_height);
- else
- g_warning ("GtkCellAreaClass::get_preferred_height not implemented for `%s'",
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
+ GTK_CELL_AREA_GET_CLASS (area)->get_preferred_height (area, context, widget,
+ minimum_height, natural_height);
}
/**
* the specified @height.
*
* @area stores some geometrical information in @context along the way
- * while calling gtk_cell_area_get_preferred_height(), it's important to
+ * while calling gtk_cell_area_get_preferred_height(). It's important to
* perform a series of gtk_cell_area_get_preferred_height() requests with
* @context first and then call gtk_cell_area_get_preferred_width_for_height()
* on each cell area individually to get the height for width of each
g_warning ("Cannot connect attribute `%s' for cell renderer class `%s' "
"since `%s' is already attributed to column %d",
attribute,
- g_type_name (G_TYPE_FROM_INSTANCE (area)),
+ G_OBJECT_TYPE_NAME (renderer),
attribute, cell_attribute->column);
return;
}
g_warning ("Cannot connect attribute `%s' for cell renderer class `%s' "
"since attribute does not exist",
attribute,
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
+ G_OBJECT_TYPE_NAME (renderer));
return;
}
}
/**
- * gtk_cell_area_apply_attributes
+ * gtk_cell_area_apply_attributes:
* @area: a #GtkCellArea
* @tree_model: the #GtkTreeModel to pull values from
* @iter: the #GtkTreeIter in @tree_model to apply values for
*
* Since: 3.0
*/
-G_CONST_RETURN gchar *
+const gchar *
gtk_cell_area_get_current_path_string (GtkCellArea *area)
{
GtkCellAreaPrivate *priv;
*
* Finds a cell property of a cell area class by name.
*
- * Return value: (allow-none): the #GParamSpec of the child property or %NULL if @aclass has no
- * child property with that name.
+ * Return value: (transfer none): the #GParamSpec of the child property
+ * or %NULL if @aclass has no child property with that name.
*
* Since: 3.0
*/
*
* Returns all cell properties of a cell area class.
*
- * Return value: a newly allocated %NULL-terminated array of #GParamSpec*.
- * The array must be freed with g_free().
+ * Return value: (array length=n_properties) (transfer container): a newly
+ * allocated %NULL-terminated array of #GParamSpec*. The array
+ * must be freed with g_free().
*
* Since: 3.0
*/
* @area: a #GtkCellArea
* @renderer: a #GtkCellRenderer to be placed inside @area
* @first_prop_name: the name of the first cell property to set
- * @Varargs: a %NULL-terminated list of property names and values, starting
- * with @first_prop_name
+ * @...: a %NULL-terminated list of property names and values, starting
+ * with @first_prop_name
*
* Adds @renderer to @area, setting cell properties at the same time.
- * See gtk_cell_area_add() and gtk_cell_area_child_set() for more details.
+ * See gtk_cell_area_add() and gtk_cell_area_cell_set() for more details.
*
* Since: 3.0
*/
* @area: a #GtkCellArea
* @renderer: a #GtkCellRenderer which is a cell inside @area
* @first_prop_name: the name of the first cell property to set
- * @Varargs: a %NULL-terminated list of property names and values, starting
+ * @...: a %NULL-terminated list of property names and values, starting
* with @first_prop_name
*
* Sets one or more cell properties for @cell in @area.
* @area: a #GtkCellArea
* @renderer: a #GtkCellRenderer which is inside @area
* @first_prop_name: the name of the first cell property to get
- * @Varargs: return location for the first cell property, followed
+ * @...: return location for the first cell property, followed
* optionally by more name/return location pairs, followed by %NULL
*
* Gets the values of one or more cell properties for @renderer in @area.
GParamSpec *pspec,
const GValue *value)
{
- GValue tmp_value = { 0, };
+ GValue tmp_value = G_VALUE_INIT;
GtkCellAreaClass *class = g_type_class_peek (pspec->owner_type);
/* provide a copy to work from, convert (if necessary) and validate */
name = first_property_name;
while (name)
{
- GValue value = { 0, };
+ GValue value = G_VALUE_INIT;
gchar *error = NULL;
GParamSpec *pspec =
g_param_spec_pool_lookup (cell_property_pool, name,
break;
}
- g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
- G_VALUE_COLLECT (&value, var_args, 0, &error);
+ G_VALUE_COLLECT_INIT (&value, G_PARAM_SPEC_VALUE_TYPE (pspec),
+ var_args, 0, &error);
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);
name = first_property_name;
while (name)
{
- GValue value = { 0, };
+ GValue value = G_VALUE_INIT;
GParamSpec *pspec;
gchar *error;
G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (area));
else
{
- GValue *prop_value, tmp_value = { 0, };
+ GValue *prop_value, tmp_value = G_VALUE_INIT;
/* auto-conversion of the callers value type
*/
* for a given @direction and row data.
*
* Implementing #GtkCellArea classes should implement this
- * method to receive and navigate focus in it's own way particular
+ * method to receive and navigate focus in its own way particular
* to how it lays out cells.
*
* Return value: %TRUE if focus remains inside @area as a result of this call.
gtk_cell_area_focus (GtkCellArea *area,
GtkDirectionType direction)
{
- GtkCellAreaClass *class;
-
g_return_val_if_fail (GTK_IS_CELL_AREA (area), FALSE);
- class = GTK_CELL_AREA_GET_CLASS (area);
-
- if (class->focus)
- return class->focus (area, direction);
-
- g_warning ("GtkCellAreaClass::focus not implemented for `%s'",
- g_type_name (G_TYPE_FROM_INSTANCE (area)));
-
- return FALSE;
+ return GTK_CELL_AREA_GET_CLASS (area)->focus (area, direction);
}
/**
/**
* gtk_cell_area_set_focus_cell:
* @area: a #GtkCellArea
- * @focus_cell: the #GtkCellRenderer to give focus to
+ * @renderer: the #GtkCellRenderer to give focus to
+ *
+ * Explicitly sets the currently focused cell to @renderer.
*
- * This is generally called from #GtkCellArea implementations
- * either gtk_cell_area_grab_focus() or gtk_cell_area_update_focus()
- * is called. It's also up to the #GtkCellArea implementation
- * to update the focused cell when receiving events from
- * gtk_cell_area_event() appropriately.
+ * This is generally called by implementations of
+ * #GtkCellAreaClass.focus() or #GtkCellAreaClass.event(),
+ * however it can also be used to implement functions such
+ * as gtk_tree_view_set_cursor_on_cell().
*
* Since: 3.0
*/
*
* Retrieves the currently focused cell for @area
*
- * Return value: the currently focused cell in @area.
+ * Return value: (transfer none): the currently focused cell in @area.
*
* Since: 3.0
*/
* @sibling: the #GtkCellRenderer to add to @renderer's focus area
*
* Adds @sibling to @renderer's focusable area, focus will be drawn
- * around @renderer and all of it's siblings if @renderer can
+ * around @renderer and all of its siblings if @renderer can
* focus for a given row.
*
* Events handled by focus siblings can also activate the given
* @renderer: the #GtkCellRenderer expected to have focus
* @sibling: the #GtkCellRenderer to check against @renderer's sibling list
*
- * Returns %TRUE if @sibling is one of @renderer's focus siblings
+ * Returns whether @sibling is one of @renderer's focus siblings
* (see gtk_cell_area_add_focus_sibling()).
*
+ * Return value: %TRUE if @sibling is a focus sibling of @renderer
+ *
* Since: 3.0
*/
gboolean
* then chose to activate the focus cell for which the event
* cell may have been a sibling.
*
- * Return value: the #GtkCellRenderer for which @renderer is a sibling, or %NULL.
+ * Return value: (transfer none): the #GtkCellRenderer for which @renderer
+ * is a sibling, or %NULL.
*
* Since: 3.0
*/
* Gets the #GtkCellRenderer in @area that is currently
* being edited.
*
- * Return value: The currently edited #GtkCellRenderer
+ * Return value: (transfer none): The currently edited #GtkCellRenderer
*
* Since: 3.0
*/
* Gets the #GtkCellEditable widget currently used
* to edit the currently edited cell.
*
- * Return value: The currently active #GtkCellEditable widget
+ * Return value: (transfer none): The currently active #GtkCellEditable widget
*
* Since: 3.0
*/
*
* This is used by #GtkCellArea subclasses when handling events
* to activate cells, the base #GtkCellArea class activates cells
- * for keyboard events for free in it's own GtkCellArea->activate()
+ * for keyboard events for free in its own GtkCellArea->activate()
* implementation.
*
* Return value: whether cell activation was successful
priv = area->priv;
+ if (!gtk_cell_renderer_get_sensitive (renderer))
+ return FALSE;
+
g_object_get (renderer, "mode", &mode, NULL);
if (mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE)
* @area: a #GtkCellArea
* @canceled: whether editing was canceled.
*
- * Explicitly stops the editing of the currently
- * edited cell (see gtk_cell_area_get_edited_cell()).
+ * Explicitly stops the editing of the currently edited cell.
*
- * If @canceled is %TRUE, the cell renderer will emit
- * the ::editing-canceled signal.
+ * If @canceled is %TRUE, the currently edited cell renderer
+ * will emit the ::editing-canceled signal, otherwise the
+ * the ::editing-done signal will be emitted on the current
+ * edit widget.
+ *
+ * See gtk_cell_area_get_edited_cell() and gtk_cell_area_get_edit_widget().
*
* Since: 3.0
*/
/* Stop editing of the cell renderer */
gtk_cell_renderer_stop_editing (priv->edited_cell, canceled);
+ /* When editing is explicitly halted either
+ * the "editing-canceled" signal is emitted on the cell
+ * renderer or the "editing-done" signal on the GtkCellEditable widget
+ */
+ if (!canceled)
+ gtk_cell_editable_editing_done (edit_widget);
+
/* Remove any references to the editable widget */
gtk_cell_area_set_edited_cell (area, NULL);
gtk_cell_area_set_edit_widget (area, NULL);
gint *minimum_size,
gint *natural_size)
{
- GtkCellAreaPrivate *priv;
- gint focus_line_width;
+ gint focus_line_width;
g_return_if_fail (GTK_IS_CELL_AREA (area));
g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
g_return_if_fail (minimum_size != NULL);
g_return_if_fail (natural_size != NULL);
- priv = area->priv;
-
gtk_widget_style_get (widget, "focus-line-width", &focus_line_width, NULL);
focus_line_width *= 2;
*minimum_size += focus_line_width;
*natural_size += focus_line_width;
}
+
+void
+_gtk_cell_area_set_cell_data_func_with_proxy (GtkCellArea *area,
+ GtkCellRenderer *cell,
+ GFunc func,
+ gpointer func_data,
+ GDestroyNotify destroy,
+ gpointer proxy)
+{
+ GtkCellAreaPrivate *priv;
+ CellInfo *info;
+
+ g_return_if_fail (GTK_IS_CELL_AREA (area));
+ g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+
+ priv = area->priv;
+
+ info = g_hash_table_lookup (priv->cell_info, cell);
+
+ /* Note we do not take a reference to the proxy, the proxy is a GtkCellLayout
+ * that is forwarding its implementation to a delegate GtkCellArea therefore
+ * its life-cycle is longer than the area's life cycle.
+ */
+ if (info)
+ {
+ if (info->destroy && info->data)
+ info->destroy (info->data);
+
+ if (func)
+ {
+ info->func = (GtkCellLayoutDataFunc)func;
+ info->data = func_data;
+ info->destroy = destroy;
+ info->proxy = proxy;
+ }
+ else
+ {
+ info->func = NULL;
+ info->data = NULL;
+ info->destroy = NULL;
+ info->proxy = NULL;
+ }
+ }
+ else
+ {
+ info = cell_info_new ((GtkCellLayoutDataFunc)func, func_data, destroy);
+ info->proxy = proxy;
+
+ g_hash_table_insert (priv->cell_info, cell, info);
+ }
+}