From f7c87fb3b78863d258092ea4cf57dd6c4480d02d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 24 Aug 2016 12:53:28 -0400 Subject: [PATCH] widget-factory: Fix smooth autoscrolling of scales There is annoying interference between formatting the value (for which we set the number of digits to show) and the small frame-to-frame value changes that we do for autoscrolling. To work around this, turn off the digits-based rounding entirely and format the value ourselves with ::format-value. --- demos/widget-factory/widget-factory.c | 9 ++++++++- demos/widget-factory/widget-factory.ui | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index d4b88a5a64..3fde995d46 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -1626,11 +1626,17 @@ reset_icon_size (GtkWidget *iv) } static gchar * -scale_format_value (GtkScale *scale, gdouble value) +scale_format_value_blank (GtkScale *scale, gdouble value) { return g_strdup (" "); } +static gchar * +scale_format_value (GtkScale *scale, gdouble value) +{ + return g_strdup_printf ("%0.*f", 1, value); +} + static void activate (GApplication *app) { @@ -1697,6 +1703,7 @@ activate (GApplication *app) gtk_builder_add_callback_symbol (builder, "decrease_icon_size", (GCallback)decrease_icon_size); gtk_builder_add_callback_symbol (builder, "reset_icon_size", (GCallback)reset_icon_size); gtk_builder_add_callback_symbol (builder, "scale_format_value", (GCallback)scale_format_value); + gtk_builder_add_callback_symbol (builder, "scale_format_value_blank", (GCallback)scale_format_value_blank); gtk_builder_connect_signals (builder, NULL); diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui index a03975d474..ee025da19a 100644 --- a/demos/widget-factory/widget-factory.ui +++ b/demos/widget-factory/widget-factory.ui @@ -1242,6 +1242,8 @@ Suspendisse feugiat quam quis dolor accumsan cursus. 0 75 1 + -1 + @@ -1255,7 +1257,8 @@ Suspendisse feugiat quam quis dolor accumsan cursus. 0 75 1 - + -1 + 1