app: rename GimpImageViewable to GimpImageProxy

We're going to have GimpImageProxy implement GimpPickable, so that
it can be used as either a viewable or a pickable proxy for an
image.
This commit is contained in:
Ell
2019-11-03 19:12:55 +02:00
parent 0ddd3330b8
commit 8d8cc12f40
7 changed files with 284 additions and 283 deletions

View File

@ -197,7 +197,7 @@ typedef struct _GimpExtensionManager GimpExtensionManager;
typedef struct _GimpHistogram GimpHistogram; typedef struct _GimpHistogram GimpHistogram;
typedef struct _GimpIdTable GimpIdTable; typedef struct _GimpIdTable GimpIdTable;
typedef struct _GimpImagefile GimpImagefile; typedef struct _GimpImagefile GimpImagefile;
typedef struct _GimpImageViewable GimpImageViewable; typedef struct _GimpImageProxy GimpImageProxy;
typedef struct _GimpInterpreterDB GimpInterpreterDB; typedef struct _GimpInterpreterDB GimpInterpreterDB;
typedef struct _GimpLineArt GimpLineArt; typedef struct _GimpLineArt GimpLineArt;
typedef struct _GimpObjectQueue GimpObjectQueue; typedef struct _GimpObjectQueue GimpObjectQueue;

View File

@ -1,7 +1,7 @@
/* GIMP - The GNU Image Manipulation Program /* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 1995 Spencer Kimball and Peter Mattis
* *
* gimpimageviewable.c * gimpimageproxy.c
* Copyright (C) 2019 Ell * Copyright (C) 2019 Ell
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -35,7 +35,7 @@
#include "gimpimage.h" #include "gimpimage.h"
#include "gimpimage-color-profile.h" #include "gimpimage-color-profile.h"
#include "gimpimage-preview.h" #include "gimpimage-preview.h"
#include "gimpimageviewable.h" #include "gimpimageproxy.h"
#include "gimppickable.h" #include "gimppickable.h"
#include "gimpprojectable.h" #include "gimpprojectable.h"
#include "gimptempbuf.h" #include "gimptempbuf.h"
@ -49,7 +49,7 @@ enum
}; };
struct _GimpImageViewablePrivate struct _GimpImageProxyPrivate
{ {
GimpImage *image; GimpImage *image;
gboolean show_all; gboolean show_all;
@ -61,86 +61,86 @@ struct _GimpImageViewablePrivate
/* local function prototypes */ /* local function prototypes */
static void gimp_image_viewable_finalize (GObject *object); static void gimp_image_proxy_finalize (GObject *object);
static void gimp_image_viewable_set_property (GObject *object, static void gimp_image_proxy_set_property (GObject *object,
guint property_id, guint property_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gimp_image_viewable_get_property (GObject *object, static void gimp_image_proxy_get_property (GObject *object,
guint property_id, guint property_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static gboolean gimp_image_viewable_get_size (GimpViewable *viewable, static gboolean gimp_image_proxy_get_size (GimpViewable *viewable,
gint *width, gint *width,
gint *height); gint *height);
static void gimp_image_viewable_get_preview_size (GimpViewable *viewable, static void gimp_image_proxy_get_preview_size (GimpViewable *viewable,
gint size, gint size,
gboolean is_popup, gboolean is_popup,
gboolean dot_for_dot, gboolean dot_for_dot,
gint *width, gint *width,
gint *height); gint *height);
static gboolean gimp_image_viewable_get_popup_size (GimpViewable *viewable, static gboolean gimp_image_proxy_get_popup_size (GimpViewable *viewable,
gint width, gint width,
gint height, gint height,
gboolean dot_for_dot, gboolean dot_for_dot,
gint *popup_width, gint *popup_width,
gint *popup_height); gint *popup_height);
static GimpTempBuf * gimp_image_viewable_get_new_preview (GimpViewable *viewable, static GimpTempBuf * gimp_image_proxy_get_new_preview (GimpViewable *viewable,
GimpContext *context, GimpContext *context,
gint width, gint width,
gint height); gint height);
static GdkPixbuf * gimp_image_viewable_get_new_pixbuf (GimpViewable *viewable, static GdkPixbuf * gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable,
GimpContext *context, GimpContext *context,
gint width, gint width,
gint height); gint height);
static gchar * gimp_image_viewable_get_description (GimpViewable *viewable, static gchar * gimp_image_proxy_get_description (GimpViewable *viewable,
gchar **tooltip); gchar **tooltip);
static void gimp_image_viewable_image_frozen_notify (GimpImage *image, static void gimp_image_proxy_image_frozen_notify (GimpImage *image,
const GParamSpec *pspec, const GParamSpec *pspec,
GimpImageViewable *image_viewable); GimpImageProxy *image_proxy);
static void gimp_image_viewable_image_invalidate_preview (GimpImage *image, static void gimp_image_proxy_image_invalidate_preview (GimpImage *image,
GimpImageViewable *image_viewable); GimpImageProxy *image_proxy);
static void gimp_image_viewable_image_size_changed (GimpImage *image, static void gimp_image_proxy_image_size_changed (GimpImage *image,
GimpImageViewable *image_viewable); GimpImageProxy *image_proxy);
static void gimp_image_viewable_image_bounds_changed (GimpImage *image, static void gimp_image_proxy_image_bounds_changed (GimpImage *image,
gint old_x, gint old_x,
gint old_y, gint old_y,
GimpImageViewable *image_viewable); GimpImageProxy *image_proxy);
static void gimp_image_viewable_set_image (GimpImageViewable *image_viewable, static void gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
GimpImage *image); GimpImage *image);
static void gimp_image_viewable_update_bounding_box (GimpImageViewable *image_viewable); static void gimp_image_proxy_update_bounding_box (GimpImageProxy *image_proxy);
static void gimp_image_viewable_update_frozen (GimpImageViewable *image_viewable); static void gimp_image_proxy_update_frozen (GimpImageProxy *image_proxy);
G_DEFINE_TYPE_WITH_PRIVATE (GimpImageViewable, gimp_image_viewable, G_DEFINE_TYPE_WITH_PRIVATE (GimpImageProxy, gimp_image_proxy,
GIMP_TYPE_VIEWABLE) GIMP_TYPE_VIEWABLE)
#define parent_class gimp_image_viewable_parent_class #define parent_class gimp_image_proxy_parent_class
/* private functions */ /* private functions */
static void static void-
gimp_image_viewable_class_init (GimpImageViewableClass *klass) gimp_image_proxy_class_init (GimpImageProxyClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass); GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
object_class->finalize = gimp_image_viewable_finalize; object_class->finalize = gimp_image_proxy_finalize;
object_class->set_property = gimp_image_viewable_set_property; object_class->set_property = gimp_image_proxy_set_property;
object_class->get_property = gimp_image_viewable_get_property; object_class->get_property = gimp_image_proxy_get_property;
viewable_class->default_icon_name = "gimp-image"; viewable_class->default_icon_name = "gimp-image";
viewable_class->get_size = gimp_image_viewable_get_size; viewable_class->get_size = gimp_image_proxy_get_size;
viewable_class->get_preview_size = gimp_image_viewable_get_preview_size; viewable_class->get_preview_size = gimp_image_proxy_get_preview_size;
viewable_class->get_popup_size = gimp_image_viewable_get_popup_size; viewable_class->get_popup_size = gimp_image_proxy_get_popup_size;
viewable_class->get_new_preview = gimp_image_viewable_get_new_preview; viewable_class->get_new_preview = gimp_image_proxy_get_new_preview;
viewable_class->get_new_pixbuf = gimp_image_viewable_get_new_pixbuf; viewable_class->get_new_pixbuf = gimp_image_proxy_get_new_pixbuf;
viewable_class->get_description = gimp_image_viewable_get_description; viewable_class->get_description = gimp_image_proxy_get_description;
g_object_class_install_property (object_class, PROP_IMAGE, g_object_class_install_property (object_class, PROP_IMAGE,
g_param_spec_object ("image", g_param_spec_object ("image",
@ -158,39 +158,39 @@ gimp_image_viewable_class_init (GimpImageViewableClass *klass)
} }
static void static void
gimp_image_viewable_init (GimpImageViewable *image_viewable) gimp_image_proxy_init (GimpImageProxy *image_proxy)
{ {
image_viewable->priv = gimp_image_viewable_get_instance_private (image_viewable); image_proxy->priv = gimp_image_proxy_get_instance_private (image_proxy);
} }
static void static void
gimp_image_viewable_finalize (GObject *object) gimp_image_proxy_finalize (GObject *object)
{ {
GimpImageViewable *image_viewable = GIMP_IMAGE_VIEWABLE (object); GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (object);
gimp_image_viewable_set_image (image_viewable, NULL); gimp_image_proxy_set_image (image_proxy, NULL);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static void static void
gimp_image_viewable_set_property (GObject *object, gimp_image_proxy_set_property (GObject *object,
guint property_id, guint property_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpImageViewable *image_viewable = GIMP_IMAGE_VIEWABLE (object); GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (object);
switch (property_id) switch (property_id)
{ {
case PROP_IMAGE: case PROP_IMAGE:
gimp_image_viewable_set_image (image_viewable, gimp_image_proxy_set_image (image_proxy,
g_value_get_object (value)); g_value_get_object (value));
break; break;
case PROP_SHOW_ALL: case PROP_SHOW_ALL:
gimp_image_viewable_set_show_all (image_viewable, gimp_image_proxy_set_show_all (image_proxy,
g_value_get_boolean (value)); g_value_get_boolean (value));
break; break;
default: default:
@ -200,23 +200,23 @@ gimp_image_viewable_set_property (GObject *object,
} }
static void static void
gimp_image_viewable_get_property (GObject *object, gimp_image_proxy_get_property (GObject *object,
guint property_id, guint property_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpImageViewable *image_viewable = GIMP_IMAGE_VIEWABLE (object); GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (object);
switch (property_id) switch (property_id)
{ {
case PROP_IMAGE: case PROP_IMAGE:
g_value_set_object (value, g_value_set_object (value,
gimp_image_viewable_get_image (image_viewable)); gimp_image_proxy_get_image (image_proxy));
break; break;
case PROP_SHOW_ALL: case PROP_SHOW_ALL:
g_value_set_boolean (value, g_value_set_boolean (value,
gimp_image_viewable_get_show_all (image_viewable)); gimp_image_proxy_get_show_all (image_proxy));
break; break;
default: default:
@ -226,32 +226,32 @@ gimp_image_viewable_get_property (GObject *object,
} }
static gboolean static gboolean
gimp_image_viewable_get_size (GimpViewable *viewable, gimp_image_proxy_get_size (GimpViewable *viewable,
gint *width, gint *width,
gint *height) gint *height)
{ {
GimpImageViewable *image_viewable = GIMP_IMAGE_VIEWABLE (viewable); GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (viewable);
*width = image_viewable->priv->bounding_box.width; *width = image_proxy->priv->bounding_box.width;
*height = image_viewable->priv->bounding_box.height; *height = image_proxy->priv->bounding_box.height;
return TRUE; return TRUE;
} }
static void static void
gimp_image_viewable_get_preview_size (GimpViewable *viewable, gimp_image_proxy_get_preview_size (GimpViewable *viewable,
gint size, gint size,
gboolean is_popup, gboolean is_popup,
gboolean dot_for_dot, gboolean dot_for_dot,
gint *width, gint *width,
gint *height) gint *height)
{ {
GimpImageViewable *image_viewable = GIMP_IMAGE_VIEWABLE (viewable); GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (viewable);
GimpImage *image = image_viewable->priv->image; GimpImage *image = image_proxy->priv->image;
gdouble xres; gdouble xres;
gdouble yres; gdouble yres;
gint viewable_width; gint viewable_width;
gint viewable_height; gint viewable_height;
gimp_image_get_resolution (image, &xres, &yres); gimp_image_get_resolution (image, &xres, &yres);
@ -270,12 +270,12 @@ gimp_image_viewable_get_preview_size (GimpViewable *viewable,
} }
static gboolean static gboolean
gimp_image_viewable_get_popup_size (GimpViewable *viewable, gimp_image_proxy_get_popup_size (GimpViewable *viewable,
gint width, gint width,
gint height, gint height,
gboolean dot_for_dot, gboolean dot_for_dot,
gint *popup_width, gint *popup_width,
gint *popup_height) gint *popup_height)
{ {
gint viewable_width; gint viewable_width;
gint viewable_height; gint viewable_height;
@ -308,27 +308,27 @@ gimp_image_viewable_get_popup_size (GimpViewable *viewable,
} }
static GimpTempBuf * static GimpTempBuf *
gimp_image_viewable_get_new_preview (GimpViewable *viewable, gimp_image_proxy_get_new_preview (GimpViewable *viewable,
GimpContext *context, GimpContext *context,
gint width, gint width,
gint height) gint height)
{ {
GimpImageViewable *image_viewable = GIMP_IMAGE_VIEWABLE (viewable); GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (viewable);
GimpImage *image = image_viewable->priv->image; GimpImage *image = image_proxy->priv->image;
GimpPickable *pickable; GimpPickable *pickable;
const Babl *format; const Babl *format;
GeglRectangle bounding_box; GeglRectangle bounding_box;
GimpTempBuf *buf; GimpTempBuf *buf;
gdouble scale_x; gdouble scale_x;
gdouble scale_y; gdouble scale_y;
gdouble scale; gdouble scale;
if (! image_viewable->priv->show_all) if (! image_proxy->priv->show_all)
pickable = GIMP_PICKABLE (image); pickable = GIMP_PICKABLE (image);
else else
pickable = GIMP_PICKABLE (gimp_image_get_projection (image)); pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
bounding_box = gimp_image_viewable_get_bounding_box (image_viewable); bounding_box = gimp_image_proxy_get_bounding_box (image_proxy);
scale_x = (gdouble) width / (gdouble) bounding_box.width; scale_x = (gdouble) width / (gdouble) bounding_box.width;
scale_y = (gdouble) height / (gdouble) bounding_box.height; scale_y = (gdouble) height / (gdouble) bounding_box.height;
@ -353,13 +353,13 @@ gimp_image_viewable_get_new_preview (GimpViewable *viewable,
} }
static GdkPixbuf * static GdkPixbuf *
gimp_image_viewable_get_new_pixbuf (GimpViewable *viewable, gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable,
GimpContext *context, GimpContext *context,
gint width, gint width,
gint height) gint height)
{ {
GimpImageViewable *image_viewable = GIMP_IMAGE_VIEWABLE (viewable); GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (viewable);
GimpImage *image = image_viewable->priv->image; GimpImage *image = image_proxy->priv->image;
GimpPickable *pickable; GimpPickable *pickable;
GeglRectangle bounding_box; GeglRectangle bounding_box;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
@ -368,12 +368,12 @@ gimp_image_viewable_get_new_pixbuf (GimpViewable *viewable,
gdouble scale; gdouble scale;
GimpColorTransform *transform; GimpColorTransform *transform;
if (! image_viewable->priv->show_all) if (! image_proxy->priv->show_all)
pickable = GIMP_PICKABLE (image); pickable = GIMP_PICKABLE (image);
else else
pickable = GIMP_PICKABLE (gimp_image_get_projection (image)); pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
bounding_box = gimp_image_viewable_get_bounding_box (image_viewable); bounding_box = gimp_image_proxy_get_bounding_box (image_proxy);
scale_x = (gdouble) width / (gdouble) bounding_box.width; scale_x = (gdouble) width / (gdouble) bounding_box.width;
scale_y = (gdouble) height / (gdouble) bounding_box.height; scale_y = (gdouble) height / (gdouble) bounding_box.height;
@ -437,11 +437,11 @@ gimp_image_viewable_get_new_pixbuf (GimpViewable *viewable,
} }
static gchar * static gchar *
gimp_image_viewable_get_description (GimpViewable *viewable, gimp_image_proxy_get_description (GimpViewable *viewable,
gchar **tooltip) gchar **tooltip)
{ {
GimpImageViewable *image_viewable = GIMP_IMAGE_VIEWABLE (viewable); GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (viewable);
GimpImage *image = image_viewable->priv->image; GimpImage *image = image_proxy->priv->image;
if (tooltip) if (tooltip)
*tooltip = g_strdup (gimp_image_get_display_path (image)); *tooltip = g_strdup (gimp_image_get_display_path (image));
@ -452,102 +452,102 @@ gimp_image_viewable_get_description (GimpViewable *viewable,
} }
static void static void
gimp_image_viewable_image_frozen_notify (GimpImage *image, gimp_image_proxy_image_frozen_notify (GimpImage *image,
const GParamSpec *pspec, const GParamSpec *pspec,
GimpImageViewable *image_viewable) GimpImageProxy *image_proxy)
{ {
gimp_image_viewable_update_frozen (image_viewable); gimp_image_proxy_update_frozen (image_proxy);
} }
static void static void
gimp_image_viewable_image_invalidate_preview (GimpImage *image, gimp_image_proxy_image_invalidate_preview (GimpImage *image,
GimpImageViewable *image_viewable) GimpImageProxy *image_proxy)
{ {
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (image_viewable)); gimp_viewable_invalidate_preview (GIMP_VIEWABLE (image_proxy));
} }
static void static void
gimp_image_viewable_image_size_changed (GimpImage *image, gimp_image_proxy_image_size_changed (GimpImage *image,
GimpImageViewable *image_viewable) GimpImageProxy *image_proxy)
{ {
gimp_image_viewable_update_bounding_box (image_viewable); gimp_image_proxy_update_bounding_box (image_proxy);
} }
static void static void
gimp_image_viewable_image_bounds_changed (GimpImage *image, gimp_image_proxy_image_bounds_changed (GimpImage *image,
gint old_x, gint old_x,
gint old_y, gint old_y,
GimpImageViewable *image_viewable) GimpImageProxy *image_proxy)
{ {
gimp_image_viewable_update_bounding_box (image_viewable); gimp_image_proxy_update_bounding_box (image_proxy);
} }
static void static void
gimp_image_viewable_set_image (GimpImageViewable *image_viewable, gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
GimpImage *image) GimpImage *image)
{ {
if (image_viewable->priv->image) if (image_proxy->priv->image)
{ {
g_signal_handlers_disconnect_by_func ( g_signal_handlers_disconnect_by_func (
image_viewable->priv->image, image_proxy->priv->image,
gimp_image_viewable_image_frozen_notify, gimp_image_proxy_image_frozen_notify,
image_viewable); image_proxy);
g_signal_handlers_disconnect_by_func ( g_signal_handlers_disconnect_by_func (
image_viewable->priv->image, image_proxy->priv->image,
gimp_image_viewable_image_invalidate_preview, gimp_image_proxy_image_invalidate_preview,
image_viewable); image_proxy);
g_signal_handlers_disconnect_by_func ( g_signal_handlers_disconnect_by_func (
image_viewable->priv->image, image_proxy->priv->image,
gimp_image_viewable_image_size_changed, gimp_image_proxy_image_size_changed,
image_viewable); image_proxy);
g_signal_handlers_disconnect_by_func ( g_signal_handlers_disconnect_by_func (
image_viewable->priv->image, image_proxy->priv->image,
gimp_image_viewable_image_bounds_changed, gimp_image_proxy_image_bounds_changed,
image_viewable); image_proxy);
g_object_unref (image_viewable->priv->image); g_object_unref (image_proxy->priv->image);
} }
image_viewable->priv->image = image; image_proxy->priv->image = image;
if (image_viewable->priv->image) if (image_proxy->priv->image)
{ {
g_object_ref (image_viewable->priv->image); g_object_ref (image_proxy->priv->image);
g_signal_connect ( g_signal_connect (
image_viewable->priv->image, "notify::frozen", image_proxy->priv->image, "notify::frozen",
G_CALLBACK (gimp_image_viewable_image_frozen_notify), G_CALLBACK (gimp_image_proxy_image_frozen_notify),
image_viewable); image_proxy);
g_signal_connect ( g_signal_connect (
image_viewable->priv->image, "invalidate-preview", image_proxy->priv->image, "invalidate-preview",
G_CALLBACK (gimp_image_viewable_image_invalidate_preview), G_CALLBACK (gimp_image_proxy_image_invalidate_preview),
image_viewable); image_proxy);
g_signal_connect ( g_signal_connect (
image_viewable->priv->image, "size-changed", image_proxy->priv->image, "size-changed",
G_CALLBACK (gimp_image_viewable_image_size_changed), G_CALLBACK (gimp_image_proxy_image_size_changed),
image_viewable); image_proxy);
g_signal_connect ( g_signal_connect (
image_viewable->priv->image, "bounds-changed", image_proxy->priv->image, "bounds-changed",
G_CALLBACK (gimp_image_viewable_image_bounds_changed), G_CALLBACK (gimp_image_proxy_image_bounds_changed),
image_viewable); image_proxy);
gimp_image_viewable_update_bounding_box (image_viewable); gimp_image_proxy_update_bounding_box (image_proxy);
gimp_image_viewable_update_frozen (image_viewable); gimp_image_proxy_update_frozen (image_proxy);
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (image_viewable)); gimp_viewable_invalidate_preview (GIMP_VIEWABLE (image_proxy));
} }
} }
static void static void
gimp_image_viewable_update_bounding_box (GimpImageViewable *image_viewable) gimp_image_proxy_update_bounding_box (GimpImageProxy *image_proxy)
{ {
GimpImage *image = image_viewable->priv->image; GimpImage *image = image_proxy->priv->image;
GeglRectangle bounding_box; GeglRectangle bounding_box;
if (gimp_viewable_preview_is_frozen (GIMP_VIEWABLE (image_viewable))) if (gimp_viewable_preview_is_frozen (GIMP_VIEWABLE (image_proxy)))
return; return;
if (! image_viewable->priv->show_all) if (! image_proxy->priv->show_all)
{ {
bounding_box.x = 0; bounding_box.x = 0;
bounding_box.y = 0; bounding_box.y = 0;
@ -561,35 +561,35 @@ gimp_image_viewable_update_bounding_box (GimpImageViewable *image_viewable)
} }
if (! gegl_rectangle_equal (&bounding_box, if (! gegl_rectangle_equal (&bounding_box,
&image_viewable->priv->bounding_box)) &image_proxy->priv->bounding_box))
{ {
image_viewable->priv->bounding_box = bounding_box; image_proxy->priv->bounding_box = bounding_box;
gimp_viewable_size_changed (GIMP_VIEWABLE (image_viewable)); gimp_viewable_size_changed (GIMP_VIEWABLE (image_proxy));
} }
} }
static void static void
gimp_image_viewable_update_frozen (GimpImageViewable *image_viewable) gimp_image_proxy_update_frozen (GimpImageProxy *image_proxy)
{ {
gboolean frozen; gboolean frozen;
frozen = gimp_viewable_preview_is_frozen ( frozen = gimp_viewable_preview_is_frozen (
GIMP_VIEWABLE (image_viewable->priv->image)); GIMP_VIEWABLE (image_proxy->priv->image));
if (frozen != image_viewable->priv->frozen) if (frozen != image_proxy->priv->frozen)
{ {
image_viewable->priv->frozen = frozen; image_proxy->priv->frozen = frozen;
if (frozen) if (frozen)
{ {
gimp_viewable_preview_freeze (GIMP_VIEWABLE (image_viewable)); gimp_viewable_preview_freeze (GIMP_VIEWABLE (image_proxy));
} }
else else
{ {
gimp_viewable_preview_thaw (GIMP_VIEWABLE (image_viewable)); gimp_viewable_preview_thaw (GIMP_VIEWABLE (image_proxy));
gimp_image_viewable_update_bounding_box (image_viewable); gimp_image_proxy_update_bounding_box (image_proxy);
} }
} }
} }
@ -598,51 +598,51 @@ gimp_image_viewable_update_frozen (GimpImageViewable *image_viewable)
/* public functions */ /* public functions */
GimpImageViewable * GimpImageProxy *
gimp_image_viewable_new (GimpImage *image) gimp_image_proxy_new (GimpImage *image)
{ {
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return g_object_new (GIMP_TYPE_IMAGE_VIEWABLE, return g_object_new (GIMP_TYPE_IMAGE_PROXY,
"image", image, "image", image,
NULL); NULL);
} }
GimpImage * GimpImage *
gimp_image_viewable_get_image (GimpImageViewable *image_viewable) gimp_image_proxy_get_image (GimpImageProxy *image_proxy)
{ {
g_return_val_if_fail (GIMP_IS_IMAGE_VIEWABLE (image_viewable), NULL); g_return_val_if_fail (GIMP_IS_IMAGE_PROXY (image_proxy), NULL);
return image_viewable->priv->image; return image_proxy->priv->image;
} }
void void
gimp_image_viewable_set_show_all (GimpImageViewable *image_viewable, gimp_image_proxy_set_show_all (GimpImageProxy *image_proxy,
gboolean show_all) gboolean show_all)
{ {
g_return_if_fail (GIMP_IS_IMAGE_VIEWABLE (image_viewable)); g_return_if_fail (GIMP_IS_IMAGE_PROXY (image_proxy));
if (show_all != image_viewable->priv->show_all) if (show_all != image_proxy->priv->show_all)
{ {
image_viewable->priv->show_all = show_all; image_proxy->priv->show_all = show_all;
gimp_image_viewable_update_bounding_box (image_viewable); gimp_image_proxy_update_bounding_box (image_proxy);
} }
} }
gboolean gboolean
gimp_image_viewable_get_show_all (GimpImageViewable *image_viewable) gimp_image_proxy_get_show_all (GimpImageProxy *image_proxy)
{ {
g_return_val_if_fail (GIMP_IS_IMAGE_VIEWABLE (image_viewable), FALSE); g_return_val_if_fail (GIMP_IS_IMAGE_PROXY (image_proxy), FALSE);
return image_viewable->priv->show_all; return image_proxy->priv->show_all;
} }
GeglRectangle GeglRectangle
gimp_image_viewable_get_bounding_box (GimpImageViewable *image_viewable) gimp_image_proxy_get_bounding_box (GimpImageProxy *image_proxy)
{ {
g_return_val_if_fail (GIMP_IS_IMAGE_VIEWABLE (image_viewable), g_return_val_if_fail (GIMP_IS_IMAGE_PROXY (image_proxy),
*GEGL_RECTANGLE (0, 0, 0, 0)); *GEGL_RECTANGLE (0, 0, 0, 0));
return image_viewable->priv->bounding_box; return image_proxy->priv->bounding_box;
} }

View File

@ -1,7 +1,7 @@
/* GIMP - The GNU Image Manipulation Program /* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 1995 Spencer Kimball and Peter Mattis
* *
* gimpimageviewable.h * gimpimageproxy.h
* Copyright (C) 2019 Ell * Copyright (C) 2019 Ell
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -18,48 +18,48 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef __GIMP_IMAGE_VIEWABLE_H__ #ifndef __GIMP_IMAGE_PROXY_H__
#define __GIMP_IMAGE_VIEWABLE_H__ #define __GIMP_IMAGE_PROXY_H__
#include "gimpviewable.h" #include "gimpviewable.h"
#define GIMP_TYPE_IMAGE_VIEWABLE (gimp_image_viewable_get_type ()) #define GIMP_TYPE_IMAGE_PROXY (gimp_image_proxy_get_type ())
#define GIMP_IMAGE_VIEWABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_VIEWABLE, GimpImageViewable)) #define GIMP_IMAGE_PROXY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_PROXY, GimpImageProxy))
#define GIMP_IMAGE_VIEWABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_VIEWABLE, GimpImageViewableClass)) #define GIMP_IMAGE_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_PROXY, GimpImageProxyClass))
#define GIMP_IS_IMAGE_VIEWABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_IMAGE_VIEWABLE)) #define GIMP_IS_IMAGE_PROXY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_IMAGE_PROXY))
#define GIMP_IS_IMAGE_VIEWABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_IMAGE_VIEWABLE)) #define GIMP_IS_IMAGE_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_IMAGE_PROXY))
#define GIMP_IMAGE_VIEWABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_IMAGE_VIEWABLE, GimpImageViewableClass)) #define GIMP_IMAGE_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_IMAGE_PROXY, GimpImageProxyClass))
typedef struct _GimpImageViewablePrivate GimpImageViewablePrivate; typedef struct _GimpImageProxyPrivate GimpImageProxyPrivate;
typedef struct _GimpImageViewableClass GimpImageViewableClass; typedef struct _GimpImageProxyClass GimpImageProxyClass;
struct _GimpImageViewable struct _GimpImageProxy
{ {
GimpViewable parent_instance; GimpViewable parent_instance;
GimpImageViewablePrivate *priv; GimpImageProxyPrivate *priv;
}; };
struct _GimpImageViewableClass struct _GimpImageProxyClass
{ {
GimpViewableClass parent_class; GimpViewableClass parent_class;
}; };
GType gimp_image_viewable_get_type (void) G_GNUC_CONST; GType gimp_image_proxy_get_type (void) G_GNUC_CONST;
GimpImageViewable * gimp_image_viewable_new (GimpImage *image); GimpImageProxy * gimp_image_proxy_new (GimpImage *image);
GimpImage * gimp_image_viewable_get_image (GimpImageViewable *image_viewable); GimpImage * gimp_image_proxy_get_image (GimpImageProxy *image_proxy);
void gimp_image_viewable_set_show_all (GimpImageViewable *image_viewable, void gimp_image_proxy_set_show_all (GimpImageProxy *image_proxy,
gboolean show_all); gboolean show_all);
gboolean gimp_image_viewable_get_show_all (GimpImageViewable *image_viewable); gboolean gimp_image_proxy_get_show_all (GimpImageProxy *image_proxy);
GeglRectangle gimp_image_viewable_get_bounding_box (GimpImageViewable *image_viewable); GeglRectangle gimp_image_proxy_get_bounding_box (GimpImageProxy *image_proxy);
#endif /* __GIMP_IMAGE_VIEWABLE_H__ */ #endif /* __GIMP_IMAGE_PROXY_H__ */

View File

@ -36,7 +36,7 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpimageviewable.h" #include "core/gimpimageproxy.h"
#include "widgets/gimpdocked.h" #include "widgets/gimpdocked.h"
#include "widgets/gimphelp-ids.h" #include "widgets/gimphelp-ids.h"
@ -151,7 +151,7 @@ gimp_navigation_editor_init (GimpNavigationEditor *editor)
editor->view = gimp_view_new_by_types (NULL, editor->view = gimp_view_new_by_types (NULL,
GIMP_TYPE_NAVIGATION_VIEW, GIMP_TYPE_NAVIGATION_VIEW,
GIMP_TYPE_IMAGE_VIEWABLE, GIMP_TYPE_IMAGE_PROXY,
GIMP_VIEW_SIZE_MEDIUM, 0, TRUE); GIMP_VIEW_SIZE_MEDIUM, 0, TRUE);
gtk_container_add (GTK_CONTAINER (frame), editor->view); gtk_container_add (GTK_CONTAINER (frame), editor->view);
gtk_widget_show (editor->view); gtk_widget_show (editor->view);
@ -540,20 +540,20 @@ gimp_navigation_editor_set_shell (GimpNavigationEditor *editor,
{ {
GimpImage *image = gimp_display_get_image (shell->display); GimpImage *image = gimp_display_get_image (shell->display);
g_clear_object (&editor->image_viewable); g_clear_object (&editor->image_proxy);
if (image) if (image)
{ {
editor->image_viewable = gimp_image_viewable_new (image); editor->image_proxy = gimp_image_proxy_new (image);
g_signal_connect ( g_signal_connect (
editor->image_viewable, "size-changed", editor->image_proxy, "size-changed",
G_CALLBACK (gimp_navigation_editor_viewable_size_changed), G_CALLBACK (gimp_navigation_editor_viewable_size_changed),
editor); editor);
} }
gimp_view_set_viewable (GIMP_VIEW (editor->view), gimp_view_set_viewable (GIMP_VIEW (editor->view),
GIMP_VIEWABLE (editor->image_viewable)); GIMP_VIEWABLE (editor->image_proxy));
g_signal_connect (editor->shell, "notify::infinite-canvas", g_signal_connect (editor->shell, "notify::infinite-canvas",
G_CALLBACK (gimp_navigation_editor_shell_infinite_canvas_notify), G_CALLBACK (gimp_navigation_editor_shell_infinite_canvas_notify),
@ -585,7 +585,7 @@ gimp_navigation_editor_set_shell (GimpNavigationEditor *editor,
gimp_view_set_viewable (GIMP_VIEW (editor->view), NULL); gimp_view_set_viewable (GIMP_VIEW (editor->view), NULL);
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
g_clear_object (&editor->image_viewable); g_clear_object (&editor->image_proxy);
} }
if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor))) if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)))
@ -622,8 +622,8 @@ gimp_navigation_editor_marker_changed (GimpNavigationView *view,
{ {
GeglRectangle bounding_box; GeglRectangle bounding_box;
bounding_box = gimp_image_viewable_get_bounding_box ( bounding_box = gimp_image_proxy_get_bounding_box (
GIMP_IMAGE_VIEWABLE (renderer->viewable)); GIMP_IMAGE_PROXY (renderer->viewable));
center_x += bounding_box.x; center_x += bounding_box.x;
center_y += bounding_box.y; center_y += bounding_box.y;
@ -800,20 +800,20 @@ gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell,
{ {
GimpImage *image = gimp_display_get_image (shell->display); GimpImage *image = gimp_display_get_image (shell->display);
g_clear_object (&editor->image_viewable); g_clear_object (&editor->image_proxy);
if (image) if (image)
{ {
editor->image_viewable = gimp_image_viewable_new (image); editor->image_proxy = gimp_image_proxy_new (image);
g_signal_connect ( g_signal_connect (
editor->image_viewable, "size-changed", editor->image_proxy, "size-changed",
G_CALLBACK (gimp_navigation_editor_viewable_size_changed), G_CALLBACK (gimp_navigation_editor_viewable_size_changed),
editor); editor);
} }
gimp_view_set_viewable (GIMP_VIEW (editor->view), gimp_view_set_viewable (GIMP_VIEW (editor->view),
GIMP_VIEWABLE (editor->image_viewable)); GIMP_VIEWABLE (editor->image_proxy));
if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor))) if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)))
gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)), gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)),
@ -837,15 +837,15 @@ gimp_navigation_editor_update_marker (GimpNavigationEditor *editor)
gdouble x, y; gdouble x, y;
gdouble w, h; gdouble w, h;
image = gimp_image_viewable_get_image ( image = gimp_image_proxy_get_image (
GIMP_IMAGE_VIEWABLE (renderer->viewable)); GIMP_IMAGE_PROXY (renderer->viewable));
gimp_image_viewable_set_show_all ( gimp_image_proxy_set_show_all (
GIMP_IMAGE_VIEWABLE (renderer->viewable), GIMP_IMAGE_PROXY (renderer->viewable),
gimp_display_shell_get_infinite_canvas (shell)); gimp_display_shell_get_infinite_canvas (shell));
bounding_box = gimp_image_viewable_get_bounding_box ( bounding_box = gimp_image_proxy_get_bounding_box (
GIMP_IMAGE_VIEWABLE (renderer->viewable)); GIMP_IMAGE_PROXY (renderer->viewable));
gimp_display_shell_scroll_get_viewport (shell, &x, &y, &w, &h); gimp_display_shell_scroll_get_viewport (shell, &x, &y, &w, &h);
gimp_display_shell_untransform_xy_f (shell, gimp_display_shell_untransform_xy_f (shell,

View File

@ -40,25 +40,25 @@ typedef struct _GimpNavigationEditorClass GimpNavigationEditorClass;
struct _GimpNavigationEditor struct _GimpNavigationEditor
{ {
GimpEditor parent_instance; GimpEditor parent_instance;
GimpContext *context; GimpContext *context;
GimpDisplayShell *shell; GimpDisplayShell *shell;
GimpImageViewable *image_viewable; GimpImageProxy *image_proxy;
GtkWidget *view; GtkWidget *view;
GtkWidget *zoom_label; GtkWidget *zoom_label;
GtkAdjustment *zoom_adjustment; GtkAdjustment *zoom_adjustment;
GtkWidget *zoom_out_button; GtkWidget *zoom_out_button;
GtkWidget *zoom_in_button; GtkWidget *zoom_in_button;
GtkWidget *zoom_100_button; GtkWidget *zoom_100_button;
GtkWidget *zoom_fit_in_button; GtkWidget *zoom_fit_in_button;
GtkWidget *zoom_fill_button; GtkWidget *zoom_fill_button;
GtkWidget *shrink_wrap_button; GtkWidget *shrink_wrap_button;
guint scale_timeout; guint scale_timeout;
}; };
struct _GimpNavigationEditorClass struct _GimpNavigationEditorClass

View File

@ -30,7 +30,8 @@
#include "core/gimpgradient.h" #include "core/gimpgradient.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpimagefile.h" #include "core/gimpimagefile.h"
#include "core/gimpimageviewable.h"
#include "core/gimpimageproxy.h"
#include "core/gimplayer.h" #include "core/gimplayer.h"
#include "core/gimppalette.h" #include "core/gimppalette.h"
@ -64,7 +65,7 @@ gimp_view_renderer_type_from_viewable_type (GType viewable_type)
type = GIMP_TYPE_VIEW_RENDERER_BUFFER; type = GIMP_TYPE_VIEW_RENDERER_BUFFER;
} }
else if (g_type_is_a (viewable_type, GIMP_TYPE_IMAGE) || else if (g_type_is_a (viewable_type, GIMP_TYPE_IMAGE) ||
g_type_is_a (viewable_type, GIMP_TYPE_IMAGE_VIEWABLE)) g_type_is_a (viewable_type, GIMP_TYPE_IMAGE_PROXY))
{ {
type = GIMP_TYPE_VIEW_RENDERER_IMAGE; type = GIMP_TYPE_VIEW_RENDERER_IMAGE;
} }

View File

@ -28,7 +28,7 @@
#include "widgets-types.h" #include "widgets-types.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpimageviewable.h" #include "core/gimpimageproxy.h"
#include "core/gimptempbuf.h" #include "core/gimptempbuf.h"
#include "gimpviewrendererimage.h" #include "gimpviewrendererimage.h"
@ -72,10 +72,10 @@ gimp_view_renderer_image_render (GimpViewRenderer *renderer,
{ {
image = GIMP_IMAGE (renderer->viewable); image = GIMP_IMAGE (renderer->viewable);
} }
else if (GIMP_IS_IMAGE_VIEWABLE (renderer->viewable)) else if (GIMP_IS_IMAGE_PROXY (renderer->viewable))
{ {
image = gimp_image_viewable_get_image ( image = gimp_image_proxy_get_image (
GIMP_IMAGE_VIEWABLE (renderer->viewable)); GIMP_IMAGE_PROXY (renderer->viewable));
} }
else else
{ {