Commit dab006d5 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

removed the unused GimpViewable parameter from

2003-11-17  Sven Neumann  <sven@gimp.org>

	* app/core/gimpviewable.[ch]: removed the unused GimpViewable
	parameter from gimp_viewable_calc_preview_size().

	* app/core/gimpbuffer.c
	* app/core/gimpimage-preview.c
	* app/core/gimpimagefile.c
	* app/core/gimpitem-preview.c
	* app/core/gimpundo.c
	* app/widgets/gimppreview.c
	* app/widgets/gimppreviewrendererdrawable.c
	* app/widgets/gimppreviewrendererimage.c: changed accordingly.

	* app/widgets/gimppreviewrenderer.[ch]: store the viewable_type in
	the preview renderer and use its default stock_id if no viewable
	is set.

	* app/core/gimpbrush.c
	* app/core/gimpbuffer.c
	* app/core/gimpgradient.c
	* app/core/gimppalette.c
	* app/core/gimppattern.c
	* app/core/gimpundo.c: set a default stock_id.
parent 3e84631e
2003-11-17 Sven Neumann <sven@gimp.org>
* app/core/gimpviewable.[ch]: removed the unused GimpViewable
parameter from gimp_viewable_calc_preview_size().
* app/core/gimpbuffer.c
* app/core/gimpimage-preview.c
* app/core/gimpimagefile.c
* app/core/gimpitem-preview.c
* app/core/gimpundo.c
* app/widgets/gimppreview.c
* app/widgets/gimppreviewrendererdrawable.c
* app/widgets/gimppreviewrendererimage.c: changed accordingly.
* app/widgets/gimppreviewrenderer.[ch]: store the viewable_type in
the preview renderer and use its default stock_id if no viewable
is set.
* app/core/gimpbrush.c
* app/core/gimpbuffer.c
* app/core/gimpgradient.c
* app/core/gimppalette.c
* app/core/gimppattern.c
* app/core/gimpundo.c: set a default stock_id.
2003-11-17 Manish Singh <yosh@gimp.org>
* tools/gimp-remote.c (gimp_remote_find_window): search for the
......@@ -152,19 +152,20 @@ gimp_brush_class_init (GimpBrushClass *klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->finalize = gimp_brush_finalize;
object_class->finalize = gimp_brush_finalize;
gimp_object_class->get_memsize = gimp_brush_get_memsize;
gimp_object_class->get_memsize = gimp_brush_get_memsize;
viewable_class->get_popup_size = gimp_brush_get_popup_size;
viewable_class->get_new_preview = gimp_brush_get_new_preview;
viewable_class->get_description = gimp_brush_get_description;
viewable_class->default_stock_id = "gimp-tool-paintbrush";
viewable_class->get_popup_size = gimp_brush_get_popup_size;
viewable_class->get_new_preview = gimp_brush_get_new_preview;
viewable_class->get_description = gimp_brush_get_description;
data_class->get_extension = gimp_brush_get_extension;
data_class->get_extension = gimp_brush_get_extension;
klass->select_brush = gimp_brush_real_select_brush;
klass->want_null_motion = gimp_brush_real_want_null_motion;
klass->spacing_changed = NULL;
klass->select_brush = gimp_brush_real_select_brush;
klass->want_null_motion = gimp_brush_real_want_null_motion;
klass->spacing_changed = NULL;
}
static void
......
......@@ -152,19 +152,20 @@ gimp_brush_class_init (GimpBrushClass *klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->finalize = gimp_brush_finalize;
object_class->finalize = gimp_brush_finalize;
gimp_object_class->get_memsize = gimp_brush_get_memsize;
gimp_object_class->get_memsize = gimp_brush_get_memsize;
viewable_class->get_popup_size = gimp_brush_get_popup_size;
viewable_class->get_new_preview = gimp_brush_get_new_preview;
viewable_class->get_description = gimp_brush_get_description;
viewable_class->default_stock_id = "gimp-tool-paintbrush";
viewable_class->get_popup_size = gimp_brush_get_popup_size;
viewable_class->get_new_preview = gimp_brush_get_new_preview;
viewable_class->get_description = gimp_brush_get_description;
data_class->get_extension = gimp_brush_get_extension;
data_class->get_extension = gimp_brush_get_extension;
klass->select_brush = gimp_brush_real_select_brush;
klass->want_null_motion = gimp_brush_real_want_null_motion;
klass->spacing_changed = NULL;
klass->select_brush = gimp_brush_real_select_brush;
klass->want_null_motion = gimp_brush_real_want_null_motion;
klass->spacing_changed = NULL;
}
static void
......
......@@ -108,6 +108,7 @@ gimp_buffer_class_init (GimpBufferClass *klass)
gimp_object_class->get_memsize = gimp_buffer_get_memsize;
viewable_class->default_stock_id = "gtk-paste";
viewable_class->get_preview_size = gimp_buffer_get_preview_size;
viewable_class->get_popup_size = gimp_buffer_get_popup_size;
viewable_class->get_new_preview = gimp_buffer_get_new_preview;
......@@ -160,12 +161,9 @@ gimp_buffer_get_preview_size (GimpViewable *viewable,
gint *width,
gint *height)
{
GimpBuffer *buffer;
buffer = GIMP_BUFFER (viewable);
GimpBuffer *buffer = GIMP_BUFFER (viewable);
gimp_viewable_calc_preview_size (viewable,
gimp_buffer_get_width (buffer),
gimp_viewable_calc_preview_size (gimp_buffer_get_width (buffer),
gimp_buffer_get_height (buffer),
size,
size,
......@@ -195,8 +193,7 @@ gimp_buffer_get_popup_size (GimpViewable *viewable,
{
gboolean scaling_up;
gimp_viewable_calc_preview_size (viewable,
buffer_width,
gimp_viewable_calc_preview_size (buffer_width,
buffer_height,
width * 2,
height * 2,
......
......@@ -134,6 +134,7 @@ gimp_gradient_class_init (GimpGradientClass *klass)
gimp_object_class->get_memsize = gimp_gradient_get_memsize;
viewable_class->default_stock_id = "gimp-tool-blend";
viewable_class->get_preview_size = gimp_gradient_get_preview_size;
viewable_class->get_popup_size = gimp_gradient_get_popup_size;
viewable_class->get_new_preview = gimp_gradient_get_new_preview;
......
......@@ -45,9 +45,7 @@ gimp_image_get_preview_size (GimpViewable *viewable,
gint *width,
gint *height)
{
GimpImage *gimage;
gimage = GIMP_IMAGE (viewable);
GimpImage *gimage = GIMP_IMAGE (viewable);
if (! gimage->gimp->config->layer_previews && ! is_popup)
{
......@@ -56,8 +54,7 @@ gimp_image_get_preview_size (GimpViewable *viewable,
return;
}
gimp_viewable_calc_preview_size (viewable,
gimage->width,
gimp_viewable_calc_preview_size (gimage->width,
gimage->height,
size,
size,
......@@ -77,9 +74,7 @@ gimp_image_get_popup_size (GimpViewable *viewable,
gint *popup_width,
gint *popup_height)
{
GimpImage *gimage;
gimage = GIMP_IMAGE (viewable);
GimpImage *gimage = GIMP_IMAGE (viewable);
if (! gimage->gimp->config->layer_previews)
return FALSE;
......@@ -88,8 +83,7 @@ gimp_image_get_popup_size (GimpViewable *viewable,
{
gboolean scaling_up;
gimp_viewable_calc_preview_size (viewable,
gimage->width,
gimp_viewable_calc_preview_size (gimage->width,
gimage->height,
width * 2,
height * 2,
......@@ -115,9 +109,7 @@ gimp_image_get_preview (GimpViewable *viewable,
gint width,
gint height)
{
GimpImage *gimage;
gimage = GIMP_IMAGE (viewable);
GimpImage *gimage = GIMP_IMAGE (viewable);
if (! gimage->gimp->config->layer_previews)
return NULL;
......
......@@ -649,8 +649,7 @@ gimp_imagefile_get_new_preview (GimpViewable *viewable,
gint preview_width;
gint preview_height;
gimp_viewable_calc_preview_size (viewable,
temp_buf->width,
gimp_viewable_calc_preview_size (temp_buf->width,
temp_buf->height,
width,
height,
......
......@@ -59,8 +59,7 @@ gimp_item_get_preview_size (GimpViewable *viewable,
if (gimage && ! is_popup)
{
gimp_viewable_calc_preview_size (viewable,
gimage->width,
gimp_viewable_calc_preview_size (gimage->width,
gimage->height,
size,
size,
......@@ -73,14 +72,11 @@ gimp_item_get_preview_size (GimpViewable *viewable,
}
else
{
gimp_viewable_calc_preview_size (viewable,
item->width,
gimp_viewable_calc_preview_size (item->width,
item->height,
size,
size,
dot_for_dot,
1.0,
1.0,
dot_for_dot, 1.0, 1.0,
width,
height,
NULL);
......@@ -108,8 +104,7 @@ gimp_item_get_popup_size (GimpViewable *viewable,
{
gboolean scaling_up;
gimp_viewable_calc_preview_size (viewable,
item->width,
gimp_viewable_calc_preview_size (item->width,
item->height,
width * 2,
height * 2,
......
......@@ -129,6 +129,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
gimp_object_class->get_memsize = gimp_palette_get_memsize;
viewable_class->default_stock_id = "gtk-select-color";
viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_popup_size = gimp_palette_get_popup_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
......
......@@ -129,6 +129,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
gimp_object_class->get_memsize = gimp_palette_get_memsize;
viewable_class->default_stock_id = "gtk-select-color";
viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_popup_size = gimp_palette_get_popup_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
......
......@@ -129,6 +129,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
gimp_object_class->get_memsize = gimp_palette_get_memsize;
viewable_class->default_stock_id = "gtk-select-color";
viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_popup_size = gimp_palette_get_popup_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
......
......@@ -126,16 +126,17 @@ gimp_pattern_class_init (GimpPatternClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_pattern_finalize;
object_class->finalize = gimp_pattern_finalize;
gimp_object_class->get_memsize = gimp_pattern_get_memsize;
gimp_object_class->get_memsize = gimp_pattern_get_memsize;
viewable_class->get_popup_size = gimp_pattern_get_popup_size;
viewable_class->get_new_preview = gimp_pattern_get_new_preview;
viewable_class->get_description = gimp_pattern_get_description;
viewable_class->default_stock_id = "gimp-tool-bucket-fill";
viewable_class->get_popup_size = gimp_pattern_get_popup_size;
viewable_class->get_new_preview = gimp_pattern_get_new_preview;
viewable_class->get_description = gimp_pattern_get_description;
data_class->get_extension = gimp_pattern_get_extension;
data_class->duplicate = gimp_pattern_duplicate;
data_class->get_extension = gimp_pattern_get_extension;
data_class->duplicate = gimp_pattern_duplicate;
}
static void
......
......@@ -126,16 +126,17 @@ gimp_pattern_class_init (GimpPatternClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_pattern_finalize;
object_class->finalize = gimp_pattern_finalize;
gimp_object_class->get_memsize = gimp_pattern_get_memsize;
gimp_object_class->get_memsize = gimp_pattern_get_memsize;
viewable_class->get_popup_size = gimp_pattern_get_popup_size;
viewable_class->get_new_preview = gimp_pattern_get_new_preview;
viewable_class->get_description = gimp_pattern_get_description;
viewable_class->default_stock_id = "gimp-tool-bucket-fill";
viewable_class->get_popup_size = gimp_pattern_get_popup_size;
viewable_class->get_new_preview = gimp_pattern_get_new_preview;
viewable_class->get_description = gimp_pattern_get_description;
data_class->get_extension = gimp_pattern_get_extension;
data_class->duplicate = gimp_pattern_duplicate;
data_class->get_extension = gimp_pattern_get_extension;
data_class->duplicate = gimp_pattern_duplicate;
}
static void
......
......@@ -133,15 +133,16 @@ gimp_undo_class_init (GimpUndoClass *klass)
G_TYPE_NONE, 1,
GIMP_TYPE_UNDO_MODE);
object_class->finalize = gimp_undo_finalize;
object_class->finalize = gimp_undo_finalize;
gimp_object_class->get_memsize = gimp_undo_get_memsize;
gimp_object_class->get_memsize = gimp_undo_get_memsize;
viewable_class->get_popup_size = gimp_undo_get_popup_size;
viewable_class->get_new_preview = gimp_undo_get_new_preview;
viewable_class->default_stock_id = "gtk-undo";
viewable_class->get_popup_size = gimp_undo_get_popup_size;
viewable_class->get_new_preview = gimp_undo_get_new_preview;
klass->pop = gimp_undo_real_pop;
klass->free = gimp_undo_real_free;
klass->pop = gimp_undo_real_pop;
klass->free = gimp_undo_real_free;
}
static void
......@@ -234,8 +235,7 @@ gimp_undo_get_new_preview (GimpViewable *viewable,
gint preview_width;
gint preview_height;
gimp_viewable_calc_preview_size (viewable,
undo->preview->width,
gimp_viewable_calc_preview_size (undo->preview->width,
undo->preview->height,
width,
height,
......
......@@ -357,23 +357,20 @@ gimp_viewable_size_changed (GimpViewable *viewable)
}
void
gimp_viewable_calc_preview_size (GimpViewable *viewable,
gint aspect_width,
gint aspect_height,
gint width,
gint height,
gboolean dot_for_dot,
gdouble xresolution,
gdouble yresolution,
gint *return_width,
gint *return_height,
gboolean *scaling_up)
gimp_viewable_calc_preview_size (gint aspect_width,
gint aspect_height,
gint width,
gint height,
gboolean dot_for_dot,
gdouble xresolution,
gdouble yresolution,
gint *return_width,
gint *return_height,
gboolean *scaling_up)
{
gdouble xratio;
gdouble yratio;
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
if (aspect_width > aspect_height)
{
xratio = yratio = (gdouble) width / (gdouble) aspect_width;
......@@ -455,7 +452,7 @@ gimp_viewable_get_popup_size (GimpViewable *viewable,
if ((w > (2 * GIMP_VIEWABLE_MAX_POPUP_SIZE)) ||
(h > (2 * GIMP_VIEWABLE_MAX_POPUP_SIZE)))
{
gimp_viewable_calc_preview_size (viewable, w, h,
gimp_viewable_calc_preview_size (w, h,
2 * GIMP_VIEWABLE_MAX_POPUP_SIZE,
2 * GIMP_VIEWABLE_MAX_POPUP_SIZE,
dot_for_dot, 1.0, 1.0,
......
......@@ -92,8 +92,7 @@ GType gimp_viewable_get_type (void) G_GNUC_CONST;
void gimp_viewable_invalidate_preview (GimpViewable *viewable);
void gimp_viewable_size_changed (GimpViewable *viewable);
void gimp_viewable_calc_preview_size (GimpViewable *viewable,
gint aspect_width,
void gimp_viewable_calc_preview_size (gint aspect_width,
gint aspect_height,
gint width,
gint height,
......
......@@ -347,9 +347,7 @@ gimp_preview_size_allocate (GtkWidget *widget,
&preview_width,
&preview_height);
gimp_viewable_calc_preview_size (preview->renderer->viewable,
preview_width,
preview_height,
gimp_viewable_calc_preview_size (preview_width, preview_height,
width, height,
TRUE, 1.0, 1.0,
&scaled_width, &scaled_height,
......@@ -696,17 +694,17 @@ gimp_preview_set_viewable (GimpPreview *preview,
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable));
if (viewable == preview->viewable)
return;
if (viewable)
{
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (preview->renderer),
gimp_preview_renderer_type_from_viewable_type (viewable_type)));
g_return_if_fail (g_type_is_a (viewable_type,
preview->renderer->viewable_type));
}
if (viewable == preview->viewable)
return;
if (preview->viewable)
{
g_object_remove_weak_pointer (G_OBJECT (preview->viewable),
......
......@@ -204,6 +204,22 @@ gimp_preview_renderer_finalize (GObject *object)
}
static GimpPreviewRenderer *
gimp_preview_renderer_new_internal (GType viewable_type,
gboolean is_popup)
{
GimpPreviewRenderer *renderer;
renderer = g_object_new (gimp_preview_renderer_type_from_viewable_type (viewable_type),
NULL);
renderer->viewable_type = viewable_type;
renderer->is_popup = is_popup ? TRUE : FALSE;
return renderer;
}
/* public functions */
GimpPreviewRenderer *
......@@ -220,10 +236,7 @@ gimp_preview_renderer_new (GType viewable_type,
g_return_val_if_fail (border_width >= 0 &&
border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH, NULL);
renderer = g_object_new (gimp_preview_renderer_type_from_viewable_type (viewable_type),
NULL);
renderer->is_popup = is_popup ? TRUE : FALSE;
renderer = gimp_preview_renderer_new_internal (viewable_type, is_popup);
gimp_preview_renderer_set_size (renderer, size, border_width);
gimp_preview_renderer_remove_idle (renderer);
......@@ -248,10 +261,7 @@ gimp_preview_renderer_new_full (GType viewable_type,
g_return_val_if_fail (border_width >= 0 &&
border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH, NULL);
renderer = g_object_new (gimp_preview_renderer_type_from_viewable_type (viewable_type),
NULL);
renderer->is_popup = is_popup ? TRUE : FALSE;
renderer = gimp_preview_renderer_new_internal (viewable_type, is_popup);
gimp_preview_renderer_set_size_full (renderer, width, height, border_width);
gimp_preview_renderer_remove_idle (renderer);
......@@ -263,18 +273,12 @@ void
gimp_preview_renderer_set_viewable (GimpPreviewRenderer *renderer,
GimpViewable *viewable)
{
GType viewable_type = G_TYPE_NONE;
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
if (viewable)
{
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (renderer),
gimp_preview_renderer_type_from_viewable_type (viewable_type)));
}
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (viewable),
renderer->viewable_type));
if (viewable == renderer->viewable)
return;
......@@ -537,12 +541,31 @@ gimp_preview_renderer_draw (GimpPreviewRenderer *renderer,
g_return_if_fail (draw_area != NULL);
g_return_if_fail (expose_area != NULL);
if (! GTK_WIDGET_DRAWABLE (widget) || ! renderer->viewable)
if (! GTK_WIDGET_DRAWABLE (widget))
return;
GIMP_PREVIEW_RENDERER_GET_CLASS (renderer)->draw (renderer,
window, widget,
draw_area, expose_area);
if (renderer->viewable)
{
GIMP_PREVIEW_RENDERER_GET_CLASS (renderer)->draw (renderer,
window, widget,
draw_area,
expose_area);
}
else
{
GimpViewableClass *viewable_class;
viewable_class = g_type_class_ref (renderer->viewable_type);
gimp_preview_renderer_default_render_stock (renderer,
widget,
viewable_class->default_stock_id);
g_type_class_unref (viewable_class);
gimp_preview_renderer_real_draw (renderer,
window, widget, draw_area, expose_area);
}
if (renderer->border_width > 0)
{
......@@ -757,26 +780,21 @@ gimp_preview_renderer_default_render_stock (GimpPreviewRenderer *renderer,
if (pixbuf)
{
if (gdk_pixbuf_get_width (pixbuf) > renderer->width ||
gdk_pixbuf_get_height (pixbuf) > renderer->height)
gint width = gdk_pixbuf_get_width (pixbuf);
gint height = gdk_pixbuf_get_height (pixbuf);
if (width > renderer->width || height > renderer->height)
{
GdkPixbuf *scaled_pixbuf;
gint pixbuf_width;
gint pixbuf_height;
gimp_viewable_calc_preview_size (renderer->viewable,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
renderer->width,
renderer->height,
gimp_viewable_calc_preview_size (width, height,
renderer->width, renderer->height,
TRUE, 1.0, 1.0,
&pixbuf_width,
&pixbuf_height,
&width, &height,
NULL);
scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
pixbuf_width,
pixbuf_height,
width, height,
GDK_INTERP_BILINEAR);
g_object_unref (pixbuf);
......
......@@ -40,6 +40,7 @@ struct _GimpPreviewRenderer
{
GObject parent_instance;
GType viewable_type;
GimpViewable *viewable;
gint width;
......
......@@ -118,8 +118,7 @@ gimp_preview_renderer_drawable_render (GimpPreviewRenderer *renderer,
height = MAX (1, ROUND ((((gdouble) height / (gdouble) gimage->height) *
(gdouble) item->height)));
gimp_viewable_calc_preview_size (renderer->viewable,
item->width,
gimp_viewable_calc_preview_size (item->width,
item->height,
width,
height,
......@@ -132,8 +131,7 @@ gimp_preview_renderer_drawable_render (GimpPreviewRenderer *renderer,
}
else
{
gimp_viewable_calc_preview_size (renderer->viewable,
item->width,
gimp_viewable_calc_preview_size (item->width,
item->height,
width,
height,
......
......@@ -105,8 +105,7 @@ gimp_preview_renderer_image_render (GimpPreviewRenderer *renderer,
gimage = GIMP_IMAGE (renderer->viewable);
gimp_viewable_calc_preview_size (renderer->viewable,
gimage->width,
gimp_viewable_calc_preview_size (gimage->width,
gimage->height,
renderer->width,
renderer->height,
......@@ -122,12 +121,12 @@ gimp_preview_renderer_image_render (GimpPreviewRenderer *renderer,
TempBuf *temp_buf;
temp_buf = gimp_viewable_get_new_preview (renderer->viewable,
gimage->width,
gimage->height);
gimage->width, gimage->height);
if (temp_buf)
{
render_buf = temp_buf_scale (temp_buf, preview_width, preview_height);
render_buf = temp_buf_scale (temp_buf,
preview_width, preview_height);
temp_buf_free (temp_buf);
}
......
......@@ -347,9 +347,7 @@ gimp_preview_size_allocate (GtkWidget *widget,
&preview_width,
&preview_height);
gimp_viewable_calc_preview_size (preview->renderer->viewable,
preview_width,
preview_height,
gimp_viewable_calc_preview_size (preview_width, preview_height,
width, height,
TRUE, 1.0, 1.0,
&scaled_width, &scaled_height,
......@@ -696,17 +694,17 @@ gimp_preview_set_viewable (GimpPreview *preview,
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable));
if (viewable == preview->viewable)
return;
if (viewable)
{
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (preview->renderer),
gimp_preview_renderer_type_from_viewable_type (viewable_type)));
g_return_if_fail (g_type_is_a (viewable_type,
preview->renderer->viewable_type));
}
if (viewable == preview->viewable)
return;
if (preview->viewable)
{
g_object_remove_weak_pointer (G_OBJECT (preview->viewable),
......
......@@ -204,6 +204,22 @@ gimp_preview_renderer_finalize (GObject *object)
}
static GimpPreviewRenderer *
gimp_preview_renderer_new_internal (GType viewable_type,
gboolean is_popup)
{
GimpPreviewRenderer *renderer;
renderer = g_object_new (gimp_preview_renderer_type_from_viewable_type (viewable_type),
NULL);
renderer->viewable_type = viewable_type;
renderer->is_popup = is_popup ? TRUE : FALSE;
return renderer;
}
/* public functions */
GimpPreviewRenderer *
......@@ -220,10 +236,7 @@ gimp_preview_renderer_new (GType viewable_type,
g_return_val_if_fail (border_width >= 0 &&
border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH, NULL);
renderer = g_object_new (gimp_preview_renderer_type_from_viewable_type (viewable_type),
NULL);
renderer->is_popup = is_popup ? TRUE : FALSE;
renderer = gimp_preview_renderer_new_internal (viewable_type, is_popup);
gimp_preview_renderer_set_size (renderer, size, border_width);
gimp_preview_renderer_remove_idle (renderer);
......@@ -248,10 +261,7 @@ gimp_preview_renderer_new_full (GType viewable_type,
g_return_val_if_fail (border_width >= 0 &&
border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH, NULL);
renderer = g_object_new (gimp_preview_renderer_type_from_viewable_type (viewable_type),
NULL);
renderer->is_popup = is_popup ? TRUE : FALSE;
renderer = gimp_preview_renderer_new_internal (viewable_type, is_popup);
gimp_preview_renderer_set_size_full (renderer, width, height, border_width);
gimp_preview_renderer_remove_idle (renderer);
......@@ -263,18 +273,12 @@ void
gimp_preview_renderer_set_viewable (GimpPreviewRenderer *renderer,
GimpViewable *viewable)
{
GType viewable_type = G_TYPE_NONE;
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
if (viewable)
{
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (renderer),
gimp_preview_renderer_type_from_viewable_type (viewable_type)));
}
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (viewable),
renderer->viewable_type));
if (viewable == renderer->viewable)
return;
......@@ -537,12 +541,31 @@ gimp_preview_renderer_draw (GimpPreviewRenderer *renderer,
g_return_if_fail (draw_area != NULL);
g_return_if_fail (expose_area != NULL);
if (! GTK_WIDGET_DRAWABLE (widget) || ! renderer->viewable)
if (! GTK_WIDGET_DRAWABLE (widget))
return;