Setting the font for Gtk::Button
- From: "John Emmas" <johne53 tiscali co uk>
- To: <gtk-app-devel-list gnome org>
- Subject: Setting the font for Gtk::Button
- Date: Thu, 6 May 2010 09:04:02 +0000 (GMT Standard Time)
Using gtkmm, I've written a small test app whose GUI contains three widgets.
The first is a Gtk::Button, the second is a Gtk::FontButton and the third
is a Gtk::ProgressBar. The font button itself has the style 'set_use_font()'
(i.e. it always displays its button text in whatever font I select). But I
want the other two widgets to use the selected font also - so I wrote this
little function to capture the "font_set" signal and update the other
widgets, like so:-
void MainWindow::on_font_changed ()
{
PangoFontDescription* pfd;
Pango::FontDescription* new_font;
// When the font button is used to select a new font, update the
// other widgets (the font button updates itself automatically).
Glib::ustring fname = m_pFontButton->get_font_name();
if (pfd = pango_font_description_from_string (fname.c_str()))
{
if (new_font = new Pango::FontDescription (pfd, true))
{
m_pProgress->modify_font (*new_font); // This succeeds
m_pButton->modify_font (*new_font); // This doesn't !
delete new_font;
}
}
}
You can probably see that the progress bar's font gets successfully changed,
whereas the button's font doesn't (not even if I move the main window, or
drag something else across it to force a re-draw). I've tried building this
app under Linux (using gcc and gtk-x11) and I've also built it for Windows
(using MSVC++ and gtk-win32). I get the same result in both cases so I'm
guessing that I must have missed out a stage that's needed to update the
button.
Should I have called something else that would force the button to use the
new font?
John
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]