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.
This commit is contained in:
Matthias Clasen 2016-08-24 12:53:28 -04:00
parent ceb18a989e
commit f7c87fb3b7
2 changed files with 12 additions and 2 deletions

View File

@ -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);

View File

@ -1242,6 +1242,8 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict_to_fill_level">0</property>
<property name="fill_level">75</property>
<property name="draw_value">1</property>
<property name="digits">-1</property>
<signal name="format-value" handler="scale_format_value"/>
</object>
</child>
<child>
@ -1255,7 +1257,8 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict_to_fill_level">0</property>
<property name="fill_level">75</property>
<property name="draw_value">1</property>
<signal name="format-value" handler="scale_format_value"/>
<property name="digits">-1</property>
<signal name="format-value" handler="scale_format_value_blank"/>
</object>
<packing>
<property name="position">1</property>