app: add gimp_viewable_has_preview() and use it in GimpRow, instead of

peeking around in GimpViewableClass manually.
This commit is contained in:
Michael Natterer 2025-08-05 17:42:32 +02:00
parent 33bfd5a12b
commit 3b6bb46d36
3 changed files with 12 additions and 4 deletions

View file

@ -696,6 +696,15 @@ gimp_viewable_calc_preview_size (gint aspect_width,
if (scaling_up) *scaling_up = (xratio > 1.0) || (yratio > 1.0);
}
gboolean
gimp_viewable_has_preview (GimpViewable *viewable)
{
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), FALSE);
return (GIMP_VIEWABLE_GET_CLASS (viewable)->get_preview != NULL ||
GIMP_VIEWABLE_GET_CLASS (viewable)->get_new_preview != NULL);
}
gboolean
gimp_viewable_get_size (GimpViewable *viewable,
gint *width,

View file

@ -124,6 +124,7 @@ void gimp_viewable_calc_preview_size (gint aspect_width,
gint *return_height,
gboolean *scaling_up);
gboolean gimp_viewable_has_preview (GimpViewable *viewable);
gboolean gimp_viewable_get_size (GimpViewable *viewable,
gint *width,
gint *height);

View file

@ -261,8 +261,7 @@ gimp_row_constructed (GObject *object)
gtk_box_pack_start (GTK_BOX (priv->box), priv->view, FALSE, FALSE, 0);
if (priv->viewable)
preview = (GIMP_VIEWABLE_GET_CLASS (priv->viewable)->get_preview != NULL ||
GIMP_VIEWABLE_GET_CLASS (priv->viewable)->get_new_preview != NULL);
preview = gimp_viewable_has_preview (priv->viewable);
gtk_widget_set_visible (priv->icon, ! preview);
gtk_widget_set_visible (priv->view, preview);
@ -516,8 +515,7 @@ gimp_row_real_set_viewable (GimpRow *row,
G_CALLBACK (gimp_row_viewable_icon_changed),
row);
preview = (GIMP_VIEWABLE_GET_CLASS (priv->viewable)->get_preview != NULL ||
GIMP_VIEWABLE_GET_CLASS (priv->viewable)->get_new_preview != NULL);
preview = gimp_viewable_has_preview (priv->viewable);
}
gimp_row_viewable_name_changed (priv->viewable, row);