progresstracker: add GTK_SLOWDOWN environment variable

As we consolidate widgets to use progress tracker, this will allow
us to control the speed of all animations in a centralized place
This commit is contained in:
Matt Watson
2016-03-14 03:38:23 -07:00
parent 44a9c0e36d
commit ed75fa655b
3 changed files with 31 additions and 1 deletions

View File

@@ -636,6 +636,7 @@ do_pre_parse_initialization (int *argc,
char ***argv)
{
const gchar *env_string;
double slowdown;
if (pre_initialized)
return;
@@ -673,6 +674,13 @@ do_pre_parse_initialization (int *argc,
g_string_append (gtk_modules_string, env_string);
}
env_string = g_getenv ("GTK_SLOWDOWN");
if (env_string)
{
slowdown = g_ascii_strtod (env_string, NULL);
_gtk_set_slowdown (slowdown);
}
}
static void

View File

@@ -91,6 +91,10 @@ gboolean _gtk_propagate_captured_event (GtkWidget *widget,
GdkEvent *event,
GtkWidget *topmost);
gdouble _gtk_get_slowdown ();
void _gtk_set_slowdown (gdouble slowdown_factor);
#ifdef G_OS_WIN32
void _gtk_load_dll_with_libgtk3_manifest (const char *dllname);
#endif

View File

@@ -18,6 +18,7 @@
*/
#include "gtkprogresstrackerprivate.h"
#include "gtkprivate.h"
#include "gtkcsseasevalueprivate.h"
#include <math.h>
@@ -30,8 +31,25 @@
*
* Progress tracker will handle translating frame clock timestamps to a
* fractional progress value for interpolating between animation targets.
*
* Progress tracker will use the GTK_SLOWDOWN environment variable to control
* the speed of animations. This can be useful for debugging.
*/
static gdouble gtk_slowdown = 1.0;
void
_gtk_set_slowdown (gdouble factor)
{
gtk_slowdown = factor;
}
gdouble
_gtk_get_slowdown (gdouble factor)
{
return gtk_slowdown;
}
/**
* gtk_progress_tracker_init_copy:
* @source: The source progress tracker
@@ -109,7 +127,7 @@ gtk_progress_tracker_advance_frame (GtkProgressTracker *tracker,
return;
}
delta = (frame_time - tracker->last_frame_time) / (gdouble) tracker->duration;
delta = (frame_time - tracker->last_frame_time) / gtk_slowdown / tracker->duration;
tracker->last_frame_time = frame_time;
tracker->iteration += delta;
}