Embedding a GTK widget in a non-GTK application



Is this (subject) possible?

I've had a look at gtk_plug_new and similar functions, but they all seem
to require a GDK window as a parent.

I've tried setting up a fake GDK window:

  GdkWindowPrivate *FakeGdkWindow=g_new(GdkWindowPrivate, 1);
  GdkWindow *window=(GdkWindow*)FakeGdkWindow;
  FakeGdkWindow->parent=NULL;
  FakeGdkWindow->xwindow=my_xwindow_id;
  FakeGdkWindow->xdisplay=my_xdisplay;
  FakeGdkWindow->x=my_x;
  FakeGdkWindow->y=my_y;
  FakeGdkWindow->width=my_width;
  FakeGdkWindow->height=my_height;
  FakeGdkWindow->resize_count=0;
  FakeGdkWindow->ref_count=1;
  FakeGdkWindow->window_type=GDK_WINDOW_FOREIGN;
  FakeGdkWindow->destroyed=FALSE;
  FakeGdkWindow->mapped=TRUE;
  FakeGdkWindow->guggaw_gravity=FALSE;
  FakeGdkWindow->extension_events=0;
  FakeGdkWindow->colormap=NULL;
  FakeGdkWindow->filters=NULL;
  FakeGdkWindow->children=NULL;
  window->user_data=NULL;
  gdk_window_ref(window);
  gdk_xid_table_insert(&FakeGdkWindow->xwindow, (gpointer)window);
  gtkWidget=gtk_plug_new(FakeGdkWindow->xwindow);

This didn't have the expected effect though (the widget and any widgets
using gtkWidget as container simply didn't display).

Any ideas what I'm doing wrong here?

[It's not a problem with the main loop, if I just run the same code with
gtkWidget=gtk_plug_new(0); it works as expected (but the Gtk widgets are
in a separate window, which I'd like to avoid)].

LLaP
bero





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