答复: Please help: How to embed a X wind ow in a GTK window?

2008-03-03 Thread Ke Jin
Hi Bin,
  Thanks for the reply. I am new to GTK and could you please explain it in
more details?

Thanks,
Kay

-邮件原件-
发件人: Bin Chen [mailto:[EMAIL PROTECTED] 
发送时间: 2008年3月2日 7:33
收件人: Ke Jin
抄送: gtk-app-devel-list@gnome.org
主题: Re: Please help: How to embed a X window in a GTK window?

On 3/2/08, Ke Jin [EMAIL PROTECTED] wrote:
 Dear All,
 I am working on a project whose code was written in Xlib and now I
 need to develop a GUI for it. I want to use GTK so I wonder if I could
 embed the former xlib window into a GTK top-level window. I wrote a
 small test program as below but it doesn't work. Does anyone have any
 idea about how this is gonna work?

 #include string.h
 #include X11/Xlib.h
 #include X11/keysym.h
 #include gtk/gtk.h
 #include gdk/gdkx.h
 #include stdlib.h
 #include stdio.h
 #include sys/types.h

 void destroy (GtkWidget *widget, gpointer *data)
 {
 gtk_main_quit ();
 }



 int main(int argc, char* argv[])
 {
 Display* display = XOpenDisplay(NULL);
 int screen = DefaultScreen(display);
 int width = DisplayWidth(display, screen)/6;
 int height = DisplayHeight(display, screen)/6;
 GtkWidget *gtkWin;
 XEvent e;
 pid_t pid;
 Bool child = FALSE;
 int timer = 0;

 gtk_init (argc, argv);

 gtkWin = gtk_window_new(GTK_WINDOW_TOPLEVEL);

 gtk_signal_connect(GTK_OBJECT(gtkWin),
 destroy,GTK_SIGNAL_FUNC(destroy),NULL);

 gtk_widget_realize(gtkWin);

 Window win = XCreateSimpleWindow(display, RootWindow(display,
 screen),
 0, 0, width, height, 3, BlackPixel(display, screen),
 WhitePixel(display, screen));
 XStoreName(display, win, hello);
 GC gc = XCreateGC(display, win, 0, NULL);

I don't think this way can work. To embed a X window in Gtk window, I
think you must handle the redraw event of the X window and manually
copy the drawables to the Gtk+ window.


Bin

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

答复: Please help: How to embed a X wind ow in a GTK window?

2008-03-02 Thread Ke Jin
Hi Kevin,
  I have looked into Gtkplug, but the problem is that Gtkplug has to be the
toplevel window, which drives the question back to how to make a Gtkplug as
a parent window of an X window. I don't quite get your code, is it
reparenting a gtk window to a gdk now?

Thanks and Regards,
Ke

-邮件原件-
发件人: Kevin DeKorte [mailto:[EMAIL PROTECTED] 
发送时间: 2008年3月2日 8:38
收件人: Bin Chen; gtk-app-devel-list@gnome.org; [EMAIL PROTECTED]
主题: Re: Please help: How to embed a X window in a GTK window?

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Bin Chen wrote:
 On 3/2/08, Ke Jin [EMAIL PROTECTED] wrote:
 Dear All,
 I am working on a project whose code was written in Xlib and now I
 need to develop a GUI for it. I want to use GTK so I wonder if I could
 embed the former xlib window into a GTK top-level window. I wrote a
 small test program as below but it doesn't work. Does anyone have any
 idea about how this is gonna work?

Look into GtkPlug or something like this... where windowid is the Xid of
a window. And window is a gtk_window object

if (windowid != 0) {

window_container = gdk_window_foreign_new(windowid);
if (GTK_WIDGET_MAPPED(window))
gtk_widget_unmap(window);

gdk_window_reparent(window-window, window_container, 0, 0);

}

Kevin


- --
Get my public GnuPG key from
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0x7D0BD5D1
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.8 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkfKrZ0ACgkQ6w2kMH0L1dE+9QCfYB2HBMX3fWww08uxSMApon1y
kSYAnjqO2yHjDFrC/s94dfNSm/3aRfbO
=GZm/
-END PGP SIGNATURE-

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list