1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * Massively updated for Pango by Owen Taylor, May 2000
5 * GtkFontSelection widget for Gtk+, by Damon Chaplin, May 1998.
6 * Based on the GnomeFontSelector widget, by Elliot Lee, but major changes.
7 * The GnomeFontSelector was derived from app/text_tool.c in the GIMP.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
26 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
27 * file for a list of people on the GTK+ Team. See the ChangeLog
28 * files for a list of changes. These files are distributed with
29 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
35 #include <glib/gprintf.h>
40 #include "gtkfontsel.h"
41 #include "gtkbutton.h"
42 #include "gtkcellrenderertext.h"
48 #include "gtkliststore.h"
52 #include "gtktreeselection.h"
53 #include "gtktreeview.h"
55 #include "gtkscrolledwindow.h"
57 #include "gtkaccessible.h"
58 #include "gtkbuildable.h"
59 #include "gtkprivate.h"
64 * @Short_description: A widget for selecting fonts
65 * @Title: GtkFontSelection
66 * @See_also: #GtkFontSelectionDialog
68 * The #GtkFontSelection widget lists the available fonts, styles and sizes,
69 * allowing the user to select a font.
70 * It is used in the #GtkFontSelectionDialog widget to provide a dialog box for
73 * To set the font which is initially selected, use
74 * gtk_font_selection_set_font_name().
76 * To get the selected font use gtk_font_selection_get_font_name().
78 * To change the text which is shown in the preview area, use
79 * gtk_font_selection_set_preview_text().
83 struct _GtkFontSelectionPrivate
85 GtkWidget *search_entry;
86 GtkWidget *family_face_list;
87 GtkWidget *size_slider;
92 PangoFontFamily *family;
96 struct _GtkFontSelectionDialogPrivate
100 GtkWidget *ok_button;
101 GtkWidget *apply_button;
102 GtkWidget *cancel_button;
106 /* We don't enable the font and style entries because they don't add
107 * much in terms of visible effect and have a weird effect on keynav.
108 * the Windows font selector has entries similarly positioned but they
109 * act in conjunction with the associated lists to form a single focus
112 #undef INCLUDE_FONT_ENTRIES
114 /* This is the default text shown in the preview entry, though the user
115 can set it. Remember that some fonts only have capital letters. */
116 #define PREVIEW_TEXT N_("abcdefghijk ABCDEFGHIJK")
118 #define DEFAULT_FONT_NAME "Sans 10"
120 /* This is the initial and maximum height of the preview entry (it expands
121 when large font sizes are selected). Initial height is also the minimum. */
122 #define INITIAL_PREVIEW_HEIGHT 44
123 #define MAX_PREVIEW_HEIGHT 300
125 /* These are the sizes of the font, style & size lists. */
126 #define FONT_LIST_HEIGHT 136
127 #define FONT_LIST_WIDTH 190
128 #define FONT_STYLE_LIST_WIDTH 170
129 #define FONT_SIZE_LIST_WIDTH 60
131 /* These are what we use as the standard font sizes, for the size list.
133 static const guint16 font_sizes[] = {
134 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28,
135 32, 36, 40, 48, 56, 64, 72
159 static void gtk_font_selection_set_property (GObject *object,
163 static void gtk_font_selection_get_property (GObject *object,
167 static void gtk_font_selection_finalize (GObject *object);
168 static void gtk_font_selection_screen_changed (GtkWidget *widget,
169 GdkScreen *previous_screen);
170 static void gtk_font_selection_style_updated (GtkWidget *widget);
172 static void gtk_font_selection_ref_family (GtkFontSelection *fontsel,
173 PangoFontFamily *family);
174 static void gtk_font_selection_ref_face (GtkFontSelection *fontsel,
175 PangoFontFace *face);
177 G_DEFINE_TYPE (GtkFontSelection, gtk_font_selection, GTK_TYPE_VBOX)
180 gtk_font_selection_class_init (GtkFontSelectionClass *klass)
182 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
183 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
185 gobject_class->finalize = gtk_font_selection_finalize;
186 gobject_class->set_property = gtk_font_selection_set_property;
187 gobject_class->get_property = gtk_font_selection_get_property;
189 widget_class->screen_changed = gtk_font_selection_screen_changed;
190 widget_class->style_updated = gtk_font_selection_style_updated;
192 g_object_class_install_property (gobject_class,
194 g_param_spec_string ("font-name",
196 P_("The string that represents this font"),
198 GTK_PARAM_READWRITE));
199 g_object_class_install_property (gobject_class,
201 g_param_spec_string ("preview-text",
203 P_("The text to display in order to demonstrate the selected font"),
205 GTK_PARAM_READWRITE));
207 g_type_class_add_private (klass, sizeof (GtkFontSelectionPrivate));
211 gtk_font_selection_set_property (GObject *object,
216 GtkFontSelection *fontsel;
218 fontsel = GTK_FONT_SELECTION (object);
223 gtk_font_selection_set_font_name (fontsel, g_value_get_string (value));
225 case PROP_PREVIEW_TEXT:
226 gtk_font_selection_set_preview_text (fontsel, g_value_get_string (value));
229 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
234 static void gtk_font_selection_get_property (GObject *object,
239 GtkFontSelection *fontsel;
241 fontsel = GTK_FONT_SELECTION (object);
246 g_value_take_string (value, gtk_font_selection_get_font_name (fontsel));
248 case PROP_PREVIEW_TEXT:
249 g_value_set_string (value, gtk_font_selection_get_preview_text (fontsel));
252 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
257 /* Handles key press events on the lists, so that we can trap Enter to
258 * activate the default button on our own.
261 list_row_activated (GtkWidget *widget)
263 GtkWidget *default_widget, *focus_widget;
266 window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget)));
267 if (!gtk_widget_is_toplevel (GTK_WIDGET (window)))
272 default_widget = gtk_window_get_default_widget (window);
273 focus_widget = gtk_window_get_focus (window);
275 if (widget != default_widget &&
276 !(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget))))
277 gtk_window_activate_default (window);
284 gtk_font_selection_init (GtkFontSelection *fontsel)
286 GtkFontSelectionPrivate *priv;
287 GtkWidget *scrolled_win;
289 GtkWidget *table, *label;
290 GtkWidget *font_label, *style_label;
293 GtkTreeViewColumn *column;
294 GList *focus_chain = NULL;
297 fontsel->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontsel,
298 GTK_TYPE_FONT_SELECTION,
299 GtkFontSelectionPrivate);
300 priv = fontsel->priv;
301 gtk_widget_push_composite_child ();
303 priv->search_entry = gtk_entry_new ();
304 priv->family_face_list = gtk_tree_view_new ();
305 priv->size_slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
307 font_sizes[(sizeof (font_sizes) /
308 sizeof (guint16)) - 1],
310 priv->size_spin = gtk_spin_button_new_with_range (font_sizes[0],
311 font_sizes[(sizeof (font_sizes) /
312 sizeof (guint16)) - 1],
315 gtk_box_pack_start (GTK_BOX (fontsel), priv->search_entry, FALSE, TRUE, 0);
317 priv->size = 12 * PANGO_SCALE;
321 gtk_widget_show_all (GTK_WIDGET (fontsel));
322 gtk_widget_hide (GTK_WIDGET (fontsel));
324 gtk_widget_pop_composite_child();
328 * gtk_font_selection_new:
330 * Creates a new #GtkFontSelection.
332 * Return value: a n ew #GtkFontSelection
335 gtk_font_selection_new (void)
337 GtkFontSelection *fontsel;
339 fontsel = g_object_new (GTK_TYPE_FONT_SELECTION, NULL);
341 return GTK_WIDGET (fontsel);
345 gtk_font_selection_finalize (GObject *object)
347 GtkFontSelection *fontsel = GTK_FONT_SELECTION (object);
349 gtk_font_selection_ref_family (fontsel, NULL);
350 gtk_font_selection_ref_face (fontsel, NULL);
352 G_OBJECT_CLASS (gtk_font_selection_parent_class)->finalize (object);
356 gtk_font_selection_screen_changed (GtkWidget *widget,
357 GdkScreen *previous_screen)
363 gtk_font_selection_style_updated (GtkWidget *widget)
365 GTK_WIDGET_CLASS (gtk_font_selection_parent_class)->style_updated (widget);
371 gtk_font_selection_ref_family (GtkFontSelection *fontsel,
372 PangoFontFamily *family)
374 GtkFontSelectionPrivate *priv = fontsel->priv;
377 family = g_object_ref (family);
379 g_object_unref (priv->family);
380 priv->family = family;
385 gtk_font_selection_ref_face (GtkFontSelection *fontsel,
388 GtkFontSelectionPrivate *priv = fontsel->priv;
391 face = g_object_ref (face);
393 g_object_unref (priv->face);
398 /*****************************************************************************
399 * These functions are the main public interface for getting/setting the font.
400 *****************************************************************************/
403 * gtk_font_selection_get_family_list:
404 * @fontsel: a #GtkFontSelection
406 * This returns the #GtkTreeView that lists font families, for
407 * example, 'Sans', 'Serif', etc.
409 * Return value: (transfer none): A #GtkWidget that is part of @fontsel
414 gtk_font_selection_get_family_list (GtkFontSelection *fontsel)
416 g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
422 * gtk_font_selection_get_face_list:
423 * @fontsel: a #GtkFontSelection
425 * This returns the #GtkTreeView which lists all styles available for
426 * the selected font. For example, 'Regular', 'Bold', etc.
428 * Return value: (transfer none): A #GtkWidget that is part of @fontsel
433 gtk_font_selection_get_face_list (GtkFontSelection *fontsel)
435 g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
441 * gtk_font_selection_get_size_entry:
442 * @fontsel: a #GtkFontSelection
444 * This returns the #GtkEntry used to allow the user to edit the font
445 * number manually instead of selecting it from the list of font sizes.
447 * Return value: (transfer none): A #GtkWidget that is part of @fontsel
452 gtk_font_selection_get_size_entry (GtkFontSelection *fontsel)
454 g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
460 * gtk_font_selection_get_size_list:
461 * @fontsel: a #GtkFontSelection
463 * This returns the #GtkTreeeView used to list font sizes.
465 * Return value: (transfer none): A #GtkWidget that is part of @fontsel
470 gtk_font_selection_get_size_list (GtkFontSelection *fontsel)
472 g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
478 * gtk_font_selection_get_preview_entry:
479 * @fontsel: a #GtkFontSelection
481 * This returns the #GtkEntry used to display the font as a preview.
483 * Return value: (transfer none): A #GtkWidget that is part of @fontsel
488 gtk_font_selection_get_preview_entry (GtkFontSelection *fontsel)
490 g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
496 * gtk_font_selection_get_family:
497 * @fontsel: a #GtkFontSelection
499 * Gets the #PangoFontFamily representing the selected font family.
501 * Return value: (transfer none): A #PangoFontFamily representing the
502 * selected font family. Font families are a collection of font
503 * faces. The returned object is owned by @fontsel and must not
504 * be modified or freed.
509 gtk_font_selection_get_family (GtkFontSelection *fontsel)
511 g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
517 * gtk_font_selection_get_face:
518 * @fontsel: a #GtkFontSelection
520 * Gets the #PangoFontFace representing the selected font group
521 * details (i.e. family, slant, weight, width, etc).
523 * Return value: (transfer none): A #PangoFontFace representing the
524 * selected font group details. The returned object is owned by
525 * @fontsel and must not be modified or freed.
530 gtk_font_selection_get_face (GtkFontSelection *fontsel)
532 g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
538 * gtk_font_selection_get_size:
539 * @fontsel: a #GtkFontSelection
541 * The selected font size.
543 * Return value: A n integer representing the selected font size,
544 * or -1 if no font size is selected.
549 gtk_font_selection_get_size (GtkFontSelection *fontsel)
551 g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), -1);
557 * gtk_font_selection_get_font_name:
558 * @fontsel: a #GtkFontSelection
560 * Gets the currently-selected font name.
562 * Note that this can be a different string than what you set with
563 * gtk_font_selection_set_font_name(), as the font selection widget may
564 * normalize font names and thus return a string with a different structure.
565 * For example, "Helvetica Italic Bold 12" could be normalized to
566 * "Helvetica Bold Italic 12". Use pango_font_description_equal()
567 * if you want to compare two font descriptions.
569 * Return value: A string with the name of the current font, or %NULL if
570 * no font is selected. You must free this string with g_free().
573 gtk_font_selection_get_font_name (GtkFontSelection *fontsel)
578 /* This sets the current font, then selecting the appropriate list rows. */
581 * gtk_font_selection_set_font_name:
582 * @fontsel: a #GtkFontSelection
583 * @fontname: a font name like "Helvetica 12" or "Times Bold 18"
585 * Sets the currently-selected font.
587 * Note that the @fontsel needs to know the screen in which it will appear
588 * for this to work; this can be guaranteed by simply making sure that the
589 * @fontsel is inserted in a toplevel window before you call this function.
591 * Return value: %TRUE if the font could be set successfully; %FALSE if no
592 * such font exists or if the @fontsel doesn't belong to a particular
596 gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
597 const gchar *fontname)
599 PangoFontFamily *family = NULL;
600 PangoFontFace *face = NULL;
601 PangoFontDescription *new_desc;
603 g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), FALSE);
609 * gtk_font_selection_get_preview_text:
610 * @fontsel: a #GtkFontSelection
612 * Gets the text displayed in the preview area.
614 * Return value: the text displayed in the preview area.
615 * This string is owned by the widget and should not be
618 G_CONST_RETURN gchar*
619 gtk_font_selection_get_preview_text (GtkFontSelection *fontsel)
626 * gtk_font_selection_set_preview_text:
627 * @fontsel: a #GtkFontSelection
628 * @text: the text to display in the preview area
630 * Sets the text displayed in the preview area.
631 * The @text is used to show how the selected font looks.
634 gtk_font_selection_set_preview_text (GtkFontSelection *fontsel,
637 GtkFontSelectionPrivate *priv;
639 g_return_if_fail (GTK_IS_FONT_SELECTION (fontsel));
640 g_return_if_fail (text != NULL);
642 priv = fontsel->priv;
647 * SECTION:gtkfontseldlg
648 * @Short_description: A dialog box for selecting fonts
649 * @Title: GtkFontSelectionDialog
650 * @See_also: #GtkFontSelection, #GtkDialog
652 * The #GtkFontSelectionDialog widget is a dialog box for selecting a font.
654 * To set the font which is initially selected, use
655 * gtk_font_selection_dialog_set_font_name().
657 * To get the selected font use gtk_font_selection_dialog_get_font_name().
659 * To change the text which is shown in the preview area, use
660 * gtk_font_selection_dialog_set_preview_text().
662 * <refsect2 id="GtkFontSelectionDialog-BUILDER-UI">
663 * <title>GtkFontSelectionDialog as GtkBuildable</title>
664 * The GtkFontSelectionDialog implementation of the GtkBuildable interface
665 * exposes the embedded #GtkFontSelection as internal child with the
666 * name "font_selection". It also exposes the buttons with the names
667 * "ok_button", "cancel_button" and "apply_button".
671 static void gtk_font_selection_dialog_buildable_interface_init (GtkBuildableIface *iface);
672 static GObject * gtk_font_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
674 const gchar *childname);
676 G_DEFINE_TYPE_WITH_CODE (GtkFontSelectionDialog, gtk_font_selection_dialog,
678 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
679 gtk_font_selection_dialog_buildable_interface_init))
681 static GtkBuildableIface *parent_buildable_iface;
684 gtk_font_selection_dialog_class_init (GtkFontSelectionDialogClass *klass)
686 g_type_class_add_private (klass, sizeof (GtkFontSelectionDialogPrivate));
690 gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
692 GtkFontSelectionDialogPrivate *priv;
693 GtkDialog *dialog = GTK_DIALOG (fontseldiag);
694 GtkWidget *action_area, *content_area;
696 fontseldiag->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontseldiag,
697 GTK_TYPE_FONT_SELECTION_DIALOG,
698 GtkFontSelectionDialogPrivate);
699 priv = fontseldiag->priv;
701 content_area = gtk_dialog_get_content_area (dialog);
702 action_area = gtk_dialog_get_action_area (dialog);
704 gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
705 gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
706 gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
707 gtk_box_set_spacing (GTK_BOX (action_area), 6);
709 gtk_widget_push_composite_child ();
711 gtk_window_set_resizable (GTK_WINDOW (fontseldiag), TRUE);
713 /* Create the content area */
714 priv->fontsel = gtk_font_selection_new ();
715 gtk_container_set_border_width (GTK_CONTAINER (priv->fontsel), 5);
716 gtk_widget_show (priv->fontsel);
717 gtk_box_pack_start (GTK_BOX (content_area),
718 priv->fontsel, TRUE, TRUE, 0);
720 /* Create the action area */
721 priv->cancel_button = gtk_dialog_add_button (dialog,
723 GTK_RESPONSE_CANCEL);
725 priv->apply_button = gtk_dialog_add_button (dialog,
728 gtk_widget_hide (priv->apply_button);
730 priv->ok_button = gtk_dialog_add_button (dialog,
733 gtk_widget_grab_default (priv->ok_button);
735 gtk_dialog_set_alternative_button_order (GTK_DIALOG (fontseldiag),
741 gtk_window_set_title (GTK_WINDOW (fontseldiag),
742 _("Font Selection"));
744 gtk_widget_pop_composite_child ();
748 * gtk_font_selection_dialog_new:
749 * @title: the title of the dialog window
751 * Creates a new #GtkFontSelectionDialog.
753 * Return value: a new #GtkFontSelectionDialog
756 gtk_font_selection_dialog_new (const gchar *title)
758 GtkFontSelectionDialog *fontseldiag;
760 fontseldiag = g_object_new (GTK_TYPE_FONT_SELECTION_DIALOG, NULL);
763 gtk_window_set_title (GTK_WINDOW (fontseldiag), title);
765 return GTK_WIDGET (fontseldiag);
769 * gtk_font_selection_dialog_get_font_selection:
770 * @fsd: a #GtkFontSelectionDialog
772 * Retrieves the #GtkFontSelection widget embedded in the dialog.
774 * Returns: (transfer none): the embedded #GtkFontSelection
779 gtk_font_selection_dialog_get_font_selection (GtkFontSelectionDialog *fsd)
781 g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
783 return fsd->priv->fontsel;
788 * gtk_font_selection_dialog_get_ok_button:
789 * @fsd: a #GtkFontSelectionDialog
791 * Gets the 'OK' button.
793 * Return value: (transfer none): the #GtkWidget used in the dialog
794 * for the 'OK' button.
799 gtk_font_selection_dialog_get_ok_button (GtkFontSelectionDialog *fsd)
801 g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
803 return fsd->priv->ok_button;
807 * gtk_font_selection_dialog_get_cancel_button:
808 * @fsd: a #GtkFontSelectionDialog
810 * Gets the 'Cancel' button.
812 * Return value: (transfer none): the #GtkWidget used in the dialog
813 * for the 'Cancel' button.
818 gtk_font_selection_dialog_get_cancel_button (GtkFontSelectionDialog *fsd)
820 g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
822 return fsd->priv->cancel_button;
826 gtk_font_selection_dialog_buildable_interface_init (GtkBuildableIface *iface)
828 parent_buildable_iface = g_type_interface_peek_parent (iface);
829 iface->get_internal_child = gtk_font_selection_dialog_buildable_get_internal_child;
833 gtk_font_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
835 const gchar *childname)
837 GtkFontSelectionDialogPrivate *priv;
839 priv = GTK_FONT_SELECTION_DIALOG (buildable)->priv;
841 if (g_strcmp0 (childname, "ok_button") == 0)
842 return G_OBJECT (priv->ok_button);
843 else if (g_strcmp0 (childname, "cancel_button") == 0)
844 return G_OBJECT (priv->cancel_button);
845 else if (g_strcmp0 (childname, "apply_button") == 0)
846 return G_OBJECT (priv->apply_button);
847 else if (g_strcmp0 (childname, "font_selection") == 0)
848 return G_OBJECT (priv->fontsel);
850 return parent_buildable_iface->get_internal_child (buildable, builder, childname);
854 * gtk_font_selection_dialog_get_font_name:
855 * @fsd: a #GtkFontSelectionDialog
857 * Gets the currently-selected font name.
859 * Note that this can be a different string than what you set with
860 * gtk_font_selection_dialog_set_font_name(), as the font selection widget
861 * may normalize font names and thus return a string with a different
862 * structure. For example, "Helvetica Italic Bold 12" could be normalized
863 * to "Helvetica Bold Italic 12". Use pango_font_description_equal()
864 * if you want to compare two font descriptions.
866 * Return value: A string with the name of the current font, or %NULL if no
867 * font is selected. You must free this string with g_free().
870 gtk_font_selection_dialog_get_font_name (GtkFontSelectionDialog *fsd)
872 GtkFontSelectionDialogPrivate *priv;
874 g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
878 return gtk_font_selection_get_font_name (GTK_FONT_SELECTION (priv->fontsel));
882 * gtk_font_selection_dialog_set_font_name:
883 * @fsd: a #GtkFontSelectionDialog
884 * @fontname: a font name like "Helvetica 12" or "Times Bold 18"
886 * Sets the currently selected font.
888 * Return value: %TRUE if the font selected in @fsd is now the
889 * @fontname specified, %FALSE otherwise.
892 gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd,
893 const gchar *fontname)
895 GtkFontSelectionDialogPrivate *priv;
897 g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), FALSE);
898 g_return_val_if_fail (fontname, FALSE);
902 return gtk_font_selection_set_font_name (GTK_FONT_SELECTION (priv->fontsel), fontname);
906 * gtk_font_selection_dialog_get_preview_text:
907 * @fsd: a #GtkFontSelectionDialog
909 * Gets the text displayed in the preview area.
911 * Return value: the text displayed in the preview area.
912 * This string is owned by the widget and should not be
915 G_CONST_RETURN gchar*
916 gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd)
918 GtkFontSelectionDialogPrivate *priv;
920 g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
924 return gtk_font_selection_get_preview_text (GTK_FONT_SELECTION (priv->fontsel));
928 * gtk_font_selection_dialog_set_preview_text:
929 * @fsd: a #GtkFontSelectionDialog
930 * @text: the text to display in the preview area
932 * Sets the text displayed in the preview area.
935 gtk_font_selection_dialog_set_preview_text (GtkFontSelectionDialog *fsd,
938 GtkFontSelectionDialogPrivate *priv;
940 g_return_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd));
941 g_return_if_fail (text != NULL);
945 gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (priv->fontsel), text);