[gtk+/gtk-3-14] fontchooser: Don't cause "row-changed" signal in cell data func



commit d8e880f7f18ef3d2d6092bb57e37d91ce808fe82
Author: Benjamin Otte <otte redhat com>
Date:   Fri Jun 12 21:23:34 2015 +0200

    fontchooser: Don't cause "row-changed" signal in cell data func
    
    The font chooser delays creating the font description from the font face
    as long as possible (it's slow). Because we use fixed height mode, we
    only have to create font descriptions for rows we are actually going to
    show.
    
    This was achieved by looking at the font description column and if it
    was NULL, we created a font description and gtk_list_stiore_set() it.
    Unfortunately this caused a "row-changed" signal to be emitted and this
    emission could happen during the cell data func.
    And that caused infinite loops with accessibility when you were unlucky.
    
    This change replaces the NULL font description with an empty one and
    instead of setting the correct font description, we
    pango_font_description_merge() it in. This way, the list store doesn't
    change and no signals are emitted.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1197267

 gtk/gtkfontchooserwidget.c |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index 66a3d45..c6d8ff7 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -377,34 +377,24 @@ static PangoFontDescription *
 tree_model_get_font_description (GtkTreeModel *model,
                                  GtkTreeIter  *iter)
 {
-  PangoFontDescription *desc;
+  PangoFontDescription *desc, *face_desc;
   PangoFontFace *face;
-  GtkTreeIter child_iter;
 
   gtk_tree_model_get (model, iter,
                       FONT_DESC_COLUMN, &desc,
                       -1);
-  if (desc != NULL)
+  if (pango_font_description_get_set_fields (desc) != 0)
     return desc;
 
   gtk_tree_model_get (model, iter,
                       FACE_COLUMN, &face,
                       -1);
-  desc = pango_font_face_describe (face);
+  face_desc = pango_font_face_describe (face);
   g_object_unref (face);
   
-  if (GTK_IS_TREE_MODEL_FILTER (model))
-    {
-      gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model),
-                                                        &child_iter,
-                                                        iter);
-      iter = &child_iter;
-      model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
-    }
+  pango_font_description_merge (desc, face_desc, TRUE);
 
-  gtk_list_store_set (GTK_LIST_STORE (model), iter,
-                      FONT_DESC_COLUMN, desc,
-                      -1);
+  pango_font_description_free (face_desc);
 
   return desc;
 }
@@ -643,19 +633,23 @@ gtk_font_chooser_widget_load_fonts (GtkFontChooserWidget *fontchooser)
 
       for (j = 0; j < n_faces; j++)
         {
+          PangoFontDescription *empty_font_desc;
           const gchar *face_name;
 
           face_name = pango_font_face_get_face_name (faces[j]);
 
           family_and_face = g_strconcat (fam_name, " ", face_name, NULL);
+          empty_font_desc = pango_font_description_new ();
 
           gtk_list_store_insert_with_values (list_store, &iter, -1,
                                              FAMILY_COLUMN, families[i],
                                              FACE_COLUMN, faces[j],
+                                             FONT_DESC_COLUMN, empty_font_desc,
                                              PREVIEW_TITLE_COLUMN, family_and_face,
                                              -1);
 
           g_free (family_and_face);
+          pango_font_description_free (empty_font_desc);
         }
 
       g_free (faces);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]