app: implement GimpColorManaged for GimpImageProxy

In GimpImageProxy, implement GimpColorManaged by forwarding the
functions to the underlying GimpImage, and forwarding the signals
in the other direction.  This fixes color-managed view in the
Navigation dockable.

(cherry picked from commit 258c8454d5)
This commit is contained in:
Ell
2020-05-22 16:28:02 +03:00
parent b742cc0a0d
commit efb97fa7bd

View File

@ -61,92 +61,102 @@ struct _GimpImageProxyPrivate
/* local function prototypes */ /* local function prototypes */
static void gimp_image_proxy_pickable_iface_init (GimpPickableInterface *iface); static void gimp_image_proxy_pickable_iface_init (GimpPickableInterface *iface);
static void gimp_image_proxy_color_managed_iface_init (GimpColorManagedInterface *iface);
static void gimp_image_proxy_finalize (GObject *object);
static void gimp_image_proxy_set_property (GObject *object, static void gimp_image_proxy_finalize (GObject *object);
guint property_id, static void gimp_image_proxy_set_property (GObject *object,
const GValue *value, guint property_id,
GParamSpec *pspec); const GValue *value,
static void gimp_image_proxy_get_property (GObject *object, GParamSpec *pspec);
guint property_id, static void gimp_image_proxy_get_property (GObject *object,
GValue *value, guint property_id,
GParamSpec *pspec); GValue *value,
GParamSpec *pspec);
static gboolean gimp_image_proxy_get_size (GimpViewable *viewable,
gint *width, static gboolean gimp_image_proxy_get_size (GimpViewable *viewable,
gint *height); gint *width,
static void gimp_image_proxy_get_preview_size (GimpViewable *viewable, gint *height);
gint size, static void gimp_image_proxy_get_preview_size (GimpViewable *viewable,
gboolean is_popup, gint size,
gboolean dot_for_dot, gboolean is_popup,
gint *width, gboolean dot_for_dot,
gint *height); gint *width,
static gboolean gimp_image_proxy_get_popup_size (GimpViewable *viewable, gint *height);
gint width, static gboolean gimp_image_proxy_get_popup_size (GimpViewable *viewable,
gint height, gint width,
gboolean dot_for_dot, gint height,
gint *popup_width, gboolean dot_for_dot,
gint *popup_height); gint *popup_width,
static GimpTempBuf * gimp_image_proxy_get_new_preview (GimpViewable *viewable, gint *popup_height);
GimpContext *context, static GimpTempBuf * gimp_image_proxy_get_new_preview (GimpViewable *viewable,
gint width, GimpContext *context,
gint height); gint width,
static GdkPixbuf * gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable, gint height);
GimpContext *context, static GdkPixbuf * gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable,
gint width, GimpContext *context,
gint height); gint width,
static gchar * gimp_image_proxy_get_description (GimpViewable *viewable, gint height);
gchar **tooltip); static gchar * gimp_image_proxy_get_description (GimpViewable *viewable,
gchar **tooltip);
static void gimp_image_proxy_flush (GimpPickable *pickable);
static const Babl * gimp_image_proxy_get_format (GimpPickable *pickable); static void gimp_image_proxy_flush (GimpPickable *pickable);
static const Babl * gimp_image_proxy_get_format_with_alpha (GimpPickable *pickable); static const Babl * gimp_image_proxy_get_format (GimpPickable *pickable);
static GeglBuffer * gimp_image_proxy_get_buffer (GimpPickable *pickable); static const Babl * gimp_image_proxy_get_format_with_alpha (GimpPickable *pickable);
static gboolean gimp_image_proxy_get_pixel_at (GimpPickable *pickable, static GeglBuffer * gimp_image_proxy_get_buffer (GimpPickable *pickable);
gint x, static gboolean gimp_image_proxy_get_pixel_at (GimpPickable *pickable,
gint y, gint x,
const Babl *format, gint y,
gpointer pixel); const Babl *format,
static gdouble gimp_image_proxy_get_opacity_at (GimpPickable *pickable, gpointer pixel);
gint x, static gdouble gimp_image_proxy_get_opacity_at (GimpPickable *pickable,
gint y); gint x,
static void gimp_image_proxy_get_pixel_average (GimpPickable *pickable, gint y);
const GeglRectangle *rect, static void gimp_image_proxy_get_pixel_average (GimpPickable *pickable,
const Babl *format, const GeglRectangle *rect,
gpointer pixel); const Babl *format,
static void gimp_image_proxy_pixel_to_srgb (GimpPickable *pickable, gpointer pixel);
const Babl *format, static void gimp_image_proxy_pixel_to_srgb (GimpPickable *pickable,
gpointer pixel, const Babl *format,
GimpRGB *color); gpointer pixel,
static void gimp_image_proxy_srgb_to_pixel (GimpPickable *pickable, GimpRGB *color);
const GimpRGB *color, static void gimp_image_proxy_srgb_to_pixel (GimpPickable *pickable,
const Babl *format, const GimpRGB *color,
gpointer pixel); const Babl *format,
gpointer pixel);
static void gimp_image_proxy_image_frozen_notify (GimpImage *image,
const GParamSpec *pspec, static const guint8 * gimp_image_proxy_get_icc_profile (GimpColorManaged *managed,
GimpImageProxy *image_proxy); gsize *len);
static void gimp_image_proxy_image_invalidate_preview (GimpImage *image, static GimpColorProfile * gimp_image_proxy_get_color_profile (GimpColorManaged *managed);
GimpImageProxy *image_proxy); static void gimp_image_proxy_profile_changed (GimpColorManaged *managed);
static void gimp_image_proxy_image_size_changed (GimpImage *image,
GimpImageProxy *image_proxy); static void gimp_image_proxy_image_frozen_notify (GimpImage *image,
static void gimp_image_proxy_image_bounds_changed (GimpImage *image, const GParamSpec *pspec,
gint old_x, GimpImageProxy *image_proxy);
gint old_y, static void gimp_image_proxy_image_invalidate_preview (GimpImage *image,
GimpImageProxy *image_proxy); GimpImageProxy *image_proxy);
static void gimp_image_proxy_image_size_changed (GimpImage *image,
static void gimp_image_proxy_set_image (GimpImageProxy *image_proxy, GimpImageProxy *image_proxy);
GimpImage *image); static void gimp_image_proxy_image_bounds_changed (GimpImage *image,
static GimpPickable * gimp_image_proxy_get_pickable (GimpImageProxy *image_proxy); gint old_x,
static void gimp_image_proxy_update_bounding_box (GimpImageProxy *image_proxy); gint old_y,
static void gimp_image_proxy_update_frozen (GimpImageProxy *image_proxy); GimpImageProxy *image_proxy);
static void gimp_image_proxy_image_profile_changed (GimpImage *image,
GimpImageProxy *image_proxy);
static void gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
GimpImage *image);
static GimpPickable * gimp_image_proxy_get_pickable (GimpImageProxy *image_proxy);
static void gimp_image_proxy_update_bounding_box (GimpImageProxy *image_proxy);
static void gimp_image_proxy_update_frozen (GimpImageProxy *image_proxy);
G_DEFINE_TYPE_WITH_CODE (GimpImageProxy, gimp_image_proxy, GIMP_TYPE_VIEWABLE, G_DEFINE_TYPE_WITH_CODE (GimpImageProxy, gimp_image_proxy, GIMP_TYPE_VIEWABLE,
G_ADD_PRIVATE (GimpImageProxy) G_ADD_PRIVATE (GimpImageProxy)
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PICKABLE, G_IMPLEMENT_INTERFACE (GIMP_TYPE_PICKABLE,
gimp_image_proxy_pickable_iface_init)) gimp_image_proxy_pickable_iface_init)
G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED,
gimp_image_proxy_color_managed_iface_init))
#define parent_class gimp_image_proxy_parent_class #define parent_class gimp_image_proxy_parent_class
@ -204,6 +214,14 @@ gimp_image_proxy_pickable_iface_init (GimpPickableInterface *iface)
iface->srgb_to_pixel = gimp_image_proxy_srgb_to_pixel; iface->srgb_to_pixel = gimp_image_proxy_srgb_to_pixel;
} }
static void
gimp_image_proxy_color_managed_iface_init (GimpColorManagedInterface *iface)
{
iface->get_icc_profile = gimp_image_proxy_get_icc_profile;
iface->get_color_profile = gimp_image_proxy_get_color_profile;
iface->profile_changed = gimp_image_proxy_profile_changed;
}
static void static void
gimp_image_proxy_init (GimpImageProxy *image_proxy) gimp_image_proxy_init (GimpImageProxy *image_proxy)
{ {
@ -610,6 +628,32 @@ gimp_image_proxy_srgb_to_pixel (GimpPickable *pickable,
gimp_pickable_srgb_to_pixel (proxy_pickable, color, format, pixel); gimp_pickable_srgb_to_pixel (proxy_pickable, color, format, pixel);
} }
static const guint8 *
gimp_image_proxy_get_icc_profile (GimpColorManaged *managed,
gsize *len)
{
GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (managed);
return gimp_color_managed_get_icc_profile (
GIMP_COLOR_MANAGED (image_proxy->priv->image),
len);
}
static GimpColorProfile *
gimp_image_proxy_get_color_profile (GimpColorManaged *managed)
{
GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (managed);
return gimp_color_managed_get_color_profile (
GIMP_COLOR_MANAGED (image_proxy->priv->image));
}
static void
gimp_image_proxy_profile_changed (GimpColorManaged *managed)
{
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (managed));
}
static void static void
gimp_image_proxy_image_frozen_notify (GimpImage *image, gimp_image_proxy_image_frozen_notify (GimpImage *image,
const GParamSpec *pspec, const GParamSpec *pspec,
@ -641,6 +685,13 @@ gimp_image_proxy_image_bounds_changed (GimpImage *image,
gimp_image_proxy_update_bounding_box (image_proxy); gimp_image_proxy_update_bounding_box (image_proxy);
} }
static void
gimp_image_proxy_image_profile_changed (GimpImage *image,
GimpImageProxy *image_proxy)
{
gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (image_proxy));
}
static void static void
gimp_image_proxy_set_image (GimpImageProxy *image_proxy, gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
GimpImage *image) GimpImage *image)
@ -663,6 +714,10 @@ gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
image_proxy->priv->image, image_proxy->priv->image,
gimp_image_proxy_image_bounds_changed, gimp_image_proxy_image_bounds_changed,
image_proxy); image_proxy);
g_signal_handlers_disconnect_by_func (
image_proxy->priv->image,
gimp_image_proxy_image_profile_changed,
image_proxy);
g_object_unref (image_proxy->priv->image); g_object_unref (image_proxy->priv->image);
} }
@ -689,6 +744,10 @@ gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
image_proxy->priv->image, "bounds-changed", image_proxy->priv->image, "bounds-changed",
G_CALLBACK (gimp_image_proxy_image_bounds_changed), G_CALLBACK (gimp_image_proxy_image_bounds_changed),
image_proxy); image_proxy);
g_signal_connect (
image_proxy->priv->image, "profile-changed",
G_CALLBACK (gimp_image_proxy_image_profile_changed),
image_proxy);
gimp_image_proxy_update_bounding_box (image_proxy); gimp_image_proxy_update_bounding_box (image_proxy);
gimp_image_proxy_update_frozen (image_proxy); gimp_image_proxy_update_frozen (image_proxy);