Compare commits

...

1 Commits

Author SHA1 Message Date
Matthias Clasen
7000b2de8d fontchooser: Fix programmatic selection
The changes in 8caadaf404 did not work
since the selection model is set to autoselect,
so the first time items are added to the list,
we select one.

Fixes: #4564

What this commit does not fix is scrolling the
selected item into view.
2021-12-30 00:45:23 -05:00
2 changed files with 5 additions and 2 deletions

View File

@@ -2334,10 +2334,12 @@ gtk_font_chooser_widget_merge_font_desc (GtkFontChooserWidget *fontchooser
if (mask & PANGO_FONT_MASK_SIZE)
{
double font_size = (double) pango_font_description_get_size (fontchooser->font_desc) / PANGO_SCALE;
/* XXX: This clamps, which can cause it to reloop into here, do we need
* to block its signal handler? */
g_signal_handlers_block_by_func (gtk_range_get_adjustment (GTK_RANGE (fontchooser->size_slider)), size_change_cb, fontchooser);
g_signal_handlers_block_by_func (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(fontchooser->size_spin)), size_change_cb, fontchooser);
gtk_range_set_value (GTK_RANGE (fontchooser->size_slider), font_size);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (fontchooser->size_spin), font_size);
g_signal_handlers_unblock_by_func (gtk_range_get_adjustment (GTK_RANGE (fontchooser->size_slider)), size_change_cb, fontchooser);
g_signal_handlers_unblock_by_func (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(fontchooser->size_spin)), size_change_cb, fontchooser);
}
if (mask & (PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_STYLE | PANGO_FONT_MASK_VARIANT |
PANGO_FONT_MASK_WEIGHT | PANGO_FONT_MASK_STRETCH))

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk40">
<object class="GtkSingleSelection" id="selection">
<property name="autoselect">0</property>
<signal name="notify::selected-item" handler="selection_changed_cb" object="GtkFontChooserWidget" swapped="0"/>
<signal name="items-changed" handler="rows_changed_cb" object="GtkFontChooserWidget" swapped="1"/>
<property name="model">