How to modify the style of a gtkmm application?

Hi all,
I want to modify the default style (enlarge the font) of a gtkmm application (gtkmm 2, not 3). I was expecting that if I modified the style of the toplevel window, the modification would be propagated down to its children. But that doesn't seem to happen.

See the attached example: calling modify_font on a label does indeed produce the desired effect. Calling it on the main window, however, does nothing -- only the first label's font is enlarged.

Can you please tell me how to change the style of all an application's widgets at once?

Thank you
#include <gtkmm.h>

class MainWindow : public Gtk::Window
  Gtk::HBox hbox;
  Gtk::Label label1, label2;

  hbox.pack_start(label1, Gtk::PACK_SHRINK);
  label1.set_label(" Label 1 ");
  hbox.pack_start(label2, Gtk::PACK_SHRINK);
  label2.set_label(" Label 2 ");


  // try changing font size
  Pango::FontDescription fd = get_pango_context()->get_font_description();
  fd.set_size(fd.get_size() * 2);
  label1.modify_font(fd); // change label style directly: ok
  modify_font(fd); // change parent window style: doesn't propagate to children

int main(int argc, char *argv[])
  Gtk::Main kit(argc, argv);
  MainWindow window;

  return 0;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]