removed idle rendering and render the preview on "expose" if needed.

2002-11-04  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimppreview.[ch]: removed idle rendering and render
	the preview on "expose" if needed. Renamed gimp_preview_render()
	to gimp_preview_update(). Cleanup.

	* app/widgets/gimpimagefilepreview.c
	* app/widgets/gimpselectioneditor.[ch]
	* app/widgets/gimptoolinfopreview.c: changed accordingly.
This commit is contained in:
Michael Natterer 2002-11-04 12:15:29 +00:00 committed by Michael Natterer
parent 7836563081
commit f901058b4b
13 changed files with 157 additions and 220 deletions

View File

@ -1,3 +1,13 @@
2002-11-04 Michael Natterer <mitch@gimp.org>
* app/widgets/gimppreview.[ch]: removed idle rendering and render
the preview on "expose" if needed. Renamed gimp_preview_render()
to gimp_preview_update(). Cleanup.
* app/widgets/gimpimagefilepreview.c
* app/widgets/gimpselectioneditor.[ch]
* app/widgets/gimptoolinfopreview.c: changed accordingly.
2002-11-03 Garry R. Osgood <grosgood@rcn.com>
* configure.in defined GIMP_ENABLE_MMX. Current value 0; to disable

View File

@ -109,12 +109,19 @@ gimp_imagefile_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
GimpImagefilePreview *preview = GIMP_IMAGEFILE_PREVIEW (widget);
GimpPreview *gimp_preview;
GdkRectangle draw_rect;
GdkRectangle rect;
if (!GTK_WIDGET_DRAWABLE (widget))
return FALSE;
preview = GIMP_IMAGEFILE_PREVIEW (widget);
gimp_preview = GIMP_PREVIEW (widget);
if (gimp_preview->viewable && gimp_preview->needs_render)
gimp_imagefile_preview_render (gimp_preview);
if (!preview->no_preview_pixbuf)
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
@ -250,7 +257,7 @@ gimp_imagefile_preview_render (GimpPreview *preview)
file_preview->no_preview_pixbuf = pixbuf;
}
gtk_widget_queue_draw (GTK_WIDGET (preview));
preview->needs_render = FALSE;
}
}

View File

@ -64,7 +64,6 @@ enum
DOUBLE_CLICKED,
EXTENDED_CLICKED,
CONTEXT,
RENDER,
LAST_SIGNAL
};
@ -86,6 +85,7 @@ static gboolean gimp_preview_enter_notify_event (GtkWidget *widget,
static gboolean gimp_preview_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event);
static void gimp_preview_render (GimpPreview *preview);
static void gimp_preview_real_render (GimpPreview *preview);
static void gimp_preview_get_size (GimpPreview *preview,
gint size,
@ -108,8 +108,6 @@ static gboolean gimp_preview_popup_timeout (GimpPreview *preview)
static void gimp_preview_size_changed (GimpPreview *preview,
GimpViewable *viewable);
static void gimp_preview_paint (GimpPreview *preview);
static gboolean gimp_preview_idle_paint (GimpPreview *preview);
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
gpointer data);
@ -237,7 +235,7 @@ gimp_preview_init (GimpPreview *preview)
preview->size = -1;
preview->in_button = FALSE;
preview->idle_id = 0;
preview->needs_render = TRUE;
preview->popup_id = 0;
preview->popup_x = 0;
preview->popup_y = 0;
@ -252,12 +250,6 @@ gimp_preview_destroy (GtkObject *object)
preview = GIMP_PREVIEW (object);
if (preview->idle_id)
{
g_source_remove (preview->idle_id);
preview->idle_id = 0;
}
gimp_preview_popup_hide (preview);
if (preview->viewable)
@ -294,10 +286,10 @@ gimp_preview_size_allocate (GtkWidget *widget,
allocation->width = width;
allocation->height = height;
preview->needs_render = TRUE;
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
gimp_preview_paint (GIMP_PREVIEW (widget));
}
static gboolean
@ -311,7 +303,10 @@ gimp_preview_expose_event (GtkWidget *widget,
preview = GIMP_PREVIEW (widget);
if (preview->idle_id || ! preview->buffer || ! GTK_WIDGET_DRAWABLE (widget))
if (preview->needs_render)
gimp_preview_render (preview);
if (! preview->buffer || ! GTK_WIDGET_DRAWABLE (widget))
return FALSE;
buf_rect.width = preview->width + 2 * preview->border_width;
@ -621,7 +616,7 @@ gimp_preview_set_viewable (GimpPreview *preview,
(gpointer *) &preview->viewable);
g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable),
G_CALLBACK (gimp_preview_paint),
G_CALLBACK (gimp_preview_update),
preview);
g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable),
@ -649,7 +644,7 @@ gimp_preview_set_viewable (GimpPreview *preview,
g_signal_connect_swapped (G_OBJECT (preview->viewable),
"invalidate_preview",
G_CALLBACK (gimp_preview_paint),
G_CALLBACK (gimp_preview_update),
preview);
g_signal_connect_swapped (G_OBJECT (preview->viewable),
@ -664,7 +659,8 @@ gimp_preview_set_viewable (GimpPreview *preview,
preview->border_width);
}
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
@ -742,7 +738,8 @@ gimp_preview_set_dot_for_dot (GimpPreview *preview,
preview->border_width);
}
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
@ -757,21 +754,32 @@ gimp_preview_set_border_color (GimpPreview *preview,
{
preview->border_color = *color;
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
void
gimp_preview_render (GimpPreview *preview)
gimp_preview_update (GimpPreview *preview)
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
GIMP_PREVIEW_GET_CLASS (preview)->render (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
/* private functions */
static void
gimp_preview_render (GimpPreview *preview)
{
if (! preview->viewable)
return;
GIMP_PREVIEW_GET_CLASS (preview)->render (preview);
}
static void
gimp_preview_real_render (GimpPreview *preview)
{
@ -953,33 +961,11 @@ gimp_preview_size_changed (GimpPreview *preview,
preview->size,
preview->border_width);
}
}
static void
gimp_preview_paint (GimpPreview *preview)
{
if (preview->idle_id)
else
{
g_source_remove (preview->idle_id);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
preview->idle_id =
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) gimp_preview_idle_paint, preview,
NULL);
}
static gboolean
gimp_preview_idle_paint (GimpPreview *preview)
{
preview->idle_id = 0;
if (! preview->viewable)
return FALSE;
gimp_preview_render (preview);
return FALSE;
}
static GimpViewable *
@ -1231,5 +1217,5 @@ gimp_preview_render_and_flush (GimpPreview *preview,
(width + 2 * border) * PREVIEW_BYTES);
}
gtk_widget_queue_draw (GTK_WIDGET (preview));
preview->needs_render = FALSE;
}

View File

@ -66,7 +66,7 @@ struct _GimpPreview
gint size;
gboolean in_button;
guint press_state;
guint idle_id;
gboolean needs_render;
guint popup_id;
gint popup_x;
gint popup_y;
@ -130,7 +130,7 @@ void gimp_preview_set_dot_for_dot (GimpPreview *preview,
void gimp_preview_set_border_color (GimpPreview *preview,
const GimpRGB *border_color);
void gimp_preview_render (GimpPreview *preview);
void gimp_preview_update (GimpPreview *preview);
/* protected */

View File

@ -64,7 +64,6 @@ enum
DOUBLE_CLICKED,
EXTENDED_CLICKED,
CONTEXT,
RENDER,
LAST_SIGNAL
};
@ -86,6 +85,7 @@ static gboolean gimp_preview_enter_notify_event (GtkWidget *widget,
static gboolean gimp_preview_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event);
static void gimp_preview_render (GimpPreview *preview);
static void gimp_preview_real_render (GimpPreview *preview);
static void gimp_preview_get_size (GimpPreview *preview,
gint size,
@ -108,8 +108,6 @@ static gboolean gimp_preview_popup_timeout (GimpPreview *preview)
static void gimp_preview_size_changed (GimpPreview *preview,
GimpViewable *viewable);
static void gimp_preview_paint (GimpPreview *preview);
static gboolean gimp_preview_idle_paint (GimpPreview *preview);
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
gpointer data);
@ -237,7 +235,7 @@ gimp_preview_init (GimpPreview *preview)
preview->size = -1;
preview->in_button = FALSE;
preview->idle_id = 0;
preview->needs_render = TRUE;
preview->popup_id = 0;
preview->popup_x = 0;
preview->popup_y = 0;
@ -252,12 +250,6 @@ gimp_preview_destroy (GtkObject *object)
preview = GIMP_PREVIEW (object);
if (preview->idle_id)
{
g_source_remove (preview->idle_id);
preview->idle_id = 0;
}
gimp_preview_popup_hide (preview);
if (preview->viewable)
@ -294,10 +286,10 @@ gimp_preview_size_allocate (GtkWidget *widget,
allocation->width = width;
allocation->height = height;
preview->needs_render = TRUE;
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
gimp_preview_paint (GIMP_PREVIEW (widget));
}
static gboolean
@ -311,7 +303,10 @@ gimp_preview_expose_event (GtkWidget *widget,
preview = GIMP_PREVIEW (widget);
if (preview->idle_id || ! preview->buffer || ! GTK_WIDGET_DRAWABLE (widget))
if (preview->needs_render)
gimp_preview_render (preview);
if (! preview->buffer || ! GTK_WIDGET_DRAWABLE (widget))
return FALSE;
buf_rect.width = preview->width + 2 * preview->border_width;
@ -621,7 +616,7 @@ gimp_preview_set_viewable (GimpPreview *preview,
(gpointer *) &preview->viewable);
g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable),
G_CALLBACK (gimp_preview_paint),
G_CALLBACK (gimp_preview_update),
preview);
g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable),
@ -649,7 +644,7 @@ gimp_preview_set_viewable (GimpPreview *preview,
g_signal_connect_swapped (G_OBJECT (preview->viewable),
"invalidate_preview",
G_CALLBACK (gimp_preview_paint),
G_CALLBACK (gimp_preview_update),
preview);
g_signal_connect_swapped (G_OBJECT (preview->viewable),
@ -664,7 +659,8 @@ gimp_preview_set_viewable (GimpPreview *preview,
preview->border_width);
}
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
@ -742,7 +738,8 @@ gimp_preview_set_dot_for_dot (GimpPreview *preview,
preview->border_width);
}
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
@ -757,21 +754,32 @@ gimp_preview_set_border_color (GimpPreview *preview,
{
preview->border_color = *color;
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
void
gimp_preview_render (GimpPreview *preview)
gimp_preview_update (GimpPreview *preview)
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
GIMP_PREVIEW_GET_CLASS (preview)->render (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
/* private functions */
static void
gimp_preview_render (GimpPreview *preview)
{
if (! preview->viewable)
return;
GIMP_PREVIEW_GET_CLASS (preview)->render (preview);
}
static void
gimp_preview_real_render (GimpPreview *preview)
{
@ -953,33 +961,11 @@ gimp_preview_size_changed (GimpPreview *preview,
preview->size,
preview->border_width);
}
}
static void
gimp_preview_paint (GimpPreview *preview)
{
if (preview->idle_id)
else
{
g_source_remove (preview->idle_id);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
preview->idle_id =
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) gimp_preview_idle_paint, preview,
NULL);
}
static gboolean
gimp_preview_idle_paint (GimpPreview *preview)
{
preview->idle_id = 0;
if (! preview->viewable)
return FALSE;
gimp_preview_render (preview);
return FALSE;
}
static GimpViewable *
@ -1231,5 +1217,5 @@ gimp_preview_render_and_flush (GimpPreview *preview,
(width + 2 * border) * PREVIEW_BYTES);
}
gtk_widget_queue_draw (GTK_WIDGET (preview));
preview->needs_render = FALSE;
}

View File

@ -66,7 +66,7 @@ struct _GimpPreview
gint size;
gboolean in_button;
guint press_state;
guint idle_id;
gboolean needs_render;
guint popup_id;
gint popup_x;
gint popup_y;
@ -130,7 +130,7 @@ void gimp_preview_set_dot_for_dot (GimpPreview *preview,
void gimp_preview_set_border_color (GimpPreview *preview,
const GimpRGB *border_color);
void gimp_preview_render (GimpPreview *preview);
void gimp_preview_update (GimpPreview *preview);
/* protected */

View File

@ -85,7 +85,6 @@ static void gimp_selection_editor_drop_color (GtkWidget *widget,
static void gimp_selection_editor_mask_changed (GimpImage *gimage,
GimpSelectionEditor *editor);
static gboolean gimp_selection_editor_idle_render (GimpSelectionEditor *editor);
static GimpEditorClass *parent_class = NULL;
@ -137,8 +136,7 @@ gimp_selection_editor_init (GimpSelectionEditor *selection_editor)
GtkWidget *frame;
GtkWidget *abox;
selection_editor->gimage = NULL;
selection_editor->idle_render_id = 0;
selection_editor->gimage = NULL;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
@ -250,12 +248,6 @@ gimp_selection_editor_set_image (GimpSelectionEditor *editor,
if (gimage == editor->gimage)
return;
if (editor->idle_render_id)
{
g_source_remove (editor->idle_render_id);
editor->idle_render_id = 0;
}
if (editor->gimage)
{
g_signal_handlers_disconnect_by_func (G_OBJECT (editor->gimage),
@ -511,19 +503,5 @@ static void
gimp_selection_editor_mask_changed (GimpImage *gimage,
GimpSelectionEditor *editor)
{
if (editor->idle_render_id)
g_source_remove (editor->idle_render_id);
editor->idle_render_id =
g_idle_add ((GSourceFunc) gimp_selection_editor_idle_render, editor);
}
static gboolean
gimp_selection_editor_idle_render (GimpSelectionEditor *editor)
{
editor->idle_render_id = 0;
gimp_preview_render (GIMP_PREVIEW (editor->preview));
return FALSE;
gimp_preview_update (GIMP_PREVIEW (editor->preview));
}

View File

@ -47,8 +47,6 @@ struct _GimpSelectionEditor
GtkWidget *all_button;
GtkWidget *none_button;
GtkWidget *save_button;
guint idle_render_id;
};
struct _GimpSelectionEditorClass

View File

@ -105,7 +105,7 @@ static void
gimp_tool_info_preview_state_changed (GtkWidget *widget,
GtkStateType previous_state)
{
gimp_preview_render (GIMP_PREVIEW (widget));
gimp_preview_update (GIMP_PREVIEW (widget));
}
static void

View File

@ -64,7 +64,6 @@ enum
DOUBLE_CLICKED,
EXTENDED_CLICKED,
CONTEXT,
RENDER,
LAST_SIGNAL
};
@ -86,6 +85,7 @@ static gboolean gimp_preview_enter_notify_event (GtkWidget *widget,
static gboolean gimp_preview_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event);
static void gimp_preview_render (GimpPreview *preview);
static void gimp_preview_real_render (GimpPreview *preview);
static void gimp_preview_get_size (GimpPreview *preview,
gint size,
@ -108,8 +108,6 @@ static gboolean gimp_preview_popup_timeout (GimpPreview *preview)
static void gimp_preview_size_changed (GimpPreview *preview,
GimpViewable *viewable);
static void gimp_preview_paint (GimpPreview *preview);
static gboolean gimp_preview_idle_paint (GimpPreview *preview);
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
gpointer data);
@ -237,7 +235,7 @@ gimp_preview_init (GimpPreview *preview)
preview->size = -1;
preview->in_button = FALSE;
preview->idle_id = 0;
preview->needs_render = TRUE;
preview->popup_id = 0;
preview->popup_x = 0;
preview->popup_y = 0;
@ -252,12 +250,6 @@ gimp_preview_destroy (GtkObject *object)
preview = GIMP_PREVIEW (object);
if (preview->idle_id)
{
g_source_remove (preview->idle_id);
preview->idle_id = 0;
}
gimp_preview_popup_hide (preview);
if (preview->viewable)
@ -294,10 +286,10 @@ gimp_preview_size_allocate (GtkWidget *widget,
allocation->width = width;
allocation->height = height;
preview->needs_render = TRUE;
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
gimp_preview_paint (GIMP_PREVIEW (widget));
}
static gboolean
@ -311,7 +303,10 @@ gimp_preview_expose_event (GtkWidget *widget,
preview = GIMP_PREVIEW (widget);
if (preview->idle_id || ! preview->buffer || ! GTK_WIDGET_DRAWABLE (widget))
if (preview->needs_render)
gimp_preview_render (preview);
if (! preview->buffer || ! GTK_WIDGET_DRAWABLE (widget))
return FALSE;
buf_rect.width = preview->width + 2 * preview->border_width;
@ -621,7 +616,7 @@ gimp_preview_set_viewable (GimpPreview *preview,
(gpointer *) &preview->viewable);
g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable),
G_CALLBACK (gimp_preview_paint),
G_CALLBACK (gimp_preview_update),
preview);
g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable),
@ -649,7 +644,7 @@ gimp_preview_set_viewable (GimpPreview *preview,
g_signal_connect_swapped (G_OBJECT (preview->viewable),
"invalidate_preview",
G_CALLBACK (gimp_preview_paint),
G_CALLBACK (gimp_preview_update),
preview);
g_signal_connect_swapped (G_OBJECT (preview->viewable),
@ -664,7 +659,8 @@ gimp_preview_set_viewable (GimpPreview *preview,
preview->border_width);
}
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
@ -742,7 +738,8 @@ gimp_preview_set_dot_for_dot (GimpPreview *preview,
preview->border_width);
}
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
@ -757,21 +754,32 @@ gimp_preview_set_border_color (GimpPreview *preview,
{
preview->border_color = *color;
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
void
gimp_preview_render (GimpPreview *preview)
gimp_preview_update (GimpPreview *preview)
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
GIMP_PREVIEW_GET_CLASS (preview)->render (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
/* private functions */
static void
gimp_preview_render (GimpPreview *preview)
{
if (! preview->viewable)
return;
GIMP_PREVIEW_GET_CLASS (preview)->render (preview);
}
static void
gimp_preview_real_render (GimpPreview *preview)
{
@ -953,33 +961,11 @@ gimp_preview_size_changed (GimpPreview *preview,
preview->size,
preview->border_width);
}
}
static void
gimp_preview_paint (GimpPreview *preview)
{
if (preview->idle_id)
else
{
g_source_remove (preview->idle_id);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
preview->idle_id =
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) gimp_preview_idle_paint, preview,
NULL);
}
static gboolean
gimp_preview_idle_paint (GimpPreview *preview)
{
preview->idle_id = 0;
if (! preview->viewable)
return FALSE;
gimp_preview_render (preview);
return FALSE;
}
static GimpViewable *
@ -1231,5 +1217,5 @@ gimp_preview_render_and_flush (GimpPreview *preview,
(width + 2 * border) * PREVIEW_BYTES);
}
gtk_widget_queue_draw (GTK_WIDGET (preview));
preview->needs_render = FALSE;
}

View File

@ -66,7 +66,7 @@ struct _GimpPreview
gint size;
gboolean in_button;
guint press_state;
guint idle_id;
gboolean needs_render;
guint popup_id;
gint popup_x;
gint popup_y;
@ -130,7 +130,7 @@ void gimp_preview_set_dot_for_dot (GimpPreview *preview,
void gimp_preview_set_border_color (GimpPreview *preview,
const GimpRGB *border_color);
void gimp_preview_render (GimpPreview *preview);
void gimp_preview_update (GimpPreview *preview);
/* protected */

View File

@ -64,7 +64,6 @@ enum
DOUBLE_CLICKED,
EXTENDED_CLICKED,
CONTEXT,
RENDER,
LAST_SIGNAL
};
@ -86,6 +85,7 @@ static gboolean gimp_preview_enter_notify_event (GtkWidget *widget,
static gboolean gimp_preview_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event);
static void gimp_preview_render (GimpPreview *preview);
static void gimp_preview_real_render (GimpPreview *preview);
static void gimp_preview_get_size (GimpPreview *preview,
gint size,
@ -108,8 +108,6 @@ static gboolean gimp_preview_popup_timeout (GimpPreview *preview)
static void gimp_preview_size_changed (GimpPreview *preview,
GimpViewable *viewable);
static void gimp_preview_paint (GimpPreview *preview);
static gboolean gimp_preview_idle_paint (GimpPreview *preview);
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
gpointer data);
@ -237,7 +235,7 @@ gimp_preview_init (GimpPreview *preview)
preview->size = -1;
preview->in_button = FALSE;
preview->idle_id = 0;
preview->needs_render = TRUE;
preview->popup_id = 0;
preview->popup_x = 0;
preview->popup_y = 0;
@ -252,12 +250,6 @@ gimp_preview_destroy (GtkObject *object)
preview = GIMP_PREVIEW (object);
if (preview->idle_id)
{
g_source_remove (preview->idle_id);
preview->idle_id = 0;
}
gimp_preview_popup_hide (preview);
if (preview->viewable)
@ -294,10 +286,10 @@ gimp_preview_size_allocate (GtkWidget *widget,
allocation->width = width;
allocation->height = height;
preview->needs_render = TRUE;
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
gimp_preview_paint (GIMP_PREVIEW (widget));
}
static gboolean
@ -311,7 +303,10 @@ gimp_preview_expose_event (GtkWidget *widget,
preview = GIMP_PREVIEW (widget);
if (preview->idle_id || ! preview->buffer || ! GTK_WIDGET_DRAWABLE (widget))
if (preview->needs_render)
gimp_preview_render (preview);
if (! preview->buffer || ! GTK_WIDGET_DRAWABLE (widget))
return FALSE;
buf_rect.width = preview->width + 2 * preview->border_width;
@ -621,7 +616,7 @@ gimp_preview_set_viewable (GimpPreview *preview,
(gpointer *) &preview->viewable);
g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable),
G_CALLBACK (gimp_preview_paint),
G_CALLBACK (gimp_preview_update),
preview);
g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable),
@ -649,7 +644,7 @@ gimp_preview_set_viewable (GimpPreview *preview,
g_signal_connect_swapped (G_OBJECT (preview->viewable),
"invalidate_preview",
G_CALLBACK (gimp_preview_paint),
G_CALLBACK (gimp_preview_update),
preview);
g_signal_connect_swapped (G_OBJECT (preview->viewable),
@ -664,7 +659,8 @@ gimp_preview_set_viewable (GimpPreview *preview,
preview->border_width);
}
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
@ -742,7 +738,8 @@ gimp_preview_set_dot_for_dot (GimpPreview *preview,
preview->border_width);
}
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
@ -757,21 +754,32 @@ gimp_preview_set_border_color (GimpPreview *preview,
{
preview->border_color = *color;
gimp_preview_paint (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
}
void
gimp_preview_render (GimpPreview *preview)
gimp_preview_update (GimpPreview *preview)
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
GIMP_PREVIEW_GET_CLASS (preview)->render (preview);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
/* private functions */
static void
gimp_preview_render (GimpPreview *preview)
{
if (! preview->viewable)
return;
GIMP_PREVIEW_GET_CLASS (preview)->render (preview);
}
static void
gimp_preview_real_render (GimpPreview *preview)
{
@ -953,33 +961,11 @@ gimp_preview_size_changed (GimpPreview *preview,
preview->size,
preview->border_width);
}
}
static void
gimp_preview_paint (GimpPreview *preview)
{
if (preview->idle_id)
else
{
g_source_remove (preview->idle_id);
preview->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
preview->idle_id =
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) gimp_preview_idle_paint, preview,
NULL);
}
static gboolean
gimp_preview_idle_paint (GimpPreview *preview)
{
preview->idle_id = 0;
if (! preview->viewable)
return FALSE;
gimp_preview_render (preview);
return FALSE;
}
static GimpViewable *
@ -1231,5 +1217,5 @@ gimp_preview_render_and_flush (GimpPreview *preview,
(width + 2 * border) * PREVIEW_BYTES);
}
gtk_widget_queue_draw (GTK_WIDGET (preview));
preview->needs_render = FALSE;
}

View File

@ -66,7 +66,7 @@ struct _GimpPreview
gint size;
gboolean in_button;
guint press_state;
guint idle_id;
gboolean needs_render;
guint popup_id;
gint popup_x;
gint popup_y;
@ -130,7 +130,7 @@ void gimp_preview_set_dot_for_dot (GimpPreview *preview,
void gimp_preview_set_border_color (GimpPreview *preview,
const GimpRGB *border_color);
void gimp_preview_render (GimpPreview *preview);
void gimp_preview_update (GimpPreview *preview);
/* protected */