app/Makefile.am A bad hack on top of another hack: The GtkHWrapBox

2001-02-06  Michael Natterer  <mitch@gimp.org>

	* app/Makefile.am
	* app/gimpconstrainedhwrapbox.[ch]: A bad hack on top of another
	hack: The GtkHWrapBox "size_request" method _always_ wants a
	maximal requisition height, which it of course gets from a
	container like the scrolled window, yielding in wrong vscrollbar
	calculation.

	* app/gimpbrush.c: create a nice preview with scale and pipe
	indicators.

	* app/gimpcontainergridview.[ch]: use the GimpConstrainderHWrapBox.

	* app/commands.c
	* app/gimpcontainerlistview.c
	* app/gimppreview.c: cleanup, fixed a crash in the preview idle
	rendering function.
This commit is contained in:
Michael Natterer 2001-02-06 15:57:07 +00:00 committed by Michael Natterer
parent 29a3407889
commit e65e4e3253
24 changed files with 1119 additions and 87 deletions

View file

@ -1,3 +1,22 @@
2001-02-06 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
* app/gimpconstrainedhwrapbox.[ch]: A bad hack on top of another
hack: The GtkHWrapBox "size_request" method _always_ wants a
maximal requisition height, which it of course gets from a
container like the scrolled window, yielding in wrong vscrollbar
calculation.
* app/gimpbrush.c: create a nice preview with scale and pipe
indicators.
* app/gimpcontainergridview.[ch]: use the GimpConstrainderHWrapBox.
* app/commands.c
* app/gimpcontainerlistview.c
* app/gimppreview.c: cleanup, fixed a crash in the preview idle
rendering function.
2001-02-06 Sven Neumann <sven@gimp.org>
* data/brushes/hsparks.gih

View file

@ -282,22 +282,24 @@ gimp_SOURCES = \
tile_swap.c \
tile_swap.h \
\
gimpcontainergridview.h \
gimpcontainergridview.c \
gimpcontainerlistview.h \
gimpcontainerlistview.c \
gimpcontainerview.h \
gimpcontainerview.c \
gimppreview.h \
gimppreview.c \
gtkwrapbox.c \
gtkwrapbox.h \
gtkhwrapbox.c \
gtkhwrapbox.h \
gtkvwrapbox.c \
gtkvwrapbox.h \
histogramwidget.c \
histogramwidget.h \
gimpcontainergridview.h \
gimpcontainergridview.c \
gimpcontainerlistview.h \
gimpcontainerlistview.c \
gimpcontainerview.h \
gimpcontainerview.c \
gimppreview.h \
gimppreview.c \
gtkwrapbox.c \
gtkwrapbox.h \
gtkhwrapbox.c \
gtkhwrapbox.h \
gtkvwrapbox.c \
gtkvwrapbox.h \
gimpconstrainedhwrapbox.c \
gimpconstrainedhwrapbox.h \
histogramwidget.c \
histogramwidget.h \
\
marching_ants.h \
pixmaps.h \

View file

@ -75,11 +75,14 @@
#include "undo.h"
#include "undo_history.h"
/* for the example dialogs */
#include "brushes.h"
#include "patterns.h"
#include "gimpcontainerlistview.h"
#include "gimpcontainergridview.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */
@ -1412,7 +1415,7 @@ void
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (FALSE, "Brush Grid", global_brush_list, 24, 24);
container_view_new (FALSE, "Brush Grid", global_brush_list, 32, 32);
}
/***** Help *****/

View file

@ -75,11 +75,14 @@
#include "undo.h"
#include "undo_history.h"
/* for the example dialogs */
#include "brushes.h"
#include "patterns.h"
#include "gimpcontainerlistview.h"
#include "gimpcontainergridview.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */
@ -1412,7 +1415,7 @@ void
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (FALSE, "Brush Grid", global_brush_list, 24, 24);
container_view_new (FALSE, "Brush Grid", global_brush_list, 32, 32);
}
/***** Help *****/

View file

@ -51,6 +51,7 @@
/* this needs to go away */
#include "tools/paint_core.h"
#include "gimpbrushpipe.h"
#include "libgimp/gimpintl.h"
@ -65,7 +66,7 @@ enum
static void gimp_brush_class_init (GimpBrushClass *klass);
static void gimp_brush_init (GimpBrush *brush);
static void gimp_brush_destroy (GtkObject *object);
static TempBuf * gimp_brush_preview (GimpViewable *viewable,
static TempBuf * gimp_brush_preview_new (GimpViewable *viewable,
gint width,
gint height);
@ -126,7 +127,7 @@ gimp_brush_class_init (GimpBrushClass *klass)
object_class->destroy = gimp_brush_destroy;
viewable_class->preview = gimp_brush_preview;
viewable_class->preview_new = gimp_brush_preview_new;
klass->dirty = NULL;
@ -166,18 +167,206 @@ gimp_brush_destroy (GtkObject *object)
}
static TempBuf *
gimp_brush_preview (GimpViewable *viewable,
gint width,
gint height)
gimp_brush_preview_new (GimpViewable *viewable,
gint width,
gint height)
{
GimpBrush *brush;
GimpBrush *brush;
gboolean is_popup = FALSE;
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 *mask;
guchar *buf;
guchar *b;
guchar bg;
gint x, y;
brush = GIMP_BRUSH (viewable);
if (brush->pixmap)
return brush->pixmap;
mask_buf = gimp_brush_get_mask (brush);
pixmap_buf = gimp_brush_get_pixmap (brush);
return brush->mask;
brush_width = mask_buf->width;
brush_height = mask_buf->height;
if (brush_width > width || brush_height > height)
{
gdouble ratio_x = (gdouble) brush_width / width;
gdouble ratio_y = (gdouble) brush_height / height;
brush_width = (gdouble) brush_width / MAX (ratio_x, ratio_y) + 0.5;
brush_height = (gdouble) brush_height / MAX (ratio_x, ratio_y) + 0.5;
mask_buf = brush_scale_mask (mask_buf, brush_width, brush_height);
if (pixmap_buf)
{
/* TODO: the scale function should scale the pixmap and the
* mask in one run
*/
pixmap_buf =
brush_scale_pixmap (pixmap_buf, brush_width, brush_height);
}
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);
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);
for (y = 0; y < brush_height; y++)
{
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++;
}
b += (return_buf->width - brush_width) * return_buf->bytes;
}
}
else
{
for (y = 0; y < brush_height; y++)
{
for (x = 0; x < brush_width ; x++)
{
bg = 255 - *mask++;
*b++ = bg;
*b++ = bg;
*b++ = bg;
}
b += (return_buf->width - brush_width) * return_buf->bytes;
}
}
#define indicator_width 7
#define indicator_height 7
#define WHT { 255, 255, 255 }
#define BLK { 0, 0, 0 }
#define RED { 255, 127, 127 }
if (scale)
{
static const guchar scale_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, BLK, BLK, BLK, BLK, BLK, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }
};
static const guchar scale_pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, RED },
{ WHT, WHT, WHT, BLK, WHT, RED, RED },
{ WHT, BLK, BLK, BLK, BLK, BLK, RED },
{ WHT, WHT, WHT, BLK, RED, RED, RED },
{ WHT, WHT, RED, BLK, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
offset_x = width - indicator_width;
offset_y = height - indicator_height;
b = buf + (offset_y * return_buf->width + offset_x) * return_buf->bytes;
for (y = 0; y < indicator_height; y++)
{
for (x = 0; x < indicator_height; x++)
{
if (GIMP_IS_BRUSH_PIPE (brush))
{
*b++ = scale_pipe_indicator_bits[y][x][0];
*b++ = scale_pipe_indicator_bits[y][x][1];
*b++ = scale_pipe_indicator_bits[y][x][2];
}
else
{
*b++ = scale_indicator_bits[y][x][0];
*b++ = scale_indicator_bits[y][x][1];
*b++ = scale_indicator_bits[y][x][2];
}
}
b += (return_buf->width - indicator_width) * return_buf->bytes;
}
temp_buf_free (mask_buf);
if (pixmap_buf)
temp_buf_free (pixmap_buf);
}
else if (!is_popup && GIMP_IS_BRUSH_PIPE (brush))
{
static const guchar pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, RED },
{ WHT, WHT, WHT, WHT, WHT, RED, RED },
{ WHT, WHT, WHT, WHT, RED, RED, RED },
{ WHT, WHT, WHT, RED, RED, RED, RED },
{ WHT, WHT, RED, RED, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
offset_x = width - indicator_width;
offset_y = height - indicator_height;
b = buf + (offset_y * return_buf->width + offset_x) * return_buf->bytes;
for (y = 0; y < indicator_height; y++)
{
for (x = 0; x < indicator_height; x++)
{
*b++ = pipe_indicator_bits[y][x][0];
*b++ = pipe_indicator_bits[y][x][1];
*b++ = pipe_indicator_bits[y][x][2];
}
b += (return_buf->width - indicator_width) * return_buf->bytes;
}
}
#undef indicator_width
#undef indicator_height
#undef WHT
#undef BLK
#undef RED
return return_buf;
}
GimpBrush *

View file

@ -51,6 +51,7 @@
/* this needs to go away */
#include "tools/paint_core.h"
#include "gimpbrushpipe.h"
#include "libgimp/gimpintl.h"
@ -65,7 +66,7 @@ enum
static void gimp_brush_class_init (GimpBrushClass *klass);
static void gimp_brush_init (GimpBrush *brush);
static void gimp_brush_destroy (GtkObject *object);
static TempBuf * gimp_brush_preview (GimpViewable *viewable,
static TempBuf * gimp_brush_preview_new (GimpViewable *viewable,
gint width,
gint height);
@ -126,7 +127,7 @@ gimp_brush_class_init (GimpBrushClass *klass)
object_class->destroy = gimp_brush_destroy;
viewable_class->preview = gimp_brush_preview;
viewable_class->preview_new = gimp_brush_preview_new;
klass->dirty = NULL;
@ -166,18 +167,206 @@ gimp_brush_destroy (GtkObject *object)
}
static TempBuf *
gimp_brush_preview (GimpViewable *viewable,
gint width,
gint height)
gimp_brush_preview_new (GimpViewable *viewable,
gint width,
gint height)
{
GimpBrush *brush;
GimpBrush *brush;
gboolean is_popup = FALSE;
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 *mask;
guchar *buf;
guchar *b;
guchar bg;
gint x, y;
brush = GIMP_BRUSH (viewable);
if (brush->pixmap)
return brush->pixmap;
mask_buf = gimp_brush_get_mask (brush);
pixmap_buf = gimp_brush_get_pixmap (brush);
return brush->mask;
brush_width = mask_buf->width;
brush_height = mask_buf->height;
if (brush_width > width || brush_height > height)
{
gdouble ratio_x = (gdouble) brush_width / width;
gdouble ratio_y = (gdouble) brush_height / height;
brush_width = (gdouble) brush_width / MAX (ratio_x, ratio_y) + 0.5;
brush_height = (gdouble) brush_height / MAX (ratio_x, ratio_y) + 0.5;
mask_buf = brush_scale_mask (mask_buf, brush_width, brush_height);
if (pixmap_buf)
{
/* TODO: the scale function should scale the pixmap and the
* mask in one run
*/
pixmap_buf =
brush_scale_pixmap (pixmap_buf, brush_width, brush_height);
}
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);
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);
for (y = 0; y < brush_height; y++)
{
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++;
}
b += (return_buf->width - brush_width) * return_buf->bytes;
}
}
else
{
for (y = 0; y < brush_height; y++)
{
for (x = 0; x < brush_width ; x++)
{
bg = 255 - *mask++;
*b++ = bg;
*b++ = bg;
*b++ = bg;
}
b += (return_buf->width - brush_width) * return_buf->bytes;
}
}
#define indicator_width 7
#define indicator_height 7
#define WHT { 255, 255, 255 }
#define BLK { 0, 0, 0 }
#define RED { 255, 127, 127 }
if (scale)
{
static const guchar scale_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, BLK, BLK, BLK, BLK, BLK, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }
};
static const guchar scale_pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, RED },
{ WHT, WHT, WHT, BLK, WHT, RED, RED },
{ WHT, BLK, BLK, BLK, BLK, BLK, RED },
{ WHT, WHT, WHT, BLK, RED, RED, RED },
{ WHT, WHT, RED, BLK, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
offset_x = width - indicator_width;
offset_y = height - indicator_height;
b = buf + (offset_y * return_buf->width + offset_x) * return_buf->bytes;
for (y = 0; y < indicator_height; y++)
{
for (x = 0; x < indicator_height; x++)
{
if (GIMP_IS_BRUSH_PIPE (brush))
{
*b++ = scale_pipe_indicator_bits[y][x][0];
*b++ = scale_pipe_indicator_bits[y][x][1];
*b++ = scale_pipe_indicator_bits[y][x][2];
}
else
{
*b++ = scale_indicator_bits[y][x][0];
*b++ = scale_indicator_bits[y][x][1];
*b++ = scale_indicator_bits[y][x][2];
}
}
b += (return_buf->width - indicator_width) * return_buf->bytes;
}
temp_buf_free (mask_buf);
if (pixmap_buf)
temp_buf_free (pixmap_buf);
}
else if (!is_popup && GIMP_IS_BRUSH_PIPE (brush))
{
static const guchar pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, RED },
{ WHT, WHT, WHT, WHT, WHT, RED, RED },
{ WHT, WHT, WHT, WHT, RED, RED, RED },
{ WHT, WHT, WHT, RED, RED, RED, RED },
{ WHT, WHT, RED, RED, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
offset_x = width - indicator_width;
offset_y = height - indicator_height;
b = buf + (offset_y * return_buf->width + offset_x) * return_buf->bytes;
for (y = 0; y < indicator_height; y++)
{
for (x = 0; x < indicator_height; x++)
{
*b++ = pipe_indicator_bits[y][x][0];
*b++ = pipe_indicator_bits[y][x][1];
*b++ = pipe_indicator_bits[y][x][2];
}
b += (return_buf->width - indicator_width) * return_buf->bytes;
}
}
#undef indicator_width
#undef indicator_height
#undef WHT
#undef BLK
#undef RED
return return_buf;
}
GimpBrush *

View file

@ -51,6 +51,7 @@
/* this needs to go away */
#include "tools/paint_core.h"
#include "gimpbrushpipe.h"
#include "libgimp/gimpintl.h"
@ -65,7 +66,7 @@ enum
static void gimp_brush_class_init (GimpBrushClass *klass);
static void gimp_brush_init (GimpBrush *brush);
static void gimp_brush_destroy (GtkObject *object);
static TempBuf * gimp_brush_preview (GimpViewable *viewable,
static TempBuf * gimp_brush_preview_new (GimpViewable *viewable,
gint width,
gint height);
@ -126,7 +127,7 @@ gimp_brush_class_init (GimpBrushClass *klass)
object_class->destroy = gimp_brush_destroy;
viewable_class->preview = gimp_brush_preview;
viewable_class->preview_new = gimp_brush_preview_new;
klass->dirty = NULL;
@ -166,18 +167,206 @@ gimp_brush_destroy (GtkObject *object)
}
static TempBuf *
gimp_brush_preview (GimpViewable *viewable,
gint width,
gint height)
gimp_brush_preview_new (GimpViewable *viewable,
gint width,
gint height)
{
GimpBrush *brush;
GimpBrush *brush;
gboolean is_popup = FALSE;
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 *mask;
guchar *buf;
guchar *b;
guchar bg;
gint x, y;
brush = GIMP_BRUSH (viewable);
if (brush->pixmap)
return brush->pixmap;
mask_buf = gimp_brush_get_mask (brush);
pixmap_buf = gimp_brush_get_pixmap (brush);
return brush->mask;
brush_width = mask_buf->width;
brush_height = mask_buf->height;
if (brush_width > width || brush_height > height)
{
gdouble ratio_x = (gdouble) brush_width / width;
gdouble ratio_y = (gdouble) brush_height / height;
brush_width = (gdouble) brush_width / MAX (ratio_x, ratio_y) + 0.5;
brush_height = (gdouble) brush_height / MAX (ratio_x, ratio_y) + 0.5;
mask_buf = brush_scale_mask (mask_buf, brush_width, brush_height);
if (pixmap_buf)
{
/* TODO: the scale function should scale the pixmap and the
* mask in one run
*/
pixmap_buf =
brush_scale_pixmap (pixmap_buf, brush_width, brush_height);
}
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);
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);
for (y = 0; y < brush_height; y++)
{
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++;
}
b += (return_buf->width - brush_width) * return_buf->bytes;
}
}
else
{
for (y = 0; y < brush_height; y++)
{
for (x = 0; x < brush_width ; x++)
{
bg = 255 - *mask++;
*b++ = bg;
*b++ = bg;
*b++ = bg;
}
b += (return_buf->width - brush_width) * return_buf->bytes;
}
}
#define indicator_width 7
#define indicator_height 7
#define WHT { 255, 255, 255 }
#define BLK { 0, 0, 0 }
#define RED { 255, 127, 127 }
if (scale)
{
static const guchar scale_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, BLK, BLK, BLK, BLK, BLK, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }
};
static const guchar scale_pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, RED },
{ WHT, WHT, WHT, BLK, WHT, RED, RED },
{ WHT, BLK, BLK, BLK, BLK, BLK, RED },
{ WHT, WHT, WHT, BLK, RED, RED, RED },
{ WHT, WHT, RED, BLK, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
offset_x = width - indicator_width;
offset_y = height - indicator_height;
b = buf + (offset_y * return_buf->width + offset_x) * return_buf->bytes;
for (y = 0; y < indicator_height; y++)
{
for (x = 0; x < indicator_height; x++)
{
if (GIMP_IS_BRUSH_PIPE (brush))
{
*b++ = scale_pipe_indicator_bits[y][x][0];
*b++ = scale_pipe_indicator_bits[y][x][1];
*b++ = scale_pipe_indicator_bits[y][x][2];
}
else
{
*b++ = scale_indicator_bits[y][x][0];
*b++ = scale_indicator_bits[y][x][1];
*b++ = scale_indicator_bits[y][x][2];
}
}
b += (return_buf->width - indicator_width) * return_buf->bytes;
}
temp_buf_free (mask_buf);
if (pixmap_buf)
temp_buf_free (pixmap_buf);
}
else if (!is_popup && GIMP_IS_BRUSH_PIPE (brush))
{
static const guchar pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, RED },
{ WHT, WHT, WHT, WHT, WHT, RED, RED },
{ WHT, WHT, WHT, WHT, RED, RED, RED },
{ WHT, WHT, WHT, RED, RED, RED, RED },
{ WHT, WHT, RED, RED, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
offset_x = width - indicator_width;
offset_y = height - indicator_height;
b = buf + (offset_y * return_buf->width + offset_x) * return_buf->bytes;
for (y = 0; y < indicator_height; y++)
{
for (x = 0; x < indicator_height; x++)
{
*b++ = pipe_indicator_bits[y][x][0];
*b++ = pipe_indicator_bits[y][x][1];
*b++ = pipe_indicator_bits[y][x][2];
}
b += (return_buf->width - indicator_width) * return_buf->bytes;
}
}
#undef indicator_width
#undef indicator_height
#undef WHT
#undef BLK
#undef RED
return return_buf;
}
GimpBrush *

View file

@ -0,0 +1,125 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* GtkHWrapBox: Horizontal wrapping box widget
* Copyright (C) 1999 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gimpconstrainedhwrapbox.h"
static void gimp_constrained_hwrap_box_class_init (GimpConstrainedHWrapBoxClass *klass);
static void gimp_constrained_hwrap_box_init (GimpConstrainedHWrapBox *hwbox);
static void gimp_constrained_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static GtkHWrapBoxClass *parent_class = NULL;
GtkType
gimp_constrained_hwrap_box_get_type (void)
{
static GtkType constrained_hwrap_box_type = 0;
if (! constrained_hwrap_box_type)
{
static const GtkTypeInfo constrained_hwrap_box_info =
{
"GimpConstrainedHWrapBox",
sizeof (GimpConstrainedHWrapBox),
sizeof (GimpConstrainedHWrapBoxClass),
(GtkClassInitFunc) gimp_constrained_hwrap_box_class_init,
(GtkObjectInitFunc) gimp_constrained_hwrap_box_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
constrained_hwrap_box_type = gtk_type_unique (GTK_TYPE_HWRAP_BOX,
&constrained_hwrap_box_info);
}
return constrained_hwrap_box_type;
}
static void
gimp_constrained_hwrap_box_class_init (GimpConstrainedHWrapBoxClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = GTK_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
parent_class = gtk_type_class (GTK_TYPE_HWRAP_BOX);
widget_class->size_request = gimp_constrained_hwrap_box_size_request;
}
static void
gimp_constrained_hwrap_box_init (GimpConstrainedHWrapBox *hwbox)
{
}
GtkWidget*
gimp_constrained_hwrap_box_new (gboolean homogeneous)
{
GimpConstrainedHWrapBox *hwbox;
hwbox = GIMP_CONSTRAINED_HWRAP_BOX (gtk_widget_new (GIMP_TYPE_CONSTRAINED_HWRAP_BOX, NULL));
GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE;
return GTK_WIDGET (hwbox);
}
static void
gimp_constrained_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
g_return_if_fail (requisition != NULL);
if (GTK_WIDGET_CLASS (parent_class)->size_request)
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
if (widget->parent &&
widget->allocation.width >= requisition->width &&
wbox->children &&
wbox->children->widget)
{
gint child_width;
gint child_height;
child_width = wbox->children->widget->requisition.width;
child_height = wbox->children->widget->requisition.height;
requisition->width =
((child_width + wbox->hspacing) *
MAX (1, (gint) ((widget->parent->allocation.width + wbox->hspacing) /
(child_width + wbox->hspacing))));
requisition->height =
(child_height + wbox->vspacing) *
(1 + (wbox->n_children /
MAX (1, (gint) ((widget->parent->allocation.width + wbox->hspacing) /
(child_width + wbox->hspacing)))));
}
}

View file

@ -0,0 +1,65 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* GtkHWrapBox: Horizontal wrapping box widget
* Copyright (C) 1999 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CONSTRAINED_HWRAP_BOX_H__
#define __GIMP_CONSTRAINED_HWRAP_BOX_H__
#include "gtkhwrapbox.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GIMP_TYPE_CONSTRAINED_HWRAP_BOX (gimp_constrained_hwrap_box_get_type ())
#define GIMP_CONSTRAINED_HWRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_CONSTRAINED_HWRAP_BOX, GimpConstrainedHWrapBox))
#define GIMP_CONSTRAINED_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONSTRAINED_HWRAP_BOX, GimpConstrainedHWrapBoxClass))
#define GIMP_IS_CONSTRAINED_HWRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_CONSTRAINED_HWRAP_BOX))
#define GIMP_IS_CONSTRAINED_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONSTRAINED_HWRAP_BOX))
#define GIMP_CONSTRAINED_HWRAP_BOX_GET_CLASS(obj) (GIMP_CONSTRAINED_HWRAP_BOX_CLASS (((GtkObject *) (obj))->klass))
typedef struct _GimpConstrainedHWrapBox GimpConstrainedHWrapBox;
typedef struct _GimpConstrainedHWrapBoxClass GimpConstrainedHWrapBoxClass;
struct _GimpConstrainedHWrapBox
{
GtkHWrapBox parent_instance;
};
struct _GimpConstrainedHWrapBoxClass
{
GtkHWrapBoxClass parent_class;
};
GtkType gimp_constrained_hwrap_box_get_type (void);
GtkWidget * gimp_constrained_hwrap_box_new (gboolean homogeneous);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_CONSTRAINED_HWRAP_BOX_H__ */

View file

@ -29,7 +29,7 @@
#include "gimpcontainer.h"
#include "gimpcontainergridview.h"
#include "gimppreview.h"
#include "gtkhwrapbox.h"
#include "gimpconstrainedhwrapbox.h"
static void gimp_container_grid_view_class_init (GimpContainerGridViewClass *klass);
@ -107,27 +107,29 @@ gimp_container_grid_view_init (GimpContainerGridView *grid_view)
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_NEVER,
GTK_POLICY_ALWAYS);
gtk_box_pack_start (GTK_BOX (grid_view), scrolled_win, TRUE, TRUE, 0);
grid_view->wrapbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_hspacing (GTK_WRAP_BOX (grid_view->wrapbox), 2);
gtk_wrap_box_set_vspacing (GTK_WRAP_BOX (grid_view->wrapbox), 2);
grid_view->wrap_box = gimp_constrained_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (grid_view->wrap_box), 256);
gtk_wrap_box_set_hspacing (GTK_WRAP_BOX (grid_view->wrap_box), 2);
gtk_wrap_box_set_vspacing (GTK_WRAP_BOX (grid_view->wrap_box), 2);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
grid_view->wrapbox);
grid_view->wrap_box);
gtk_widget_set_style
(grid_view->wrapbox->parent,
(grid_view->wrap_box->parent,
GIMP_CONTAINER_GRID_VIEW_CLASS (GTK_OBJECT (grid_view)->klass)->white_style);
gtk_container_set_focus_vadjustment
(GTK_CONTAINER (grid_view->wrapbox),
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_win)));
(GTK_CONTAINER (grid_view->wrap_box),
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_win)));
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (scrolled_win)->vscrollbar,
GTK_CAN_FOCUS);
gtk_widget_show (grid_view->wrapbox);
gtk_widget_show (grid_view->wrap_box);
gtk_widget_show (scrolled_win);
}
@ -180,10 +182,11 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
preview = gimp_preview_new (viewable,
view->preview_width,
view->preview_height);
gtk_container_add (GTK_CONTAINER (grid_view->wrapbox), preview);
gtk_wrap_box_pack (GTK_WRAP_BOX (grid_view->wrap_box), preview,
FALSE, FALSE, FALSE, FALSE);
if (index != -1)
gtk_wrap_box_reorder_child (GTK_WRAP_BOX (grid_view->wrapbox),
gtk_wrap_box_reorder_child (GTK_WRAP_BOX (grid_view->wrap_box),
preview, index);
gtk_widget_show (preview);
@ -204,7 +207,7 @@ gimp_container_grid_view_remove_item (GimpContainerView *view,
if (preview)
{
gtk_container_remove (GTK_CONTAINER (grid_view->wrapbox), preview);
gtk_container_remove (GTK_CONTAINER (grid_view->wrap_box), preview);
}
}
@ -215,9 +218,9 @@ gimp_container_grid_view_clear_items (GimpContainerView *view)
grid_view = GIMP_CONTAINER_GRID_VIEW (view);
while (GTK_WRAP_BOX (grid_view->wrapbox)->children)
gtk_container_remove (GTK_CONTAINER (grid_view->wrapbox),
GTK_WRAP_BOX (grid_view->wrapbox)->children->widget);
while (GTK_WRAP_BOX (grid_view->wrap_box)->children)
gtk_container_remove (GTK_CONTAINER (grid_view->wrap_box),
GTK_WRAP_BOX (grid_view->wrap_box)->children->widget);
}
static void
@ -228,7 +231,7 @@ gimp_container_grid_view_set_preview_size (GimpContainerView *view)
grid_view = GIMP_CONTAINER_GRID_VIEW (view);
for (child = GTK_WRAP_BOX (grid_view->wrapbox)->children;
for (child = GTK_WRAP_BOX (grid_view->wrap_box)->children;
child;
child = child->next)
{
@ -237,5 +240,5 @@ gimp_container_grid_view_set_preview_size (GimpContainerView *view)
view->preview_height);
}
gtk_widget_queue_resize (grid_view->wrapbox);
gtk_widget_queue_resize (grid_view->wrap_box);
}

View file

@ -36,14 +36,14 @@ struct _GimpContainerGridView
{
GimpContainerView parent_instance;
GtkWidget *wrapbox;
GtkWidget *wrap_box;
};
struct _GimpContainerGridViewClass
{
GimpContainerViewClass parent_class;
GtkStyle *white_style;
GtkStyle *white_style;
};

View file

@ -110,11 +110,14 @@ gimp_container_list_view_init (GimpContainerListView *list_view)
list_view->gtk_list = gtk_list_new ();
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
list_view->gtk_list);
gtk_list_set_selection_mode (GTK_LIST (list_view->gtk_list),
GTK_SELECTION_BROWSE);
gtk_container_set_focus_vadjustment
(GTK_CONTAINER (list_view->gtk_list),
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_win)));
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (scrolled_win)->vscrollbar,
GTK_CAN_FOCUS);

View file

@ -144,6 +144,11 @@ gimp_preview_new (GimpViewable *viewable,
GTK_SIGNAL_FUNC (gimp_preview_paint),
GTK_OBJECT (preview));
gtk_signal_connect_while_alive (GTK_OBJECT (viewable), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&preview->viewable,
GTK_OBJECT (preview));
gtk_preview_size (GTK_PREVIEW (preview), width, height);
return GTK_WIDGET (preview);
@ -194,6 +199,9 @@ gimp_preview_idle_paint (GimpPreview *preview)
preview->idle_id = 0;
if (! preview->viewable)
return FALSE;
temp_buf = gimp_viewable_preview_new (preview->viewable,
GTK_WIDGET (preview)->allocation.width,
GTK_WIDGET (preview)->allocation.height);

View file

@ -75,11 +75,14 @@
#include "undo.h"
#include "undo_history.h"
/* for the example dialogs */
#include "brushes.h"
#include "patterns.h"
#include "gimpcontainerlistview.h"
#include "gimpcontainergridview.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */
@ -1412,7 +1415,7 @@ void
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (FALSE, "Brush Grid", global_brush_list, 24, 24);
container_view_new (FALSE, "Brush Grid", global_brush_list, 32, 32);
}
/***** Help *****/

View file

@ -75,11 +75,14 @@
#include "undo.h"
#include "undo_history.h"
/* for the example dialogs */
#include "brushes.h"
#include "patterns.h"
#include "gimpcontainerlistview.h"
#include "gimpcontainergridview.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */
@ -1412,7 +1415,7 @@ void
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (FALSE, "Brush Grid", global_brush_list, 24, 24);
container_view_new (FALSE, "Brush Grid", global_brush_list, 32, 32);
}
/***** Help *****/

View file

@ -0,0 +1,125 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* GtkHWrapBox: Horizontal wrapping box widget
* Copyright (C) 1999 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gimpconstrainedhwrapbox.h"
static void gimp_constrained_hwrap_box_class_init (GimpConstrainedHWrapBoxClass *klass);
static void gimp_constrained_hwrap_box_init (GimpConstrainedHWrapBox *hwbox);
static void gimp_constrained_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static GtkHWrapBoxClass *parent_class = NULL;
GtkType
gimp_constrained_hwrap_box_get_type (void)
{
static GtkType constrained_hwrap_box_type = 0;
if (! constrained_hwrap_box_type)
{
static const GtkTypeInfo constrained_hwrap_box_info =
{
"GimpConstrainedHWrapBox",
sizeof (GimpConstrainedHWrapBox),
sizeof (GimpConstrainedHWrapBoxClass),
(GtkClassInitFunc) gimp_constrained_hwrap_box_class_init,
(GtkObjectInitFunc) gimp_constrained_hwrap_box_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
constrained_hwrap_box_type = gtk_type_unique (GTK_TYPE_HWRAP_BOX,
&constrained_hwrap_box_info);
}
return constrained_hwrap_box_type;
}
static void
gimp_constrained_hwrap_box_class_init (GimpConstrainedHWrapBoxClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = GTK_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
parent_class = gtk_type_class (GTK_TYPE_HWRAP_BOX);
widget_class->size_request = gimp_constrained_hwrap_box_size_request;
}
static void
gimp_constrained_hwrap_box_init (GimpConstrainedHWrapBox *hwbox)
{
}
GtkWidget*
gimp_constrained_hwrap_box_new (gboolean homogeneous)
{
GimpConstrainedHWrapBox *hwbox;
hwbox = GIMP_CONSTRAINED_HWRAP_BOX (gtk_widget_new (GIMP_TYPE_CONSTRAINED_HWRAP_BOX, NULL));
GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE;
return GTK_WIDGET (hwbox);
}
static void
gimp_constrained_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
g_return_if_fail (requisition != NULL);
if (GTK_WIDGET_CLASS (parent_class)->size_request)
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
if (widget->parent &&
widget->allocation.width >= requisition->width &&
wbox->children &&
wbox->children->widget)
{
gint child_width;
gint child_height;
child_width = wbox->children->widget->requisition.width;
child_height = wbox->children->widget->requisition.height;
requisition->width =
((child_width + wbox->hspacing) *
MAX (1, (gint) ((widget->parent->allocation.width + wbox->hspacing) /
(child_width + wbox->hspacing))));
requisition->height =
(child_height + wbox->vspacing) *
(1 + (wbox->n_children /
MAX (1, (gint) ((widget->parent->allocation.width + wbox->hspacing) /
(child_width + wbox->hspacing)))));
}
}

View file

@ -0,0 +1,65 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* GtkHWrapBox: Horizontal wrapping box widget
* Copyright (C) 1999 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CONSTRAINED_HWRAP_BOX_H__
#define __GIMP_CONSTRAINED_HWRAP_BOX_H__
#include "gtkhwrapbox.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GIMP_TYPE_CONSTRAINED_HWRAP_BOX (gimp_constrained_hwrap_box_get_type ())
#define GIMP_CONSTRAINED_HWRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_CONSTRAINED_HWRAP_BOX, GimpConstrainedHWrapBox))
#define GIMP_CONSTRAINED_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONSTRAINED_HWRAP_BOX, GimpConstrainedHWrapBoxClass))
#define GIMP_IS_CONSTRAINED_HWRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_CONSTRAINED_HWRAP_BOX))
#define GIMP_IS_CONSTRAINED_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONSTRAINED_HWRAP_BOX))
#define GIMP_CONSTRAINED_HWRAP_BOX_GET_CLASS(obj) (GIMP_CONSTRAINED_HWRAP_BOX_CLASS (((GtkObject *) (obj))->klass))
typedef struct _GimpConstrainedHWrapBox GimpConstrainedHWrapBox;
typedef struct _GimpConstrainedHWrapBoxClass GimpConstrainedHWrapBoxClass;
struct _GimpConstrainedHWrapBox
{
GtkHWrapBox parent_instance;
};
struct _GimpConstrainedHWrapBoxClass
{
GtkHWrapBoxClass parent_class;
};
GtkType gimp_constrained_hwrap_box_get_type (void);
GtkWidget * gimp_constrained_hwrap_box_new (gboolean homogeneous);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_CONSTRAINED_HWRAP_BOX_H__ */

View file

@ -29,7 +29,7 @@
#include "gimpcontainer.h"
#include "gimpcontainergridview.h"
#include "gimppreview.h"
#include "gtkhwrapbox.h"
#include "gimpconstrainedhwrapbox.h"
static void gimp_container_grid_view_class_init (GimpContainerGridViewClass *klass);
@ -107,27 +107,29 @@ gimp_container_grid_view_init (GimpContainerGridView *grid_view)
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_NEVER,
GTK_POLICY_ALWAYS);
gtk_box_pack_start (GTK_BOX (grid_view), scrolled_win, TRUE, TRUE, 0);
grid_view->wrapbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_hspacing (GTK_WRAP_BOX (grid_view->wrapbox), 2);
gtk_wrap_box_set_vspacing (GTK_WRAP_BOX (grid_view->wrapbox), 2);
grid_view->wrap_box = gimp_constrained_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (grid_view->wrap_box), 256);
gtk_wrap_box_set_hspacing (GTK_WRAP_BOX (grid_view->wrap_box), 2);
gtk_wrap_box_set_vspacing (GTK_WRAP_BOX (grid_view->wrap_box), 2);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
grid_view->wrapbox);
grid_view->wrap_box);
gtk_widget_set_style
(grid_view->wrapbox->parent,
(grid_view->wrap_box->parent,
GIMP_CONTAINER_GRID_VIEW_CLASS (GTK_OBJECT (grid_view)->klass)->white_style);
gtk_container_set_focus_vadjustment
(GTK_CONTAINER (grid_view->wrapbox),
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_win)));
(GTK_CONTAINER (grid_view->wrap_box),
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_win)));
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (scrolled_win)->vscrollbar,
GTK_CAN_FOCUS);
gtk_widget_show (grid_view->wrapbox);
gtk_widget_show (grid_view->wrap_box);
gtk_widget_show (scrolled_win);
}
@ -180,10 +182,11 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
preview = gimp_preview_new (viewable,
view->preview_width,
view->preview_height);
gtk_container_add (GTK_CONTAINER (grid_view->wrapbox), preview);
gtk_wrap_box_pack (GTK_WRAP_BOX (grid_view->wrap_box), preview,
FALSE, FALSE, FALSE, FALSE);
if (index != -1)
gtk_wrap_box_reorder_child (GTK_WRAP_BOX (grid_view->wrapbox),
gtk_wrap_box_reorder_child (GTK_WRAP_BOX (grid_view->wrap_box),
preview, index);
gtk_widget_show (preview);
@ -204,7 +207,7 @@ gimp_container_grid_view_remove_item (GimpContainerView *view,
if (preview)
{
gtk_container_remove (GTK_CONTAINER (grid_view->wrapbox), preview);
gtk_container_remove (GTK_CONTAINER (grid_view->wrap_box), preview);
}
}
@ -215,9 +218,9 @@ gimp_container_grid_view_clear_items (GimpContainerView *view)
grid_view = GIMP_CONTAINER_GRID_VIEW (view);
while (GTK_WRAP_BOX (grid_view->wrapbox)->children)
gtk_container_remove (GTK_CONTAINER (grid_view->wrapbox),
GTK_WRAP_BOX (grid_view->wrapbox)->children->widget);
while (GTK_WRAP_BOX (grid_view->wrap_box)->children)
gtk_container_remove (GTK_CONTAINER (grid_view->wrap_box),
GTK_WRAP_BOX (grid_view->wrap_box)->children->widget);
}
static void
@ -228,7 +231,7 @@ gimp_container_grid_view_set_preview_size (GimpContainerView *view)
grid_view = GIMP_CONTAINER_GRID_VIEW (view);
for (child = GTK_WRAP_BOX (grid_view->wrapbox)->children;
for (child = GTK_WRAP_BOX (grid_view->wrap_box)->children;
child;
child = child->next)
{
@ -237,5 +240,5 @@ gimp_container_grid_view_set_preview_size (GimpContainerView *view)
view->preview_height);
}
gtk_widget_queue_resize (grid_view->wrapbox);
gtk_widget_queue_resize (grid_view->wrap_box);
}

View file

@ -36,14 +36,14 @@ struct _GimpContainerGridView
{
GimpContainerView parent_instance;
GtkWidget *wrapbox;
GtkWidget *wrap_box;
};
struct _GimpContainerGridViewClass
{
GimpContainerViewClass parent_class;
GtkStyle *white_style;
GtkStyle *white_style;
};

View file

@ -110,11 +110,14 @@ gimp_container_list_view_init (GimpContainerListView *list_view)
list_view->gtk_list = gtk_list_new ();
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
list_view->gtk_list);
gtk_list_set_selection_mode (GTK_LIST (list_view->gtk_list),
GTK_SELECTION_BROWSE);
gtk_container_set_focus_vadjustment
(GTK_CONTAINER (list_view->gtk_list),
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_win)));
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (scrolled_win)->vscrollbar,
GTK_CAN_FOCUS);

View file

@ -144,6 +144,11 @@ gimp_preview_new (GimpViewable *viewable,
GTK_SIGNAL_FUNC (gimp_preview_paint),
GTK_OBJECT (preview));
gtk_signal_connect_while_alive (GTK_OBJECT (viewable), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&preview->viewable,
GTK_OBJECT (preview));
gtk_preview_size (GTK_PREVIEW (preview), width, height);
return GTK_WIDGET (preview);
@ -194,6 +199,9 @@ gimp_preview_idle_paint (GimpPreview *preview)
preview->idle_id = 0;
if (! preview->viewable)
return FALSE;
temp_buf = gimp_viewable_preview_new (preview->viewable,
GTK_WIDGET (preview)->allocation.width,
GTK_WIDGET (preview)->allocation.height);

View file

@ -144,6 +144,11 @@ gimp_preview_new (GimpViewable *viewable,
GTK_SIGNAL_FUNC (gimp_preview_paint),
GTK_OBJECT (preview));
gtk_signal_connect_while_alive (GTK_OBJECT (viewable), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&preview->viewable,
GTK_OBJECT (preview));
gtk_preview_size (GTK_PREVIEW (preview), width, height);
return GTK_WIDGET (preview);
@ -194,6 +199,9 @@ gimp_preview_idle_paint (GimpPreview *preview)
preview->idle_id = 0;
if (! preview->viewable)
return FALSE;
temp_buf = gimp_viewable_preview_new (preview->viewable,
GTK_WIDGET (preview)->allocation.width,
GTK_WIDGET (preview)->allocation.height);

View file

@ -144,6 +144,11 @@ gimp_preview_new (GimpViewable *viewable,
GTK_SIGNAL_FUNC (gimp_preview_paint),
GTK_OBJECT (preview));
gtk_signal_connect_while_alive (GTK_OBJECT (viewable), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&preview->viewable,
GTK_OBJECT (preview));
gtk_preview_size (GTK_PREVIEW (preview), width, height);
return GTK_WIDGET (preview);
@ -194,6 +199,9 @@ gimp_preview_idle_paint (GimpPreview *preview)
preview->idle_id = 0;
if (! preview->viewable)
return FALSE;
temp_buf = gimp_viewable_preview_new (preview->viewable,
GTK_WIDGET (preview)->allocation.width,
GTK_WIDGET (preview)->allocation.height);

View file

@ -144,6 +144,11 @@ gimp_preview_new (GimpViewable *viewable,
GTK_SIGNAL_FUNC (gimp_preview_paint),
GTK_OBJECT (preview));
gtk_signal_connect_while_alive (GTK_OBJECT (viewable), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&preview->viewable,
GTK_OBJECT (preview));
gtk_preview_size (GTK_PREVIEW (preview), width, height);
return GTK_WIDGET (preview);
@ -194,6 +199,9 @@ gimp_preview_idle_paint (GimpPreview *preview)
preview->idle_id = 0;
if (! preview->viewable)
return FALSE;
temp_buf = gimp_viewable_preview_new (preview->viewable,
GTK_WIDGET (preview)->allocation.width,
GTK_WIDGET (preview)->allocation.height);