3

My C application uses X11 calls to create and manage a window. I only want to use GTK3 for menus.

I create a window using Window wnd = XCreateWindow(...);

Now I want to use GTK to add menus to wnd.

GTK APIs such as gtk_container_add(GTK_CONTAINER(gtk_wnd), vbox) want a GtkWindow, which I do not have.

How do I accomplish this?

Ideally I'd like to get a X11 handle to work with GTK, potentially via a conversion. Alternatively, I'd also settle for getting the current window via some GTK API.

3
  • What do you mean by "add menus" ? Where do you want these menus to appear? Do you mean that you want to add a whole menu bar with drop-down menus? That can be done in GTK/X11 by creating a GTK window with a menu bar and a GtkEventBox that occupies the rest of the window. Then re-parent the X11 window so that it is a child of the GtkEventBox. It's a horrible job, however. Commented Aug 27, 2017 at 8:21
  • 1
    Yeah, just don't do this.
    – ptomato
    Commented Aug 28, 2017 at 5:38
  • There's no notion of current window in X11. If you want to create a top level window via GTK and then use it with X11 calls, use something like gdk_x11_drawable_get_xid(gtk_widget_get_window(widget)). Commented Aug 29, 2017 at 14:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.