Do not use deprecated gtk_cell_renderer_get_size()

Use gtk_cell_size_request_get_size() instead

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=629785
This commit is contained in:
Javier Jardón 2010-09-13 02:50:04 +02:00
parent efbf04236e
commit 15a5a231fc
2 changed files with 74 additions and 59 deletions

View File

@ -29,6 +29,7 @@
#include "gtkcellrenderer.h"
#include "gtkcellrenderertext.h"
#include "gtkcellrendererpixbuf.h"
#include "gtkcellsizerequest.h"
#include "gtkmarshalers.h"
#include "gtkbindings.h"
#include "gtkdnd.h"
@ -2963,11 +2964,12 @@ adjust_wrap_width (GtkIconView *icon_view,
{
GtkIconViewCellInfo *text_info;
GtkIconViewCellInfo *pixbuf_info;
gint pixbuf_width, wrap_width;
gint wrap_width;
if (icon_view->priv->text_cell != -1 &&
icon_view->priv->pixbuf_cell != -1)
{
GtkRequisition min_size;
gint item_width;
text_info = g_list_nth_data (icon_view->priv->cell_list,
@ -2975,12 +2977,9 @@ adjust_wrap_width (GtkIconView *icon_view,
pixbuf_info = g_list_nth_data (icon_view->priv->cell_list,
icon_view->priv->pixbuf_cell);
gtk_cell_renderer_get_size (pixbuf_info->cell,
gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (pixbuf_info->cell),
GTK_WIDGET (icon_view),
NULL, NULL, NULL,
&pixbuf_width,
NULL);
&min_size, NULL);
if (icon_view->priv->item_width > 0)
item_width = icon_view->priv->item_width;
@ -2991,9 +2990,9 @@ adjust_wrap_width (GtkIconView *icon_view,
wrap_width = item_width;
else {
if (item->width == -1 && item_width <= 0)
wrap_width = MAX (2 * pixbuf_width, 50);
wrap_width = MAX (2 * min_size.width, 50);
else
wrap_width = item_width - pixbuf_width - icon_view->priv->spacing;
wrap_width = item_width - min_size.width - icon_view->priv->spacing;
}
wrap_width -= icon_view->priv->item_padding * 2;
@ -3007,6 +3006,7 @@ static void
gtk_icon_view_calculate_item_size (GtkIconView *icon_view,
GtkIconViewItem *item)
{
GtkRequisition min_size;
gint spacing;
GList *l;
@ -3039,10 +3039,11 @@ gtk_icon_view_calculate_item_size (GtkIconView *icon_view,
if (!gtk_cell_renderer_get_visible (info->cell))
continue;
gtk_cell_renderer_get_size (info->cell, GTK_WIDGET (icon_view),
NULL, NULL, NULL,
&item->box[info->position].width,
&item->box[info->position].height);
gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (info->cell),
GTK_WIDGET (icon_view),
&min_size, NULL);
item->box[info->position].width = min_size.width;
item->box[info->position].height = min_size.height;
if (icon_view->priv->item_orientation == GTK_ORIENTATION_HORIZONTAL)
{
@ -3066,6 +3067,7 @@ gtk_icon_view_calculate_item_size2 (GtkIconView *icon_view,
GtkIconViewItem *item,
gint *max_height)
{
GtkRequisition min_size;
GdkRectangle cell_area;
gint spacing;
GList *l;
@ -3119,13 +3121,19 @@ gtk_icon_view_calculate_item_size2 (GtkIconView *icon_view,
cell_area.height = max_height[i];
}
gtk_cell_renderer_get_size (info->cell, GTK_WIDGET (icon_view),
&cell_area,
&item->box[info->position].x, &item->box[info->position].y,
&item->box[info->position].width, &item->box[info->position].height);
gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (info->cell),
GTK_WIDGET (icon_view),
&min_size, NULL);
item->box[info->position].width = min_size.width;
item->box[info->position].height = min_size.height;
_gtk_cell_renderer_calc_offset (info->cell, &cell_area,
gtk_widget_get_direction (GTK_WIDGET (icon_view)),
item->box[info->position].width, item->box[info->position].height,
&item->box[info->position].x, &item->box[info->position].y);
item->box[info->position].x += cell_area.x;
item->box[info->position].y += cell_area.y;
if (icon_view->priv->item_orientation == GTK_ORIENTATION_HORIZONTAL)
{
item->before[info->position] = item->box[info->position].x - cell_area.x;

View File

@ -18,8 +18,12 @@
*/
#include "config.h"
#include <string.h>
#include "gtktreeviewcolumn.h"
#include <string.h>
#include "gtkcellsizerequest.h"
#include "gtktreeview.h"
#include "gtktreeprivate.h"
#include "gtkcelllayout.h"
@ -2611,6 +2615,7 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
gint *width,
gint *height)
{
GtkRequisition min_size;
GList *list;
gboolean first_cell = TRUE;
gint focus_line_width;
@ -2628,8 +2633,6 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
{
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
gboolean visible;
gint new_height = 0;
gint new_width = 0;
g_object_get (info->cell, "visible", &visible, NULL);
if (visible == FALSE)
@ -2638,17 +2641,13 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
if (first_cell == FALSE && width)
*width += tree_column->spacing;
gtk_cell_renderer_get_size (info->cell,
tree_column->tree_view,
cell_area,
x_offset,
y_offset,
&new_width,
&new_height);
gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (info->cell),
GTK_WIDGET (tree_column->tree_view),
&min_size, NULL);
if (height)
* height = MAX (*height, new_height + focus_line_width * 2);
info->requested_width = MAX (info->requested_width, new_width + focus_line_width * 2);
* height = MAX (*height, min_size.height + focus_line_width * 2);
info->requested_width = MAX (info->requested_width, min_size.width + focus_line_width * 2);
if (width)
* width += info->requested_width;
first_cell = FALSE;
@ -2839,34 +2838,38 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
/* FOCUS */
else if (action == CELL_ACTION_FOCUS)
{
gint x_offset, y_offset, width, height;
gint x_offset, y_offset;
GtkRequisition min_size;
gtk_cell_renderer_get_size (info->cell,
gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (info->cell),
tree_column->tree_view,
&rtl_cell_area,
&x_offset, &y_offset,
&width, &height);
&min_size, NULL);
_gtk_cell_renderer_calc_offset (info->cell, &rtl_cell_area,
gtk_widget_get_direction (tree_column->tree_view),
min_size.width, min_size.height,
&x_offset, &y_offset);
if (special_cells > 1)
{
if (info->has_focus)
{
min_x = rtl_cell_area.x + x_offset;
max_x = min_x + width;
max_x = min_x + min_size.width;
min_y = rtl_cell_area.y + y_offset;
max_y = min_y + height;
max_y = min_y + min_size.height;
}
}
else
{
if (min_x > (rtl_cell_area.x + x_offset))
min_x = rtl_cell_area.x + x_offset;
if (max_x < rtl_cell_area.x + x_offset + width)
max_x = rtl_cell_area.x + x_offset + width;
if (max_x < rtl_cell_area.x + x_offset + min_size.width)
max_x = rtl_cell_area.x + x_offset + min_size.width;
if (min_y > (rtl_cell_area.y + y_offset))
min_y = rtl_cell_area.y + y_offset;
if (max_y < rtl_cell_area.y + y_offset + height)
max_y = rtl_cell_area.y + y_offset + height;
if (max_y < rtl_cell_area.y + y_offset + min_size.height)
max_y = rtl_cell_area.y + y_offset + min_size.height;
}
}
/* EVENT */
@ -3004,34 +3007,38 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
/* FOCUS */
else if (action == CELL_ACTION_FOCUS)
{
gint x_offset, y_offset, width, height;
gint x_offset, y_offset;
GtkRequisition min_size;
gtk_cell_renderer_get_size (info->cell,
gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (info->cell),
tree_column->tree_view,
&rtl_cell_area,
&x_offset, &y_offset,
&width, &height);
&min_size, NULL);
_gtk_cell_renderer_calc_offset (info->cell, &rtl_cell_area,
gtk_widget_get_direction (tree_column->tree_view),
min_size.width, min_size.height,
&x_offset, &y_offset);
if (special_cells > 1)
{
if (info->has_focus)
{
min_x = rtl_cell_area.x + x_offset;
max_x = min_x + width;
max_x = min_x + min_size.width;
min_y = rtl_cell_area.y + y_offset;
max_y = min_y + height;
max_y = min_y + min_size.height;
}
}
else
{
if (min_x > (rtl_cell_area.x + x_offset))
min_x = rtl_cell_area.x + x_offset;
if (max_x < rtl_cell_area.x + x_offset + width)
max_x = rtl_cell_area.x + x_offset + width;
if (max_x < rtl_cell_area.x + x_offset + min_size.width)
max_x = rtl_cell_area.x + x_offset + min_size.width;
if (min_y > (rtl_cell_area.y + y_offset))
min_y = rtl_cell_area.y + y_offset;
if (max_y < rtl_cell_area.y + y_offset + height)
max_y = rtl_cell_area.y + y_offset + height;
if (max_y < rtl_cell_area.y + y_offset + min_size.height)
max_y = rtl_cell_area.y + y_offset + min_size.height;
}
}
/* EVENT */