The FontSelectionDialog allows the user to choose a
font.
File: examplewindow.h
#ifndef GTKMM_EXAMPLEWINDOW_H
#define GTKMM_EXAMPLEWINDOW_H
#include <gtkmm.h>
class ExampleWindow : public Gtk::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
protected:
//Signal handlers:
virtual void on_button_font_set();
//Child widgets:
Gtk::FontButton m_Button;
};
#endif //GTKMM_EXAMPLEWINDOW_H
File: main.cc
#include <gtkmm/main.h>
#include "examplewindow.h"
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
ExampleWindow window;
Gtk::Main::run(window); //Shows the window and returns when it is closed.
return 0;
}
File: examplewindow.cc
#include "examplewindow.h"
#include <iostream>
ExampleWindow::ExampleWindow()
: m_Button("sans")
{
set_title("Gtk::FontSelectionDialog example");
add(m_Button);
m_Button.signal_font_set().connect( sigc::mem_fun(*this, &ExampleWindow::on_button_font_set) );
show_all_children();
}
ExampleWindow::~ExampleWindow()
{
}
void ExampleWindow::on_button_font_set()
{
Glib::ustring font_name = m_Button.get_font_name();
std::cout << "Font chosen: " << font_name << std::endl;
}