mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 09:23:24 +00:00
libgimp: make GimpDrawablePreview a final type.
This commit is contained in:
parent
3051796f3e
commit
993fae97df
2 changed files with 38 additions and 60 deletions
|
@ -58,12 +58,12 @@ typedef struct
|
||||||
} PreviewSettings;
|
} PreviewSettings;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GimpDrawablePreviewPrivate
|
struct _GimpDrawablePreview
|
||||||
{
|
{
|
||||||
GimpDrawable *drawable;
|
GimpScrolledPreview parent_instance;
|
||||||
} GimpDrawablePreviewPrivate;
|
|
||||||
|
|
||||||
#define GET_PRIVATE(obj) (gimp_drawable_preview_get_instance_private ((GimpDrawablePreview *) (obj)))
|
GimpDrawable *drawable;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static void gimp_drawable_preview_constructed (GObject *object);
|
static void gimp_drawable_preview_constructed (GObject *object);
|
||||||
|
@ -92,8 +92,7 @@ static void gimp_drawable_preview_set_drawable (GimpDrawablePreview *preview,
|
||||||
GimpDrawable *drawable);
|
GimpDrawable *drawable);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpDrawablePreview, gimp_drawable_preview,
|
G_DEFINE_TYPE (GimpDrawablePreview, gimp_drawable_preview, GIMP_TYPE_SCROLLED_PREVIEW)
|
||||||
GIMP_TYPE_SCROLLED_PREVIEW)
|
|
||||||
|
|
||||||
#define parent_class gimp_drawable_preview_parent_class
|
#define parent_class gimp_drawable_preview_parent_class
|
||||||
|
|
||||||
|
@ -176,8 +175,8 @@ gimp_drawable_preview_constructed (GObject *object)
|
||||||
static void
|
static void
|
||||||
gimp_drawable_preview_dispose (GObject *object)
|
gimp_drawable_preview_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
GimpDrawablePreviewPrivate *priv = GET_PRIVATE (object);
|
GimpDrawablePreview *preview = GIMP_DRAWABLE_PREVIEW (object);
|
||||||
const gchar *data_name;
|
const gchar *data_name;
|
||||||
|
|
||||||
data_name = g_object_get_data (G_OBJECT (object),
|
data_name = g_object_get_data (G_OBJECT (object),
|
||||||
"gimp-drawable-preview-data-name");
|
"gimp-drawable-preview-data-name");
|
||||||
|
@ -195,7 +194,7 @@ gimp_drawable_preview_dispose (GObject *object)
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_object (&priv->drawable);
|
g_clear_object (&preview->drawable);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -271,17 +270,17 @@ gimp_drawable_preview_style_updated (GtkWidget *widget)
|
||||||
static void
|
static void
|
||||||
gimp_drawable_preview_draw_original (GimpPreview *preview)
|
gimp_drawable_preview_draw_original (GimpPreview *preview)
|
||||||
{
|
{
|
||||||
GimpDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
|
GimpDrawablePreview *drawable_preview = GIMP_DRAWABLE_PREVIEW (preview);
|
||||||
GBytes *buffer;
|
GBytes *buffer;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint tn_width, tn_height;
|
gint tn_width, tn_height;
|
||||||
gint xoff, yoff;
|
gint xoff, yoff;
|
||||||
gint xmin, ymin;
|
gint xmin, ymin;
|
||||||
gint xmax, ymax;
|
gint xmax, ymax;
|
||||||
gint bpp;
|
gint bpp;
|
||||||
GimpImageType type;
|
GimpImageType type;
|
||||||
|
|
||||||
if (priv->drawable == NULL)
|
if (drawable_preview->drawable == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gimp_preview_get_size (preview, &width, &height);
|
gimp_preview_get_size (preview, &width, &height);
|
||||||
|
@ -293,7 +292,7 @@ gimp_drawable_preview_draw_original (GimpPreview *preview)
|
||||||
|
|
||||||
gimp_preview_set_offsets (preview, xoff, yoff);
|
gimp_preview_set_offsets (preview, xoff, yoff);
|
||||||
|
|
||||||
buffer = gimp_drawable_get_sub_thumbnail_data (priv->drawable,
|
buffer = gimp_drawable_get_sub_thumbnail_data (drawable_preview->drawable,
|
||||||
xoff + xmin,
|
xoff + xmin,
|
||||||
yoff + ymin,
|
yoff + ymin,
|
||||||
width, height,
|
width, height,
|
||||||
|
@ -323,10 +322,10 @@ gimp_drawable_preview_draw_thumb (GimpPreview *preview,
|
||||||
gint width,
|
gint width,
|
||||||
gint height)
|
gint height)
|
||||||
{
|
{
|
||||||
GimpDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
|
GimpDrawablePreview *drawable_preview = GIMP_DRAWABLE_PREVIEW (preview);
|
||||||
|
|
||||||
if (priv->drawable)
|
if (drawable_preview->drawable)
|
||||||
_gimp_drawable_preview_area_draw_thumb (area, priv->drawable,
|
_gimp_drawable_preview_area_draw_thumb (area, drawable_preview->drawable,
|
||||||
width, height);
|
width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,17 +420,16 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
|
||||||
const guchar *buf,
|
const guchar *buf,
|
||||||
gint rowstride)
|
gint rowstride)
|
||||||
{
|
{
|
||||||
GimpDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
|
GimpPreview *gimp_preview = GIMP_PREVIEW (preview);
|
||||||
GimpPreview *gimp_preview = GIMP_PREVIEW (preview);
|
GtkWidget *area = gimp_preview_get_area (gimp_preview);
|
||||||
GtkWidget *area = gimp_preview_get_area (gimp_preview);
|
GimpImage *image;
|
||||||
GimpImage *image;
|
gint xmin, ymin;
|
||||||
gint xmin, ymin;
|
gint xoff, yoff;
|
||||||
gint xoff, yoff;
|
|
||||||
|
|
||||||
gimp_preview_get_bounds (gimp_preview, &xmin, &ymin, NULL, NULL);
|
gimp_preview_get_bounds (gimp_preview, &xmin, &ymin, NULL, NULL);
|
||||||
gimp_preview_get_offsets (gimp_preview, &xoff, &yoff);
|
gimp_preview_get_offsets (gimp_preview, &xoff, &yoff);
|
||||||
|
|
||||||
image = gimp_item_get_image (GIMP_ITEM (priv->drawable));
|
image = gimp_item_get_image (GIMP_ITEM (preview->drawable));
|
||||||
|
|
||||||
if (gimp_selection_is_empty (image))
|
if (gimp_selection_is_empty (image))
|
||||||
{
|
{
|
||||||
|
@ -440,7 +438,7 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
|
||||||
y - yoff - ymin,
|
y - yoff - ymin,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
gimp_drawable_type (priv->drawable),
|
gimp_drawable_type (preview->drawable),
|
||||||
buf, rowstride);
|
buf, rowstride);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -451,9 +449,9 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
|
||||||
gint draw_x, draw_y;
|
gint draw_x, draw_y;
|
||||||
gint draw_width, draw_height;
|
gint draw_width, draw_height;
|
||||||
|
|
||||||
gimp_drawable_get_offsets (priv->drawable, &offset_x, &offset_y);
|
gimp_drawable_get_offsets (preview->drawable, &offset_x, &offset_y);
|
||||||
|
|
||||||
if (gimp_drawable_mask_intersect (priv->drawable,
|
if (gimp_drawable_mask_intersect (preview->drawable,
|
||||||
&mask_x, &mask_y,
|
&mask_x, &mask_y,
|
||||||
&mask_width, &mask_height) &&
|
&mask_width, &mask_height) &&
|
||||||
gimp_rectangle_intersect (mask_x, mask_y,
|
gimp_rectangle_intersect (mask_x, mask_y,
|
||||||
|
@ -471,7 +469,7 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
|
||||||
|
|
||||||
selection = gimp_image_get_selection (image);
|
selection = gimp_image_get_selection (image);
|
||||||
|
|
||||||
src = gimp_drawable_get_sub_thumbnail_data (priv->drawable,
|
src = gimp_drawable_get_sub_thumbnail_data (preview->drawable,
|
||||||
draw_x, draw_y,
|
draw_x, draw_y,
|
||||||
draw_width, draw_height,
|
draw_width, draw_height,
|
||||||
draw_width, draw_height,
|
draw_width, draw_height,
|
||||||
|
@ -538,13 +536,12 @@ static void
|
||||||
gimp_drawable_preview_set_drawable (GimpDrawablePreview *drawable_preview,
|
gimp_drawable_preview_set_drawable (GimpDrawablePreview *drawable_preview,
|
||||||
GimpDrawable *drawable)
|
GimpDrawable *drawable)
|
||||||
{
|
{
|
||||||
GimpPreview *preview = GIMP_PREVIEW (drawable_preview);
|
GimpPreview *preview = GIMP_PREVIEW (drawable_preview);
|
||||||
GimpDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
|
gint x1, y1, x2, y2;
|
||||||
gint x1, y1, x2, y2;
|
|
||||||
|
|
||||||
g_return_if_fail (priv->drawable == NULL);
|
g_return_if_fail (drawable_preview->drawable == NULL);
|
||||||
|
|
||||||
priv->drawable = drawable;
|
drawable_preview->drawable = drawable;
|
||||||
|
|
||||||
_gimp_drawable_preview_get_bounds (drawable, &x1, &y1, &x2, &y2);
|
_gimp_drawable_preview_get_bounds (drawable, &x1, &y1, &x2, &y2);
|
||||||
|
|
||||||
|
@ -635,11 +632,7 @@ gimp_drawable_preview_new_from_drawable (GimpDrawable *drawable)
|
||||||
GimpDrawable *
|
GimpDrawable *
|
||||||
gimp_drawable_preview_get_drawable (GimpDrawablePreview *preview)
|
gimp_drawable_preview_get_drawable (GimpDrawablePreview *preview)
|
||||||
{
|
{
|
||||||
GimpDrawablePreviewPrivate *priv;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_DRAWABLE_PREVIEW (preview), NULL);
|
g_return_val_if_fail (GIMP_IS_DRAWABLE_PREVIEW (preview), NULL);
|
||||||
|
|
||||||
priv = GET_PRIVATE (preview);
|
return preview->drawable;
|
||||||
|
|
||||||
return priv->drawable;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,22 +32,7 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_DRAWABLE_PREVIEW (gimp_drawable_preview_get_type ())
|
#define GIMP_TYPE_DRAWABLE_PREVIEW (gimp_drawable_preview_get_type ())
|
||||||
G_DECLARE_DERIVABLE_TYPE (GimpDrawablePreview, gimp_drawable_preview, GIMP, DRAWABLE_PREVIEW, GimpScrolledPreview)
|
G_DECLARE_FINAL_TYPE (GimpDrawablePreview, gimp_drawable_preview, GIMP, DRAWABLE_PREVIEW, GimpScrolledPreview)
|
||||||
|
|
||||||
struct _GimpDrawablePreviewClass
|
|
||||||
{
|
|
||||||
GimpScrolledPreviewClass parent_class;
|
|
||||||
|
|
||||||
/* Padding for future expansion */
|
|
||||||
void (* _gimp_reserved1) (void);
|
|
||||||
void (* _gimp_reserved2) (void);
|
|
||||||
void (* _gimp_reserved3) (void);
|
|
||||||
void (* _gimp_reserved4) (void);
|
|
||||||
void (* _gimp_reserved5) (void);
|
|
||||||
void (* _gimp_reserved6) (void);
|
|
||||||
void (* _gimp_reserved7) (void);
|
|
||||||
void (* _gimp_reserved8) (void);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GtkWidget * gimp_drawable_preview_new_from_drawable (GimpDrawable *drawable);
|
GtkWidget * gimp_drawable_preview_new_from_drawable (GimpDrawable *drawable);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue