Commit 9ee632a6 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Started migration from GtkList to GtkTreeView:

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

	Started migration from GtkList to GtkTreeView:

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpcontainertreeview.[ch]; new GimpContainerView
	subclass using GtkListStore/GtkTreeView.

	* app/widgets/widgets-enums.h: added GIMP_VIEW_TYPE_TREE to
	thje GimpViewType enum.

	* app/widgets/gimpcontainereditor.c: added GimpContainerTreeView
	to the switch() which selects the view type.

	* app/gui/dialogs-commands.c
	* app/gui/dialogs-constructors.[ch]
	* app/gui/dialogs-menu.c
	* app/gui/dialogs.c: added tree view versions of many dialogs.

	* app/widgets/gimppreview.[ch]: removed the get_size() virtual
	function and gimp_preview_calc_size().

	* app/core/gimpviewable.[ch]: added virtual function
	get_preview_size() and gimp_viewable_calc_preview_size().

	* app/core/gimpbuffer.c
	* app/core/gimpdrawable-preview.[ch]
	* app/core/gimpdrawable.c
	* app/core/gimpgradient.c
	* app/core/gimpimage.c
	* app/core/gimppalette.c: added get_preview_size() implementations.

	* app/widgets/gimpbufferpreview.c
	* app/widgets/gimpdrawablepreview.c
	* app/widgets/gimpgradientpreview.c
	* app/widgets/gimpimagepreview.c
	* app/widgets/gimppalettepreview.c
	* app/widgets/gimpselectioneditor.c
	* app/widgets/gimpundopreview.c
	* app/display/gimpnavigationview.c: changed accordingly, removed
	get_size() implementations.

	* app/widgets/widgets-types.h: changed the first param of
	GimpItemGetNameFunc from GtkWidget to GObject.

	* app/widgets/gimpcontainerview-utils.c: accept a GimpViewable as
	object in the built-in get_name funcs.

	* app/widgets/gimpcomponentlistitem.c
	* app/widgets/gimpcontainergridview.c
	* app/widgets/gimplistitem.c
	* app/widgets/gimpmenuitem.c: changed accordingly.
parent 758635d7
2003-02-21 Michael Natterer <mitch@gimp.org>
Started migration from GtkList to GtkTreeView:
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpcontainertreeview.[ch]; new GimpContainerView
subclass using GtkListStore/GtkTreeView.
* app/widgets/widgets-enums.h: added GIMP_VIEW_TYPE_TREE to
thje GimpViewType enum.
* app/widgets/gimpcontainereditor.c: added GimpContainerTreeView
to the switch() which selects the view type.
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.[ch]
* app/gui/dialogs-menu.c
* app/gui/dialogs.c: added tree view versions of many dialogs.
* app/widgets/gimppreview.[ch]: removed the get_size() virtual
function and gimp_preview_calc_size().
* app/core/gimpviewable.[ch]: added virtual function
get_preview_size() and gimp_viewable_calc_preview_size().
* app/core/gimpbuffer.c
* app/core/gimpdrawable-preview.[ch]
* app/core/gimpdrawable.c
* app/core/gimpgradient.c
* app/core/gimpimage.c
* app/core/gimppalette.c: added get_preview_size() implementations.
* app/widgets/gimpbufferpreview.c
* app/widgets/gimpdrawablepreview.c
* app/widgets/gimpgradientpreview.c
* app/widgets/gimpimagepreview.c
* app/widgets/gimppalettepreview.c
* app/widgets/gimpselectioneditor.c
* app/widgets/gimpundopreview.c
* app/display/gimpnavigationview.c: changed accordingly, removed
get_size() implementations.
* app/widgets/widgets-types.h: changed the first param of
GimpItemGetNameFunc from GtkWidget to GObject.
* app/widgets/gimpcontainerview-utils.c: accept a GimpViewable as
object in the built-in get_name funcs.
* app/widgets/gimpcomponentlistitem.c
* app/widgets/gimpcontainergridview.c
* app/widgets/gimplistitem.c
* app/widgets/gimpmenuitem.c: changed accordingly.
2003-02-21 Sven Neumann <sven@gimp.org>
 
* app/display/gimpdisplayshell-scroll.c (gimp_display_shell_scroll):
......
......@@ -172,16 +172,13 @@ dialogs_toggle_view_cmd_callback (GtkWidget *widget,
identifier = g_strdup (entry->identifier);
if ((substring = strstr (identifier, "grid")) &&
view_type == GIMP_VIEW_TYPE_LIST)
{
memcpy (substring, "list", 4);
}
else if ((substring = strstr (identifier, "list")) &&
view_type == GIMP_VIEW_TYPE_GRID)
{
memcpy (substring, "grid", 4);
}
substring = strstr (identifier, "grid");
if (! substring)
substring = strstr (identifier, "list");
if (! substring)
substring = strstr (identifier, "grid");
if (substring)
{
......@@ -189,6 +186,13 @@ dialogs_toggle_view_cmd_callback (GtkWidget *widget,
GtkWidget *new_dockable;
gint preview_size = -1;
if (view_type == GIMP_VIEW_TYPE_LIST)
memcpy (substring, "list", 4);
else if (view_type == GIMP_VIEW_TYPE_GRID)
memcpy (substring, "grid", 4);
else if (view_type == GIMP_VIEW_TYPE_TREE)
memcpy (substring, "tree", 4);
old_view = gimp_container_view_get_by_dockable (dockable);
if (old_view)
......
......@@ -33,16 +33,22 @@
#include "gimpbuffer.h"
static void gimp_buffer_class_init (GimpBufferClass *klass);
static void gimp_buffer_init (GimpBuffer *buffer);
static void gimp_buffer_class_init (GimpBufferClass *klass);
static void gimp_buffer_init (GimpBuffer *buffer);
static void gimp_buffer_finalize (GObject *object);
static void gimp_buffer_finalize (GObject *object);
static gsize gimp_buffer_get_memsize (GimpObject *object);
static gsize gimp_buffer_get_memsize (GimpObject *object);
static TempBuf * gimp_buffer_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
static void gimp_buffer_get_preview_size (GimpViewable *viewable,
gint size,
gboolean is_popup,
gboolean dot_for_dot,
gint *width,
gint *height);
static TempBuf * gimp_buffer_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
static GimpViewableClass *parent_class = NULL;
......@@ -89,11 +95,12 @@ gimp_buffer_class_init (GimpBufferClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_buffer_finalize;
object_class->finalize = gimp_buffer_finalize;
gimp_object_class->get_memsize = gimp_buffer_get_memsize;
gimp_object_class->get_memsize = gimp_buffer_get_memsize;
viewable_class->get_new_preview = gimp_buffer_get_new_preview;
viewable_class->get_preview_size = gimp_buffer_get_preview_size;
viewable_class->get_new_preview = gimp_buffer_get_new_preview;
}
static void
......@@ -132,6 +139,29 @@ gimp_buffer_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static void
gimp_buffer_get_preview_size (GimpViewable *viewable,
gint size,
gboolean is_popup,
gboolean dot_for_dot,
gint *width,
gint *height)
{
GimpBuffer *buffer;
buffer = GIMP_BUFFER (viewable);
gimp_viewable_calc_preview_size (viewable,
gimp_buffer_get_width (buffer),
gimp_buffer_get_height (buffer),
size,
size,
dot_for_dot, 1.0, 1.0,
width,
height,
NULL);
}
static TempBuf *
gimp_buffer_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -54,6 +54,50 @@ static void gimp_drawable_preview_scale (GimpImageBaseType type,
/* public functions */
void
gimp_drawable_get_preview_size (GimpViewable *viewable,
gint size,
gboolean is_popup,
gboolean dot_for_dot,
gint *width,
gint *height)
{
GimpDrawable *drawable;
GimpImage *gimage;
drawable = GIMP_DRAWABLE (viewable);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
if (gimage && ! is_popup)
{
gimp_viewable_calc_preview_size (viewable,
gimage->width,
gimage->height,
size,
size,
dot_for_dot,
gimage->xresolution,
gimage->yresolution,
width,
height,
NULL);
}
else
{
gimp_viewable_calc_preview_size (viewable,
drawable->width,
drawable->height,
size,
size,
dot_for_dot,
1.0,
1.0,
width,
height,
NULL);
}
}
TempBuf *
gimp_drawable_get_preview (GimpViewable *viewable,
gint width,
......
......@@ -21,12 +21,18 @@
/*
* virtual function of GimpDrawable -- dont't call directly
* virtual functions of GimpDrawable -- dont't call directly
*/
TempBuf * gimp_drawable_get_preview (GimpViewable *viewable,
gint width,
gint height);
void gimp_drawable_get_preview_size (GimpViewable *viewable,
gint size,
gboolean is_popup,
gboolean dot_for_dot,
gint *width,
gint *height);
TempBuf * gimp_drawable_get_preview (GimpViewable *viewable,
gint width,
gint height);
#endif /* __GIMP_DRAWABLE__PREVIEW_H__ */
......@@ -140,6 +140,7 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
gimp_object_class->get_memsize = gimp_drawable_get_memsize;
viewable_class->invalidate_preview = gimp_drawable_invalidate_preview;
viewable_class->get_preview_size = gimp_drawable_get_preview_size;
viewable_class->get_preview = gimp_drawable_get_preview;
item_class->duplicate = gimp_drawable_duplicate;
......
......@@ -42,22 +42,28 @@
#define EPSILON 1e-10
static void gimp_gradient_class_init (GimpGradientClass *klass);
static void gimp_gradient_init (GimpGradient *gradient);
static void gimp_gradient_finalize (GObject *object);
static gsize gimp_gradient_get_memsize (GimpObject *object);
static TempBuf * gimp_gradient_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
static void gimp_gradient_dirty (GimpData *data);
static gboolean gimp_gradient_save (GimpData *data,
GError **error);
static gchar * gimp_gradient_get_extension (GimpData *data);
static GimpData * gimp_gradient_duplicate (GimpData *data,
gboolean stingy_memory_use);
static void gimp_gradient_class_init (GimpGradientClass *klass);
static void gimp_gradient_init (GimpGradient *gradient);
static void gimp_gradient_finalize (GObject *object);
static gsize gimp_gradient_get_memsize (GimpObject *object);
static void gimp_gradient_get_preview_size (GimpViewable *viewable,
gint size,
gboolean popup,
gboolean dot_for_dot,
gint *width,
gint *height);
static TempBuf * gimp_gradient_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
static void gimp_gradient_dirty (GimpData *data);
static gboolean gimp_gradient_save (GimpData *data,
GError **error);
static gchar * gimp_gradient_get_extension (GimpData *data);
static GimpData * gimp_gradient_duplicate (GimpData *data,
gboolean stingy_memory_use);
static gdouble gimp_gradient_calc_linear_factor (gdouble middle,
gdouble pos);
......@@ -117,16 +123,17 @@ gimp_gradient_class_init (GimpGradientClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_gradient_finalize;
object_class->finalize = gimp_gradient_finalize;
gimp_object_class->get_memsize = gimp_gradient_get_memsize;
gimp_object_class->get_memsize = gimp_gradient_get_memsize;
viewable_class->get_new_preview = gimp_gradient_get_new_preview;
viewable_class->get_preview_size = gimp_gradient_get_preview_size;
viewable_class->get_new_preview = gimp_gradient_get_new_preview;
data_class->dirty = gimp_gradient_dirty;
data_class->save = gimp_gradient_save;
data_class->get_extension = gimp_gradient_get_extension;
data_class->duplicate = gimp_gradient_duplicate;
data_class->dirty = gimp_gradient_dirty;
data_class->save = gimp_gradient_save;
data_class->get_extension = gimp_gradient_get_extension;
data_class->duplicate = gimp_gradient_duplicate;
}
static void
......@@ -169,6 +176,18 @@ gimp_gradient_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static void
gimp_gradient_get_preview_size (GimpViewable *viewable,
gint size,
gboolean popup,
gboolean dot_for_dot,
gint *width,
gint *height)
{
*width = size;
*height = size / 2;
}
static TempBuf *
gimp_gradient_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -109,6 +109,12 @@ static gsize gimp_image_get_memsize (GimpObject *object);
static void gimp_image_invalidate_preview (GimpViewable *viewable);
static void gimp_image_size_changed (GimpViewable *viewable);
static void gimp_image_get_preview_size (GimpViewable *viewable,
gint size,
gboolean is_popup,
gboolean dot_for_dot,
gint *width,
gint *height);
static TempBuf *gimp_image_get_preview (GimpViewable *gimage,
gint width,
gint height);
......@@ -393,6 +399,7 @@ gimp_image_class_init (GimpImageClass *klass)
viewable_class->invalidate_preview = gimp_image_invalidate_preview;
viewable_class->size_changed = gimp_image_size_changed;
viewable_class->get_preview_size = gimp_image_get_preview_size;
viewable_class->get_preview = gimp_image_get_preview;
viewable_class->get_new_preview = gimp_image_get_new_preview;
......@@ -677,6 +684,31 @@ gimp_image_size_changed (GimpViewable *viewable)
NULL);
}
static void
gimp_image_get_preview_size (GimpViewable *viewable,
gint size,
gboolean is_popup,
gboolean dot_for_dot,
gint *width,
gint *height)
{
GimpImage *gimage;
gimage = GIMP_IMAGE (viewable);
gimp_viewable_calc_preview_size (viewable,
gimage->width,
gimage->height,
size,
size,
dot_for_dot,
gimage->xresolution,
gimage->yresolution,
width,
height,
NULL);
}
static TempBuf *
gimp_image_get_preview (GimpViewable *viewable,
gint width,
......
......@@ -48,6 +48,12 @@ static void gimp_palette_finalize (GObject *object);
static gsize gimp_palette_get_memsize (GimpObject *object);
static void gimp_palette_get_preview_size (GimpViewable *viewable,
gint size,
gboolean popup,
gboolean dot_for_dot,
gint *width,
gint *height);
static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
......@@ -107,15 +113,16 @@ gimp_palette_class_init (GimpPaletteClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_palette_finalize;
object_class->finalize = gimp_palette_finalize;
gimp_object_class->get_memsize = gimp_palette_get_memsize;
gimp_object_class->get_memsize = gimp_palette_get_memsize;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save;
data_class->get_extension = gimp_palette_get_extension;
data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save;
data_class->get_extension = gimp_palette_get_extension;
}
static void
......@@ -169,6 +176,18 @@ gimp_palette_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static void
gimp_palette_get_preview_size (GimpViewable *viewable,
gint size,
gboolean popup,
gboolean dot_for_dot,
gint *width,
gint *height)
{
*width = size;
*height = size / 2;
}
static TempBuf *
gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -48,6 +48,12 @@ static void gimp_palette_finalize (GObject *object);
static gsize gimp_palette_get_memsize (GimpObject *object);
static void gimp_palette_get_preview_size (GimpViewable *viewable,
gint size,
gboolean popup,
gboolean dot_for_dot,
gint *width,
gint *height);
static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
......@@ -107,15 +113,16 @@ gimp_palette_class_init (GimpPaletteClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_palette_finalize;
object_class->finalize = gimp_palette_finalize;
gimp_object_class->get_memsize = gimp_palette_get_memsize;
gimp_object_class->get_memsize = gimp_palette_get_memsize;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save;
data_class->get_extension = gimp_palette_get_extension;
data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save;
data_class->get_extension = gimp_palette_get_extension;
}
static void
......@@ -169,6 +176,18 @@ gimp_palette_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static void
gimp_palette_get_preview_size (GimpViewable *viewable,
gint size,
gboolean popup,
gboolean dot_for_dot,
gint *width,
gint *height)
{
*width = size;
*height = size / 2;
}
static TempBuf *
gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -48,6 +48,12 @@ static void gimp_palette_finalize (GObject *object);
static gsize gimp_palette_get_memsize (GimpObject *object);
static void gimp_palette_get_preview_size (GimpViewable *viewable,
gint size,
gboolean popup,
gboolean dot_for_dot,
gint *width,
gint *height);
static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
......@@ -107,15 +113,16 @@ gimp_palette_class_init (GimpPaletteClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_palette_finalize;
object_class->finalize = gimp_palette_finalize;
gimp_object_class->get_memsize = gimp_palette_get_memsize;
gimp_object_class->get_memsize = gimp_palette_get_memsize;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save;
data_class->get_extension = gimp_palette_get_extension;
data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save;
data_class->get_extension = gimp_palette_get_extension;
}
static void
......@@ -169,6 +176,18 @@ gimp_palette_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static void
gimp_palette_get_preview_size (GimpViewable *viewable,
gint size,
gboolean popup,
gboolean dot_for_dot,
gint *width,
gint *height)
{
*width = size;
*height = size / 2;
}
static TempBuf *
gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -46,6 +46,13 @@ static gsize gimp_viewable_get_memsize (GimpObject *object);
static void gimp_viewable_real_invalidate_preview (GimpViewable *viewable);
static void gimp_viewable_real_get_preview_size (GimpViewable *viewable,
gint size,
gboolean popup,
gboolean dot_for_dot,
gint *width,
gint *height);
static guint viewable_signals[LAST_SIGNAL] = { 0 };
......@@ -120,6 +127,7 @@ gimp_viewable_class_init (GimpViewableClass *klass)
klass->invalidate_preview = gimp_viewable_real_invalidate_preview;
klass->size_changed = NULL;
klass->get_preview_size = gimp_viewable_real_get_preview_size;
klass->get_preview = NULL;
klass->get_new_preview = NULL;
}
......@@ -165,6 +173,27 @@ gimp_viewable_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static void
gimp_viewable_real_invalidate_preview (GimpViewable *viewable)
{
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
g_object_set_qdata (G_OBJECT (viewable), quark_preview_temp_buf, NULL);
g_object_set_qdata (G_OBJECT (viewable), quark_preview_pixbuf, NULL);
}
static void
gimp_viewable_real_get_preview_size (GimpViewable *viewable,
gint size,
gboolean popup,
gboolean dot_for_dot,
gint *width,
gint *height)
{
*width = size;
*height = size;
}
void
gimp_viewable_invalidate_preview (GimpViewable *viewable)
{
......@@ -181,13 +210,65 @@ gimp_viewable_size_changed (GimpViewable *viewable)
g_signal_emit (viewable, viewable_signals[SIZE_CHANGED], 0);
}
static void
gimp_viewable_real_invalidate_preview (GimpViewable *viewable)
void
gimp_viewable_calc_preview_size (GimpViewable *viewable,
gint aspect_width,
gint aspect_height,
gint width,
gint height,
gboolean dot_for_dot,