]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfontsel.c
Use gtk_box_new() instead gtk_[v|h]box_new()
[~andy/gtk] / gtk / gtkfontsel.c
index ffe67b88fcc10bcaa6c82dc55231999805893a2b..7dfcfbdb2a96a57a675fab7fe1024e827af2d6b2 100644 (file)
 #include "gtkscrolledwindow.h"
 #include "gtkintl.h"
 #include "gtkaccessible.h"
-#include "gtkprivate.h"
 #include "gtkbuildable.h"
+#include "gtkprivate.h"
 
-struct _GtkFontSelectionPriv
+struct _GtkFontSelectionPrivate
 {
   GtkWidget *font_entry;        /* Used _get_family_entry() for consistency, -mr */
   GtkWidget *font_style_entry;  /* Used _get_face_entry() for consistency, -mr */
@@ -80,7 +80,7 @@ struct _GtkFontSelectionPriv
 };
 
 
-struct _GtkFontSelectionDialogPriv
+struct _GtkFontSelectionDialogPrivate
 {
   GtkWidget *fontsel;
 
@@ -232,7 +232,7 @@ gtk_font_selection_class_init (GtkFontSelectionClass *klass)
                                                         _(PREVIEW_TEXT),
                                                         GTK_PARAM_READWRITE));
 
-  g_type_class_add_private (klass, sizeof (GtkFontSelectionPriv));
+  g_type_class_add_private (klass, sizeof (GtkFontSelectionPrivate));
 }
 
 static void 
@@ -311,7 +311,7 @@ list_row_activated (GtkWidget *widget)
 static void
 gtk_font_selection_init (GtkFontSelection *fontsel)
 {
-  GtkFontSelectionPriv *priv;
+  GtkFontSelectionPrivate *priv;
   GtkWidget *scrolled_win;
   GtkWidget *text_box;
   GtkWidget *table, *label;
@@ -324,7 +324,7 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
 
   fontsel->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontsel,
                                                GTK_TYPE_FONT_SELECTION,
-                                               GtkFontSelectionPriv);
+                                               GtkFontSelectionPrivate);
   priv = fontsel->priv;
 
   gtk_widget_push_composite_child ();
@@ -551,7 +551,7 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
     }    
       
 
-  vbox = gtk_vbox_new (FALSE, 6);
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 6);
   gtk_widget_show (vbox);
   gtk_box_pack_start (GTK_BOX (fontsel), vbox, FALSE, TRUE, 0);
   
@@ -561,7 +561,7 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
   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, FALSE, 0);
   gtk_widget_show (text_box);
   gtk_box_pack_start (GTK_BOX (vbox), text_box, FALSE, TRUE, 0);
   
@@ -611,7 +611,7 @@ static void
 gtk_font_selection_ref_family (GtkFontSelection *fontsel,
                               PangoFontFamily  *family)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
 
   if (family)
     family = g_object_ref (family);
@@ -623,7 +623,7 @@ gtk_font_selection_ref_family (GtkFontSelection *fontsel,
 static void gtk_font_selection_ref_face (GtkFontSelection *fontsel,
                                         PangoFontFace    *face)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
 
   if (face)
     face = g_object_ref (face);
@@ -703,7 +703,7 @@ set_cursor_to_iter (GtkTreeView *view,
 static void
 gtk_font_selection_scroll_to_selection (GtkFontSelection *fontsel)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
 
   /* Try to scroll the font family list to the selected item */
   scroll_to_selection (GTK_TREE_VIEW (priv->family_list));
@@ -730,7 +730,7 @@ gtk_font_selection_select_font (GtkTreeSelection *selection,
                                gpointer          data)
 {
   GtkFontSelection *fontsel;
-  GtkFontSelectionPriv *priv;
+  GtkFontSelectionPrivate *priv;
   GtkTreeModel *model;
   GtkTreeIter iter;
 #ifdef INCLUDE_FONT_ENTRIES
@@ -774,7 +774,7 @@ cmp_families (const void *a, const void *b)
 static void
 gtk_font_selection_show_available_fonts (GtkFontSelection *fontsel)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   GtkListStore *model;
   PangoFontFamily **families;
   PangoFontFamily *match_family = NULL;
@@ -871,7 +871,7 @@ font_description_style_equal (const PangoFontDescription *a,
 static void
 gtk_font_selection_show_available_styles (GtkFontSelection *fontsel)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   gint n_faces, i;
   PangoFontFace **faces;
   PangoFontDescription *old_desc;
@@ -947,7 +947,7 @@ static void
 gtk_font_selection_select_best_style (GtkFontSelection *fontsel,
                                      gboolean          use_first)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   GtkTreeIter iter;
   GtkTreeModel *model;
 
@@ -990,7 +990,7 @@ static void
 gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel,
                                         gboolean          first_time)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   gint i;
   GtkListStore *model;
   gchar buffer[128];
@@ -1067,7 +1067,7 @@ static void
 gtk_font_selection_set_size (GtkFontSelection *fontsel,
                             gint              new_size)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
 
   if (priv->size != new_size)
     {
@@ -1085,7 +1085,7 @@ gtk_font_selection_size_activate (GtkWidget   *w,
                                   gpointer     data)
 {
   GtkFontSelection *fontsel = GTK_FONT_SELECTION (data);
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   gint new_size;
   const gchar *text;
 
@@ -1104,7 +1104,7 @@ gtk_font_selection_size_focus_out (GtkWidget     *w,
                                   gpointer       data)
 {
   GtkFontSelection *fontsel = GTK_FONT_SELECTION (data);
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   gint new_size;
   const gchar *text;
 
@@ -1142,7 +1142,7 @@ gtk_font_selection_load_font (GtkFontSelection *fontsel)
 static PangoFontDescription *
 gtk_font_selection_get_font_description (GtkFontSelection *fontsel)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   PangoFontDescription *font_desc;
 
   if (priv->face)
@@ -1165,25 +1165,25 @@ gtk_font_selection_get_font_description (GtkFontSelection *fontsel)
 static void
 gtk_font_selection_update_preview (GtkFontSelection *fontsel)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   GtkRcStyle *rc_style;
   gint new_height;
-  GtkRequisition old_requisition;
+  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);
@@ -1206,8 +1206,8 @@ gtk_font_selection_update_preview (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
  */
@@ -1226,7 +1226,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
  */
@@ -1243,9 +1243,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
  */
@@ -1261,9 +1261,9 @@ gtk_font_selection_get_size_entry (GtkFontSelection *fontsel)
  * 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
  */
@@ -1278,10 +1278,10 @@ gtk_font_selection_get_size_list (GtkFontSelection *fontsel)
 /**
  * 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
  */
@@ -1296,13 +1296,13 @@ gtk_font_selection_get_preview_entry (GtkFontSelection *fontsel)
 /**
  * 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
  */
@@ -1317,13 +1317,13 @@ gtk_font_selection_get_family (GtkFontSelection *fontsel)
 /**
  * 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
  */
@@ -1338,10 +1338,10 @@ gtk_font_selection_get_face (GtkFontSelection *fontsel)
 /**
  * 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
@@ -1393,7 +1393,7 @@ gtk_font_selection_select_font_desc (GtkFontSelection      *fontsel,
                                     PangoFontFamily      **pfamily,
                                     PangoFontFace        **pface)
 {
-  GtkFontSelectionPriv *priv = fontsel->priv;
+  GtkFontSelectionPrivate *priv = fontsel->priv;
   PangoFontFamily *new_family = NULL;
   PangoFontFace *new_face = NULL;
   PangoFontFace *fallback_face = NULL;
@@ -1549,7 +1549,7 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
 G_CONST_RETURN gchar*
 gtk_font_selection_get_preview_text (GtkFontSelection *fontsel)
 {
-  GtkFontSelectionPriv *priv;
+  GtkFontSelectionPrivate *priv;
 
   g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
 
@@ -1571,7 +1571,7 @@ void
 gtk_font_selection_set_preview_text  (GtkFontSelection *fontsel,
                                      const gchar      *text)
 {
-  GtkFontSelectionPriv *priv;
+  GtkFontSelectionPrivate *priv;
 
   g_return_if_fail (GTK_IS_FONT_SELECTION (fontsel));
   g_return_if_fail (text != NULL);
@@ -1600,25 +1600,24 @@ static GtkBuildableIface *parent_buildable_iface;
 static void
 gtk_font_selection_dialog_class_init (GtkFontSelectionDialogClass *klass)
 {
-  g_type_class_add_private (klass, sizeof (GtkFontSelectionDialogPriv));
+  g_type_class_add_private (klass, sizeof (GtkFontSelectionDialogPrivate));
 }
 
 static void
 gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
 {
-  GtkFontSelectionDialogPriv *priv;
+  GtkFontSelectionDialogPrivate *priv;
   GtkDialog *dialog = GTK_DIALOG (fontseldiag);
   GtkWidget *action_area, *content_area;
 
   fontseldiag->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontseldiag,
                                                    GTK_TYPE_FONT_SELECTION_DIALOG,
-                                                   GtkFontSelectionDialogPriv);
+                                                   GtkFontSelectionDialogPrivate);
   priv = fontseldiag->priv;
 
   content_area = gtk_dialog_get_content_area (dialog);
   action_area = gtk_dialog_get_action_area (dialog);
 
-  gtk_dialog_set_has_separator (dialog, FALSE);
   gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
   gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
   gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
@@ -1660,8 +1659,6 @@ gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
                         _("Font Selection"));
 
   gtk_widget_pop_composite_child ();
-
-  _gtk_dialog_set_ignore_separator (dialog, TRUE);
 }
 
 /**
@@ -1687,11 +1684,11 @@ gtk_font_selection_dialog_new (const gchar *title)
 
 /**
  * gtk_font_selection_dialog_get_font_selection:
- * @colorsel: a #GtkFontSelectionDialog
+ * @fsd: a #GtkFontSelectionDialog
  *
  * Retrieves the #GtkFontSelection widget embedded in the dialog.
  *
- * Returns: the embedded #GtkFontSelection
+ * Returns: (transfer none): the embedded #GtkFontSelection
  *
  * Since: 2.22
  **/
@@ -1710,7 +1707,8 @@ gtk_font_selection_dialog_get_font_selection (GtkFontSelectionDialog *fsd)
  *
  * Gets the 'OK' button.
  *
- * Return value: the #GtkWidget used in the dialog for the 'OK' button.
+ * Return value: (transfer none): the #GtkWidget used in the dialog
+ *     for the 'OK' button.
  *
  * Since: 2.14
  */
@@ -1728,7 +1726,8 @@ gtk_font_selection_dialog_get_ok_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
  */
@@ -1752,7 +1751,7 @@ gtk_font_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
                                                        GtkBuilder   *builder,
                                                        const gchar  *childname)
 {
-  GtkFontSelectionDialogPriv *priv;
+  GtkFontSelectionDialogPrivate *priv;
 
   priv = GTK_FONT_SELECTION_DIALOG (buildable)->priv;
 
@@ -1787,7 +1786,7 @@ gtk_font_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
 gchar*
 gtk_font_selection_dialog_get_font_name (GtkFontSelectionDialog *fsd)
 {
-  GtkFontSelectionDialogPriv *priv;
+  GtkFontSelectionDialogPrivate *priv;
 
   g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
 
@@ -1810,7 +1809,7 @@ gboolean
 gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd,
                                         const gchar            *fontname)
 {
-  GtkFontSelectionDialogPriv *priv;
+  GtkFontSelectionDialogPrivate *priv;
 
   g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), FALSE);
   g_return_val_if_fail (fontname, FALSE);
@@ -1833,7 +1832,7 @@ gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd,
 G_CONST_RETURN gchar*
 gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd)
 {
-  GtkFontSelectionDialogPriv *priv;
+  GtkFontSelectionDialogPrivate *priv;
 
   g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
 
@@ -1853,7 +1852,7 @@ void
 gtk_font_selection_dialog_set_preview_text (GtkFontSelectionDialog *fsd,
                                            const gchar            *text)
 {
-  GtkFontSelectionDialogPriv *priv;
+  GtkFontSelectionDialogPrivate *priv;
 
   g_return_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd));
   g_return_if_fail (text != NULL);