[gtk+/gtk-3-14] fontchooserwidget: Don't invalidate priv->font_iter in load_fonts
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-14] fontchooserwidget: Don't invalidate priv->font_iter in load_fonts
- Date: Mon, 27 Oct 2014 01:58:05 +0000 (UTC)
commit 9e96e13d2871aae9a33721dba355469fe25923f0
Author: Christophe Fergeau <cfergeau redhat com>
Date: Thu Oct 23 23:30:35 2014 +0200
fontchooserwidget: Don't invalidate priv->font_iter in load_fonts
When using GtkFontChooserButton, the same GtkFontChooserWidget can be
hidden and shown multiple times. When doing that, the font that was
chosen the previous time should be the selected one in the
GtkFontChooserWidget, however this does not work as expected and a
somehow 'random' font gets selected (or none) instead.
Every time the font chooser widget is shown, its style will be updated,
causing gtk_font_chooser_widget_style_updated and then
gtk_font_chooser_widget_load_fonts to be called.
gtk_font_chooser_widget_load_fonts starts by clearing the GtkListStore
listing the available fonts, repopulates it, and then makes sure the
current font is selected.
However, this does not work as expected, as during the call to
gtk_list_store_clear, the cursor_changed_cb will be invoked multiple
times when the GtkTreeView cursor gets moved when the line where the
cursor currently is gets removed. This will cause the 'current font'
state (priv->font_desc) to be unexpectedly modified, and when
gtk_font_chooser_widget_load_fonts tries to reposition the cursor to the
'current font', we won't get the expect result.
This commit avoids that by making sure cursor_changed_cb does not get
called when we call gtk_list_store_clear in
gtk_font_chooser_widget_load_fonts.
https://bugzilla.gnome.org/show_bug.cgi?id=739111
gtk/gtkfontchooserwidget.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index 14171f3..71f23d9 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -627,7 +627,9 @@ gtk_font_chooser_widget_load_fonts (GtkFontChooserWidget *fontchooser)
qsort (families, n_families, sizeof (PangoFontFamily *), cmp_families);
+ g_signal_handlers_block_by_func(priv->family_face_list, cursor_changed_cb, fontchooser);
gtk_list_store_clear (list_store);
+ g_signal_handlers_unblock_by_func (priv->family_face_list, cursor_changed_cb, fontchooser);
/* Iterate over families and faces */
for (i = 0; i < n_families; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]