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.
This commit is contained in:
Ell
2020-05-22 16:28:02 +03:00
parent d9f5558977
commit 258c8454d5

View File

@ -63,6 +63,7 @@ struct _GimpImageProxyPrivate
/* local function prototypes */
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,
@ -125,6 +126,11 @@ static void gimp_image_proxy_srgb_to_pixel (GimpPickable
const Babl *format,
gpointer pixel);
static const guint8 * gimp_image_proxy_get_icc_profile (GimpColorManaged *managed,
gsize *len);
static GimpColorProfile * gimp_image_proxy_get_color_profile (GimpColorManaged *managed);
static void gimp_image_proxy_profile_changed (GimpColorManaged *managed);
static void gimp_image_proxy_image_frozen_notify (GimpImage *image,
const GParamSpec *pspec,
GimpImageProxy *image_proxy);
@ -136,6 +142,8 @@ static void gimp_image_proxy_image_bounds_changed (GimpImage
gint old_x,
gint old_y,
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);
@ -147,7 +155,9 @@ static void gimp_image_proxy_update_frozen (GimpImageProxy
G_DEFINE_TYPE_WITH_CODE (GimpImageProxy, gimp_image_proxy, GIMP_TYPE_VIEWABLE,
G_ADD_PRIVATE (GimpImageProxy)
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
@ -205,6 +215,14 @@ gimp_image_proxy_pickable_iface_init (GimpPickableInterface *iface)
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
gimp_image_proxy_init (GimpImageProxy *image_proxy)
{
@ -611,6 +629,32 @@ gimp_image_proxy_srgb_to_pixel (GimpPickable *pickable,
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
gimp_image_proxy_image_frozen_notify (GimpImage *image,
const GParamSpec *pspec,
@ -642,6 +686,13 @@ gimp_image_proxy_image_bounds_changed (GimpImage *image,
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
gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
GimpImage *image)
@ -664,6 +715,10 @@ gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
image_proxy->priv->image,
gimp_image_proxy_image_bounds_changed,
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);
}
@ -690,6 +745,10 @@ gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
image_proxy->priv->image, "bounds-changed",
G_CALLBACK (gimp_image_proxy_image_bounds_changed),
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_frozen (image_proxy);