[gimp] app: enable a pulsing progress bar in the splash
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: enable a pulsing progress bar in the splash
- Date: Sun, 17 Apr 2016 15:54:25 +0000 (UTC)
commit d23135ef974cf70f3d172273b7c97e24392eda7c
Author: Michael Natterer <mitch gimp org>
Date: Sun Apr 17 16:52:31 2016 +0100
app: enable a pulsing progress bar in the splash
Startup functions can now make the progress bar pulse in order
to report that something of unknown duration is in progress.
Call status_callback (NULL, NULL, same_percentage)
app/gui/splash.c | 92 +++++++++++++++++++++++++++--------------------------
1 files changed, 47 insertions(+), 45 deletions(-)
---
diff --git a/app/gui/splash.c b/app/gui/splash.c
index 74443fc..37a76b5 100644
--- a/app/gui/splash.c
+++ b/app/gui/splash.c
@@ -36,9 +36,6 @@
#include "gimp-intl.h"
-/* #define STARTUP_TIMER 1 */
-
-
typedef struct
{
GtkWidget *window;
@@ -53,12 +50,14 @@ typedef struct
PangoLayout *lower;
gint lower_x;
gint lower_y;
-#ifdef STARTUP_TIMER
- GTimer *timer;
- gdouble last_time;
+
+ gdouble percentage;
gchar *text1;
gchar *text2;
-#endif
+
+ /* debug timer */
+ GTimer *timer;
+ gdouble last_time;
} GimpSplash;
static GimpSplash *splash = NULL;
@@ -79,15 +78,13 @@ static gboolean splash_average_text_area (GimpSplash *splash,
GdkPixbuf *pixbuf,
GdkColor *color);
-static GdkPixbufAnimation * splash_image_load (gboolean be_verbose);
-static GdkPixbufAnimation * splash_image_pick_from_dir (const gchar *dirname,
- gboolean be_verbose);
+static GdkPixbufAnimation *
+ splash_image_load (gboolean be_verbose);
+static GdkPixbufAnimation *
+ splash_image_pick_from_dir (const gchar *dirname,
+ gboolean be_verbose);
-#ifdef STARTUP_TIMER
-static void splash_timer_elapsed (const gchar *text1,
- const gchar *text2,
- gdouble percentage);
-#endif
+static void splash_timer_elapsed (void);
/* public functions */
@@ -171,9 +168,8 @@ splash_create (gboolean be_verbose,
gtk_widget_show (splash->window);
-#ifdef STARTUP_TIMER
- splash->timer = g_timer_new ();
-#endif
+ if (FALSE)
+ splash->timer = g_timer_new ();
}
void
@@ -187,11 +183,11 @@ splash_destroy (void)
g_object_unref (splash->upper);
g_object_unref (splash->lower);
-#ifdef STARTUP_TIMER
- g_timer_destroy (splash->timer);
g_free (splash->text1);
g_free (splash->text2);
-#endif
+
+ if (splash->timer)
+ g_timer_destroy (splash->timer);
g_slice_free (GimpSplash, splash);
splash = NULL;
@@ -209,10 +205,6 @@ splash_update (const gchar *text1,
if (! splash)
return;
-#ifdef STARTUP_TIMER
- splash_timer_elapsed (text1, text2, percentage);
-#endif
-
splash_position_layouts (splash, text1, text2, &expose);
if (expose.width > 0 && expose.height > 0)
@@ -220,8 +212,34 @@ splash_update (const gchar *text1,
expose.x, expose.y,
expose.width, expose.height);
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (splash->progress),
- percentage);
+ if ((text1 == NULL || ! g_strcmp0 (text1, splash->text1)) &&
+ (text2 == NULL || ! g_strcmp0 (text2, splash->text2)) &&
+ percentage == splash->percentage)
+ {
+ if (text1)
+ {
+ g_free (splash->text1);
+ splash->text1 = g_strdup (text1);
+ }
+
+ if (text2)
+ {
+ g_free (splash->text2);
+ splash->text2 = g_strdup (text2);
+ }
+
+ gtk_progress_bar_pulse (GTK_PROGRESS_BAR (splash->progress));
+ }
+ else
+ {
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (splash->progress),
+ percentage);
+ }
+
+ splash->percentage = percentage;
+
+ if (splash->timer)
+ splash_timer_elapsed ();
if (gtk_events_pending ())
gtk_main_iteration ();
@@ -473,33 +491,17 @@ splash_image_pick_from_dir (const gchar *dirname,
return pixbuf;
}
-#ifdef STARTUP_TIMER
static void
-splash_timer_elapsed (const gchar *text1,
- const gchar *text2,
- gdouble percentage)
+splash_timer_elapsed (void)
{
gdouble elapsed = g_timer_elapsed (splash->timer, NULL);
- if (text1)
- {
- g_free (splash->text1);
- splash->text1 = g_strdup (text1);
- }
-
- if (text2)
- {
- g_free (splash->text2);
- splash->text2 = g_strdup (text2);
- }
-
g_printerr ("%8g %8g - %s %g%% - %s\n",
elapsed,
elapsed - splash->last_time,
splash->text1 ? splash->text1 : "",
- percentage * 100.0,
+ splash->percentage * 100.0,
splash->text2 ? splash->text2 : "");
splash->last_time = elapsed;
}
-#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]