Commit a8ed0dd4 authored by Matthias Clasen's avatar Matthias Clasen

GtkFontChooserWidget: Allow fractional font sizes

With this change, we let users enter up to 2 decimals in the entry,
to specify font sizes exactly. The slider still rounds to whole
numbers.

https://bugzilla.gnome.org/show_bug.cgi?id=665711
parent e23f7c13
......@@ -262,6 +262,23 @@ size_change_cb (GtkAdjustment *adjustment,
gtk_font_chooser_widget_take_font_desc (fontchooser, font_desc);
}
static gboolean
output_cb (GtkSpinButton *spin,
gpointer data)
{
GtkAdjustment *adjustment;
gchar *text;
gdouble value;
adjustment = gtk_spin_button_get_adjustment (spin);
value = gtk_adjustment_get_value (adjustment);
text = g_strdup_printf ("%2.4g", value);
gtk_entry_set_text (GTK_ENTRY (spin), text);
g_free (text);
return TRUE;
}
static void
gtk_font_chooser_widget_update_marks (GtkFontChooserWidget *fontchooser)
{
......@@ -516,6 +533,7 @@ gtk_font_chooser_widget_class_init (GtkFontChooserWidgetClass *klass)
gtk_widget_class_bind_template_callback (widget_class, row_inserted_cb);
gtk_widget_class_bind_template_callback (widget_class, row_deleted_cb);
gtk_widget_class_bind_template_callback (widget_class, size_change_cb);
gtk_widget_class_bind_template_callback (widget_class, output_cb);
}
static void
......
......@@ -155,8 +155,8 @@
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">slider_adjustment</property>
<property name="digits">0</property>
<property name="draw_value">False</property>
<property name="round-digits">0</property>
<signal name="scroll-event" handler="resize_by_scroll_cb" swapped="no"/>
</object>
<packing>
......@@ -172,6 +172,7 @@
<property name="can_focus">True</property>
<property name="invisible_char"></property>
<property name="adjustment">spin_adjustment</property>
<signal name="output" handler="output_cb"/>
</object>
<packing>
<property name="left_attach">1</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment