:right-sidebar: True FontDialogButton =================================================================== .. currentmodule:: gi.repository.Gtk .. versionadded:: 4.10 .. class:: FontDialogButton(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget` The ``GtkFontDialogButton`` is wrapped around a :obj:`~gi.repository.Gtk.FontDialog` and allows to open a font chooser dialog to change the font. .. image:: https://docs.gtk.org/gtk4/font-button.png It is suitable widget for selecting a font in a preference dialog. CSS nodes --------- .. code-block:: :dedent: fontbutton ╰── button.font ╰── [content] ``GtkFontDialogButton`` has a single CSS node with name fontbutton which contains a button node with the .font style class. Constructors ------------ .. rst-class:: interim-class .. class:: FontDialogButton :no-index: .. classmethod:: new(dialog: ~gi.repository.Gtk.FontDialog | None = None) -> ~gi.repository.Gtk.Widget Creates a new ``GtkFontDialogButton`` with the given ``GtkFontDialog``. You can pass ``NULL`` to this function and set a ``GtkFontDialog`` later. The button will be insensitive until that happens. .. versionadded:: 4.10 :param dialog: the ``GtkFontDialog`` to use Methods ------- .. rst-class:: interim-class .. class:: FontDialogButton :no-index: .. method:: get_dialog() -> ~gi.repository.Gtk.FontDialog | None Returns the ``GtkFontDialog`` of ``self``. .. versionadded:: 4.10 .. method:: get_font_desc() -> ~gi.repository.Pango.FontDescription | None Returns the font of the button. This function is what should be used to obtain the font that was chosen by the user. To get informed about changes, listen to "notify::font-desc". .. versionadded:: 4.10 .. method:: get_font_features() -> str | None Returns the font features of the button. This function is what should be used to obtain the font features that were chosen by the user. To get informed about changes, listen to "notify::font-features". Note that the button will only let users choose font features if :obj:`~gi.repository.Gtk.FontDialogButton.props.level` is set to ``GTK_FONT_LEVEL_FEATURES``. .. versionadded:: 4.10 .. method:: get_language() -> ~gi.repository.Pango.Language | None Returns the language that is used for font features. .. versionadded:: 4.10 .. method:: get_level() -> ~gi.repository.Gtk.FontLevel Returns the level of detail at which this dialog lets the user select fonts. .. versionadded:: 4.10 .. method:: get_use_font() -> bool Returns whether the selected font is used in the label. .. versionadded:: 4.10 .. method:: get_use_size() -> bool Returns whether the selected font size is used in the label. .. versionadded:: 4.10 .. method:: set_dialog(dialog: ~gi.repository.Gtk.FontDialog) -> None Sets a ``GtkFontDialog`` object to use for creating the font chooser dialog that is presented when the user clicks the button. .. versionadded:: 4.10 :param dialog: the new ``GtkFontDialog`` .. method:: set_font_desc(font_desc: ~gi.repository.Pango.FontDescription) -> None Sets the font of the button. .. versionadded:: 4.10 :param font_desc: the new font .. method:: set_font_features(font_features: str | None = None) -> None Sets the font features of the button. .. versionadded:: 4.10 :param font_features: the font features .. method:: set_language(language: ~gi.repository.Pango.Language | None = None) -> None Sets the language to use for font features. .. versionadded:: 4.10 :param language: the new language .. method:: set_level(level: ~gi.repository.Gtk.FontLevel) -> None Sets the level of detail at which this dialog lets the user select fonts. .. versionadded:: 4.10 :param level: the level of detail .. method:: set_use_font(use_font: bool) -> None If ``use_font`` is ``TRUE``, the font name will be written using the selected font. .. versionadded:: 4.10 :param use_font: If ``TRUE``, font name will be written using the chosen font .. method:: set_use_size(use_size: bool) -> None If ``use_size`` is ``TRUE``, the font name will be written using the selected font size. .. versionadded:: 4.10 :param use_size: If ``TRUE``, font name will be written using the chosen font size Properties ---------- .. rst-class:: interim-class .. class:: FontDialogButton :no-index: .. attribute:: props.dialog :type: ~gi.repository.Gtk.FontDialog The ``GtkFontDialog`` that contains parameters for the font chooser dialog. .. versionadded:: 4.10 .. attribute:: props.font_desc :type: ~gi.repository.Pango.FontDescription The selected font. This property can be set to give the button its initial font, and it will be updated to reflect the users choice in the font chooser dialog. Listen to ``notify::font-desc`` to get informed about changes to the buttons font. .. versionadded:: 4.10 .. attribute:: props.font_features :type: str The selected font features. This property will be updated to reflect the users choice in the font chooser dialog. Listen to ``notify::font-features`` to get informed about changes to the buttons font features. .. versionadded:: 4.10 .. attribute:: props.language :type: ~gi.repository.Pango.Language The selected language for font features. This property will be updated to reflect the users choice in the font chooser dialog. Listen to ``notify::language`` to get informed about changes to the buttons language. .. versionadded:: 4.10 .. attribute:: props.level :type: ~gi.repository.Gtk.FontLevel The level of detail for the font chooser dialog. .. attribute:: props.use_font :type: bool Whether the buttons label will be drawn in the selected font. .. attribute:: props.use_size :type: bool Whether the buttons label will use the selected font size. Signals ------- .. rst-class:: interim-class .. class:: FontDialogButton.signals :no-index: .. method:: activate() -> None Emitted when the font dialog button is activated. The ``::activate`` signal on ``GtkFontDialogButton`` is an action signal and emitting it causes the button to pop up its dialog. .. versionadded:: 4.14