PerBeatus wrote:
> Hi.
>
> Simple question. Why it compiles ok, and at run prints "segmentation
> fault" ?
>
> Gtk::Main main(argc, argv);
>
> Gtk::Window w;
>
> Gdk::Color c_red;
> c_red.set_red(65535);
>
> Glib::RefPtr<Gdk::Window> gdk_w = w.get_frame();
> gdk_w->set_background(c_red);
I don't think Gtk::Window::get_frame() does what you're expecting. It actually
only returns a valid Gdk::Window when GTK is providing its own window frames*,
which on most platforms (X, Windows, etc) isn't the case, given window frames
are provided by a separate window manager process or the OS, so it isn't really
useful for GTK to give programs access to them. Instead get_frame() returns a
Glib::RefPtr<Gdk::Window> containing NULL, hence your segfault.
By the way, not everybody likes red. ;) If you want to draw attention to your
window, try Gtk::Window::set_urgency_hint(). Or possibly you were just looking
for:
w.modify_bg(Gtk::STATE_NORMAL, Gdk::Color("red"));
[*] I think GTK only does this with DirectFB, which doesn't or didn't always
provide window management.
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list