diff --git a/ChangeLog b/ChangeLog index efc4e20657..0a5077bca0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-12-30 Sven Neumann + + * app/display/gimpstatusbar.[ch] + * app/widgets/gimpprogressbox.[ch]: only update the GtkProgressBar + if that would cause a visible change. + 2007-12-30 Manish Singh * plug-ins/pygimp/pygimp-tile.c: subscript API for PixelFetcher. diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c index c3a5ddbec1..76047cfcce 100644 --- a/app/display/gimpstatusbar.c +++ b/app/display/gimpstatusbar.c @@ -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; diff --git a/app/display/gimpstatusbar.h b/app/display/gimpstatusbar.h index 8fdef85e27..e6a00312e1 100644 --- a/app/display/gimpstatusbar.h +++ b/app/display/gimpstatusbar.h @@ -62,6 +62,7 @@ struct _GimpStatusbar GtkWidget *cancel_button; gboolean progress_active; gboolean progress_shown; + gdouble progress_value; }; struct _GimpStatusbarClass diff --git a/app/widgets/gimpprogressbox.c b/app/widgets/gimpprogressbox.c index 0738477af3..31a4af53f3 100644 --- a/app/widgets/gimpprogressbox.c +++ b/app/widgets/gimpprogressbox.c @@ -23,6 +23,7 @@ #include +#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; } diff --git a/app/widgets/gimpprogressbox.h b/app/widgets/gimpprogressbox.h index 646f56ed14..64cf5d9846 100644 --- a/app/widgets/gimpprogressbox.h +++ b/app/widgets/gimpprogressbox.h @@ -43,6 +43,7 @@ struct _GimpProgressBox gboolean active; gboolean cancelable; + gdouble value; GtkWidget *label; GtkWidget *progress;