[gtk+/native-layout: 57/59] Simulate gtk_cell_renderer_get_size() with height-for-width api
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/native-layout: 57/59] Simulate gtk_cell_renderer_get_size() with height-for-width api
- Date: Thu, 24 Jun 2010 23:25:56 +0000 (UTC)
commit f1998d568ae37c0cfeca6a05abaa94e186434bd3
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Thu Jun 24 17:59:15 2010 -0400
Simulate gtk_cell_renderer_get_size() with height-for-width api
Same as GtkWidget does with GtkSizeRequestIface, this will allow
removal of the ->get_size() implementation for renderers that
implement the new api.
gtk/gtkcellrenderer.c | 38 +++++++++++++++-----------------------
gtk/gtkcellrenderer.h | 2 +-
2 files changed, 16 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c
index d8f5645..793cd02 100644
--- a/gtk/gtkcellrenderer.c
+++ b/gtk/gtkcellrenderer.c
@@ -571,30 +571,22 @@ 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);
+
+ if (width)
+ *width = request.width;
+
+ if (height)
+ *height = request.height;
- GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell,
- widget,
- (GdkRectangle *) cell_area,
- x_offset,
- y_offset,
- real_width,
- real_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);
}
/**
@@ -1058,8 +1050,8 @@ gtk_cell_renderer_get_desired_size (GtkCellSizeRequest *cell,
/* Fallback on the old API to get the size. */
if (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size)
- gtk_cell_renderer_get_size (GTK_CELL_RENDERER (cell), widget, NULL, NULL, NULL,
- &min_req.width, &min_req.height);
+ 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;
@@ -1135,7 +1127,7 @@ gtk_cell_renderer_get_width_for_height (GtkCellSizeRequest *cell,
*/
void
_gtk_cell_renderer_calc_offset (GtkCellRenderer *cell,
- GdkRectangle *cell_area,
+ const GdkRectangle *cell_area,
GtkTextDirection direction,
gint width,
gint height,
diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h
index cb5cf07..5cf7e5d 100644
--- a/gtk/gtkcellrenderer.h
+++ b/gtk/gtkcellrenderer.h
@@ -188,7 +188,7 @@ void gtk_cell_renderer_stop_editing (GtkCellRenderer *cell,
void _gtk_cell_renderer_calc_offset (GtkCellRenderer *cell,
- GdkRectangle *cell_area,
+ const GdkRectangle *cell_area,
GtkTextDirection direction,
gint width,
gint height,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]