GtkFontButton

GtkFontButton — A button to launch a font chooser dialog

Properties

gboolean modal Read / Write
char * title Read / Write
gboolean use-font Read / Write
gboolean use-size Read / Write

Signals

void font-set Run First

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkFontButton

Implemented Interfaces

GtkFontButton implements GtkAccessible, GtkBuildable, GtkConstraintTarget and GtkFontChooser.

Includes

#include <gtk/gtk.h>

Description

The GtkFontButton is a button which displays the currently selected font an allows to open a font chooser dialog to change the font. It is suitable widget for selecting a font in a preference dialog.

CSS nodes

1
2
3
fontbutton
╰── button.font
    ╰── [content]

GtkFontButton has a single CSS node with name fontbutton which contains a button node with the .font style class.

Functions

gtk_font_button_new ()

GtkWidget *
gtk_font_button_new (void);

Creates a new font picker widget.

Returns

a new font picker widget.


gtk_font_button_new_with_font ()

GtkWidget *
gtk_font_button_new_with_font (const char *fontname);

Creates a new font picker widget.

Parameters

fontname

Name of font to display in font chooser dialog

 

Returns

a new font picker widget.


gtk_font_button_set_use_font ()

void
gtk_font_button_set_use_font (GtkFontButton *font_button,
                              gboolean use_font);

If use_font is TRUE, the font name will be written using the selected font.

Parameters

font_button

a GtkFontButton

 

use_font

If TRUE, font name will be written using font chosen.

 

gtk_font_button_get_use_font ()

gboolean
gtk_font_button_get_use_font (GtkFontButton *font_button);

Returns whether the selected font is used in the label.

Parameters

font_button

a GtkFontButton

 

Returns

whether the selected font is used in the label.


gtk_font_button_set_use_size ()

void
gtk_font_button_set_use_size (GtkFontButton *font_button,
                              gboolean use_size);

If use_size is TRUE, the font name will be written using the selected size.

Parameters

font_button

a GtkFontButton

 

use_size

If TRUE, font name will be written using the selected size.

 

gtk_font_button_get_use_size ()

gboolean
gtk_font_button_get_use_size (GtkFontButton *font_button);

Returns whether the selected size is used in the label.

Parameters

font_button

a GtkFontButton

 

Returns

whether the selected size is used in the label.


gtk_font_button_set_title ()

void
gtk_font_button_set_title (GtkFontButton *font_button,
                           const char *title);

Sets the title for the font chooser dialog.

Parameters

font_button

a GtkFontButton

 

title

a string containing the font chooser dialog title

 

gtk_font_button_get_title ()

const char *
gtk_font_button_get_title (GtkFontButton *font_button);

Retrieves the title of the font chooser dialog.

Parameters

font_button

a GtkFontButton

 

Returns

an internal copy of the title string which must not be freed.


gtk_font_button_set_modal ()

void
gtk_font_button_set_modal (GtkFontButton *font_button,
                           gboolean modal);

Sets whether the dialog should be modal.

Parameters

font_button

a GtkFontButton

 

modal

TRUE to make the dialog modal

 

gtk_font_button_get_modal ()

gboolean
gtk_font_button_get_modal (GtkFontButton *font_button);

Gets whether the dialog is modal.

Parameters

font_button

a GtkFontButton

 

Returns

TRUE if the dialog is modal

Types and Values

GtkFontButton

typedef struct _GtkFontButton GtkFontButton;

Property Details

The “modal” property

  “modal”                    gboolean

Whether the dialog is modal.

Owner: GtkFontButton

Flags: Read / Write

Default value: TRUE


The “title” property

  “title”                    char *

The title of the font chooser dialog.

Owner: GtkFontButton

Flags: Read / Write

Default value: "Pick a Font"


The “use-font” property

  “use-font”                 gboolean

If this property is set to TRUE, the label will be drawn in the selected font.

Owner: GtkFontButton

Flags: Read / Write

Default value: FALSE


The “use-size” property

  “use-size”                 gboolean

If this property is set to TRUE, the label will be drawn with the selected font size.

Owner: GtkFontButton

Flags: Read / Write

Default value: FALSE

Signal Details

The “font-set” signal

void
user_function (GtkFontButton *widget,
               gpointer       user_data)

The ::font-set signal is emitted when the user selects a font. When handling this signal, use gtk_font_chooser_get_font() to find out which font was just selected.

Note that this signal is only emitted when the user changes the font. If you need to react to programmatic font changes as well, use the notify::font signal.

Parameters

widget

the object which received the signal.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First