Commit d87eddb1 authored by Michael Natterer's avatar Michael Natterer 😴

libgimpwidgets: move all GimpPreview members to private

and add tons of API so subclasses can still do their thing, probably
subject to change/fix.
parent 9cb67fa9
......@@ -145,7 +145,7 @@ gimp_aspect_preview_init (GimpAspectPreview *preview)
GIMP_TYPE_ASPECT_PREVIEW,
GimpAspectPreviewPrivate);
g_object_set (GIMP_PREVIEW (preview)->area,
g_object_set (gimp_preview_get_area (GIMP_PREVIEW (preview)),
"check-size", gimp_check_size (),
"check-type", gimp_check_type (),
NULL);
......@@ -237,14 +237,17 @@ static void
gimp_aspect_preview_style_updated (GtkWidget *widget)
{
GimpPreview *preview = GIMP_PREVIEW (widget);
GtkWidget *area = gimp_preview_get_area (preview);
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
if (preview->area)
if (area)
{
GimpAspectPreviewPrivate *priv = GET_PRIVATE (preview);
gint width;
gint height;
gint preview_width;
gint preview_height;
gint size;
width = gimp_drawable_width (priv->drawable_ID);
......@@ -256,29 +259,31 @@ gimp_aspect_preview_style_updated (GtkWidget *widget)
if (width > height)
{
preview->width = MIN (width, size);
preview->height = (height * preview->width) / width;
preview_width = MIN (width, size);
preview_height = (height * preview_width) / width;
}
else
{
preview->height = MIN (height, size);
preview->width = (width * preview->height) / height;
preview_height = MIN (height, size);
preview_width = (width * preview_height) / height;
}
gtk_widget_set_size_request (preview->area,
preview->width, preview->height);
gimp_preview_set_size (preview, preview_width, preview_height);
}
}
static void
gimp_aspect_preview_draw (GimpPreview *preview)
{
g_return_if_fail (GIMP_IS_ASPECT_PREVIEW (preview));
GtkWidget *area = gimp_preview_get_area (preview);
gint width;
gint height;
gimp_preview_area_fill (GIMP_PREVIEW_AREA (preview->area),
gimp_preview_get_size (preview, &width, &height);
gimp_preview_area_fill (GIMP_PREVIEW_AREA (area),
0, 0,
preview->width,
preview->height,
width, height,
0, 0, 0);
}
......@@ -288,15 +293,20 @@ gimp_aspect_preview_draw_buffer (GimpPreview *preview,
gint rowstride)
{
GimpAspectPreviewPrivate *priv = GET_PRIVATE (preview);
GtkWidget *area = gimp_preview_get_area (preview);
gint width;
gint height;
gint32 image_ID;
gimp_preview_get_size (preview, &width, &height);
image_ID = gimp_item_get_image (priv->drawable_ID);
if (gimp_selection_is_empty (image_ID))
{
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview->area),
gimp_preview_area_draw (GIMP_PREVIEW_AREA (area),
0, 0,
preview->width, preview->height,
width, height,
gimp_drawable_type (priv->drawable_ID),
buffer,
rowstride);
......@@ -306,21 +316,21 @@ gimp_aspect_preview_draw_buffer (GimpPreview *preview,
guchar *sel;
guchar *src;
gint selection_ID;
gint width, height;
gint w, h;
gint bpp;
selection_ID = gimp_image_get_selection (image_ID);
width = preview->width;
height = preview->height;
w = width;
h = height;
src = gimp_drawable_get_thumbnail_data (priv->drawable_ID,
&width, &height, &bpp);
&w, &h, &bpp);
sel = gimp_drawable_get_thumbnail_data (selection_ID,
&width, &height, &bpp);
&w, &h, &bpp);
gimp_preview_area_mask (GIMP_PREVIEW_AREA (preview->area),
0, 0, preview->width, preview->height,
gimp_preview_area_mask (GIMP_PREVIEW_AREA (area),
0, 0, width, height,
gimp_drawable_type (priv->drawable_ID),
src, width * gimp_drawable_bpp (priv->drawable_ID),
buffer, rowstride,
......@@ -339,9 +349,13 @@ gimp_aspect_preview_transform (GimpPreview *preview,
gint *dest_y)
{
GimpAspectPreviewPrivate *priv = GET_PRIVATE (preview);
gint width;
gint height;
gimp_preview_get_size (preview, &width, &height);
*dest_x = (gdouble) src_x * preview->width / gimp_drawable_width (priv->drawable_ID);
*dest_y = (gdouble) src_y * preview->height / gimp_drawable_height (priv->drawable_ID);
*dest_x = (gdouble) src_x * width / gimp_drawable_width (priv->drawable_ID);
*dest_y = (gdouble) src_y * height / gimp_drawable_height (priv->drawable_ID);
}
static void
......@@ -352,9 +366,13 @@ gimp_aspect_preview_untransform (GimpPreview *preview,
gint *dest_y)
{
GimpAspectPreviewPrivate *priv = GET_PRIVATE (preview);
gint width;
gint height;
gimp_preview_get_size (preview, &width, &height);
*dest_x = (gdouble) src_x * gimp_drawable_width (priv->drawable_ID) / preview->width;
*dest_y = (gdouble) src_y * gimp_drawable_height (priv->drawable_ID) / preview->height;
*dest_x = (gdouble) src_x * gimp_drawable_width (priv->drawable_ID) / width;
*dest_y = (gdouble) src_y * gimp_drawable_height (priv->drawable_ID) / height;
}
static void
......@@ -388,7 +406,7 @@ gimp_aspect_preview_set_drawable_id (GimpAspectPreview *preview,
gimp_preview_set_bounds (GIMP_PREVIEW (preview), 0, 0, width, height);
if (height > 0)
g_object_set (GIMP_PREVIEW (preview)->frame,
g_object_set (gimp_preview_get_frame (GIMP_PREVIEW (preview)),
"ratio",
(gdouble) d_width / (gdouble) d_height,
NULL);
......
......@@ -144,7 +144,7 @@ gimp_drawable_preview_init (GimpDrawablePreview *preview)
GIMP_TYPE_DRAWABLE_PREVIEW,
GimpDrawablePreviewPrivate);
g_object_set (GIMP_PREVIEW (preview)->area,
g_object_set (gimp_preview_get_area (GIMP_PREVIEW (preview)),
"check-size", gimp_check_size (),
"check-type", gimp_check_type (),
NULL);
......@@ -184,8 +184,7 @@ gimp_drawable_preview_dispose (GObject *object)
GimpPreview *preview = GIMP_PREVIEW (object);
PreviewSettings settings;
settings.x = preview->xoff + preview->xmin;
settings.y = preview->yoff + preview->ymin;
gimp_preview_get_position (preview, &settings.x, &settings.y);
settings.update = gimp_preview_get_update (preview);
gimp_set_data (data_name, &settings, sizeof (PreviewSettings));
......@@ -240,21 +239,25 @@ static void
gimp_drawable_preview_style_updated (GtkWidget *widget)
{
GimpPreview *preview = GIMP_PREVIEW (widget);
GtkWidget *area = gimp_preview_get_area (preview);
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
if (preview->area)
if (area)
{
gint width = preview->xmax - preview->xmin;
gint height = preview->ymax - preview->ymin;
gint xmin, ymin;
gint xmax, ymax;
gint size;
gimp_preview_get_bounds (preview, &xmin, &ymin, &xmax, &ymax);
gtk_widget_style_get (widget,
"size", &size,
NULL);
gtk_widget_set_size_request (GIMP_PREVIEW (preview)->area,
MIN (width, size), MIN (height, size));
gtk_widget_set_size_request (area,
MIN (xmax - xmin, size),
MIN (ymax - ymin, size));
}
}
......@@ -264,24 +267,28 @@ gimp_drawable_preview_draw_original (GimpPreview *preview)
GimpDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
guchar *buffer;
gint width, height;
gint xoff, yoff;
gint xmin, ymin;
gint xmax, ymax;
gint bpp;
GimpImageType type;
if (priv->drawable_ID < 1)
return;
preview->xoff = CLAMP (preview->xoff,
0, preview->xmax - preview->xmin - preview->width);
preview->yoff = CLAMP (preview->yoff,
0, preview->ymax - preview->ymin - preview->height);
gimp_preview_get_size (preview, &width, &height);
gimp_preview_get_offsets (preview, &xoff, &yoff);
gimp_preview_get_bounds (preview, &xmin, &ymin, &xmax, &ymax);
xoff = CLAMP (xoff, 0, xmax - xmin - width);
yoff = CLAMP (yoff, 0, ymax - ymin - height);
width = preview->width;
height = preview->height;
gimp_preview_set_offsets (preview, xoff, yoff);
buffer = gimp_drawable_get_sub_thumbnail_data (priv->drawable_ID,
preview->xoff + preview->xmin,
preview->yoff + preview->ymin,
preview->width, preview->height,
xoff + xmin,
yoff + ymin,
width, height,
&width, &height, &bpp);
switch (bpp)
......@@ -295,7 +302,7 @@ gimp_drawable_preview_draw_original (GimpPreview *preview)
return;
}
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview->area),
gimp_preview_area_draw (GIMP_PREVIEW_AREA (gimp_preview_get_area (preview)),
0, 0, width, height, type, buffer, width * bpp);
g_free (buffer);
}
......@@ -402,15 +409,21 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
{
GimpDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
GimpPreview *gimp_preview = GIMP_PREVIEW (preview);
GtkWidget *area = gimp_preview_get_area (gimp_preview);
gint xmin, ymin;
gint xoff, yoff;
gint32 image_ID;
gimp_preview_get_bounds (gimp_preview, &xmin, &ymin, NULL, NULL);
gimp_preview_get_offsets (gimp_preview, &xoff, &yoff);
image_ID = gimp_item_get_image (priv->drawable_ID);
if (gimp_selection_is_empty (image_ID))
{
gimp_preview_area_draw (GIMP_PREVIEW_AREA (gimp_preview->area),
x - gimp_preview->xoff - gimp_preview->xmin,
y - gimp_preview->yoff - gimp_preview->ymin,
gimp_preview_area_draw (GIMP_PREVIEW_AREA (area),
x - xoff - xmin,
y - yoff - ymin,
width,
height,
gimp_drawable_type (priv->drawable_ID),
......@@ -475,9 +488,9 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
return;
}
gimp_preview_area_mask (GIMP_PREVIEW_AREA (gimp_preview->area),
draw_x - gimp_preview->xoff - gimp_preview->xmin,
draw_y - gimp_preview->yoff - gimp_preview->ymin,
gimp_preview_area_mask (GIMP_PREVIEW_AREA (area),
draw_x - xoff - xmin,
draw_y - yoff - ymin,
draw_width,
draw_height,
type,
......@@ -499,11 +512,15 @@ gimp_drawable_preview_draw_buffer (GimpPreview *preview,
const guchar *buffer,
gint rowstride)
{
gint x, y;
gint width, height;
gimp_preview_get_position (preview, &x, &y);
gimp_preview_get_size (preview, &width, &height);
gimp_drawable_preview_draw_area (GIMP_DRAWABLE_PREVIEW (preview),
preview->xmin + preview->xoff,
preview->ymin + preview->yoff,
preview->width,
preview->height,
x, y,
width, height,
buffer, rowstride);
}
......@@ -525,12 +542,13 @@ gimp_drawable_preview_set_drawable_id (GimpDrawablePreview *drawable_preview,
if (gimp_drawable_is_indexed (drawable_ID))
{
guint32 image_ID = gimp_item_get_image (drawable_ID);
guchar *cmap;
gint num_colors;
guint32 image_ID = gimp_item_get_image (drawable_ID);
GtkWidget *area = gimp_preview_get_area (preview);
guchar *cmap;
gint num_colors;
cmap = gimp_image_get_colormap (image_ID, &num_colors);
gimp_preview_area_set_colormap (GIMP_PREVIEW_AREA (preview->area),
gimp_preview_area_set_colormap (GIMP_PREVIEW_AREA (area),
cmap, num_colors);
g_free (cmap);
}
......
......@@ -185,18 +185,20 @@ gimp_zoom_preview_class_init (GimpZoomPreviewClass *klass)
static void
gimp_zoom_preview_init (GimpZoomPreview *preview)
{
GtkWidget *area = gimp_preview_get_area (GIMP_PREVIEW (preview));
preview->priv = G_TYPE_INSTANCE_GET_PRIVATE (preview,
GIMP_TYPE_ZOOM_PREVIEW,
GimpZoomPreviewPrivate);
g_signal_connect (GIMP_PREVIEW (preview)->area, "size-allocate",
g_signal_connect (area, "size-allocate",
G_CALLBACK (gimp_zoom_preview_size_allocate),
preview);
g_signal_connect (GIMP_PREVIEW (preview)->area, "scroll-event",
g_signal_connect (area, "scroll-event",
G_CALLBACK (gimp_zoom_preview_scroll_event),
preview);
g_object_set (GIMP_PREVIEW (preview)->area,
g_object_set (area,
"check-size", gimp_check_size (),
"check-type", gimp_check_type (),
NULL);
......@@ -324,14 +326,13 @@ gimp_zoom_preview_set_adjustments (GimpZoomPreview *preview,
GimpScrolledPreview *scrolled_preview = GIMP_SCROLLED_PREVIEW (preview);
GtkAdjustment *hadj;
GtkAdjustment *vadj;
gdouble width;
gdouble height;
gint width;
gint height;
gdouble ratio;
gimp_scrolled_preview_freeze (scrolled_preview);
width = GIMP_PREVIEW (preview)->width;
height = GIMP_PREVIEW (preview)->height;
gimp_preview_get_size (GIMP_PREVIEW (preview), &width, &height);
ratio = new_factor / old_factor;
......@@ -365,11 +366,13 @@ gimp_zoom_preview_size_allocate (GtkWidget *widget,
{
gdouble zoom;
#if 0
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);
#endif
zoom = gimp_zoom_model_get_factor (preview->priv->model);
......@@ -380,14 +383,18 @@ static void
gimp_zoom_preview_style_updated (GtkWidget *widget)
{
GimpPreview *preview = GIMP_PREVIEW (widget);
GtkWidget *area = gimp_preview_get_area (preview);
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
if (preview->area)
if (area)
{
GimpZoomPreviewPrivate *priv = GET_PRIVATE (preview);
gint size;
gint width, height;
gint width;
gint height;
gint preview_width;
gint preview_height;
gint x1, y1;
gint x2, y2;
......@@ -407,17 +414,16 @@ gimp_zoom_preview_style_updated (GtkWidget *widget)
if (width > height)
{
preview->width = MIN (width, size);
preview->height = (height * preview->width) / width;
preview_width = MIN (width, size);
preview_height = (height * preview_width) / width;
}
else
{
preview->height = MIN (height, size);
preview->width = (width * preview->height) / height;
preview_height = MIN (height, size);
preview_width = (width * preview_height) / height;
}
gtk_widget_set_size_request (preview->area,
preview->width, preview->height);
gimp_preview_set_size (preview, preview_width, preview_height);
}
}
......@@ -472,7 +478,9 @@ gimp_zoom_preview_draw (GimpPreview *preview)
if (data)
{
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview->area),
GtkWidget *area = gimp_preview_get_area (preview);
gimp_preview_area_draw (GIMP_PREVIEW_AREA (area),
0, 0, width, height,
gimp_drawable_type (priv->drawable_ID),
data, width * bpp);
......@@ -486,15 +494,19 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
gint rowstride)
{
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW (preview)->priv;
GtkWidget *area = gimp_preview_get_area (preview);
gint width;
gint height;
gint32 image_ID;
gimp_preview_get_size (preview, &width, &height);
image_ID = gimp_item_get_image (priv->drawable_ID);
if (gimp_selection_is_empty (image_ID))
{
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview->area),
gimp_preview_area_draw (GIMP_PREVIEW_AREA (area),
0, 0,
preview->width, preview->height,
width, height,
gimp_drawable_type (priv->drawable_ID),
buffer,
rowstride);
......@@ -504,7 +516,7 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
guchar *sel;
guchar *src;
gint selection_ID;
gint width, height;
gint w, h;
gint bpp;
gint src_x;
gint src_y;
......@@ -515,8 +527,8 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
selection_ID = gimp_image_get_selection (image_ID);
width = preview->width;
height = preview->height;
w = width;
h = height;
gimp_zoom_preview_get_source_area (preview,
&src_x, &src_y,
......@@ -525,15 +537,15 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
src = gimp_drawable_get_sub_thumbnail_data (priv->drawable_ID,
src_x, src_y,
src_width, src_height,
&width, &height, &bpp);
&w, &h, &bpp);
gimp_drawable_offsets (priv->drawable_ID, &offsx, &offsy);
sel = gimp_drawable_get_sub_thumbnail_data (selection_ID,
src_x + offsx, src_y + offsy,
src_width, src_height,
&width, &height, &bpp);
gimp_preview_area_mask (GIMP_PREVIEW_AREA (preview->area),
0, 0, preview->width, preview->height,
gimp_preview_area_mask (GIMP_PREVIEW_AREA (area),
0, 0, width, height,
gimp_drawable_type (priv->drawable_ID),
src, width * gimp_drawable_bpp (priv->drawable_ID),
buffer, rowstride,
......@@ -561,7 +573,9 @@ gimp_zoom_preview_draw_thumb (GimpPreview *preview,
static void
gimp_zoom_preview_set_cursor (GimpPreview *preview)
{
if (! gtk_widget_get_realized (preview->area))
GtkWidget *area = gimp_preview_get_area (preview);
if (! gtk_widget_get_realized (area))
return;
if (gimp_zoom_preview_get_factor (GIMP_ZOOM_PREVIEW (preview)) > 1.0)
......@@ -570,14 +584,14 @@ gimp_zoom_preview_set_cursor (GimpPreview *preview)
GdkCursor *cursor;
cursor = gdk_cursor_new_for_display (display, GDK_HAND1);
gdk_window_set_cursor (gtk_widget_get_window (preview->area),
gdk_window_set_cursor (gtk_widget_get_window (area),
cursor);
g_object_unref (cursor);
}
else
{
gdk_window_set_cursor (gtk_widget_get_window (preview->area),
preview->default_cursor);
gdk_window_set_cursor (gtk_widget_get_window (area),
gimp_preview_get_default_cursor (preview));
}
}
......@@ -589,14 +603,22 @@ gimp_zoom_preview_transform (GimpPreview *preview,
gint *dest_y)
{
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW (preview)->priv;
gint width;
gint height;
gint xoff;
gint yoff;
gdouble zoom;
gimp_preview_get_size (preview, &width, &height);
gimp_preview_get_offsets (preview, &xoff, &yoff);
gdouble zoom = gimp_zoom_preview_get_factor (GIMP_ZOOM_PREVIEW (preview));
zoom = gimp_zoom_preview_get_factor (GIMP_ZOOM_PREVIEW (preview));
*dest_x = ((gdouble) (src_x - priv->extents.x) *
preview->width / priv->extents.width * zoom) - preview->xoff;
width / priv->extents.width * zoom) - xoff;
*dest_y = ((gdouble) (src_y - priv->extents.y) *
preview->height / priv->extents.height * zoom) - preview->yoff;
height / priv->extents.height * zoom) - yoff;
}
static void
......@@ -607,16 +629,24 @@ gimp_zoom_preview_untransform (GimpPreview *preview,
gint *dest_y)
{
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW (preview)->priv;
gint width;
gint height;
gint xoff;
gint yoff;
gdouble zoom;
gimp_preview_get_size (preview, &width, &height);
gimp_preview_get_offsets (preview, &xoff, &yoff);
gdouble zoom = gimp_zoom_preview_get_factor (GIMP_ZOOM_PREVIEW (preview));
zoom = gimp_zoom_preview_get_factor (GIMP_ZOOM_PREVIEW (preview));
*dest_x = (priv->extents.x +
((gdouble) (src_x + preview->xoff) *
priv->extents.width / preview->width / zoom));
((gdouble) (src_x + xoff) *
priv->extents.width / width / zoom));
*dest_y = (priv->extents.y +
((gdouble) (src_y + preview->yoff) *
priv->extents.height / preview->height / zoom));
((gdouble) (src_y + yoff) *
priv->extents.height / height / zoom));
}
static void
......@@ -663,7 +693,7 @@ gimp_zoom_preview_set_drawable_id (GimpZoomPreview *preview,
gimp_preview_set_bounds (GIMP_PREVIEW (preview),
0, 0, max_width, max_height);
g_object_set (GIMP_PREVIEW (preview)->frame,
g_object_set (gimp_preview_get_frame (GIMP_PREVIEW (preview)),
"ratio", (gdouble) width / (gdouble) height,
NULL);
}
......@@ -877,8 +907,7 @@ gimp_zoom_preview_get_source (GimpZoomPreview *preview,
gint src_width;
gint src_height;
*width = gimp_preview->width;
*height = gimp_preview->height;
gimp_preview_get_size (gimp_preview, width, height);
gimp_zoom_preview_get_source_area (gimp_preview,
&src_x, &src_y,
......
......@@ -62,7 +62,20 @@ enum
struct _GimpPreviewPrivate
{
GtkWidget *area;
GtkWidget *table;
GtkWidget *frame;
GtkWidget *toggle;
GtkWidget *controls;
GdkCursor *cursor_busy;
GdkCursor *default_cursor;
gint xoff, yoff;
gint xmin, xmax, ymin, ymax;
gint width, height;
gboolean update_preview;
guint timeout_id;
};
#define GET_PRIVATE(obj) (((GimpPreview *) (obj))->priv)
......@@ -224,88 +237,88 @@ gimp_preview_init (GimpPreview *preview)
if (gtk_widget_get_direction (GTK_WIDGET (preview)) == GTK_TEXT_DIR_RTL)
xalign = 1.0;
preview->frame = gtk_aspect_frame_new (NULL, xalign, 0.0, 1.0, TRUE);
gtk_frame_set_shadow_type (GTK_FRAME (preview->frame), GTK_SHADOW_NONE);
gtk_box_pack_start (GTK_BOX (preview), preview->frame, TRUE, TRUE, 0);
gtk_widget_show (preview->frame);
priv->frame = gtk_aspect_frame_new (NULL, xalign, 0.0, 1.0, TRUE);
gtk_frame_set_shadow_type (GTK_FRAME (priv->frame), GTK_SHADOW_NONE);
gtk_box_pack_start (GTK_BOX (preview), priv->frame, TRUE, TRUE, 0);
gtk_widget_show (priv->frame);
preview->table = gtk_table_new (3, 2, FALSE);
gtk_table_set_row_spacing (GTK_TABLE (preview->table), 1, 3);
gtk_container_add (GTK_CONTAINER (preview->frame), preview->table);
gtk_widget_show (preview->table);
priv->table = gtk_table_new (3, 2, FALSE);
gtk_table_set_row_spacing (GTK_TABLE (priv->table), 1, 3);
gtk_container_add (GTK_CONTAINER (priv->frame), priv->table);
gtk_widget_show (priv->table);
preview->timeout_id = 0;
priv->timeout_id = 0;
preview->xmin = preview->ymin = 0;
preview->xmax = preview->ymax = 1;
preview->width = preview->xmax - preview->xmin;
preview->height = preview->ymax - preview->ymin;
priv->xmin = priv->ymin = 0;
priv->xmax = priv->ymax = 1;
priv->width = priv->xmax - priv->xmin;
priv->height = priv->ymax - priv->ymin;
preview->xoff = 0;
preview->yoff = 0;
priv->xoff = 0;
priv->yoff = 0;
preview->default_cursor = NULL;
priv->default_cursor = NULL;
/* preview area */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_table_attach (GTK_TABLE (preview->table), frame, 0, 1, 0, 1,
gtk_table_attach (GTK_TABLE (priv->table), frame, 0, 1, 0, 1,
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
gtk_widget_show (frame);
preview->area = gimp_preview_area_new ();
gtk_container_add (GTK_CONTAINER (frame), preview->area);
gtk_widget_show (preview->area);
priv->area = gimp_preview_area_new ();
gtk_container_add (GTK_CONTAINER (frame), priv->area);
gtk_widget_show (priv->area);
g_signal_connect_swapped (preview->area, "notify::check-size",
g_signal_connect_swapped (priv->area, "notify::check-size",
G_CALLBACK (gimp_preview_notify_checks),
preview);
g_signal_connect_swapped (preview->area, "notify::check-type",
g_signal_connect_swapped (priv->area, "notify::check-type",
G_CALLBACK (gimp_preview_notify_checks),
preview);
gtk_widget_add_events (preview->area,
gtk_widget_add_events (priv->area,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_MOTION_MASK);
g_signal_connect (preview->area, "event",
g_signal_connect (priv->area, "event",
G_CALLBACK (gimp_preview_area_event),
preview);
g_signal_connect (preview->area, "realize",
g_signal_connect (priv->area, "realize",
G_CALLBACK (gimp_preview_area_realize),
preview);
g_signal_connect (preview->area, "unrealize",
g_signal_connect (priv->area, "unrealize",
G_CALLBACK (gimp_preview_area_unrealize),
preview);
g_signal_connect_data (preview->area, "realize",
g_signal_connect_data (priv->area, "realize",
G_CALLBACK (gimp_preview_area_set_cursor),
preview, NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect (preview->area, "size-allocate",
g_signal_connect (priv->area, "size-allocate",
G_CALLBACK (gimp_preview_area_size_allocate),
preview);