diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-11-10 01:15:59 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-11-10 01:15:59 -0500 |
commit | 4a789f5036b48b2dc060cfd37e8086a39d144ade (patch) | |
tree | a0b650e9e58c36319fcae46d4cac31dbbe32461d /demos | |
parent | 2b177587e65a5cded88d0c20d293597fda6a06a8 (diff) | |
download | gtk+-4a789f5036b48b2dc060cfd37e8086a39d144ade.tar.gz |
Make the progress bar speed variable
Arrange for the scales to control the speed of the activity
mode progress bar in gtk3-widget-factory. This will be useful
in demonstrating smoother progress bar animation in the future.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/widget-factory/widget-factory.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 20ab75093f..da830e2c15 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -129,11 +129,27 @@ dismiss (GtkWidget *button) gtk_revealer_set_reveal_child (GTK_REVEALER (w), FALSE); } +static gint pulse_time = 250; + +static void +update_pulse_time (GtkAdjustment *adjustment) +{ + gdouble value; + + value = gtk_adjustment_get_value (adjustment); + + /* vary between 50 and 450 */ + pulse_time = 50 + 4 * value; +} + static gboolean pulse_it (GtkWidget *widget) { gtk_progress_bar_pulse (GTK_PROGRESS_BAR (widget)); - return TRUE; + + g_timeout_add (pulse_time, pulse_it, widget); + + return G_SOURCE_REMOVE; } static void @@ -172,6 +188,10 @@ activate (GApplication *app) win_entries, G_N_ELEMENTS (win_entries), window); + g_signal_connect (gtk_builder_get_object (builder, "adjustment1"), + "value-changed", + G_CALLBACK (update_pulse_time), NULL); + widget = (GtkWidget *)gtk_builder_get_object (builder, "progressbar3"); g_timeout_add (250, (GSourceFunc)pulse_it, widget); |