Please help: How to embed a X window in a GTK window?
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); XMapWindow(display, win); XSelectInput(display, win, ExposureMask|ButtonPressMask); if((pid = fork()) 0 ) { perror(fork); exit(1); } else if(pid 0) { printf(parent\n); XReparentWindow(display,win,GDK_WINDOW_XID(gtkWin-window), 50,50); XMapWindow(display,GDK_WINDOW_XID(gtkWin-window)); gtk_widget_show(gtkWin); gtk_main(); } else { printf(child\n); while(1) { XNextEvent(display, e); if(e.type==Expose e.xexpose.count1) { XDrawString(display, win, gc, 10, 10, Hello World!, 12); } else if(e.type==ButtonPress) { XCloseDisplay(display); break; } else { } } } return 0; } Thanks Regards, Kay ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
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
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
Re: 答复: Please help: How to embed a X w indow in a GTK window?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ke Jin wrote: 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 Maybe that was the wrong code in gnome-mplayer. I think that was the code to embed gnome-mplayer into an X window. Sorry. 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 iEYEARECAAYFAkfKtrcACgkQ6w2kMH0L1dHjJQCggqFJkR9nB74T/4QgqjqBkEp7 4VEAni3bXrFPy0ZX9nKK3yZ7AOPEhKAf =kyac -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
答复: Please help: How to embed a X wind ow in a GTK window?
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
short-cut accelerators
Hi, Could someone show me how to create a shortcurt to a menuitem, using an accelerator group? on GTK 1.2* I used the code below. What is the equivalent in GTK 2.12? accel_group = gtk_accel_group_new (); gtk_accel_group_attach (accel_group, GTK_OBJECT (window)); gtk_widget_add_accelerator (menu_item, activate, accel_group, 'c', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); Carlos ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Fwd: high light/selection color from GTK
oops, not CCed the mailling list. -- Forwarded message -- From: Shixin Zeng [EMAIL PROTECTED] Date: Sun, Mar 2, 2008 at 8:13 PM Subject: Re: high light/selection color from GTK To: Steve Splonskowski [EMAIL PROTECTED] http://library.gnome.org/devel/gtk/2.8/GtkWidget.html#gtk-widget-get-style and http://library.gnome.org/devel/gtk/2.8/GtkStyle.html On Tue, Feb 26, 2008 at 5:20 PM, Steve Splonskowski [EMAIL PROTECTED] wrote: Hello, I would like to get the selection/high light color for the currently selected UI theme (as setup in the Appearance Preferences panel). Can someone point me to how I can get this color via GTK? thanks, steve ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list -- Best Regards Shixin Zeng -- Best Regards Shixin Zeng ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list