make use of private data instead of struct members. Added a

* libgimp/gimpzoompreview.[ch]: make use of private data instead of struct
  members. Added a gimp_zoom_preview_get_drawable so we can still get the
  drawable from a preview in plug-ins.

  Also changed gimp_zoom_preview_get_data to gimp_zoom_preview_get_source,
  to make it more obvious what it returns.

* libgimp/gimpui.def
* plug-ins/common/AlienMap2.c
* plug-ins/common/apply_lens.c
* plug-ins/common/blinds.c
* plug-ins/common/channel_mixer.c
* plug-ins/common/colorify.c
* plug-ins/common/flarefx.c
* plug-ins/common/illusion.c
* plug-ins/common/jigsaw.c
* plug-ins/common/mapcolor.c
* plug-ins/common/max_rgb.c
* plug-ins/common/nova.c
* plug-ins/common/polar.c
* plug-ins/common/retinex.c
* plug-ins/common/waves.c
* plug-ins/common/whirlpinch.c: changed accordingly.
This commit is contained in:
David Odin 2005-09-20 21:52:54 +00:00
parent c5d1298244
commit 0730c66b4c
19 changed files with 175 additions and 123 deletions

View File

@ -1,3 +1,29 @@
2005-09-20 DindinX <dindinx@gimp.org>
* libgimp/gimpzoompreview.[ch]: make use of private data instead of
struct members. Added a gimp_zoom_preview_get_drawable so we can still
get the drawable from a preview in plug-ins.
Also changed gimp_zoom_preview_get_data to
gimp_zoom_preview_get_source, to make it more obvious what it returns.
* libgimp/gimpui.def
* plug-ins/common/AlienMap2.c
* plug-ins/common/apply_lens.c
* plug-ins/common/blinds.c
* plug-ins/common/channel_mixer.c
* plug-ins/common/colorify.c
* plug-ins/common/flarefx.c
* plug-ins/common/illusion.c
* plug-ins/common/jigsaw.c
* plug-ins/common/mapcolor.c
* plug-ins/common/max_rgb.c
* plug-ins/common/nova.c
* plug-ins/common/polar.c
* plug-ins/common/retinex.c
* plug-ins/common/waves.c
* plug-ins/common/whirlpinch.c: changed accordingly.
2005-09-20 DindinX <dindinx@gimp.org>
* libgimpwidgets/gimpzoommodel.[ch]: use private data instead of

View File

@ -48,6 +48,7 @@ EXPORTS
gimp_ui_get_progress_window
gimp_window_set_transient
gimp_window_set_transient_for_display
gimp_zoom_preview_get_data
gimp_zoom_preview_get_drawable
gimp_zoom_preview_get_source
gimp_zoom_preview_get_type
gimp_zoom_preview_new

View File

@ -36,6 +36,17 @@
#define SELECTION_BORDER 2
typedef struct _GimpZoomPreviewPrivate GimpZoomPreviewPrivate;
struct _GimpZoomPreviewPrivate
{
GimpDrawable *drawable;
GimpZoomModel *zoom;
GdkRectangle extents;
};
#define GIMP_ZOOM_PREVIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIMP_TYPE_ZOOM_PREVIEW, GimpZoomPreviewPrivate))
static void gimp_zoom_preview_set_adjustments (GimpZoomPreview *preview);
static void gimp_zoom_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
@ -63,6 +74,7 @@ G_DEFINE_TYPE (GimpZoomPreview, gimp_zoom_preview,
static void
gimp_zoom_preview_class_init (GimpZoomPreviewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GimpPreviewClass *preview_class = GIMP_PREVIEW_CLASS (klass);
@ -73,18 +85,21 @@ gimp_zoom_preview_class_init (GimpZoomPreviewClass *klass)
preview_class->draw = gimp_zoom_preview_draw;
preview_class->draw_buffer = gimp_zoom_preview_draw_buffer;
preview_class->draw_thumb = gimp_zoom_preview_draw_thumb;
g_type_class_add_private (object_class, sizeof (GimpZoomPreviewPrivate));
}
static void
gimp_zoom_preview_init (GimpZoomPreview *preview)
{
GtkWidget *button_bar;
GtkWidget *button;
GtkWidget *label;
GtkWidget *button_bar;
GtkWidget *button;
GtkWidget *label;
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
preview->zoom = gimp_zoom_model_new (1.1);
gimp_zoom_model_set_range (GIMP_ZOOM_MODEL (preview->zoom), 1.0, 256.0);
g_signal_connect_swapped (preview->zoom, "notify::zoom-factor",
priv->zoom = gimp_zoom_model_new (1.1);
gimp_zoom_model_set_range (GIMP_ZOOM_MODEL (priv->zoom), 1.0, 256.0);
g_signal_connect_swapped (priv->zoom, "notify::zoom-factor",
G_CALLBACK (gimp_zoom_preview_set_adjustments),
preview);
@ -93,19 +108,19 @@ gimp_zoom_preview_init (GimpZoomPreview *preview)
gtk_widget_show (button_bar);
/* zoom out */
button = gimp_zoom_widget_new (preview->zoom, GIMP_ZOOM_OUT_BUTTON);
button = gimp_zoom_widget_new (priv->zoom, GIMP_ZOOM_OUT_BUTTON);
gtk_box_pack_start (GTK_BOX (button_bar), button,
FALSE, FALSE, 0);
gtk_widget_show (button);
/* zoom in */
button = gimp_zoom_widget_new (preview->zoom, GIMP_ZOOM_IN_BUTTON);
button = gimp_zoom_widget_new (priv->zoom, GIMP_ZOOM_IN_BUTTON);
gtk_box_pack_start (GTK_BOX (button_bar), button,
FALSE, FALSE, 0);
gtk_widget_show (button);
/* label */
label = gimp_zoom_widget_new (preview->zoom, GIMP_ZOOM_LABEL);
label = gimp_zoom_widget_new (priv->zoom, GIMP_ZOOM_LABEL);
gtk_box_pack_start (GTK_BOX (button_bar), label,
FALSE, FALSE, 0);
gtk_widget_show (label);
@ -123,12 +138,13 @@ gimp_zoom_preview_init (GimpZoomPreview *preview)
static void
gimp_zoom_preview_set_adjustments (GimpZoomPreview *preview)
{
GimpScrolledPreview *scrolled_preview;
GtkAdjustment *adj;
gdouble zoom_factor;
GimpScrolledPreview *scrolled_preview;
GtkAdjustment *adj;
gdouble zoom_factor;
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
scrolled_preview = GIMP_SCROLLED_PREVIEW (preview);
zoom_factor = gimp_zoom_model_get_factor (preview->zoom);
zoom_factor = gimp_zoom_model_get_factor (priv->zoom);
if (fabs (zoom_factor - 1.0) < 0.05)
{
@ -173,8 +189,8 @@ gimp_zoom_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
GimpZoomPreview *preview)
{
gint width = GIMP_PREVIEW (preview)->xmax - GIMP_PREVIEW (preview)->xmin;
gint height = GIMP_PREVIEW (preview)->ymax - GIMP_PREVIEW (preview)->ymin;
gint width = GIMP_PREVIEW (preview)->xmax - GIMP_PREVIEW (preview)->xmin;
gint height = GIMP_PREVIEW (preview)->ymax - GIMP_PREVIEW (preview)->ymin;
GIMP_PREVIEW (preview)->width = MIN (width, allocation->width);
GIMP_PREVIEW (preview)->height = MIN (height, allocation->height);
@ -186,10 +202,11 @@ static void
gimp_zoom_preview_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
GimpPreview *preview = GIMP_PREVIEW (widget);
GimpDrawable *drawable = GIMP_ZOOM_PREVIEW (preview)->drawable;
gint size;
gint width, height;
GimpPreview *preview = GIMP_PREVIEW (widget);
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
GimpDrawable *drawable = priv->drawable;
gint size;
gint width, height;
if (GTK_WIDGET_CLASS (parent_class)->style_set)
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
@ -216,29 +233,31 @@ gimp_zoom_preview_style_set (GtkWidget *widget,
}
guchar *
gimp_zoom_preview_get_data (GimpZoomPreview *preview,
gint *width,
gint *height,
gint *bpp)
gimp_zoom_preview_get_source (GimpZoomPreview *preview,
gint *width,
gint *height,
gint *bpp)
{
guchar *data;
GimpDrawable *drawable = preview->drawable;
gint src_x;
gint src_y;
gint src_width;
gint src_height;
gdouble zoom_factor = gimp_zoom_model_get_factor (preview->zoom);
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
guchar *data;
GimpDrawable *drawable = priv->drawable;
gint src_x;
gint src_y;
gint src_width;
gint src_height;
gdouble zoom_factor;
GimpPreview *gimp_preview = GIMP_PREVIEW (preview);
zoom_factor = gimp_zoom_model_get_factor (priv->zoom);
*width = gimp_preview->width;
*height = gimp_preview->height;
src_x = preview->extents.x +
gimp_preview->xoff * preview->extents.width / *width / zoom_factor;
src_y = preview->extents.y +
gimp_preview->yoff * preview->extents.height / *height / zoom_factor;
src_width = preview->extents.width / zoom_factor;
src_height = preview->extents.height / zoom_factor;
src_x = priv->extents.x +
gimp_preview->xoff * priv->extents.width / *width / zoom_factor;
src_y = priv->extents.y +
gimp_preview->yoff * priv->extents.height / *height / zoom_factor;
src_width = priv->extents.width / zoom_factor;
src_height = priv->extents.height / zoom_factor;
data = gimp_drawable_get_sub_thumbnail_data (drawable->drawable_id,
src_x, src_y,
@ -248,42 +267,41 @@ gimp_zoom_preview_get_data (GimpZoomPreview *preview,
}
static void
gimp_zoom_preview_draw (GimpPreview *gimp_preview)
gimp_zoom_preview_draw (GimpPreview *preview)
{
guchar *data;
gint width;
gint height;
gint bpp;
gint src_x;
gint src_y;
gint src_width;
gint src_height;
GimpZoomPreview *preview;
GimpDrawable *drawable;
gdouble zoom_factor;
guchar *data;
gint width;
gint height;
gint bpp;
gint src_x;
gint src_y;
gint src_width;
gint src_height;
GimpDrawable *drawable;
gdouble zoom_factor;
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
g_return_if_fail (GIMP_IS_ZOOM_PREVIEW (gimp_preview));
g_return_if_fail (GIMP_IS_ZOOM_PREVIEW (preview));
preview = GIMP_ZOOM_PREVIEW (gimp_preview);
drawable = preview->drawable;
drawable = priv->drawable;
if (!drawable)
return;
zoom_factor = gimp_zoom_model_get_factor (preview->zoom);
zoom_factor = gimp_zoom_model_get_factor (priv->zoom);
width = gimp_preview->width;
height = gimp_preview->height;
src_x = preview->extents.x +
gimp_preview->xoff * preview->extents.width / width / zoom_factor;
src_y = preview->extents.y +
gimp_preview->yoff * preview->extents.height / height / zoom_factor;
src_width = preview->extents.width / zoom_factor;
src_height = preview->extents.height / zoom_factor;
width = preview->width;
height = preview->height;
src_x = priv->extents.x +
preview->xoff * priv->extents.width / width / zoom_factor;
src_y = priv->extents.y +
preview->yoff * priv->extents.height / height / zoom_factor;
src_width = priv->extents.width / zoom_factor;
src_height = priv->extents.height / zoom_factor;
data = gimp_drawable_get_sub_thumbnail_data (drawable->drawable_id,
src_x, src_y,
src_width, src_height,
&width, &height, &bpp);
gimp_preview_area_draw (GIMP_PREVIEW_AREA (gimp_preview->area),
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview->area),
0, 0, width, height,
gimp_drawable_type (drawable->drawable_id),
data, width * bpp);
@ -292,11 +310,12 @@ gimp_zoom_preview_draw (GimpPreview *gimp_preview)
static void
gimp_zoom_preview_draw_buffer (GimpPreview *preview,
const guchar *buffer,
gint rowstride)
const guchar *buffer,
gint rowstride)
{
gint32 image_id;
GimpDrawable *drawable = GIMP_ZOOM_PREVIEW (preview)->drawable;
gint32 image_id;
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
GimpDrawable *drawable = priv->drawable;
image_id = gimp_drawable_get_image (drawable->drawable_id);
@ -345,11 +364,11 @@ gimp_zoom_preview_draw_thumb (GimpPreview *preview,
gint width,
gint height)
{
GimpZoomPreview *zoom_preview = GIMP_ZOOM_PREVIEW (preview);
GimpDrawable *drawable = zoom_preview->drawable;
guchar *buffer;
gint x1, y1, x2, y2;
gint bpp;
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
GimpDrawable *drawable = priv->drawable;
guchar *buffer;
gint x1, y1, x2, y2;
gint bpp;
if (! drawable)
return;
@ -429,20 +448,22 @@ gimp_zoom_preview_get_bounds (GimpDrawable *drawable,
GtkWidget *
gimp_zoom_preview_new (GimpDrawable *drawable)
{
GimpZoomPreview *preview;
gint width, height;
gint max_width, max_height;
GimpZoomPreview *preview;
gint width, height;
gint max_width, max_height;
GimpZoomPreviewPrivate *priv;
preview = g_object_new (GIMP_TYPE_ZOOM_PREVIEW, NULL);
priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
preview->drawable = drawable;
priv->drawable = drawable;
width = gimp_drawable_width (drawable->drawable_id);
height = gimp_drawable_height (drawable->drawable_id);
preview->extents.x = 0;
preview->extents.y = 0;
preview->extents.width = width;
preview->extents.height = height;
priv->extents.x = 0;
priv->extents.y = 0;
priv->extents.width = width;
priv->extents.height = height;
if (width > height)
{
@ -465,3 +486,11 @@ gimp_zoom_preview_new (GimpDrawable *drawable)
return GTK_WIDGET (preview);
}
GimpDrawable *
gimp_zoom_preview_get_drawable (GimpZoomPreview *preview)
{
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
return priv->drawable;
}

View File

@ -43,11 +43,6 @@ typedef struct _GimpZoomPreviewClass GimpZoomPreviewClass;
struct _GimpZoomPreview
{
GimpScrolledPreview parent_instance;
/*< private >*/
GimpDrawable *drawable;
GimpZoomModel *zoom;
GdkRectangle extents;
};
struct _GimpZoomPreviewClass
@ -62,13 +57,14 @@ struct _GimpZoomPreviewClass
};
GType gimp_zoom_preview_get_type (void) G_GNUC_CONST;
GType gimp_zoom_preview_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_zoom_preview_new (GimpDrawable *drawable);
guchar * gimp_zoom_preview_get_data (GimpZoomPreview *preview,
gint *width,
gint *height,
gint *bpp);
GtkWidget * gimp_zoom_preview_new (GimpDrawable *drawable);
guchar * gimp_zoom_preview_get_source (GimpZoomPreview *preview,
gint *width,
gint *height,
gint *bpp);
GimpDrawable * gimp_zoom_preview_get_drawable (GimpZoomPreview *preview);
G_END_DECLS

View File

@ -111,7 +111,6 @@ static alienmap2_vals_t wvals =
RGB_MODEL,
TRUE,
TRUE,
TRUE,
TRUE
};
@ -576,8 +575,8 @@ dialog_update_preview (GimpDrawable *drawable,
gint width, height, bpp;
gint i;
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
dest = g_new (guchar, width * height * bpp);
for (i = 0 ; i < width * height ; i++)

View File

@ -251,8 +251,8 @@ drawlens (GimpDrawable *drawable,
if (preview)
{
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bytes);
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bytes);
gimp_preview_get_position (preview, &x1, &y1);
x2 = x1 + width;
y2 = y1 + height;

View File

@ -453,8 +453,8 @@ dialog_update_preview (GimpDrawable *drawable,
guchar bg[4];
gint width, height, bpp;
cache = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
cache = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
p = cache;

View File

@ -768,15 +768,17 @@ cm_preview (CmParamsType *mix,
gint offset, rowsize;
gdouble red_norm, green_norm, blue_norm, black_norm;
gint width, height, bpp;
GimpDrawable *drawable = GIMP_ZOOM_PREVIEW (preview)->drawable;
GimpDrawable *drawable;
drawable = gimp_zoom_preview_get_drawable (GIMP_ZOOM_PREVIEW (preview));
red_norm = cm_calculate_norm (mix, &mix->red);
green_norm = cm_calculate_norm (mix, &mix->green);
blue_norm = cm_calculate_norm (mix, &mix->blue);
black_norm = cm_calculate_norm (mix, &mix->black);
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
rowsize = width * bpp;
dst = g_new (guchar, rowsize * height);

View File

@ -223,7 +223,7 @@ colorify (GimpDrawable *drawable,
gint width, height, bytes;
guchar *src;
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bytes);
for (i = 0; i < width * height; i++)
colorify_func (src + i * bytes, src + i * bytes, bytes, NULL);

View File

@ -157,8 +157,7 @@ GimpPlugInInfo PLUG_IN_INFO =
static FlareValues fvals =
{
128, 128, /* posx, posy */
TRUE /* preview */
128, 128 /* posx, posy */
};
static gfloat scolor, sglow, sinner, souter; /* size */
@ -368,8 +367,8 @@ FlareFX (GimpDrawable *drawable,
bytes = drawable->bpp;
if (preview)
{
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bytes);
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bytes);
xs = (gdouble)fvals.posx * width / drawable->width;
ys = (gdouble)fvals.posy * height / drawable->height;

View File

@ -291,8 +291,8 @@ illusion_preview (GimpPreview *preview,
gint yy = 0;
gdouble scale, radius, cx, cy, angle, offset;
preview_cache = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
preview_cache = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
center_x = (gdouble)width / 2.0;
center_y = (gdouble)height / 2.0;

View File

@ -445,8 +445,8 @@ jigsaw (GimpDrawable *drawable,
if (preview)
{
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bytes);
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bytes);
}
else
{

View File

@ -314,8 +314,8 @@ update_img_preview (GimpDrawable *drawable,
plvals.map_mode,
redmap, greenmap, bluemap);
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
j = width * height;

View File

@ -215,8 +215,8 @@ main_function (GimpDrawable *drawable,
guchar *src;
gint width, height, bpp;
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
buffer = g_new (guchar, width * height * bpp);

View File

@ -737,8 +737,8 @@ nova (GimpDrawable *drawable,
if (preview)
{
cache = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
cache = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
xc = (gdouble) pvals.xcenter * width / drawable->width;
yc = (gdouble) pvals.ycenter * height / drawable->height;

View File

@ -736,8 +736,8 @@ dialog_update_preview (GimpDrawable *drawable,
bottom = sel_y2 - 1;
top = sel_y1;
preview_cache = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
preview_cache = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
dx = (right - left) / (width - 1);
dy = (bottom - top) / (height - 1);

View File

@ -420,8 +420,8 @@ retinex (GimpDrawable *drawable,
*/
if (preview)
{
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bytes);
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bytes);
}
else
{

View File

@ -357,8 +357,8 @@ waves_preview (GimpDrawable *drawable,
gint width, height;
gint bpp;
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &bpp);
dest = g_new (guchar, width * height * bpp);
wave (src, dest, width, height, bpp,

View File

@ -658,8 +658,8 @@ dialog_update_preview (GimpDrawable *drawable,
bottom = sel_y2 - 1;
top = sel_y1;
src = gimp_zoom_preview_get_data (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &img_bpp);
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
&width, &height, &img_bpp);
dest = g_new (guchar, width * height * img_bpp);
dx = (right - left) / (width - 1);