[gtk+/wip/watson/progress-tracker: 6/7] progresstracker: add GTK_SLOWDONW environment variable
- From: Matthew Watson <watson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/watson/progress-tracker: 6/7] progresstracker: add GTK_SLOWDONW environment variable
- Date: Tue, 15 Mar 2016 00:12:21 +0000 (UTC)
commit 6efbbc987d00a2b428cce21476441a897f31fca7
Author: Matt Watson <mattdangerw gmail com>
Date: Mon Mar 14 03:38:23 2016 -0700
progresstracker: add GTK_SLOWDONW 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
gtk/gtkmain.c | 8 ++++++++
gtk/gtkprivate.h | 4 ++++
gtk/gtkprogresstracker.c | 17 ++++++++++++++++-
3 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 71693ef..46ecb28 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -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
diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
index cd48558..7602394 100644
--- a/gtk/gtkprivate.h
+++ b/gtk/gtkprivate.h
@@ -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
diff --git a/gtk/gtkprogresstracker.c b/gtk/gtkprogresstracker.c
index d6e736e..0e4a42f 100644
--- a/gtk/gtkprogresstracker.c
+++ b/gtk/gtkprogresstracker.c
@@ -18,10 +18,25 @@
*/
#include "gtkprogresstrackerprivate.h"
+#include "gtkprivate.h"
#include "gtkcsseasevalueprivate.h"
#include <math.h>
+static gdouble gtk_slowdown = 1.0;
+
+void
+_gtk_set_slowdown (gdouble factor)
+{
+ gtk_slowdown = factor;
+}
+
+gdouble
+_gtk_get_slowdown (gdouble factor)
+{
+ return gtk_slowdown;
+}
+
void
gtk_progress_tracker_start (GtkProgressTracker *tracker,
guint64 duration,
@@ -56,7 +71,7 @@ gtk_progress_tracker_next_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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]