Can't get Gdk::Window from Gtk::Window



Hi all,

I'm just starting out with gtkmm (and GTK in general) and I'm trying to make one of these fancy semi-transparent windows. I have some example C code, but I'm trying to port it to C++ with gtkmm.

I'm stuck trying to figure out how to get a Gdk::Window from a Gtk::Window. The docs at http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1Widget.html reflect the C code and say I should do this:

gtk_widget_realize (window);
gdk_window_set_back_pixmap (window->window, <tt>0</tt>, <tt>false</tt>);
gtk_widget_show (window);

I'm guessing the C code (and HTML!) were included in the C++ docs by accident, but the best I can come up with as a C++ translation is this: (which is in a class descended from Gtk::Window)

  this->realize();
  gdk_window_set_back_pixmap(GTK_WIDGET(this->gobj())->window, 0,
    false);
  this->show();

Which looks horrible, and I don't even know if it works. I thought maybe I could use Gtk::Window::get_frame() to get a Gdk::Window instead, but that function always returns NULL, apparently because of the underlying windowing system.

At any rate, even if I could get a valid Gdk::Window object, the documentation at http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGdk_1_1Window.html says I should pass 0 as the first parameter to Gdk::Window::set_back_pixmap(), but this gives me a compile-time error, because the first parameter is not an integer (it's a const Glib::RefPtr<Pixmap>&)

Am I looking at the latest version of the documentation? Does anyone know how to make this work? There seems to be very little use of this in C++, all the example code I can find is in C.

Many thanks,
Adam.


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