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:
@ -29,6 +29,7 @@
|
|||||||
#include "gtkcellrenderer.h"
|
#include "gtkcellrenderer.h"
|
||||||
#include "gtkcellrenderertext.h"
|
#include "gtkcellrenderertext.h"
|
||||||
#include "gtkcellrendererpixbuf.h"
|
#include "gtkcellrendererpixbuf.h"
|
||||||
|
#include "gtkcellsizerequest.h"
|
||||||
#include "gtkmarshalers.h"
|
#include "gtkmarshalers.h"
|
||||||
#include "gtkbindings.h"
|
#include "gtkbindings.h"
|
||||||
#include "gtkdnd.h"
|
#include "gtkdnd.h"
|
||||||
@ -2963,24 +2964,22 @@ adjust_wrap_width (GtkIconView *icon_view,
|
|||||||
{
|
{
|
||||||
GtkIconViewCellInfo *text_info;
|
GtkIconViewCellInfo *text_info;
|
||||||
GtkIconViewCellInfo *pixbuf_info;
|
GtkIconViewCellInfo *pixbuf_info;
|
||||||
gint pixbuf_width, wrap_width;
|
gint wrap_width;
|
||||||
|
|
||||||
if (icon_view->priv->text_cell != -1 &&
|
if (icon_view->priv->text_cell != -1 &&
|
||||||
icon_view->priv->pixbuf_cell != -1)
|
icon_view->priv->pixbuf_cell != -1)
|
||||||
{
|
{
|
||||||
|
GtkRequisition min_size;
|
||||||
gint item_width;
|
gint item_width;
|
||||||
|
|
||||||
text_info = g_list_nth_data (icon_view->priv->cell_list,
|
text_info = g_list_nth_data (icon_view->priv->cell_list,
|
||||||
icon_view->priv->text_cell);
|
icon_view->priv->text_cell);
|
||||||
pixbuf_info = g_list_nth_data (icon_view->priv->cell_list,
|
pixbuf_info = g_list_nth_data (icon_view->priv->cell_list,
|
||||||
icon_view->priv->pixbuf_cell);
|
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),
|
GTK_WIDGET (icon_view),
|
||||||
NULL, NULL, NULL,
|
&min_size, NULL);
|
||||||
&pixbuf_width,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
|
|
||||||
if (icon_view->priv->item_width > 0)
|
if (icon_view->priv->item_width > 0)
|
||||||
item_width = icon_view->priv->item_width;
|
item_width = icon_view->priv->item_width;
|
||||||
@ -2991,9 +2990,9 @@ adjust_wrap_width (GtkIconView *icon_view,
|
|||||||
wrap_width = item_width;
|
wrap_width = item_width;
|
||||||
else {
|
else {
|
||||||
if (item->width == -1 && item_width <= 0)
|
if (item->width == -1 && item_width <= 0)
|
||||||
wrap_width = MAX (2 * pixbuf_width, 50);
|
wrap_width = MAX (2 * min_size.width, 50);
|
||||||
else
|
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;
|
wrap_width -= icon_view->priv->item_padding * 2;
|
||||||
@ -3007,6 +3006,7 @@ static void
|
|||||||
gtk_icon_view_calculate_item_size (GtkIconView *icon_view,
|
gtk_icon_view_calculate_item_size (GtkIconView *icon_view,
|
||||||
GtkIconViewItem *item)
|
GtkIconViewItem *item)
|
||||||
{
|
{
|
||||||
|
GtkRequisition min_size;
|
||||||
gint spacing;
|
gint spacing;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
@ -3038,11 +3038,12 @@ gtk_icon_view_calculate_item_size (GtkIconView *icon_view,
|
|||||||
|
|
||||||
if (!gtk_cell_renderer_get_visible (info->cell))
|
if (!gtk_cell_renderer_get_visible (info->cell))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
gtk_cell_renderer_get_size (info->cell, GTK_WIDGET (icon_view),
|
gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (info->cell),
|
||||||
NULL, NULL, NULL,
|
GTK_WIDGET (icon_view),
|
||||||
&item->box[info->position].width,
|
&min_size, NULL);
|
||||||
&item->box[info->position].height);
|
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)
|
if (icon_view->priv->item_orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
{
|
{
|
||||||
@ -3066,6 +3067,7 @@ gtk_icon_view_calculate_item_size2 (GtkIconView *icon_view,
|
|||||||
GtkIconViewItem *item,
|
GtkIconViewItem *item,
|
||||||
gint *max_height)
|
gint *max_height)
|
||||||
{
|
{
|
||||||
|
GtkRequisition min_size;
|
||||||
GdkRectangle cell_area;
|
GdkRectangle cell_area;
|
||||||
gint spacing;
|
gint spacing;
|
||||||
GList *l;
|
GList *l;
|
||||||
@ -3094,7 +3096,7 @@ gtk_icon_view_calculate_item_size2 (GtkIconView *icon_view,
|
|||||||
for (l = icon_view->priv->cell_list, i = 0; l; l = l->next, i++)
|
for (l = icon_view->priv->cell_list, i = 0; l; l = l->next, i++)
|
||||||
{
|
{
|
||||||
GtkIconViewCellInfo *info = (GtkIconViewCellInfo *)l->data;
|
GtkIconViewCellInfo *info = (GtkIconViewCellInfo *)l->data;
|
||||||
|
|
||||||
if (info->pack == (k ? GTK_PACK_START : GTK_PACK_END))
|
if (info->pack == (k ? GTK_PACK_START : GTK_PACK_END))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -3118,14 +3120,20 @@ gtk_icon_view_calculate_item_size2 (GtkIconView *icon_view,
|
|||||||
cell_area.width = item->width - 2 * icon_view->priv->item_padding;
|
cell_area.width = item->width - 2 * icon_view->priv->item_padding;
|
||||||
cell_area.height = max_height[i];
|
cell_area.height = max_height[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_cell_renderer_get_size (info->cell, GTK_WIDGET (icon_view),
|
gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (info->cell),
|
||||||
&cell_area,
|
GTK_WIDGET (icon_view),
|
||||||
&item->box[info->position].x, &item->box[info->position].y,
|
&min_size, NULL);
|
||||||
&item->box[info->position].width, &item->box[info->position].height);
|
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].x += cell_area.x;
|
||||||
item->box[info->position].y += cell_area.y;
|
item->box[info->position].y += cell_area.y;
|
||||||
|
|
||||||
if (icon_view->priv->item_orientation == GTK_ORIENTATION_HORIZONTAL)
|
if (icon_view->priv->item_orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
{
|
{
|
||||||
item->before[info->position] = item->box[info->position].x - cell_area.x;
|
item->before[info->position] = item->box[info->position].x - cell_area.x;
|
||||||
|
@ -18,8 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <string.h>
|
|
||||||
#include "gtktreeviewcolumn.h"
|
#include "gtktreeviewcolumn.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gtkcellsizerequest.h"
|
||||||
#include "gtktreeview.h"
|
#include "gtktreeview.h"
|
||||||
#include "gtktreeprivate.h"
|
#include "gtktreeprivate.h"
|
||||||
#include "gtkcelllayout.h"
|
#include "gtkcelllayout.h"
|
||||||
@ -2611,6 +2615,7 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
|
|||||||
gint *width,
|
gint *width,
|
||||||
gint *height)
|
gint *height)
|
||||||
{
|
{
|
||||||
|
GtkRequisition min_size;
|
||||||
GList *list;
|
GList *list;
|
||||||
gboolean first_cell = TRUE;
|
gboolean first_cell = TRUE;
|
||||||
gint focus_line_width;
|
gint focus_line_width;
|
||||||
@ -2628,8 +2633,6 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
|
|||||||
{
|
{
|
||||||
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
|
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
gint new_height = 0;
|
|
||||||
gint new_width = 0;
|
|
||||||
g_object_get (info->cell, "visible", &visible, NULL);
|
g_object_get (info->cell, "visible", &visible, NULL);
|
||||||
|
|
||||||
if (visible == FALSE)
|
if (visible == FALSE)
|
||||||
@ -2638,17 +2641,13 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
|
|||||||
if (first_cell == FALSE && width)
|
if (first_cell == FALSE && width)
|
||||||
*width += tree_column->spacing;
|
*width += tree_column->spacing;
|
||||||
|
|
||||||
gtk_cell_renderer_get_size (info->cell,
|
gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (info->cell),
|
||||||
tree_column->tree_view,
|
GTK_WIDGET (tree_column->tree_view),
|
||||||
cell_area,
|
&min_size, NULL);
|
||||||
x_offset,
|
|
||||||
y_offset,
|
|
||||||
&new_width,
|
|
||||||
&new_height);
|
|
||||||
|
|
||||||
if (height)
|
if (height)
|
||||||
* height = MAX (*height, new_height + focus_line_width * 2);
|
* height = MAX (*height, min_size.height + focus_line_width * 2);
|
||||||
info->requested_width = MAX (info->requested_width, new_width + focus_line_width * 2);
|
info->requested_width = MAX (info->requested_width, min_size.width + focus_line_width * 2);
|
||||||
if (width)
|
if (width)
|
||||||
* width += info->requested_width;
|
* width += info->requested_width;
|
||||||
first_cell = FALSE;
|
first_cell = FALSE;
|
||||||
@ -2839,34 +2838,38 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
|||||||
/* FOCUS */
|
/* FOCUS */
|
||||||
else if (action == CELL_ACTION_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,
|
tree_column->tree_view,
|
||||||
&rtl_cell_area,
|
&min_size, NULL);
|
||||||
&x_offset, &y_offset,
|
|
||||||
&width, &height);
|
_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 (special_cells > 1)
|
||||||
{
|
{
|
||||||
if (info->has_focus)
|
if (info->has_focus)
|
||||||
{
|
{
|
||||||
min_x = rtl_cell_area.x + x_offset;
|
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;
|
min_y = rtl_cell_area.y + y_offset;
|
||||||
max_y = min_y + height;
|
max_y = min_y + min_size.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (min_x > (rtl_cell_area.x + x_offset))
|
if (min_x > (rtl_cell_area.x + x_offset))
|
||||||
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)
|
if (max_x < rtl_cell_area.x + x_offset + min_size.width)
|
||||||
max_x = rtl_cell_area.x + x_offset + width;
|
max_x = rtl_cell_area.x + x_offset + min_size.width;
|
||||||
if (min_y > (rtl_cell_area.y + y_offset))
|
if (min_y > (rtl_cell_area.y + y_offset))
|
||||||
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)
|
if (max_y < rtl_cell_area.y + y_offset + min_size.height)
|
||||||
max_y = rtl_cell_area.y + y_offset + height;
|
max_y = rtl_cell_area.y + y_offset + min_size.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* EVENT */
|
/* EVENT */
|
||||||
@ -3004,34 +3007,38 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
|||||||
/* FOCUS */
|
/* FOCUS */
|
||||||
else if (action == CELL_ACTION_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,
|
tree_column->tree_view,
|
||||||
&rtl_cell_area,
|
&min_size, NULL);
|
||||||
&x_offset, &y_offset,
|
|
||||||
&width, &height);
|
_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 (special_cells > 1)
|
||||||
{
|
{
|
||||||
if (info->has_focus)
|
if (info->has_focus)
|
||||||
{
|
{
|
||||||
min_x = rtl_cell_area.x + x_offset;
|
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;
|
min_y = rtl_cell_area.y + y_offset;
|
||||||
max_y = min_y + height;
|
max_y = min_y + min_size.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (min_x > (rtl_cell_area.x + x_offset))
|
if (min_x > (rtl_cell_area.x + x_offset))
|
||||||
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)
|
if (max_x < rtl_cell_area.x + x_offset + min_size.width)
|
||||||
max_x = rtl_cell_area.x + x_offset + width;
|
max_x = rtl_cell_area.x + x_offset + min_size.width;
|
||||||
if (min_y > (rtl_cell_area.y + y_offset))
|
if (min_y > (rtl_cell_area.y + y_offset))
|
||||||
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)
|
if (max_y < rtl_cell_area.y + y_offset + min_size.height)
|
||||||
max_y = rtl_cell_area.y + y_offset + height;
|
max_y = rtl_cell_area.y + y_offset + min_size.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* EVENT */
|
/* EVENT */
|
||||||
|
Reference in New Issue
Block a user