mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
Add a GtkIconView::item-padding property
The property can be used to fine-tune who much space each column needs. See bug 586100.
This commit is contained in:
parent
ae37d2097e
commit
549ffcbf5c
@ -1972,6 +1972,8 @@ gtk_icon_view_set_column_spacing
|
||||
gtk_icon_view_get_column_spacing
|
||||
gtk_icon_view_set_margin
|
||||
gtk_icon_view_get_margin
|
||||
gtk_icon_view_set_item_padding
|
||||
gtk_icon_view_get_item_padding
|
||||
gtk_icon_view_select_path
|
||||
gtk_icon_view_unselect_path
|
||||
gtk_icon_view_path_is_selected
|
||||
|
@ -1988,6 +1988,7 @@ gtk_icon_theme_set_search_path_utf8
|
||||
gtk_icon_view_get_column_spacing
|
||||
gtk_icon_view_get_columns
|
||||
gtk_icon_view_get_cursor
|
||||
gtk_icon_view_get_item_padding
|
||||
gtk_icon_view_get_item_width
|
||||
gtk_icon_view_get_margin
|
||||
gtk_icon_view_get_markup_column
|
||||
@ -2015,6 +2016,7 @@ gtk_icon_view_select_path
|
||||
gtk_icon_view_set_column_spacing
|
||||
gtk_icon_view_set_columns
|
||||
gtk_icon_view_set_cursor
|
||||
gtk_icon_view_set_item_padding
|
||||
gtk_icon_view_set_item_width
|
||||
gtk_icon_view_set_margin
|
||||
gtk_icon_view_set_markup_column
|
||||
|
@ -46,7 +46,6 @@
|
||||
#undef DEBUG_ICON_VIEW
|
||||
|
||||
#define SCROLL_EDGE_SIZE 15
|
||||
#define ITEM_PADDING 6
|
||||
|
||||
#define GTK_ICON_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ICON_VIEW, GtkIconViewPrivate))
|
||||
|
||||
@ -150,6 +149,7 @@ struct _GtkIconViewPrivate
|
||||
gint row_spacing;
|
||||
gint column_spacing;
|
||||
gint margin;
|
||||
gint item_padding;
|
||||
|
||||
gint text_column;
|
||||
gint markup_column;
|
||||
@ -220,7 +220,8 @@ enum
|
||||
PROP_COLUMN_SPACING,
|
||||
PROP_MARGIN,
|
||||
PROP_REORDERABLE,
|
||||
PROP_TOOLTIP_COLUMN
|
||||
PROP_TOOLTIP_COLUMN,
|
||||
PROP_ITEM_PADDING
|
||||
};
|
||||
|
||||
/* GObject vfuncs */
|
||||
@ -714,7 +715,6 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
|
||||
0, G_MAXINT, 6,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
|
||||
/**
|
||||
* GtkIconView:orientation:
|
||||
*
|
||||
@ -758,6 +758,22 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
|
||||
-1,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkIconView:item-padding:
|
||||
*
|
||||
* The item-padding property specifies the padding around each
|
||||
* of the icon view's item.
|
||||
*
|
||||
* Since: 2.18
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ITEM_PADDING,
|
||||
g_param_spec_int ("item-padding",
|
||||
P_("Item Padding"),
|
||||
P_("Padding around icon view items"),
|
||||
0, G_MAXINT, 6,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
|
||||
|
||||
/* Style properties */
|
||||
@ -1106,6 +1122,7 @@ gtk_icon_view_init (GtkIconView *icon_view)
|
||||
icon_view->priv->row_spacing = 6;
|
||||
icon_view->priv->column_spacing = 6;
|
||||
icon_view->priv->margin = 6;
|
||||
icon_view->priv->item_padding = 6;
|
||||
|
||||
icon_view->priv->draw_focus = TRUE;
|
||||
}
|
||||
@ -1418,10 +1435,10 @@ gtk_icon_view_allocate_children (GtkIconView *icon_view)
|
||||
/* totally ignore our child's requisition */
|
||||
if (child->cell < 0)
|
||||
{
|
||||
allocation.x = child->item->x + ITEM_PADDING;
|
||||
allocation.y = child->item->y + ITEM_PADDING;
|
||||
allocation.width = child->item->width - ITEM_PADDING * 2;
|
||||
allocation.height = child->item->height - ITEM_PADDING * 2;
|
||||
allocation.x = child->item->x + icon_view->priv->item_padding;
|
||||
allocation.y = child->item->y + icon_view->priv->item_padding;
|
||||
allocation.width = child->item->width - icon_view->priv->item_padding * 2;
|
||||
allocation.height = child->item->height - icon_view->priv->item_padding * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2858,16 +2875,16 @@ gtk_icon_view_get_cell_area (GtkIconView *icon_view,
|
||||
if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
cell_area->x = item->box[info->position].x - item->before[info->position];
|
||||
cell_area->y = item->y + ITEM_PADDING;
|
||||
cell_area->y = item->y + icon_view->priv->item_padding;
|
||||
cell_area->width = item->box[info->position].width +
|
||||
item->before[info->position] + item->after[info->position];
|
||||
cell_area->height = item->height - ITEM_PADDING * 2;
|
||||
cell_area->height = item->height - icon_view->priv->item_padding * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
cell_area->x = item->x + ITEM_PADDING;
|
||||
cell_area->x = item->x + icon_view->priv->item_padding;
|
||||
cell_area->y = item->box[info->position].y - item->before[info->position];
|
||||
cell_area->width = item->width - ITEM_PADDING * 2;
|
||||
cell_area->width = item->width - icon_view->priv->item_padding * 2;
|
||||
cell_area->height = item->box[info->position].height +
|
||||
item->before[info->position] + item->after[info->position];
|
||||
}
|
||||
@ -2925,7 +2942,7 @@ adjust_wrap_width (GtkIconView *icon_view,
|
||||
wrap_width = item_width - pixbuf_width - icon_view->priv->spacing;
|
||||
}
|
||||
|
||||
wrap_width -= ITEM_PADDING * 2;
|
||||
wrap_width -= icon_view->priv->item_padding * 2;
|
||||
|
||||
g_object_set (text_info->cell, "wrap-width", wrap_width, NULL);
|
||||
g_object_set (text_info->cell, "width", wrap_width, NULL);
|
||||
@ -2986,8 +3003,8 @@ gtk_icon_view_calculate_item_size (GtkIconView *icon_view,
|
||||
}
|
||||
}
|
||||
|
||||
item->width += ITEM_PADDING * 2;
|
||||
item->height += ITEM_PADDING * 2;
|
||||
item->width += icon_view->priv->item_padding * 2;
|
||||
item->height += icon_view->priv->item_padding * 2;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3016,8 +3033,8 @@ gtk_icon_view_calculate_item_size2 (GtkIconView *icon_view,
|
||||
item->height += max_height[i] + (i > 0 ? spacing : 0);
|
||||
}
|
||||
|
||||
cell_area.x = item->x + ITEM_PADDING;
|
||||
cell_area.y = item->y + ITEM_PADDING;
|
||||
cell_area.x = item->x + icon_view->priv->item_padding;
|
||||
cell_area.y = item->y + icon_view->priv->item_padding;
|
||||
|
||||
for (k = 0; k < 2; k++)
|
||||
for (l = icon_view->priv->cell_list, i = 0; l; l = l->next, i++)
|
||||
@ -3032,7 +3049,7 @@ gtk_icon_view_calculate_item_size2 (GtkIconView *icon_view,
|
||||
|
||||
if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
/* We should not subtract ITEM_PADDING from item->height,
|
||||
/* We should not subtract icon_view->priv->item_padding from item->height,
|
||||
* because item->height is recalculated above using
|
||||
* max_height which does not contain item padding.
|
||||
*/
|
||||
@ -3044,7 +3061,7 @@ gtk_icon_view_calculate_item_size2 (GtkIconView *icon_view,
|
||||
/* item->width is not recalculated and thus needs to be
|
||||
* corrected for the padding.
|
||||
*/
|
||||
cell_area.width = item->width - 2 * ITEM_PADDING;
|
||||
cell_area.width = item->width - 2 * icon_view->priv->item_padding;
|
||||
cell_area.height = max_height[i];
|
||||
}
|
||||
|
||||
@ -3063,9 +3080,9 @@ gtk_icon_view_calculate_item_size2 (GtkIconView *icon_view,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item->box[info->position].width > item->width - ITEM_PADDING * 2)
|
||||
if (item->box[info->position].width > item->width - icon_view->priv->item_padding * 2)
|
||||
{
|
||||
item->width = item->box[info->position].width + ITEM_PADDING * 2;
|
||||
item->width = item->box[info->position].width + icon_view->priv->item_padding * 2;
|
||||
cell_area.width = item->width;
|
||||
}
|
||||
item->before[info->position] = item->box[info->position].y - cell_area.y;
|
||||
@ -3083,7 +3100,7 @@ gtk_icon_view_calculate_item_size2 (GtkIconView *icon_view,
|
||||
}
|
||||
}
|
||||
|
||||
item->height += ITEM_PADDING * 2;
|
||||
item->height += icon_view->priv->item_padding * 2;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -6239,6 +6256,51 @@ gtk_icon_view_get_margin (GtkIconView *icon_view)
|
||||
return icon_view->priv->margin;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_icon_view_set_item_padding:
|
||||
* @icon_view: a #GtkIconView
|
||||
* @column_spacing: the item padding
|
||||
*
|
||||
* Sets the ::item-padding property which specifies the padding
|
||||
* around each of the icon view's items.
|
||||
*
|
||||
* Since: 2.18
|
||||
*/
|
||||
void
|
||||
gtk_icon_view_set_item_padding (GtkIconView *icon_view,
|
||||
gint item_padding)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
|
||||
|
||||
if (icon_view->priv->item_padding != item_padding)
|
||||
{
|
||||
icon_view->priv->item_padding = item_padding;
|
||||
|
||||
gtk_icon_view_stop_editing (icon_view, TRUE);
|
||||
gtk_icon_view_invalidate_sizes (icon_view);
|
||||
gtk_icon_view_queue_layout (icon_view);
|
||||
|
||||
g_object_notify (G_OBJECT (icon_view), "item-padding");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_icon_view_get_item_padding:
|
||||
* @icon_view: a #GtkIconView
|
||||
*
|
||||
* Returns the value of the ::item-padding property.
|
||||
*
|
||||
* Return value: the padding around items
|
||||
*
|
||||
* Since: 2.18
|
||||
*/
|
||||
gint
|
||||
gtk_icon_view_get_item_padding (GtkIconView *icon_view)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), -1);
|
||||
|
||||
return icon_view->priv->item_padding;
|
||||
}
|
||||
|
||||
/* Get/set whether drag_motion requested the drag data and
|
||||
* drag_data_received should thus not actually insert the data,
|
||||
|
@ -125,6 +125,9 @@ gint gtk_icon_view_get_column_spacing (GtkIconView *icon_view);
|
||||
void gtk_icon_view_set_margin (GtkIconView *icon_view,
|
||||
gint margin);
|
||||
gint gtk_icon_view_get_margin (GtkIconView *icon_view);
|
||||
void gtk_icon_view_set_item_padding (GtkIconView *icon_view,
|
||||
gint item_padding);
|
||||
gint gtk_icon_view_get_item_padding (GtkIconView *icon_view);
|
||||
|
||||
|
||||
GtkTreePath * gtk_icon_view_get_path_at_pos (GtkIconView *icon_view,
|
||||
|
Loading…
Reference in New Issue
Block a user