[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: How to add a GtkWidget to an existing X-Window Widget hierarchy?
- From: Kevin DeKorte <kdekorte yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: Re: How to add a GtkWidget to an existing X-Window Widget hierarchy?
- Date: Fri, 1 Apr 2005 15:42:28 -0700
On Friday 01 April 2005 03:19 pm, Marcel Ruff wrote:
> Hi Kevin,
>
> thank you for the feedback.
>
> But your code snippet fails in my case, see below:
>
> Kevin DeKorte wrote:
> > 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);
>
> The above line results in:
>
> Gdk-WARNING **: gdkdrawable-x11.c:970 drawable is not a pixmap or window
> Segmentation fault
>
> What could be the reason (x_window is a XtWindow(XmForm Widget), the same
> result when i try a XtWindow(XmDrawingArea Widget)).
>
Are you sure you are using it right...
I guess I might have missed one thing...
you have to have the gtkwidget shown.
gtk_widget_show(gtkwidget) for the XReparent to work
And the Window that comes into the SetWindow command from Mozilla is a
structure.
NPError nsPluginInstance::SetWindow(NPWindow * aWindow)
aWindow->window is the actual X window handle.
Look at the SetWindow method in mplayerplug-in. It has everything you need.
http://mplayerplug-in.sf.net
This might also come in handy
gtk_widget_set_size_request(gtkwidget, aWindow->width,
aWindow->height);
Something like this perhaps?
GtkWidget *gtkwidget;
gtkwidget = gtk_window_new(GTK_WINDOW_POPUP);
gtk_widget_set_size_request(gtkwidget, aWindow->width,
aWindow->height);
gtk_widget_show(gtkwidget);
XReparentWindow(GDK_WINDOW_XDISPLAY(gtkwidget->window),
GDK_WINDOW_XWINDOW(gtkwidget->window), x_window, 0,0);
Kevin
> thanks
> Marcel
>
> PS: I have posted a bug to bugzilla about the gtk_vbox_new():
> Bug 172348
> http://bugzilla.gnome.org
>
> > gtk_widget_map(gtkwidget);
> >
> >
> > Where "x_window" is a X window id.
> >
> > Kevin
> >
> > Visit: http://mplayerplug-in.sf.net
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > gtk-app-devel-list mailing list
> > gtk-app-devel-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]