app/display/gimpstatusbar.[ch] only update the GtkProgressBar if that

2007-12-30  Sven Neumann  <sven@gimp.org>

	* app/display/gimpstatusbar.[ch]
	* app/widgets/gimpprogressbox.[ch]: only update the 
GtkProgressBar
	if that would cause a visible change.


svn path=/trunk/; revision=24487
This commit is contained in:
Sven Neumann 2007-12-30 17:25:58 +00:00 committed by Sven Neumann
parent 7313f6d06c
commit 0d818d9ad3
5 changed files with 36 additions and 14 deletions

View File

@ -1,3 +1,9 @@
2007-12-30 Sven Neumann <sven@gimp.org>
* app/display/gimpstatusbar.[ch]
* app/widgets/gimpprogressbox.[ch]: only update the GtkProgressBar
if that would cause a visible change.
2007-12-30 Manish Singh <yosh@gimp.org>
* plug-ins/pygimp/pygimp-tile.c: subscript API for PixelFetcher.

View File

@ -281,6 +281,7 @@ gimp_statusbar_progress_start (GimpProgress *progress,
gtk_widget_show (statusbar->cancel_button);
statusbar->progress_active = TRUE;
statusbar->progress_value = 0.0;
if (! GTK_WIDGET_VISIBLE (statusbar))
{
@ -313,6 +314,7 @@ gimp_statusbar_progress_end (GimpProgress *progress)
}
statusbar->progress_active = FALSE;
statusbar->progress_value = 0.0;
gimp_statusbar_pop (statusbar, "progress");
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), 0.0);
@ -356,10 +358,18 @@ gimp_statusbar_progress_set_value (GimpProgress *progress,
{
GtkWidget *bar = statusbar->progressbar;
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), percentage);
statusbar->progress_value = percentage;
if (GTK_WIDGET_DRAWABLE (bar))
gdk_window_process_updates (bar->window, TRUE);
/* only update the progress bar if this causes a visible change */
if (fabs (bar->allocation.width *
(percentage -
gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (bar)))) > 1.0)
{
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), percentage);
if (GTK_WIDGET_DRAWABLE (bar))
gdk_window_process_updates (bar->window, TRUE);
}
}
}
@ -370,9 +380,7 @@ gimp_statusbar_progress_get_value (GimpProgress *progress)
if (statusbar->progress_active)
{
GtkWidget *bar = statusbar->progressbar;
return gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (bar));
return statusbar->progress_value;
}
return 0.0;

View File

@ -62,6 +62,7 @@ struct _GimpStatusbar
GtkWidget *cancel_button;
gboolean progress_active;
gboolean progress_shown;
gdouble progress_value;
};
struct _GimpStatusbarClass

View File

@ -23,6 +23,7 @@
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
@ -108,6 +109,7 @@ gimp_progress_box_progress_start (GimpProgress *progress,
box->active = TRUE;
box->cancelable = cancelable;
box->value = 0.0;
if (GTK_WIDGET_DRAWABLE (box->progress))
gdk_window_process_updates (box->progress->window, TRUE);
@ -132,6 +134,7 @@ gimp_progress_box_progress_end (GimpProgress *progress)
box->active = FALSE;
box->cancelable = FALSE;
box->value = 0.0;
}
}
@ -168,10 +171,17 @@ gimp_progress_box_progress_set_value (GimpProgress *progress,
{
GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
gtk_progress_bar_set_fraction (bar, percentage);
box->value = percentage;
if (GTK_WIDGET_DRAWABLE (box->progress))
gdk_window_process_updates (box->progress->window, TRUE);
/* only update the progress bar if this causes a visible change */
if (fabs (GTK_WIDGET (bar)->allocation.width *
(percentage - gtk_progress_bar_get_fraction (bar))) > 1.0)
{
gtk_progress_bar_set_fraction (bar, box->value);
if (GTK_WIDGET_DRAWABLE (box->progress))
gdk_window_process_updates (box->progress->window, TRUE);
}
}
}
@ -181,11 +191,7 @@ gimp_progress_box_progress_get_value (GimpProgress *progress)
GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
if (box->active)
{
GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
return gtk_progress_bar_get_fraction (bar);
}
return box->value;
return 0.0;
}

View File

@ -43,6 +43,7 @@ struct _GimpProgressBox
gboolean active;
gboolean cancelable;
gdouble value;
GtkWidget *label;
GtkWidget *progress;