Object Hierarchy:

Object hierarchy for FontButton


The FontButton 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

GtkFontButton has a single CSS node with name button and style class .font.


Example: FontButton:

public class Application : Gtk.Window {

public Application () {
// Prepare Gtk.Window:
this.title = "My Gtk.FontButton";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);

// The button:
Gtk.FontButton button = new Gtk.FontButton ();
this.add (button);

// Use the selected font & size to draw the button-label:
button.use_font = true;
button.use_size = true;

// Sets the title for the font chooser dialog:
button.set_title ("Pick your favourite font");

// Connect a signal:
button.font_set.connect (() => {
// Emitted when a font has been chosen:
unowned string name = button.get_font_name ();
print ("Selected font: %s\n", name);

public static int main (string[] args) {
Gtk.init (ref args);

Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;

valac --pkg gtk+-3.0 Gtk.FontButton.vala

Namespace: Gtk
Package: gtk+-3.0



Creation methods:



Inherited Members:

All known members inherited from class Gtk.Bin
All known members inherited from class Gtk.Widget
All known members inherited from interface Atk.Implementor