added "gchar *stock_id" to the GimpViewable struct. It is used by the GUI

2003-02-25  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpviewable.[ch]: added "gchar *stock_id" to the
	GimpViewable struct. It is used by the GUI if the get_preview()
	functions return NULL. Default to GTK_STOCK_DIALOG_QUESTION.

	* app/core/gimptoolinfo.[ch]: set the tool's stock_id. Removed
	the cached GdkPixbuf. Don't implement any preview function
	so the GUI uses the stock_id.

	* app/tools/tool_manager.c: removed GdkPixbuf creation, removed
	the #warning about the buggy way we created the pixbuf.

	* app/gui/dialogs-constructors.c
	* app/gui/image-menu.c
	* app/tools/gimpcroptool.c
	* app/tools/gimphistogramtool.c
	* app/tools/gimpimagemaptool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimptransformtool.c
	* app/widgets/gimptoolbox.c: use viewable->stock_id instead
	of tool_info->stock_id.

	* app/core/gimpbrush.c
	* app/core/gimpgradient.c
	* app/core/gimpimagefile.c
	* app/core/gimpundo.c: simplified get_preview() implementations:

	- never scale previews up, only down.
	- don't render white or checks backgrounds but simply return
	  TempBufs with alpha and let the preview system do its job.
	- don't add padding but simply return previews smaller than
	  requested.

	* app/display/gimpdisplayshell-render.[ch]: added
	"render_blend_white", a 2d lookup table for blending on white,
	just as the check lookup tables. Added "render_white_buf".

	* app/widgets/gimppreview.[ch]: changed a lot:

	- don't render the preview's border into the buffer.
	- added "GdkGC *border_gc" and draw the preview's border in expose()
	  using gdk_draw_rectangle().
	- added "GdkPixbuf *no_preview_pixbuf" and create it in
	  gimp_preview_real_render() if gimp_viewable_get_preview()
	  returned NULL.
	- factored the actual preview rendering out to
	  gimp_preview_render_to_buffer(). Added configurable background
	  rendering for the preview itself and it's padding area
	  (the area the preview is larger than the buffer returned
	  by gimp_viewable_get_preview()).
	- changed gimp_preview_render_and_flush() to
	  gimp_preview_render_preview() and added "inside_bg" and
	  "outside_bg" parameters.
	- use the new render buffers for blending on white.

	* app/widgets/gimpbrushpreview.c
	* app/widgets/gimpbufferpreview.c
	* app/widgets/gimpdrawablepreview.c
	* app/widgets/gimpgradientpreview.c
	* app/widgets/gimpimagepreview.c
	* app/widgets/gimppalettepreview.c
	* app/widgets/gimppatternpreview.c: don't create large white
	TempBufs to center the previews in but simply set the TempBuf's
	offsets to get them centered. Simplified & cleaned up many preview
	render functions. Pass the correct GimpPreviewBG modes to
	gimp_preview_render_preview().

	* app/widgets/gimpcellrendererviewable.[ch]: new GtkCellRenderer
	class derived from GtkCellRendererPixbuf which knows how
	to use gimp_viewable_get_preview_size() and renders the
	viewable's stock item if no preview can be created.

	* app/widgets/gimpcontainertreeview.c: added a GtkTreeCellDataFunc
	which creates the preview pixbuf if needed so we don't create it
	unconditionally upon item insertion. Fixed preview size assertion
	to use GIMP_PREVIEW_MAX_SIZE, not "64". Block "selection_changed"
	while reordering the selected item.

	* app/widgets/gimpcontainerview.c: cosmetic.

	* app/widgets/gimpimagefilepreview.[ch]
	* app/widgets/gimptoolinfopreview.[ch]
	* app/widgets/gimpundopreview.[ch]: removed because the default
	implementation is good enough.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimppreview-utils.c: changed accordingly.

	* app/gui/dialogs-constructors.[ch]
	* app/gui/dialogs-menu.c
	* app/gui/dialogs.c
	* app/gui/image-menu.c
	* app/gui/toolbox-menu.c: register grid and tree view variants
	of the document history.

	Unrelated:

	* app/gui/gui.c (gui_exit_finish_callback): disconnect from
	signals earlier.

	* app/gui/user-install-dialog.c: create the "tool-options" subdir
	of the user's ~/.gimp-1.3 directory.
This commit is contained in:
Michael Natterer 2003-02-26 16:15:50 +00:00 committed by Michael Natterer
parent 4144a12773
commit 2d5828ec2d
10 changed files with 259 additions and 230 deletions

105
ChangeLog
View File

@ -1,3 +1,108 @@
2003-02-25 Michael Natterer <mitch@gimp.org>
* app/core/gimpviewable.[ch]: added "gchar *stock_id" to the
GimpViewable struct. It is used by the GUI if the get_preview()
functions return NULL. Default to GTK_STOCK_DIALOG_QUESTION.
* app/core/gimptoolinfo.[ch]: set the tool's stock_id. Removed
the cached GdkPixbuf. Don't implement any preview function
so the GUI uses the stock_id.
* app/tools/tool_manager.c: removed GdkPixbuf creation, removed
the #warning about the buggy way we created the pixbuf.
* app/gui/dialogs-constructors.c
* app/gui/image-menu.c
* app/tools/gimpcroptool.c
* app/tools/gimphistogramtool.c
* app/tools/gimpimagemaptool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimptransformtool.c
* app/widgets/gimptoolbox.c: use viewable->stock_id instead
of tool_info->stock_id.
* app/core/gimpbrush.c
* app/core/gimpgradient.c
* app/core/gimpimagefile.c
* app/core/gimpundo.c: simplified get_preview() implementations:
- never scale previews up, only down.
- don't render white or checks backgrounds but simply return
TempBufs with alpha and let the preview system do its job.
- don't add padding but simply return previews smaller than
requested.
* app/display/gimpdisplayshell-render.[ch]: added
"render_blend_white", a 2d lookup table for blending on white,
just as the check lookup tables. Added "render_white_buf".
* app/widgets/gimppreview.[ch]: changed a lot:
- don't render the preview's border into the buffer.
- added "GdkGC *border_gc" and draw the preview's border in expose()
using gdk_draw_rectangle().
- added "GdkPixbuf *no_preview_pixbuf" and create it in
gimp_preview_real_render() if gimp_viewable_get_preview()
returned NULL.
- factored the actual preview rendering out to
gimp_preview_render_to_buffer(). Added configurable background
rendering for the preview itself and it's padding area
(the area the preview is larger than the buffer returned
by gimp_viewable_get_preview()).
- changed gimp_preview_render_and_flush() to
gimp_preview_render_preview() and added "inside_bg" and
"outside_bg" parameters.
- use the new render buffers for blending on white.
* app/widgets/gimpbrushpreview.c
* app/widgets/gimpbufferpreview.c
* app/widgets/gimpdrawablepreview.c
* app/widgets/gimpgradientpreview.c
* app/widgets/gimpimagepreview.c
* app/widgets/gimppalettepreview.c
* app/widgets/gimppatternpreview.c: don't create large white
TempBufs to center the previews in but simply set the TempBuf's
offsets to get them centered. Simplified & cleaned up many preview
render functions. Pass the correct GimpPreviewBG modes to
gimp_preview_render_preview().
* app/widgets/gimpcellrendererviewable.[ch]: new GtkCellRenderer
class derived from GtkCellRendererPixbuf which knows how
to use gimp_viewable_get_preview_size() and renders the
viewable's stock item if no preview can be created.
* app/widgets/gimpcontainertreeview.c: added a GtkTreeCellDataFunc
which creates the preview pixbuf if needed so we don't create it
unconditionally upon item insertion. Fixed preview size assertion
to use GIMP_PREVIEW_MAX_SIZE, not "64". Block "selection_changed"
while reordering the selected item.
* app/widgets/gimpcontainerview.c: cosmetic.
* app/widgets/gimpimagefilepreview.[ch]
* app/widgets/gimptoolinfopreview.[ch]
* app/widgets/gimpundopreview.[ch]: removed because the default
implementation is good enough.
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimppreview-utils.c: changed accordingly.
* app/gui/dialogs-constructors.[ch]
* app/gui/dialogs-menu.c
* app/gui/dialogs.c
* app/gui/image-menu.c
* app/gui/toolbox-menu.c: register grid and tree view variants
of the document history.
Unrelated:
* app/gui/gui.c (gui_exit_finish_callback): disconnect from
signals earlier.
* app/gui/user-install-dialog.c: create the "tool-options" subdir
of the user's ~/.gimp-1.3 directory.
2003-02-26 Sven Neumann <sven@gimp.org>
* autogen.sh: moved the call to libtoolize before automake.

View File

@ -212,25 +212,21 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
gint height)
{
GimpBrush *brush;
gboolean scale = FALSE;
gint brush_width;
gint brush_height;
gint offset_x;
gint offset_y;
TempBuf *mask_buf = NULL;
TempBuf *pixmap_buf = NULL;
TempBuf *return_buf = NULL;
guchar white[3] = { 255, 255, 255 };
guchar transp[4] = { 0, 0, 0, 0 };
guchar *mask;
guchar *buf;
guchar *b;
guchar bg;
gint x, y;
gboolean scale = FALSE;
brush = GIMP_BRUSH (viewable);
mask_buf = gimp_brush_get_mask (brush);
pixmap_buf = gimp_brush_get_pixmap (brush);
mask_buf = gimp_brush_get_mask (brush);
pixmap_buf = gimp_brush_get_pixmap (brush);
brush_width = mask_buf->width;
brush_height = mask_buf->height;
@ -257,16 +253,11 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
scale = TRUE;
}
offset_x = (width - brush_width) / 2;
offset_y = (height - brush_height) / 2;
return_buf = temp_buf_new (width, height, 3, 0, 0, white);
return_buf = temp_buf_new (brush_width, brush_height, 4, 0, 0, transp);
mask = temp_buf_data (mask_buf);
buf = temp_buf_data (return_buf);
b = buf + (offset_y * return_buf->width + offset_x) * return_buf->bytes;
if (pixmap_buf)
{
guchar *pixmap = temp_buf_data (pixmap_buf);
@ -275,16 +266,11 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
{
for (x = 0; x < brush_width ; x++)
{
bg = (255 - *mask);
*b++ = bg + (*mask * *pixmap++) / 255;
*b++ = bg + (*mask * *pixmap++) / 255;
*b++ = bg + (*mask * *pixmap++) / 255;
mask++;
*buf++ = *pixmap++;
*buf++ = *pixmap++;
*buf++ = *pixmap++;
*buf++ = *mask++;
}
b += (return_buf->width - brush_width) * return_buf->bytes;
}
}
else
@ -293,14 +279,11 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
{
for (x = 0; x < brush_width ; x++)
{
bg = 255 - *mask++;
*b++ = bg;
*b++ = bg;
*b++ = bg;
*buf++ = 0;
*buf++ = 0;
*buf++ = 0;
*buf++ = *mask++;
}
b += (return_buf->width - brush_width) * return_buf->bytes;
}
}

View File

@ -212,25 +212,21 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
gint height)
{
GimpBrush *brush;
gboolean scale = FALSE;
gint brush_width;
gint brush_height;
gint offset_x;
gint offset_y;
TempBuf *mask_buf = NULL;
TempBuf *pixmap_buf = NULL;
TempBuf *return_buf = NULL;
guchar white[3] = { 255, 255, 255 };
guchar transp[4] = { 0, 0, 0, 0 };
guchar *mask;
guchar *buf;
guchar *b;
guchar bg;
gint x, y;
gboolean scale = FALSE;
brush = GIMP_BRUSH (viewable);
mask_buf = gimp_brush_get_mask (brush);
pixmap_buf = gimp_brush_get_pixmap (brush);
mask_buf = gimp_brush_get_mask (brush);
pixmap_buf = gimp_brush_get_pixmap (brush);
brush_width = mask_buf->width;
brush_height = mask_buf->height;
@ -257,16 +253,11 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
scale = TRUE;
}
offset_x = (width - brush_width) / 2;
offset_y = (height - brush_height) / 2;
return_buf = temp_buf_new (width, height, 3, 0, 0, white);
return_buf = temp_buf_new (brush_width, brush_height, 4, 0, 0, transp);
mask = temp_buf_data (mask_buf);
buf = temp_buf_data (return_buf);
b = buf + (offset_y * return_buf->width + offset_x) * return_buf->bytes;
if (pixmap_buf)
{
guchar *pixmap = temp_buf_data (pixmap_buf);
@ -275,16 +266,11 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
{
for (x = 0; x < brush_width ; x++)
{
bg = (255 - *mask);
*b++ = bg + (*mask * *pixmap++) / 255;
*b++ = bg + (*mask * *pixmap++) / 255;
*b++ = bg + (*mask * *pixmap++) / 255;
mask++;
*buf++ = *pixmap++;
*buf++ = *pixmap++;
*buf++ = *pixmap++;
*buf++ = *mask++;
}
b += (return_buf->width - brush_width) * return_buf->bytes;
}
}
else
@ -293,14 +279,11 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
{
for (x = 0; x < brush_width ; x++)
{
bg = 255 - *mask++;
*b++ = bg;
*b++ = bg;
*b++ = bg;
*buf++ = 0;
*buf++ = 0;
*buf++ = 0;
*buf++ = *mask++;
}
b += (return_buf->width - brush_width) * return_buf->bytes;
}
}

View File

@ -196,19 +196,17 @@ gimp_gradient_get_new_preview (GimpViewable *viewable,
GimpGradient *gradient;
TempBuf *temp_buf;
guchar *buf;
guchar *p0, *p1;
guchar *even, *odd;
guchar *p;
guchar *row;
gint x, y;
gdouble dx, cur_x;
GimpRGB color;
gdouble c0, c1;
gradient = GIMP_GRADIENT (viewable);
dx = 1.0 / (width - 1);
cur_x = 0.0;
p0 = even = g_malloc (width * 3);
p1 = odd = g_malloc (width * 3);
p = row = g_malloc (width * 4);
/* Create lines to fill the image */
@ -216,49 +214,22 @@ gimp_gradient_get_new_preview (GimpViewable *viewable,
{
gimp_gradient_get_color_at (gradient, cur_x, &color);
if ((x / GIMP_CHECK_SIZE_SM) & 1)
{
c0 = GIMP_CHECK_LIGHT;
c1 = GIMP_CHECK_DARK;
}
else
{
c0 = GIMP_CHECK_DARK;
c1 = GIMP_CHECK_LIGHT;
}
*p0++ = (c0 + (color.r - c0) * color.a) * 255.0;
*p0++ = (c0 + (color.g - c0) * color.a) * 255.0;
*p0++ = (c0 + (color.b - c0) * color.a) * 255.0;
*p1++ = (c1 + (color.r - c1) * color.a) * 255.0;
*p1++ = (c1 + (color.g - c1) * color.a) * 255.0;
*p1++ = (c1 + (color.b - c1) * color.a) * 255.0;
*p++ = color.r * 255.0;
*p++ = color.g * 255.0;
*p++ = color.b * 255.0;
*p++ = color.a * 255.0;
cur_x += dx;
}
temp_buf = temp_buf_new (width, height,
3,
0, 0,
NULL);
temp_buf = temp_buf_new (width, height, 4, 0, 0, NULL);
buf = temp_buf_data (temp_buf);
for (y = 0; y < height; y++)
{
if ((y / GIMP_CHECK_SIZE_SM) & 1)
{
memcpy (buf + (width * y * 3), odd, width * 3);
}
else
{
memcpy (buf + (width * y * 3), even, width * 3);
}
}
memcpy (buf + (width * y * 4), row, width * 4);
g_free (even);
g_free (odd);
g_free (row);
return temp_buf;
}

View File

@ -636,9 +636,38 @@ gimp_imagefile_get_new_preview (GimpViewable *viewable,
temp_buf = gimp_imagefile_read_png_thumb (imagefile, MAX (width, height));
if (!temp_buf)
if (! temp_buf)
temp_buf = gimp_imagefile_read_xv_thumb (imagefile);
if (temp_buf)
{
gint preview_width;
gint preview_height;
gimp_viewable_calc_preview_size (viewable,
temp_buf->width,
temp_buf->height,
width,
height,
TRUE, 1.0, 1.0,
&preview_width,
&preview_height,
NULL);
if (preview_width < temp_buf->width &&
preview_height < temp_buf->height)
{
TempBuf *scaled_buf;
scaled_buf = temp_buf_scale (temp_buf,
preview_width, preview_height);
temp_buf_free (temp_buf);
return scaled_buf;
}
}
return temp_buf;
}

View File

@ -38,10 +38,6 @@ static void gimp_tool_info_init (GimpToolInfo *tool_info);
static void gimp_tool_info_finalize (GObject *object);
static TempBuf * gimp_tool_info_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
static GimpDataClass *parent_class = NULL;
@ -77,17 +73,13 @@ gimp_tool_info_get_type (void)
static void
gimp_tool_info_class_init (GimpToolInfoClass *klass)
{
GObjectClass *object_class;
GimpViewableClass *viewable_class;
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass);
object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_tool_info_finalize;
viewable_class->get_new_preview = gimp_tool_info_get_new_preview;
object_class->finalize = gimp_tool_info_finalize;
}
static void
@ -105,9 +97,6 @@ gimp_tool_info_init (GimpToolInfo *tool_info)
tool_info->help_domain = NULL;
tool_info->help_data = NULL;
tool_info->stock_id = NULL;
tool_info->stock_pixbuf = NULL;
tool_info->tool_options = NULL;
tool_info->paint_info = NULL;
}
@ -152,17 +141,6 @@ gimp_tool_info_finalize (GObject *object)
tool_info->help_data = NULL;
}
if (tool_info->stock_id)
{
g_free (tool_info->stock_id);
tool_info->stock_id = NULL;
}
if (tool_info->stock_pixbuf)
{
g_object_unref (tool_info->stock_pixbuf);
tool_info->stock_pixbuf = NULL;
}
if (tool_info->tool_options)
{
g_object_unref (tool_info->tool_options);
@ -172,72 +150,6 @@ gimp_tool_info_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static TempBuf *
temp_buf_new_from_pixbuf (GdkPixbuf *pixbuf,
gint width,
gint height)
{
TempBuf *temp_buf;
gint pixbuf_width;
gint pixbuf_height;
gint bytes;
guchar transparent[4] = { 0, 0, 0, 0 };
guchar *p_data;
guchar *t_data;
gint y;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
pixbuf_width = gdk_pixbuf_get_width (pixbuf);
pixbuf_height = gdk_pixbuf_get_height (pixbuf);
if (pixbuf_width != width || pixbuf_height != height)
{
GdkPixbuf *scaled_pixbuf;
scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
width, height,
GDK_INTERP_BILINEAR);
pixbuf = scaled_pixbuf;
}
else
{
g_object_ref (pixbuf);
}
bytes = gdk_pixbuf_get_n_channels (pixbuf);
temp_buf = temp_buf_new (width, height, bytes, 0, 0, transparent);
p_data = gdk_pixbuf_get_pixels (pixbuf);
t_data = temp_buf_data (temp_buf);
for (y = 0; y < height; y++)
{
memcpy (t_data, p_data, width * bytes);
p_data += gdk_pixbuf_get_rowstride (pixbuf);
t_data += width * bytes;
}
g_object_unref (pixbuf);
return temp_buf;
}
static TempBuf *
gimp_tool_info_get_new_preview (GimpViewable *viewable,
gint width,
gint height)
{
GimpToolInfo *tool_info;
tool_info = GIMP_TOOL_INFO (viewable);
return temp_buf_new_from_pixbuf (tool_info->stock_pixbuf, width, height);
}
GimpToolInfo *
gimp_tool_info_new (Gimp *gimp,
GType tool_type,
@ -251,11 +163,11 @@ gimp_tool_info_new (Gimp *gimp,
const gchar *help_domain,
const gchar *help_data,
const gchar *paint_core_name,
const gchar *stock_id,
GdkPixbuf *stock_pixbuf)
const gchar *stock_id)
{
GimpPaintInfo *paint_info;
GimpToolInfo *tool_info;
GimpViewable *viewable;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (identifier != NULL, NULL);
@ -264,7 +176,6 @@ gimp_tool_info_new (Gimp *gimp,
g_return_val_if_fail (menu_path != NULL, NULL);
g_return_val_if_fail (paint_core_name != NULL, NULL);
g_return_val_if_fail (stock_id != NULL, NULL);
g_return_val_if_fail (! stock_pixbuf || GDK_IS_PIXBUF (stock_pixbuf), NULL);
paint_info = (GimpPaintInfo *)
gimp_container_get_child_by_name (gimp->paint_info_list, paint_core_name);
@ -275,6 +186,8 @@ gimp_tool_info_new (Gimp *gimp,
"name", identifier,
NULL);
viewable = GIMP_VIEWABLE (tool_info);
tool_info->use_context = tool_context;
tool_info->tool_options = NULL;
tool_info->paint_info = paint_info;
@ -292,11 +205,9 @@ gimp_tool_info_new (Gimp *gimp,
tool_info->help_domain = g_strdup (help_domain);
tool_info->help_data = g_strdup (help_data);
tool_info->stock_id = g_strdup (stock_id);
tool_info->stock_pixbuf = stock_pixbuf;
if (stock_pixbuf)
g_object_ref (stock_pixbuf);
if (viewable->stock_id)
g_free (viewable->stock_id);
viewable->stock_id = g_strdup (stock_id);
return tool_info;
}

View File

@ -20,8 +20,6 @@
#define __GIMP_TOOL_INFO_H__
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gimpdata.h"
@ -37,28 +35,25 @@ typedef struct _GimpToolInfoClass GimpToolInfoClass;
struct _GimpToolInfo
{
GimpData parent_instance;
GimpData parent_instance;
Gimp *gimp;
Gimp *gimp;
GType tool_type;
GType tool_options_type;
GType tool_type;
GType tool_options_type;
gchar *blurb;
gchar *help;
gchar *blurb;
gchar *help;
gchar *menu_path;
gchar *menu_accel;
gchar *menu_path;
gchar *menu_accel;
gchar *help_domain;
gchar *help_data;
gchar *help_domain;
gchar *help_data;
gchar *stock_id;
GdkPixbuf *stock_pixbuf;
gboolean use_context;
GimpToolOptions *tool_options;
GimpPaintInfo *paint_info;
gboolean use_context;
GimpToolOptions *tool_options;
GimpPaintInfo *paint_info;
};
struct _GimpToolInfoClass
@ -81,8 +76,7 @@ GimpToolInfo * gimp_tool_info_new (Gimp *gimp,
const gchar *help_domain,
const gchar *help_data,
const gchar *paint_core_name,
const gchar *stock_id,
GdkPixbuf *stock_pixbuf);
const gchar *stock_id);
void gimp_tool_info_set_standard (Gimp *gimp,
GimpToolInfo *tool_info);

View File

@ -45,7 +45,7 @@ static void gimp_undo_finalize (GObject *object);
static gsize gimp_undo_get_memsize (GimpObject *object);
static TempBuf * gimp_undo_get_preview (GimpViewable *viewable,
static TempBuf * gimp_undo_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
@ -126,14 +126,14 @@ 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_preview = gimp_undo_get_preview;
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
@ -187,11 +187,39 @@ gimp_undo_get_memsize (GimpObject *object)
}
static TempBuf *
gimp_undo_get_preview (GimpViewable *viewable,
gint width,
gint height)
gimp_undo_get_new_preview (GimpViewable *viewable,
gint width,
gint height)
{
return GIMP_UNDO (viewable)->preview;
GimpUndo *undo;
undo = GIMP_UNDO (viewable);
if (undo->preview)
{
gint preview_width;
gint preview_height;
gimp_viewable_calc_preview_size (viewable,
undo->preview->width,
undo->preview->height,
width,
height,
TRUE, 1.0, 1.0,
&preview_width,
&preview_height,
NULL);
if (preview_width < undo->preview->width &&
preview_height < undo->preview->height)
{
return temp_buf_scale (undo->preview, preview_width, preview_height);
}
return temp_buf_copy (undo->preview, NULL);
}
return NULL;
}
static void

View File

@ -42,7 +42,9 @@ enum
static void gimp_viewable_class_init (GimpViewableClass *klass);
static void gimp_viewable_init (GimpViewable *viewable);
static gsize gimp_viewable_get_memsize (GimpObject *object);
static void gimp_viewable_finalize (GObject *object);
static gsize gimp_viewable_get_memsize (GimpObject *object);
static void gimp_viewable_real_invalidate_preview (GimpViewable *viewable);
@ -93,8 +95,10 @@ gimp_viewable_get_type (void)
static void
gimp_viewable_class_init (GimpViewableClass *klass)
{
GObjectClass *object_class;
GimpObjectClass *gimp_object_class;
object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -120,6 +124,8 @@ gimp_viewable_class_init (GimpViewableClass *klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->finalize = gimp_viewable_finalize;
gimp_object_class->get_memsize = gimp_viewable_get_memsize;
klass->name_changed_signal = "name_changed";
@ -135,6 +141,23 @@ gimp_viewable_class_init (GimpViewableClass *klass)
static void
gimp_viewable_init (GimpViewable *viewable)
{
viewable->stock_id = g_strdup ("gtk-dialog-question");
}
static void
gimp_viewable_finalize (GObject *object)
{
GimpViewable *viewable;
viewable = GIMP_VIEWABLE (object);
if (viewable->stock_id)
{
g_free (viewable->stock_id);
viewable->stock_id = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gsize

View File

@ -41,6 +41,8 @@ typedef struct _GimpViewableClass GimpViewableClass;
struct _GimpViewable
{
GimpObject parent_instance;
gchar *stock_id;
};
struct _GimpViewableClass