As seen in the Gtk documentation here there is a method to set the visual of the Widget which seems to be missing from gtkmm (C++ wrapper).
While trying to port a Gtk application from C to C++ using gtkmm-3.0, quickly discovered that the set_visual() method is missing. Although there is a get_visual() that returns the visual of the widget.
The C code looks like this:
GdkScreen *screen = gtk_widget_get_screen(widget);
GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
if (visual == NULL)
visual = gdk_screen_get_system_visual(screen);
gtk_widget_set_visual(widget, visual);
Does anyone know how can i set the widget visual with a custom one?
If the C++ wrapper does not provide what you need, you can always get a pointer to the underlying C GObject
instance and work with it as you would in a typical GTK C application. Check out this method for Gtk::Widget
:
GtkWidget* Gtk::Widget::gobj()
So you can call this on your widget, get a C GtkWidget
pointer and call gtk_widget_set_visual
on it like you are doing in your question. Note that this solution works all across Gtkmm, which in my opinion is a really nice feature that other wrappers do not have.