]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfontsel.c
gtk: remove "gboolean homogeneous" from gtk_box_new()
[~andy/gtk] / gtk / gtkfontsel.c
index ef01b05329f8cc31d27d8aec54c2b52123076379..e73b4ba426fafa63f5e1c91add8abde49744a72e 100644 (file)
 #include "gtkscrolledwindow.h"
 #include "gtkintl.h"
 #include "gtkaccessible.h"
-#include "gtkprivate.h"
 #include "gtkbuildable.h"
-#include "gtkalias.h"
+#include "gtkprivate.h"
+
+struct _GtkFontSelectionPrivate
+{
+  GtkWidget *font_entry;        /* Used _get_family_entry() for consistency, -mr */
+  GtkWidget *font_style_entry;  /* Used _get_face_entry() for consistency, -mr */
+
+  GtkWidget *size_entry;
+  GtkWidget *preview_entry;
+
+  GtkWidget *family_list;
+  GtkWidget *face_list;
+  GtkWidget *size_list;
+
+  PangoFontFamily *family;      /* Current family */
+  PangoFontFace *face;          /* Current face */
+
+  gint size;
+};
+
+
+struct _GtkFontSelectionDialogPrivate
+{
+  GtkWidget *fontsel;
+
+  GtkWidget *ok_button;
+  GtkWidget *apply_button;
+  GtkWidget *cancel_button;
+};
+
 
 /* We don't enable the font and style entries because they don't add
  * much in terms of visible effect and have a weird effect on keynav.
 /* These are what we use as the standard font sizes, for the size list.
  */
 static const guint16 font_sizes[] = {
-  6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 26, 28,
+  6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28,
   32, 36, 40, 48, 56, 64, 72
 };
 
 enum {
    PROP_0,
    PROP_FONT_NAME,
-   PROP_FONT,
    PROP_PREVIEW_TEXT
 };
 
@@ -124,9 +151,11 @@ static void    gtk_font_selection_get_property       (GObject         *object,
                                                      guint            prop_id,
                                                      GValue          *value,
                                                      GParamSpec      *pspec);
-static void    gtk_font_selection_finalize          (GObject               *object);
-static void    gtk_font_selection_screen_changed     (GtkWidget                    *widget,
-                                                     GdkScreen             *previous_screen);
+static void    gtk_font_selection_finalize          (GObject         *object);
+static void    gtk_font_selection_screen_changed     (GtkWidget              *widget,
+                                                     GdkScreen       *previous_screen);
+static void    gtk_font_selection_style_set          (GtkWidget      *widget,
+                                                     GtkStyle       *prev_style);
 
 /* These are the callbacks & related functions. */
 static void     gtk_font_selection_select_font           (GtkTreeSelection *selection,
@@ -155,12 +184,23 @@ static void     gtk_font_selection_scroll_on_map         (GtkWidget        *w,
 
 static void     gtk_font_selection_preview_changed       (GtkWidget        *entry,
                                                          GtkFontSelection *fontsel);
+static void     gtk_font_selection_scroll_to_selection   (GtkFontSelection *fontsel);
+
 
 /* Misc. utility functions. */
 static void    gtk_font_selection_load_font          (GtkFontSelection *fs);
 static void    gtk_font_selection_update_preview     (GtkFontSelection *fs);
 
-static GdkFont* gtk_font_selection_get_font_internal (GtkFontSelection *fontsel);
+static PangoFontDescription *gtk_font_selection_get_font_description (GtkFontSelection *fontsel);
+static gboolean gtk_font_selection_select_font_desc  (GtkFontSelection      *fontsel,
+                                                     PangoFontDescription  *new_desc,
+                                                     PangoFontFamily      **pfamily,
+                                                     PangoFontFace        **pface);
+static void     gtk_font_selection_reload_fonts          (GtkFontSelection *fontsel);
+static void     gtk_font_selection_ref_family            (GtkFontSelection *fontsel,
+                                                         PangoFontFamily  *family);
+static void     gtk_font_selection_ref_face              (GtkFontSelection *fontsel,
+                                                         PangoFontFace    *face);
 
 G_DEFINE_TYPE (GtkFontSelection, gtk_font_selection, GTK_TYPE_VBOX)
 
@@ -169,11 +209,13 @@ gtk_font_selection_class_init (GtkFontSelectionClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-  
+
+  gobject_class->finalize = gtk_font_selection_finalize;
   gobject_class->set_property = gtk_font_selection_set_property;
   gobject_class->get_property = gtk_font_selection_get_property;
 
   widget_class->screen_changed = gtk_font_selection_screen_changed;
+  widget_class->style_set = gtk_font_selection_style_set;
    
   g_object_class_install_property (gobject_class,
                                    PROP_FONT_NAME,
@@ -182,13 +224,6 @@ gtk_font_selection_class_init (GtkFontSelectionClass *klass)
                                                         P_("The string that represents this font"),
                                                         DEFAULT_FONT_NAME,
                                                         GTK_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class,
-                                  PROP_FONT,
-                                  g_param_spec_boxed ("font",
-                                                      P_("Font"),
-                                                      P_("The GdkFont that is currently selected"),
-                                                      GDK_TYPE_FONT,
-                                                      GTK_PARAM_READABLE));
   g_object_class_install_property (gobject_class,
                                    PROP_PREVIEW_TEXT,
                                    g_param_spec_string ("preview-text",
@@ -196,7 +231,8 @@ gtk_font_selection_class_init (GtkFontSelectionClass *klass)
                                                         P_("The text to display in order to demonstrate the selected font"),
                                                         _(PREVIEW_TEXT),
                                                         GTK_PARAM_READWRITE));
-  gobject_class->finalize = gtk_font_selection_finalize;
+
+  g_type_class_add_private (klass, sizeof (GtkFontSelectionPrivate));
 }
 
 static void 
@@ -237,9 +273,6 @@ static void gtk_font_selection_get_property (GObject         *object,
     case PROP_FONT_NAME:
       g_value_take_string (value, gtk_font_selection_get_font_name (fontsel));
       break;
-    case PROP_FONT:
-      g_value_set_boxed (value, gtk_font_selection_get_font_internal (fontsel));
-      break;
     case PROP_PREVIEW_TEXT:
       g_value_set_string (value, gtk_font_selection_get_preview_text (fontsel));
       break;
@@ -255,26 +288,30 @@ static void gtk_font_selection_get_property (GObject         *object,
 static gboolean
 list_row_activated (GtkWidget *widget)
 {
+  GtkWidget *default_widget, *focus_widget;
   GtkWindow *window;
   
   window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget)));
-  if (!GTK_WIDGET_TOPLEVEL (window))
+  if (!gtk_widget_is_toplevel (GTK_WIDGET (window)))
     window = NULL;
-  
-  if (window
-      && widget != window->default_widget
-      && !(widget == window->focus_widget &&
-          (!window->default_widget || !GTK_WIDGET_SENSITIVE (window->default_widget))))
+
+  if (window)
     {
-      gtk_window_activate_default (window);
+      default_widget = gtk_window_get_default_widget (window);
+      focus_widget = gtk_window_get_focus (window);
+
+      if (widget != default_widget &&
+          !(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget))))
+        gtk_window_activate_default (window);
     }
-  
+
   return TRUE;
 }
 
 static void
 gtk_font_selection_init (GtkFontSelection *fontsel)
 {
+  GtkFontSelectionPrivate *priv;
   GtkWidget *scrolled_win;
   GtkWidget *text_box;
   GtkWidget *table, *label;
@@ -285,10 +322,15 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
   GList *focus_chain = NULL;
   AtkObject *atk_obj;
 
+  fontsel->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontsel,
+                                               GTK_TYPE_FONT_SELECTION,
+                                               GtkFontSelectionPrivate);
+  priv = fontsel->priv;
+
   gtk_widget_push_composite_child ();
 
   gtk_box_set_spacing (GTK_BOX (fontsel), 12);
-  fontsel->size = 12 * PANGO_SCALE;
+  priv->size = 12 * PANGO_SCALE;
   
   /* Create the table of font, style & size. */
   table = gtk_table_new (3, 3, FALSE);
@@ -298,30 +340,30 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
   gtk_box_pack_start (GTK_BOX (fontsel), table, TRUE, TRUE, 0);
 
 #ifdef INCLUDE_FONT_ENTRIES
-  fontsel->font_entry = gtk_entry_new ();
-  gtk_editable_set_editable (GTK_EDITABLE (fontsel->font_entry), FALSE);
-  gtk_widget_set_size_request (fontsel->font_entry, 20, -1);
-  gtk_widget_show (fontsel->font_entry);
-  gtk_table_attach (GTK_TABLE (table), fontsel->font_entry, 0, 1, 1, 2,
+  priv->font_entry = gtk_entry_new ();
+  gtk_editable_set_editable (GTK_EDITABLE (priv->font_entry), FALSE);
+  gtk_widget_set_size_request (priv->font_entry, 20, -1);
+  gtk_widget_show (priv->font_entry);
+  gtk_table_attach (GTK_TABLE (table), priv->font_entry, 0, 1, 1, 2,
                    GTK_FILL, 0, 0, 0);
   
-  fontsel->font_style_entry = gtk_entry_new ();
-  gtk_editable_set_editable (GTK_EDITABLE (fontsel->font_style_entry), FALSE);
-  gtk_widget_set_size_request (fontsel->font_style_entry, 20, -1);
-  gtk_widget_show (fontsel->font_style_entry);
-  gtk_table_attach (GTK_TABLE (table), fontsel->font_style_entry, 1, 2, 1, 2,
+  priv->font_style_entry = gtk_entry_new ();
+  gtk_editable_set_editable (GTK_EDITABLE (priv->font_style_entry), FALSE);
+  gtk_widget_set_size_request (priv->font_style_entry, 20, -1);
+  gtk_widget_show (priv->font_style_entry);
+  gtk_table_attach (GTK_TABLE (table), priv->font_style_entry, 1, 2, 1, 2,
                    GTK_FILL, 0, 0, 0);
 #endif /* INCLUDE_FONT_ENTRIES */
   
-  fontsel->size_entry = gtk_entry_new ();
-  gtk_widget_set_size_request (fontsel->size_entry, 20, -1);
-  gtk_widget_show (fontsel->size_entry);
-  gtk_table_attach (GTK_TABLE (table), fontsel->size_entry, 2, 3, 1, 2,
+  priv->size_entry = gtk_entry_new ();
+  gtk_widget_set_size_request (priv->size_entry, 20, -1);
+  gtk_widget_show (priv->size_entry);
+  gtk_table_attach (GTK_TABLE (table), priv->size_entry, 2, 3, 1, 2,
                    GTK_FILL, 0, 0, 0);
-  g_signal_connect (fontsel->size_entry, "activate",
+  g_signal_connect (priv->size_entry, "activate",
                    G_CALLBACK (gtk_font_selection_size_activate),
                    fontsel);
-  g_signal_connect_after (fontsel->size_entry, "focus-out-event",
+  g_signal_connect_after (priv->size_entry, "focus-out-event",
                          G_CALLBACK (gtk_font_selection_size_focus_out),
                          fontsel);
   
@@ -339,7 +381,7 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
   
   label = gtk_label_new_with_mnemonic (_("Si_ze:"));
   gtk_label_set_mnemonic_widget (GTK_LABEL (label),
-                                 fontsel->size_entry);
+                                 priv->size_entry);
   gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
   gtk_widget_show (label);
   gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1,
@@ -351,10 +393,10 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
   model = gtk_list_store_new (2,
                              G_TYPE_OBJECT,  /* FAMILY_COLUMN */
                              G_TYPE_STRING); /* FAMILY_NAME_COLUMN */
-  fontsel->family_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+  priv->family_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
   g_object_unref (model);
 
-  g_signal_connect (fontsel->family_list, "row-activated",
+  g_signal_connect (priv->family_list, "row-activated",
                    G_CALLBACK (list_row_activated), fontsel);
 
   column = gtk_tree_view_column_new_with_attributes ("Family",
@@ -362,22 +404,22 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
                                                     "text", FAMILY_NAME_COLUMN,
                                                     NULL);
   gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (fontsel->family_list), column);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->family_list), column);
 
-  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (fontsel->family_list), FALSE);
-  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (fontsel->family_list)),
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->family_list), FALSE);
+  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->family_list)),
                               GTK_SELECTION_BROWSE);
   
-  gtk_label_set_mnemonic_widget (GTK_LABEL (font_label), fontsel->family_list);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (font_label), priv->family_list);
 
   scrolled_win = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);
   gtk_widget_set_size_request (scrolled_win,
                               FONT_LIST_WIDTH, FONT_LIST_HEIGHT);
-  gtk_container_add (GTK_CONTAINER (scrolled_win), fontsel->family_list);
+  gtk_container_add (GTK_CONTAINER (scrolled_win), priv->family_list);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
-  gtk_widget_show (fontsel->family_list);
+  gtk_widget_show (priv->family_list);
   gtk_widget_show (scrolled_win);
 
   gtk_table_attach (GTK_TABLE (table), scrolled_win, 0, 1, 1, 3,
@@ -388,44 +430,44 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
   model = gtk_list_store_new (2,
                              G_TYPE_OBJECT,  /* FACE_COLUMN */
                              G_TYPE_STRING); /* FACE_NAME_COLUMN */
-  fontsel->face_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+  priv->face_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
   g_object_unref (model);
-  g_signal_connect (fontsel->face_list, "row-activated",
+  g_signal_connect (priv->face_list, "row-activated",
                    G_CALLBACK (list_row_activated), fontsel);
 
-  gtk_label_set_mnemonic_widget (GTK_LABEL (style_label), fontsel->face_list);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (style_label), priv->face_list);
 
   column = gtk_tree_view_column_new_with_attributes ("Face",
                                                     gtk_cell_renderer_text_new (),
                                                     "text", FACE_NAME_COLUMN,
                                                     NULL);
   gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (fontsel->face_list), column);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->face_list), column);
 
-  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (fontsel->face_list), FALSE);
-  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (fontsel->face_list)),
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->face_list), FALSE);
+  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->face_list)),
                               GTK_SELECTION_BROWSE);
   
   scrolled_win = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);
   gtk_widget_set_size_request (scrolled_win,
                               FONT_STYLE_LIST_WIDTH, FONT_LIST_HEIGHT);
-  gtk_container_add (GTK_CONTAINER (scrolled_win), fontsel->face_list);
+  gtk_container_add (GTK_CONTAINER (scrolled_win), priv->face_list);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
-  gtk_widget_show (fontsel->face_list);
+  gtk_widget_show (priv->face_list);
   gtk_widget_show (scrolled_win);
   gtk_table_attach (GTK_TABLE (table), scrolled_win, 1, 2, 1, 3,
                    GTK_EXPAND | GTK_FILL,
                    GTK_EXPAND | GTK_FILL, 0, 0);
   focus_chain = g_list_append (focus_chain, scrolled_win);
   
-  focus_chain = g_list_append (focus_chain, fontsel->size_entry);
+  focus_chain = g_list_append (focus_chain, priv->size_entry);
 
   model = gtk_list_store_new (1, G_TYPE_INT);
-  fontsel->size_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+  priv->size_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
   g_object_unref (model);
-  g_signal_connect (fontsel->size_list, "row-activated",
+  g_signal_connect (priv->size_list, "row-activated",
                    G_CALLBACK (list_row_activated), fontsel);
 
   column = gtk_tree_view_column_new_with_attributes ("Size",
@@ -433,19 +475,19 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
                                                     "text", SIZE_COLUMN,
                                                     NULL);
   gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (fontsel->size_list), column);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->size_list), column);
 
-  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (fontsel->size_list), FALSE);
-  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (fontsel->size_list)),
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->size_list), FALSE);
+  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->size_list)),
                               GTK_SELECTION_BROWSE);
   
   scrolled_win = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);
-  gtk_container_add (GTK_CONTAINER (scrolled_win), fontsel->size_list);
+  gtk_container_add (GTK_CONTAINER (scrolled_win), priv->size_list);
   gtk_widget_set_size_request (scrolled_win, -1, FONT_LIST_HEIGHT);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                  GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
-  gtk_widget_show (fontsel->size_list);
+  gtk_widget_show (priv->size_list);
   gtk_widget_show (scrolled_win);
   gtk_table_attach (GTK_TABLE (table), scrolled_win, 2, 3, 2, 3,
                    GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
@@ -455,19 +497,19 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
   g_list_free (focus_chain);
   
   /* Insert the fonts. */
-  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (fontsel->family_list)), "changed",
+  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->family_list)), "changed",
                    G_CALLBACK (gtk_font_selection_select_font), fontsel);
 
-  g_signal_connect_after (fontsel->family_list, "map",
+  g_signal_connect_after (priv->family_list, "map",
                          G_CALLBACK (gtk_font_selection_scroll_on_map),
                          fontsel);
   
-  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (fontsel->face_list)), "changed",
+  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->face_list)), "changed",
                    G_CALLBACK (gtk_font_selection_select_style), fontsel);
 
-  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (fontsel->size_list)), "changed",
+  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->size_list)), "changed",
                    G_CALLBACK (gtk_font_selection_select_size), fontsel);
-  atk_obj = gtk_widget_get_accessible (fontsel->size_list);
+  atk_obj = gtk_widget_get_accessible (priv->size_list);
   if (GTK_IS_ACCESSIBLE (atk_obj))
     {
       /* Accessibility support is enabled.
@@ -506,10 +548,9 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
           atk_relation_set_add (relation_set, relation);
         }
       g_object_unref (relation_set);
-    }    
-      
+    }
 
-  vbox = gtk_vbox_new (FALSE, 6);
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
   gtk_widget_show (vbox);
   gtk_box_pack_start (GTK_BOX (fontsel), vbox, FALSE, TRUE, 0);
   
@@ -518,23 +559,22 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
   gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
   gtk_widget_show (label);
   gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
-  
-  text_box = gtk_hbox_new (FALSE, 0);
+
+  text_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   gtk_widget_show (text_box);
   gtk_box_pack_start (GTK_BOX (vbox), text_box, FALSE, TRUE, 0);
   
-  fontsel->preview_entry = gtk_entry_new ();
-  gtk_label_set_mnemonic_widget (GTK_LABEL (label), fontsel->preview_entry);
-  gtk_entry_set_text (GTK_ENTRY (fontsel->preview_entry), _(PREVIEW_TEXT));
+  priv->preview_entry = gtk_entry_new ();
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->preview_entry);
+  gtk_entry_set_text (GTK_ENTRY (priv->preview_entry), _(PREVIEW_TEXT));
   
-  gtk_widget_show (fontsel->preview_entry);
-  g_signal_connect (fontsel->preview_entry, "changed",
+  gtk_widget_show (priv->preview_entry);
+  g_signal_connect (priv->preview_entry, "changed",
                    G_CALLBACK (gtk_font_selection_preview_changed), fontsel);
-  gtk_widget_set_size_request (fontsel->preview_entry,
+  gtk_widget_set_size_request (priv->preview_entry,
                               -1, INITIAL_PREVIEW_HEIGHT);
-  gtk_box_pack_start (GTK_BOX (text_box), fontsel->preview_entry,
+  gtk_box_pack_start (GTK_BOX (text_box), priv->preview_entry,
                      TRUE, TRUE, 0);
-
   gtk_widget_pop_composite_child();
 }
 
@@ -558,32 +598,73 @@ gtk_font_selection_new (void)
 static void
 gtk_font_selection_finalize (GObject *object)
 {
-  GtkFontSelection *fontsel;
-  
-  g_return_if_fail (GTK_IS_FONT_SELECTION (object));
-  
-  fontsel = GTK_FONT_SELECTION (object);
+  GtkFontSelection *fontsel = GTK_FONT_SELECTION (object);
 
-  if (fontsel->font)
-    gdk_font_unref (fontsel->font);
+  gtk_font_selection_ref_family (fontsel, NULL);
+  gtk_font_selection_ref_face (fontsel, NULL);
 
   G_OBJECT_CLASS (gtk_font_selection_parent_class)->finalize (object);
 }
 
 static void
-gtk_font_selection_screen_changed (GtkWidget *widget,
-                                  GdkScreen *previous_screen)
+gtk_font_selection_ref_family (GtkFontSelection *fontsel,
+                              PangoFontFamily  *family)
 {
-  GtkFontSelection *fontsel = GTK_FONT_SELECTION (widget);
+  GtkFontSelectionPrivate *priv = fontsel->priv;
+
+  if (family)
+    family = g_object_ref (family);
+  if (priv->family)
+    g_object_unref (priv->family);
+  priv->family = family;
+}
+
+static void gtk_font_selection_ref_face (GtkFontSelection *fontsel,
+                                        PangoFontFace    *face)
+{
+  GtkFontSelectionPrivate *priv = fontsel->priv;
+
+  if (face)
+    face = g_object_ref (face);
+  if (priv->face)
+    g_object_unref (priv->face);
+  priv->face = face;
+}
 
+static void
+gtk_font_selection_reload_fonts (GtkFontSelection *fontsel)
+{
   if (gtk_widget_has_screen (GTK_WIDGET (fontsel)))
     {
+      PangoFontDescription *desc;
+      desc = gtk_font_selection_get_font_description (fontsel);
+
       gtk_font_selection_show_available_fonts (fontsel);
       gtk_font_selection_show_available_sizes (fontsel, TRUE);
       gtk_font_selection_show_available_styles (fontsel);
+
+      gtk_font_selection_select_font_desc (fontsel, desc, NULL, NULL);
+      gtk_font_selection_scroll_to_selection (fontsel);
+
+      pango_font_description_free (desc);
     }
 }
 
+static void
+gtk_font_selection_screen_changed (GtkWidget *widget,
+                                  GdkScreen *previous_screen)
+{
+  gtk_font_selection_reload_fonts (GTK_FONT_SELECTION (widget));
+}
+
+static void
+gtk_font_selection_style_set (GtkWidget *widget,
+                             GtkStyle  *prev_style)
+{
+  /* Maybe fonts where installed or removed... */
+  gtk_font_selection_reload_fonts (GTK_FONT_SELECTION (widget));
+}
+
 static void
 gtk_font_selection_preview_changed (GtkWidget        *entry,
                                    GtkFontSelection *fontsel)
@@ -618,27 +699,28 @@ set_cursor_to_iter (GtkTreeView *view,
   gtk_tree_path_free (path);
 }
 
+static void
+gtk_font_selection_scroll_to_selection (GtkFontSelection *fontsel)
+{
+  GtkFontSelectionPrivate *priv = fontsel->priv;
+
+  /* Try to scroll the font family list to the selected item */
+  scroll_to_selection (GTK_TREE_VIEW (priv->family_list));
+
+  /* Try to scroll the font family list to the selected item */
+  scroll_to_selection (GTK_TREE_VIEW (priv->face_list));
+
+  /* Try to scroll the font family list to the selected item */
+  scroll_to_selection (GTK_TREE_VIEW (priv->size_list));
 /* This is called when the list is mapped. Here we scroll to the current
    font if necessary. */
+}
+
 static void
 gtk_font_selection_scroll_on_map (GtkWidget            *widget,
                                   gpointer              data)
 {
-  GtkFontSelection *fontsel;
-  
-#ifdef FONTSEL_DEBUG
-  g_message ("In expose_list\n");
-#endif
-  fontsel = GTK_FONT_SELECTION (data);
-  
-  /* Try to scroll the font family list to the selected item */
-  scroll_to_selection (GTK_TREE_VIEW (fontsel->family_list));
-      
-  /* Try to scroll the font family list to the selected item */
-  scroll_to_selection (GTK_TREE_VIEW (fontsel->face_list));
-      
-  /* Try to scroll the font family list to the selected item */
-  scroll_to_selection (GTK_TREE_VIEW (fontsel->size_list));
+  gtk_font_selection_scroll_to_selection (GTK_FONT_SELECTION (data));
 }
 
 /* This is called when a family is selected in the list. */
@@ -647,6 +729,7 @@ gtk_font_selection_select_font (GtkTreeSelection *selection,
                                gpointer          data)
 {
   GtkFontSelection *fontsel;
+  GtkFontSelectionPrivate *priv;
   GtkTreeModel *model;
   GtkTreeIter iter;
 #ifdef INCLUDE_FONT_ENTRIES
@@ -654,21 +737,22 @@ gtk_font_selection_select_font (GtkTreeSelection *selection,
 #endif
 
   fontsel = GTK_FONT_SELECTION (data);
+  priv = fontsel->priv;
 
   if (gtk_tree_selection_get_selected (selection, &model, &iter))
     {
       PangoFontFamily *family;
-      
+
       gtk_tree_model_get (model, &iter, FAMILY_COLUMN, &family, -1);
-      if (fontsel->family != family)
+      if (priv->family != family)
        {
-         fontsel->family = family;
-         
+         gtk_font_selection_ref_family (fontsel, family);
+
 #ifdef INCLUDE_FONT_ENTRIES
-         family_name = pango_font_family_get_name (fontsel->family);
-         gtk_entry_set_text (GTK_ENTRY (fontsel->font_entry), family_name);
+         family_name = pango_font_family_get_name (priv->family);
+         gtk_entry_set_text (GTK_ENTRY (priv->font_entry), family_name);
 #endif
-         
+
          gtk_font_selection_show_available_styles (fontsel);
          gtk_font_selection_select_best_style (fontsel, TRUE);
        }
@@ -689,14 +773,15 @@ cmp_families (const void *a, const void *b)
 static void
 gtk_font_selection_show_available_fonts (GtkFontSelection *fontsel)
 {
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   GtkListStore *model;
   PangoFontFamily **families;
   PangoFontFamily *match_family = NULL;
   gint n_families, i;
   GtkTreeIter match_row;
-  
-  model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fontsel->family_list)));
-  
+
+  model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->family_list)));
+
   pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (fontsel)),
                               &families, &n_families);
   qsort (families, n_families, sizeof (PangoFontFamily *), cmp_families);
@@ -721,12 +806,12 @@ gtk_font_selection_show_available_fonts (GtkFontSelection *fontsel)
        }
     }
 
-  fontsel->family = match_family;
+  gtk_font_selection_ref_family (fontsel, match_family);
   if (match_family)
     {
-      set_cursor_to_iter (GTK_TREE_VIEW (fontsel->family_list), &match_row);
+      set_cursor_to_iter (GTK_TREE_VIEW (priv->family_list), &match_row);
 #ifdef INCLUDE_FONT_ENTRIES
-      gtk_entry_set_text (GTK_ENTRY (fontsel->font_entry), 
+      gtk_entry_set_text (GTK_ENTRY (priv->font_entry), 
                          pango_font_family_get_name (match_family));
 #endif /* INCLUDE_FONT_ENTRIES */
     }
@@ -785,21 +870,22 @@ font_description_style_equal (const PangoFontDescription *a,
 static void
 gtk_font_selection_show_available_styles (GtkFontSelection *fontsel)
 {
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   gint n_faces, i;
   PangoFontFace **faces;
   PangoFontDescription *old_desc;
   GtkListStore *model;
   GtkTreeIter match_row;
   PangoFontFace *match_face = NULL;
-  
-  model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fontsel->face_list)));
-  
-  if (fontsel->face)
-    old_desc = pango_font_face_describe (fontsel->face);
+
+  model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->face_list)));
+
+  if (priv->face)
+    old_desc = pango_font_face_describe (priv->face);
   else
     old_desc= NULL;
 
-  pango_font_family_list_faces (fontsel->family, &faces, &n_faces);
+  pango_font_family_list_faces (priv->family, &faces, &n_faces);
   qsort (faces, n_faces, sizeof (PangoFontFace *), faces_sort_func);
 
   gtk_list_store_clear (model);
@@ -837,15 +923,15 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel)
   if (old_desc)
     pango_font_description_free (old_desc);
 
-  fontsel->face = match_face;
+  gtk_font_selection_ref_face (fontsel, match_face);
   if (match_face)
     {
 #ifdef INCLUDE_FONT_ENTRIES
-      const gchar *str = pango_font_face_get_face_name (fontsel->face);
+      const gchar *str = pango_font_face_get_face_name (priv->face);
 
-      gtk_entry_set_text (GTK_ENTRY (fontsel->font_style_entry), str);
-#endif      
-      set_cursor_to_iter (GTK_TREE_VIEW (fontsel->face_list), &match_row);
+      gtk_entry_set_text (GTK_ENTRY (priv->font_style_entry), str);
+#endif
+      set_cursor_to_iter (GTK_TREE_VIEW (priv->face_list), &match_row);
     }
 
   g_free (faces);
@@ -860,15 +946,16 @@ static void
 gtk_font_selection_select_best_style (GtkFontSelection *fontsel,
                                      gboolean          use_first)
 {
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   GtkTreeIter iter;
   GtkTreeModel *model;
 
-  model = gtk_tree_view_get_model (GTK_TREE_VIEW (fontsel->face_list));
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->face_list));
 
   if (gtk_tree_model_get_iter_first (model, &iter))
     {
-      set_cursor_to_iter (GTK_TREE_VIEW (fontsel->face_list), &iter);
-      scroll_to_selection (GTK_TREE_VIEW (fontsel->face_list));
+      set_cursor_to_iter (GTK_TREE_VIEW (priv->face_list), &iter);
+      scroll_to_selection (GTK_TREE_VIEW (priv->face_list));
     }
 
   gtk_font_selection_show_available_sizes (fontsel, FALSE);
@@ -884,14 +971,13 @@ gtk_font_selection_select_style (GtkTreeSelection *selection,
   GtkFontSelection *fontsel = GTK_FONT_SELECTION (data);
   GtkTreeModel *model;
   GtkTreeIter iter;
-  
+
   if (gtk_tree_selection_get_selected (selection, &model, &iter))
     {
       PangoFontFace *face;
       
       gtk_tree_model_get (model, &iter, FACE_COLUMN, &face, -1);
-      fontsel->face = face;
-
+      gtk_font_selection_ref_face (fontsel, face);
       g_object_unref (face);
     }
 
@@ -903,12 +989,13 @@ static void
 gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel,
                                         gboolean          first_time)
 {
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   gint i;
   GtkListStore *model;
   gchar buffer[128];
   gchar *p;
-      
-  model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fontsel->size_list)));
+
+  model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->size_list)));
 
   /* Insert the standard font sizes */
   if (first_time)
@@ -918,25 +1005,25 @@ gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel,
       for (i = 0; i < G_N_ELEMENTS (font_sizes); i++)
        {
          GtkTreeIter iter;
-         
+
          gtk_list_store_append (model, &iter);
          gtk_list_store_set (model, &iter, SIZE_COLUMN, font_sizes[i], -1);
-         
-         if (font_sizes[i] * PANGO_SCALE == fontsel->size)
-           set_cursor_to_iter (GTK_TREE_VIEW (fontsel->size_list), &iter);
+
+         if (font_sizes[i] * PANGO_SCALE == priv->size)
+           set_cursor_to_iter (GTK_TREE_VIEW (priv->size_list), &iter);
        }
     }
   else
     {
       GtkTreeIter iter;
       gboolean found = FALSE;
-      
+
       gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter);
       for (i = 0; i < G_N_ELEMENTS (font_sizes) && !found; i++)
        {
-         if (font_sizes[i] * PANGO_SCALE == fontsel->size)
+         if (font_sizes[i] * PANGO_SCALE == priv->size)
            {
-             set_cursor_to_iter (GTK_TREE_VIEW (fontsel->size_list), &iter);
+             set_cursor_to_iter (GTK_TREE_VIEW (priv->size_list), &iter);
              found = TRUE;
            }
 
@@ -945,7 +1032,7 @@ gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel,
 
       if (!found)
        {
-         GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (fontsel->size_list));
+         GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->size_list));
          gtk_tree_selection_unselect_all (selection);
        }
     }
@@ -953,7 +1040,7 @@ gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel,
   /* Set the entry to the new size, rounding to 1 digit,
    * trimming of trailing 0's and a trailing period
    */
-  g_snprintf (buffer, sizeof (buffer), "%.1f", fontsel->size / (1.0 * PANGO_SCALE));
+  g_snprintf (buffer, sizeof (buffer), "%.1f", priv->size / (1.0 * PANGO_SCALE));
   if (strchr (buffer, '.'))
     {
       p = buffer + strlen (buffer) - 1;
@@ -965,8 +1052,8 @@ gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel,
     }
 
   /* Compare, to avoid moving the cursor unecessarily */
-  if (strcmp (gtk_entry_get_text (GTK_ENTRY (fontsel->size_entry)), buffer) != 0)
-    gtk_entry_set_text (GTK_ENTRY (fontsel->size_entry), buffer);
+  if (strcmp (gtk_entry_get_text (GTK_ENTRY (priv->size_entry)), buffer) != 0)
+    gtk_entry_set_text (GTK_ENTRY (priv->size_entry), buffer);
 }
 
 static void
@@ -979,9 +1066,11 @@ static void
 gtk_font_selection_set_size (GtkFontSelection *fontsel,
                             gint              new_size)
 {
-  if (fontsel->size != new_size)
+  GtkFontSelectionPrivate *priv = fontsel->priv;
+
+  if (priv->size != new_size)
     {
-      fontsel->size = new_size;
+      priv->size = new_size;
 
       gtk_font_selection_show_available_sizes (fontsel, FALSE);      
       gtk_font_selection_load_font (fontsel);
@@ -994,16 +1083,15 @@ static void
 gtk_font_selection_size_activate (GtkWidget   *w,
                                   gpointer     data)
 {
-  GtkFontSelection *fontsel;
+  GtkFontSelection *fontsel = GTK_FONT_SELECTION (data);
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   gint new_size;
   const gchar *text;
-  
-  fontsel = GTK_FONT_SELECTION (data);
 
-  text = gtk_entry_get_text (GTK_ENTRY (fontsel->size_entry));
+  text = gtk_entry_get_text (GTK_ENTRY (priv->size_entry));
   new_size = MAX (0.1, atof (text) * PANGO_SCALE + 0.5);
 
-  if (fontsel->size != new_size)
+  if (priv->size != new_size)
     gtk_font_selection_set_size (fontsel, new_size);
   else 
     list_row_activated (w);
@@ -1014,17 +1102,16 @@ gtk_font_selection_size_focus_out (GtkWidget     *w,
                                   GdkEventFocus *event,
                                   gpointer       data)
 {
-  GtkFontSelection *fontsel;
+  GtkFontSelection *fontsel = GTK_FONT_SELECTION (data);
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   gint new_size;
   const gchar *text;
-  
-  fontsel = GTK_FONT_SELECTION (data);
 
-  text = gtk_entry_get_text (GTK_ENTRY (fontsel->size_entry));
+  text = gtk_entry_get_text (GTK_ENTRY (priv->size_entry));
   new_size = MAX (0.1, atof (text) * PANGO_SCALE + 0.5);
 
   gtk_font_selection_set_size (fontsel, new_size);
-  
+
   return TRUE;
 }
 
@@ -1033,13 +1120,11 @@ static void
 gtk_font_selection_select_size (GtkTreeSelection *selection,
                                gpointer          data)
 {
-  GtkFontSelection *fontsel;
+  GtkFontSelection *fontsel = GTK_FONT_SELECTION (data);
   GtkTreeModel *model;
   GtkTreeIter iter;
   gint new_size;
-  
-  fontsel = GTK_FONT_SELECTION (data);
-  
+
   if (gtk_tree_selection_get_selected (selection, &model, &iter))
     {
       gtk_tree_model_get (model, &iter, SIZE_COLUMN, &new_size, -1);
@@ -1050,22 +1135,19 @@ gtk_font_selection_select_size (GtkTreeSelection *selection,
 static void
 gtk_font_selection_load_font (GtkFontSelection *fontsel)
 {
-  if (fontsel->font)
-    gdk_font_unref (fontsel->font);
-  fontsel->font = NULL;
-
   gtk_font_selection_update_preview (fontsel);
 }
 
 static PangoFontDescription *
 gtk_font_selection_get_font_description (GtkFontSelection *fontsel)
 {
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   PangoFontDescription *font_desc;
 
-  if (fontsel->face)
+  if (priv->face)
     {
-      font_desc = pango_font_face_describe (fontsel->face);
-      pango_font_description_set_size (font_desc, fontsel->size);
+      font_desc = pango_font_face_describe (priv->face);
+      pango_font_description_set_size (font_desc, priv->size);
     }
   else
     font_desc = pango_font_description_from_string (DEFAULT_FONT_NAME);
@@ -1082,24 +1164,25 @@ gtk_font_selection_get_font_description (GtkFontSelection *fontsel)
 static void
 gtk_font_selection_update_preview (GtkFontSelection *fontsel)
 {
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   GtkRcStyle *rc_style;
   gint new_height;
-  GtkRequisition old_requisition;
-  GtkWidget *preview_entry = fontsel->preview_entry;
+  GtkRequisition old_requisition, new_requisition;
+  GtkWidget *preview_entry = priv->preview_entry;
   const gchar *text;
 
-  gtk_widget_get_child_requisition (preview_entry, &old_requisition);
-  
+  gtk_widget_get_preferred_size (preview_entry, &old_requisition, NULL);
+
   rc_style = gtk_rc_style_new ();
   rc_style->font_desc = gtk_font_selection_get_font_description (fontsel);
   
   gtk_widget_modify_style (preview_entry, rc_style);
   g_object_unref (rc_style);
 
-  gtk_widget_size_request (preview_entry, NULL);
+  gtk_widget_get_preferred_size (preview_entry, &new_requisition, NULL);
   
   /* We don't ever want to be over MAX_PREVIEW_HEIGHT pixels high. */
-  new_height = CLAMP (preview_entry->requisition.height, INITIAL_PREVIEW_HEIGHT, MAX_PREVIEW_HEIGHT);
+  new_height = CLAMP (new_requisition.height, INITIAL_PREVIEW_HEIGHT, MAX_PREVIEW_HEIGHT);
 
   if (new_height > old_requisition.height || new_height < old_requisition.height - 30)
     gtk_widget_set_size_request (preview_entry, -1, new_height);
@@ -1111,19 +1194,6 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel)
   gtk_editable_set_position (GTK_EDITABLE (preview_entry), 0);
 }
 
-static GdkFont*
-gtk_font_selection_get_font_internal (GtkFontSelection *fontsel)
-{
-  if (!fontsel->font)
-    {
-      PangoFontDescription *font_desc = gtk_font_selection_get_font_description (fontsel);
-      fontsel->font = gdk_font_from_description_for_display (gtk_widget_get_display (GTK_WIDGET (fontsel)), font_desc);
-      pango_font_description_free (font_desc);
-    }
-  
-  return fontsel->font;
-}
-
 
 /*****************************************************************************
  * These functions are the main public interface for getting/setting the font.
@@ -1135,8 +1205,8 @@ gtk_font_selection_get_font_internal (GtkFontSelection *fontsel)
  *
  * This returns the #GtkTreeView that lists font families, for
  * example, 'Sans', 'Serif', etc.
- * 
- * Return value: A #GtkWidget that is part of @fontsel
+ *
+ * Return value: (transfer none): A #GtkWidget that is part of @fontsel
  *
  * Since: 2.14
  */
@@ -1144,8 +1214,8 @@ GtkWidget *
 gtk_font_selection_get_family_list (GtkFontSelection *fontsel)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
-  
-  return fontsel->family_list;
+
+  return fontsel->priv->family_list;
 }
 
 /**
@@ -1155,7 +1225,7 @@ gtk_font_selection_get_family_list (GtkFontSelection *fontsel)
  * This returns the #GtkTreeView which lists all styles available for
  * the selected font. For example, 'Regular', 'Bold', etc.
  * 
- * Return value: A #GtkWidget that is part of @fontsel
+ * Return value: (transfer none): A #GtkWidget that is part of @fontsel
  *
  * Since: 2.14
  */
@@ -1163,8 +1233,8 @@ GtkWidget *
 gtk_font_selection_get_face_list (GtkFontSelection *fontsel)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
-  
-  return fontsel->face_list;
+
+  return fontsel->priv->face_list;
 }
 
 /**
@@ -1172,9 +1242,9 @@ gtk_font_selection_get_face_list (GtkFontSelection *fontsel)
  * @fontsel: a #GtkFontSelection
  *
  * This returns the #GtkEntry used to allow the user to edit the font
- * number manually instead of selecting it from the list of font sizes. 
- * 
- * Return value: A #GtkWidget that is part of @fontsel
+ * number manually instead of selecting it from the list of font sizes.
+ *
+ * Return value: (transfer none): A #GtkWidget that is part of @fontsel
  *
  * Since: 2.14
  */
@@ -1182,17 +1252,17 @@ GtkWidget *
 gtk_font_selection_get_size_entry (GtkFontSelection *fontsel)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
-  
-  return fontsel->size_entry;
+
+  return fontsel->priv->size_entry;
 }
 
 /**
  * gtk_font_selection_get_size_list:
  * @fontsel: a #GtkFontSelection
  *
- * This returns the #GtkTreeeView used to list font sizes. 
- * 
- * Return value: A #GtkWidget that is part of @fontsel
+ * This returns the #GtkTreeeView used to list font sizes.
+ *
+ * Return value: (transfer none): A #GtkWidget that is part of @fontsel
  *
  * Since: 2.14
  */
@@ -1200,17 +1270,17 @@ GtkWidget *
 gtk_font_selection_get_size_list (GtkFontSelection *fontsel)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
-  
-  return fontsel->size_list;
+
+  return fontsel->priv->size_list;
 }
 
 /**
  * gtk_font_selection_get_preview_entry:
  * @fontsel: a #GtkFontSelection
- * 
+ *
  * This returns the #GtkEntry used to display the font as a preview.
  *
- * Return value: A #GtkWidget that is part of @fontsel
+ * Return value: (transfer none): A #GtkWidget that is part of @fontsel
  *
  * Since: 2.14
  */
@@ -1218,20 +1288,20 @@ GtkWidget *
 gtk_font_selection_get_preview_entry (GtkFontSelection *fontsel)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
-  
-  return fontsel->preview_entry;
+
+  return fontsel->priv->preview_entry;
 }
 
 /**
  * gtk_font_selection_get_family:
  * @fontsel: a #GtkFontSelection
- * 
+ *
  * Gets the #PangoFontFamily representing the selected font family.
  *
- * Return value: A #PangoFontFamily representing the selected font
- *     family. Font families are a collection of font faces. The 
- *     returned object is owned by @fontsel and must not be modified 
- *     or freed.
+ * Return value: (transfer none): A #PangoFontFamily representing the
+ *     selected font family. Font families are a collection of font
+ *     faces. The returned object is owned by @fontsel and must not
+ *     be modified or freed.
  *
  * Since: 2.14
  */
@@ -1239,20 +1309,20 @@ PangoFontFamily *
 gtk_font_selection_get_family (GtkFontSelection *fontsel)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
-  
-  return fontsel->family;
+
+  return fontsel->priv->family;
 }
 
 /**
  * gtk_font_selection_get_face:
  * @fontsel: a #GtkFontSelection
- * 
+ *
  * Gets the #PangoFontFace representing the selected font group
- * details (i.e. family, slant, weight, width, etc).   
+ * details (i.e. family, slant, weight, width, etc).
  *
- * Return value: A #PangoFontFace representing the selected font 
- *     group details. The returned object is owned by @fontsel and
- *     must not be modified or freed. 
+ * Return value: (transfer none): A #PangoFontFace representing the
+ *     selected font group details. The returned object is owned by
+ *     @fontsel and must not be modified or freed.
  *
  * Since: 2.14
  */
@@ -1260,17 +1330,17 @@ PangoFontFace *
 gtk_font_selection_get_face (GtkFontSelection *fontsel)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
-  
-  return fontsel->face;
+
+  return fontsel->priv->face;
 }
 
 /**
  * gtk_font_selection_get_size:
  * @fontsel: a #GtkFontSelection
- * 
+ *
  * The selected font size.
  *
- * Return value: A n integer representing the selected font size, 
+ * Return value: A n integer representing the selected font size,
  *     or -1 if no font size is selected.
  *
  * Since: 2.14
@@ -1279,26 +1349,8 @@ gint
 gtk_font_selection_get_size (GtkFontSelection *fontsel)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), -1);
-  
-  return fontsel->size;
-}
 
-/**
- * gtk_font_selection_get_font:
- * @fontsel: a #GtkFontSelection
- *
- * Gets the currently-selected font.
- * 
- * Return value: A #GdkFont.
- *
- * Deprecated: 2.0: Use gtk_font_selection_get_font_name() instead.
- */
-GdkFont *
-gtk_font_selection_get_font (GtkFontSelection *fontsel)
-{
-  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
-
-  return gtk_font_selection_get_font_internal (fontsel);
+  return fontsel->priv->size;
 }
 
 /**
@@ -1329,48 +1381,27 @@ gtk_font_selection_get_font_name (GtkFontSelection *fontsel)
   return result;
 }
 
-
-/* This sets the current font, selecting the appropriate list rows.
+/* This selects the appropriate list rows.
    First we check the fontname is valid and try to find the font family
    - i.e. the name in the main list. If we can't find that, then just return.
    Next we try to set each of the properties according to the fontname.
    Finally we select the font family & style in the lists. */
-
-/**
- * gtk_font_selection_set_font_name:
- * @fontsel: a #GtkFontSelection
- * @fontname: a font name like "Helvetica 12" or "Times Bold 18"
- * 
- * Sets the currently-selected font. 
- *
- * Note that the @fontsel needs to know the screen in which it will appear 
- * for this to work; this can be guaranteed by simply making sure that the 
- * @fontsel is inserted in a toplevel window before you call this function.
- * 
- * Return value: %TRUE if the font could be set successfully; %FALSE if no 
- *     such font exists or if the @fontsel doesn't belong to a particular 
- *     screen yet.
- */
-gboolean
-gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
-                                 const gchar      *fontname)
+static gboolean
+gtk_font_selection_select_font_desc (GtkFontSelection      *fontsel,
+                                    PangoFontDescription  *new_desc,
+                                    PangoFontFamily      **pfamily,
+                                    PangoFontFace        **pface)
 {
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   PangoFontFamily *new_family = NULL;
   PangoFontFace *new_face = NULL;
   PangoFontFace *fallback_face = NULL;
-  PangoFontDescription *new_desc;
   GtkTreeModel *model;
   GtkTreeIter iter;
   GtkTreeIter match_iter;
   gboolean valid;
   const gchar *new_family_name;
-  
-  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), FALSE);
 
-  if (!gtk_widget_has_screen (GTK_WIDGET (fontsel)))
-    return FALSE;
-
-  new_desc = pango_font_description_from_string (fontname);
   new_family_name = pango_font_description_get_family (new_desc);
 
   if (!new_family_name)
@@ -1378,7 +1409,7 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
 
   /* Check to make sure that this is in the list of allowed fonts 
    */
-  model = gtk_tree_view_get_model (GTK_TREE_VIEW (fontsel->family_list));
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->family_list));
   for (valid = gtk_tree_model_get_iter_first (model, &iter);
        valid;
        valid = gtk_tree_model_iter_next (model, &iter))
@@ -1389,8 +1420,8 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
       
       if (g_ascii_strcasecmp (pango_font_family_get_name (family),
                              new_family_name) == 0)
-       new_family = family;
-      
+       new_family = g_object_ref (family);
+
       g_object_unref (family);
       
       if (new_family)
@@ -1400,11 +1431,14 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
   if (!new_family)
     return FALSE;
 
-  fontsel->family = new_family;
-  set_cursor_to_iter (GTK_TREE_VIEW (fontsel->family_list), &iter);
+  if (pfamily)
+    *pfamily = new_family;
+  else
+    g_object_unref (new_family);
+  set_cursor_to_iter (GTK_TREE_VIEW (priv->family_list), &iter);
   gtk_font_selection_show_available_styles (fontsel);
 
-  model = gtk_tree_view_get_model (GTK_TREE_VIEW (fontsel->face_list));
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->face_list));
   for (valid = gtk_tree_model_get_iter_first (model, &iter);
        valid;
        valid = gtk_tree_model_iter_next (model, &iter))
@@ -1416,11 +1450,11 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
       tmp_desc = pango_font_face_describe (face);
       
       if (font_description_style_equal (tmp_desc, new_desc))
-       new_face = face;
+       new_face = g_object_ref (face);
       
       if (!fallback_face)
        {
-         fallback_face = face;
+         fallback_face = g_object_ref (face);
          match_iter = iter;
        }
       
@@ -1436,18 +1470,67 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
 
   if (!new_face)
     new_face = fallback_face;
+  else if (fallback_face)
+    g_object_unref (fallback_face);
 
-  fontsel->face = new_face;
-  set_cursor_to_iter (GTK_TREE_VIEW (fontsel->face_list), &match_iter);  
+  if (pface)
+    *pface = new_face;
+  else if (new_face)
+    g_object_unref (new_face);
+  set_cursor_to_iter (GTK_TREE_VIEW (priv->face_list), &match_iter);  
 
   gtk_font_selection_set_size (fontsel, pango_font_description_get_size (new_desc));
+
+  return TRUE;
+}
+
+
+/* This sets the current font, then selecting the appropriate list rows. */
+
+/**
+ * gtk_font_selection_set_font_name:
+ * @fontsel: a #GtkFontSelection
+ * @fontname: a font name like "Helvetica 12" or "Times Bold 18"
+ * 
+ * Sets the currently-selected font. 
+ *
+ * Note that the @fontsel needs to know the screen in which it will appear 
+ * for this to work; this can be guaranteed by simply making sure that the 
+ * @fontsel is inserted in a toplevel window before you call this function.
+ * 
+ * Return value: %TRUE if the font could be set successfully; %FALSE if no 
+ *     such font exists or if the @fontsel doesn't belong to a particular 
+ *     screen yet.
+ */
+gboolean
+gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
+                                 const gchar      *fontname)
+{
+  PangoFontFamily *family = NULL;
+  PangoFontFace *face = NULL;
+  PangoFontDescription *new_desc;
   
-  g_object_freeze_notify (G_OBJECT (fontsel));
-  g_object_notify (G_OBJECT (fontsel), "font-name");
-  g_object_notify (G_OBJECT (fontsel), "font");
-  g_object_thaw_notify (G_OBJECT (fontsel));
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), FALSE);
+
+  if (!gtk_widget_has_screen (GTK_WIDGET (fontsel)))
+    return FALSE;
+
+  new_desc = pango_font_description_from_string (fontname);
+
+  if (gtk_font_selection_select_font_desc (fontsel, new_desc, &family, &face))
+    {
+      gtk_font_selection_ref_family (fontsel, family);
+      if (family)
+        g_object_unref (family);
+
+      gtk_font_selection_ref_face (fontsel, face);
+      if (face)
+        g_object_unref (face);
+    }
 
   pango_font_description_free (new_desc);
+  
+  g_object_notify (G_OBJECT (fontsel), "font-name");
 
   return TRUE;
 }
@@ -1465,9 +1548,13 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
 G_CONST_RETURN gchar*
 gtk_font_selection_get_preview_text (GtkFontSelection *fontsel)
 {
+  GtkFontSelectionPrivate *priv;
+
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
 
-  return gtk_entry_get_text (GTK_ENTRY (fontsel->preview_entry));
+  priv = fontsel->priv;
+
+  return gtk_entry_get_text (GTK_ENTRY (priv->preview_entry));
 }
 
 
@@ -1483,10 +1570,14 @@ void
 gtk_font_selection_set_preview_text  (GtkFontSelection *fontsel,
                                      const gchar      *text)
 {
+  GtkFontSelectionPrivate *priv;
+
   g_return_if_fail (GTK_IS_FONT_SELECTION (fontsel));
   g_return_if_fail (text != NULL);
 
-  gtk_entry_set_text (GTK_ENTRY (fontsel->preview_entry), text);
+  priv = fontsel->priv;
+
+  gtk_entry_set_text (GTK_ENTRY (priv->preview_entry), text);
 }
 
 /*****************************************************************************
@@ -1508,48 +1599,55 @@ static GtkBuildableIface *parent_buildable_iface;
 static void
 gtk_font_selection_dialog_class_init (GtkFontSelectionDialogClass *klass)
 {
+  g_type_class_add_private (klass, sizeof (GtkFontSelectionDialogPrivate));
 }
 
 static void
 gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
 {
+  GtkFontSelectionDialogPrivate *priv;
   GtkDialog *dialog = GTK_DIALOG (fontseldiag);
-  
-  gtk_dialog_set_has_separator (dialog, FALSE);
+  GtkWidget *action_area, *content_area;
+
+  fontseldiag->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontseldiag,
+                                                   GTK_TYPE_FONT_SELECTION_DIALOG,
+                                                   GtkFontSelectionDialogPrivate);
+  priv = fontseldiag->priv;
+
+  content_area = gtk_dialog_get_content_area (dialog);
+  action_area = gtk_dialog_get_action_area (dialog);
+
   gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-  gtk_box_set_spacing (GTK_BOX (dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
-  gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5);
-  gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
+  gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+  gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
+  gtk_box_set_spacing (GTK_BOX (action_area), 6);
 
   gtk_widget_push_composite_child ();
 
   gtk_window_set_resizable (GTK_WINDOW (fontseldiag), TRUE);
-  
-  fontseldiag->main_vbox = dialog->vbox;
-  
-  fontseldiag->fontsel = gtk_font_selection_new ();
-  gtk_container_set_border_width (GTK_CONTAINER (fontseldiag->fontsel), 5);
-  gtk_widget_show (fontseldiag->fontsel);
-  gtk_box_pack_start (GTK_BOX (fontseldiag->main_vbox),
-                     fontseldiag->fontsel, TRUE, TRUE, 0);
-  
+
+  /* Create the content area */
+  priv->fontsel = gtk_font_selection_new ();
+  gtk_container_set_border_width (GTK_CONTAINER (priv->fontsel), 5);
+  gtk_widget_show (priv->fontsel);
+  gtk_box_pack_start (GTK_BOX (content_area),
+                     priv->fontsel, TRUE, TRUE, 0);
+
   /* Create the action area */
-  fontseldiag->action_area = dialog->action_area;
+  priv->cancel_button = gtk_dialog_add_button (dialog,
+                                               GTK_STOCK_CANCEL,
+                                               GTK_RESPONSE_CANCEL);
 
-  fontseldiag->cancel_button = gtk_dialog_add_button (dialog,
-                                                      GTK_STOCK_CANCEL,
-                                                      GTK_RESPONSE_CANCEL);
+  priv->apply_button = gtk_dialog_add_button (dialog,
+                                              GTK_STOCK_APPLY,
+                                              GTK_RESPONSE_APPLY);
+  gtk_widget_hide (priv->apply_button);
 
-  fontseldiag->apply_button = gtk_dialog_add_button (dialog,
-                                                     GTK_STOCK_APPLY,
-                                                     GTK_RESPONSE_APPLY);
-  gtk_widget_hide (fontseldiag->apply_button);
+  priv->ok_button = gtk_dialog_add_button (dialog,
+                                           GTK_STOCK_OK,
+                                           GTK_RESPONSE_OK);
+  gtk_widget_grab_default (priv->ok_button);
 
-  fontseldiag->ok_button = gtk_dialog_add_button (dialog,
-                                                  GTK_STOCK_OK,
-                                                  GTK_RESPONSE_OK);
-  gtk_widget_grab_default (fontseldiag->ok_button);
-  
   gtk_dialog_set_alternative_button_order (GTK_DIALOG (fontseldiag),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_APPLY,
@@ -1560,8 +1658,6 @@ gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
                         _("Font Selection"));
 
   gtk_widget_pop_composite_child ();
-
-  _gtk_dialog_set_ignore_separator (dialog, TRUE);
 }
 
 /**
@@ -1586,41 +1682,41 @@ gtk_font_selection_dialog_new (const gchar *title)
 }
 
 /**
- * gtk_font_selection_dialog_get_ok_button:
+ * gtk_font_selection_dialog_get_font_selection:
  * @fsd: a #GtkFontSelectionDialog
  *
- * Gets the 'OK' button.
+ * Retrieves the #GtkFontSelection widget embedded in the dialog.
  *
- * Return value: the #GtkWidget used in the dialog for the 'OK' button.
+ * Returns: (transfer none): the embedded #GtkFontSelection
  *
- * Since: 2.14
- */
-GtkWidget *
-gtk_font_selection_dialog_get_ok_button (GtkFontSelectionDialog *fsd)
+ * Since: 2.22
+ **/
+GtkWidget*
+gtk_font_selection_dialog_get_font_selection (GtkFontSelectionDialog *fsd)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
 
-  return fsd->ok_button;
+  return fsd->priv->fontsel;
 }
 
+
 /**
- * gtk_font_selection_dialog_get_apply_button:
+ * gtk_font_selection_dialog_get_ok_button:
  * @fsd: a #GtkFontSelectionDialog
  *
- * Obtains a button. The button doesn't have any function.
+ * Gets the 'OK' button.
  *
- * Return value: a #GtkWidget
+ * Return value: (transfer none): the #GtkWidget used in the dialog
+ *     for the 'OK' button.
  *
  * Since: 2.14
- *
- * Deprecated: 2.16: Don't use this function.
  */
 GtkWidget *
-gtk_font_selection_dialog_get_apply_button (GtkFontSelectionDialog *fsd)
+gtk_font_selection_dialog_get_ok_button (GtkFontSelectionDialog *fsd)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
 
-  return fsd->apply_button;
+  return fsd->priv->ok_button;
 }
 
 /**
@@ -1629,7 +1725,8 @@ gtk_font_selection_dialog_get_apply_button (GtkFontSelectionDialog *fsd)
  *
  * Gets the 'Cancel' button.
  *
- * Return value: the #GtkWidget used in the dialog for the 'Cancel' button.
+ * Return value: (transfer none): the #GtkWidget used in the dialog
+ *     for the 'Cancel' button.
  *
  * Since: 2.14
  */
@@ -1638,7 +1735,7 @@ gtk_font_selection_dialog_get_cancel_button (GtkFontSelectionDialog *fsd)
 {
   g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
 
-  return fsd->cancel_button;
+  return fsd->priv->cancel_button;
 }
 
 static void
@@ -1653,16 +1750,20 @@ gtk_font_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
                                                        GtkBuilder   *builder,
                                                        const gchar  *childname)
 {
-    if (strcmp(childname, "ok_button") == 0)
-       return G_OBJECT (GTK_FONT_SELECTION_DIALOG(buildable)->ok_button);
-    else if (strcmp(childname, "cancel_button") == 0)
-       return G_OBJECT (GTK_FONT_SELECTION_DIALOG (buildable)->cancel_button);
-    else if (strcmp(childname, "apply_button") == 0)
-       return G_OBJECT (GTK_FONT_SELECTION_DIALOG(buildable)->apply_button);
-    else if (strcmp(childname, "font_selection") == 0)
-       return G_OBJECT (GTK_FONT_SELECTION_DIALOG(buildable)->fontsel);
-
-    return parent_buildable_iface->get_internal_child (buildable, builder, childname);
+  GtkFontSelectionDialogPrivate *priv;
+
+  priv = GTK_FONT_SELECTION_DIALOG (buildable)->priv;
+
+  if (g_strcmp0 (childname, "ok_button") == 0)
+    return G_OBJECT (priv->ok_button);
+  else if (g_strcmp0 (childname, "cancel_button") == 0)
+    return G_OBJECT (priv->cancel_button);
+  else if (g_strcmp0 (childname, "apply_button") == 0)
+    return G_OBJECT (priv->apply_button);
+  else if (g_strcmp0 (childname, "font_selection") == 0)
+    return G_OBJECT (priv->fontsel);
+
+  return parent_buildable_iface->get_internal_child (buildable, builder, childname);
 }
 
 /**
@@ -1684,28 +1785,13 @@ gtk_font_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
 gchar*
 gtk_font_selection_dialog_get_font_name (GtkFontSelectionDialog *fsd)
 {
-  g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
-
-  return gtk_font_selection_get_font_name (GTK_FONT_SELECTION (fsd->fontsel));
-}
+  GtkFontSelectionDialogPrivate *priv;
 
-/**
- * gtk_font_selection_dialog_get_font:
- * @fsd: a #GtkFontSelectionDialog
- *
- * Gets the currently-selected font.
- *
- * Return value: the #GdkFont from the #GtkFontSelection for the
- *     currently selected font in the dialog, or %NULL if no font is selected
- *
- * Deprecated: 2.0: Use gtk_font_selection_dialog_get_font_name() instead.
- */
-GdkFont*
-gtk_font_selection_dialog_get_font (GtkFontSelectionDialog *fsd)
-{
   g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
 
-  return gtk_font_selection_get_font_internal (GTK_FONT_SELECTION (fsd->fontsel));
+  priv = fsd->priv;
+
+  return gtk_font_selection_get_font_name (GTK_FONT_SELECTION (priv->fontsel));
 }
 
 /**
@@ -1722,10 +1808,14 @@ gboolean
 gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd,
                                         const gchar            *fontname)
 {
+  GtkFontSelectionDialogPrivate *priv;
+
   g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), FALSE);
   g_return_val_if_fail (fontname, FALSE);
 
-  return gtk_font_selection_set_font_name (GTK_FONT_SELECTION (fsd->fontsel), fontname);
+  priv = fsd->priv;
+
+  return gtk_font_selection_set_font_name (GTK_FONT_SELECTION (priv->fontsel), fontname);
 }
 
 /**
@@ -1741,9 +1831,13 @@ gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd,
 G_CONST_RETURN gchar*
 gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd)
 {
+  GtkFontSelectionDialogPrivate *priv;
+
   g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
 
-  return gtk_font_selection_get_preview_text (GTK_FONT_SELECTION (fsd->fontsel));
+  priv = fsd->priv;
+
+  return gtk_font_selection_get_preview_text (GTK_FONT_SELECTION (priv->fontsel));
 }
 
 /**
@@ -1757,11 +1851,12 @@ void
 gtk_font_selection_dialog_set_preview_text (GtkFontSelectionDialog *fsd,
                                            const gchar            *text)
 {
+  GtkFontSelectionDialogPrivate *priv;
+
   g_return_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd));
   g_return_if_fail (text != NULL);
 
-  gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (fsd->fontsel), text);
-}
+  priv = fsd->priv;
 
-#define __GTK_FONTSEL_C__
-#include "gtkaliasdef.c"
+  gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (priv->fontsel), text);
+}