mirror of https://github.com/GNOME/gimp.git
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:
parent
7313f6d06c
commit
0d818d9ad3
|
@ -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.
|
||||
|
|
|
@ -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,11 +358,19 @@ gimp_statusbar_progress_set_value (GimpProgress *progress,
|
|||
{
|
||||
GtkWidget *bar = statusbar->progressbar;
|
||||
|
||||
statusbar->progress_value = percentage;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gdouble
|
||||
|
@ -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;
|
||||
|
|
|
@ -62,6 +62,7 @@ struct _GimpStatusbar
|
|||
GtkWidget *cancel_button;
|
||||
gboolean progress_active;
|
||||
gboolean progress_shown;
|
||||
gdouble progress_value;
|
||||
};
|
||||
|
||||
struct _GimpStatusbarClass
|
||||
|
|
|
@ -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,11 +171,18 @@ 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;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gdouble
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ struct _GimpProgressBox
|
|||
|
||||
gboolean active;
|
||||
gboolean cancelable;
|
||||
gdouble value;
|
||||
|
||||
GtkWidget *label;
|
||||
GtkWidget *progress;
|
||||
|
|
Loading…
Reference in New Issue