Re: How to add a GtkWidget to an existing X-Window Widget hierarchy?



On Thursday 31 March 2005 12:21 pm, Marcel Ruff wrote:
Hi,

i'm running on Linux 2.6.8 with gtk-2 and gcc 3.3.4

I have an existing X-Window application (Motif)
to which i want to add a GtkWidget.

I have for example plain X:

  ----------------------------------------
  Widget w_form = ...
  guint32 xid = XtWindow(w_form);
  ----------------------------------------

To add a gtk+ VBOX child to the above w_form i'm trying now since hours
approaches like:

  ----------------------------------------
  ...
  gtk_init(&argc, &argv);

  Display *xdisplay = XtDisplay(w_form);
  GdkDisplay *gdkDisplay = gdk_x11_lookup_xdisplay(xdisplay);
  GdkWindow* gdkWindow = gdk_window_foreign_new_for_display(gdkDisplay,
xid);

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add(GTK_CONTAINER(gdkWindow), vbox);
  ----------------------------------------

with no success.
How can i expand my X-Window Widgets with GtkWidgets?

Thank you for some help,

Marcel

PS: In fact i want to embed mozilla into my X app using
the gtk_socket_new() and gtk_plug_new(xid) approach in
the same executable. Is this possible? Is there a more simple approach?
We had a first running approach with gtk_plug_new(xid)running
under gtk-1.2 but this embedding fails with gtk-2 for some unknown
reason (nothing is displayed without any error message).


Marcel,

I have the same issue in mplayerplug-in in that I cannot use a gtk_plug_new in 
gtk2 (although it works in gtk1). I worked around it with this code (many 
hours of bashing around to get something working, and it turns out to be 
simple). A GTK_WINDOW_POPUP is an undecorated window.

        GtkWidget *gtkwidget;

        gtkwidget = gtk_window_new(GTK_WINDOW_POPUP);

        XReparentWindow(GDK_WINDOW_XDISPLAY(gtkwidget->window),
                        GDK_WINDOW_XWINDOW(gtkwidget->window), x_window, 0,0);

        gtk_widget_map(gtkwidget);


        Where "x_window" is a X window id.

Kevin

Visit: http://mplayerplug-in.sf.net


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