experimenting with embedding with windowid



Hi,
What I'm trying to do is embed an xterm(and possibly mc)
into a gtk2 window.

In Tk it is possible to do this, by creating windows in containers
in different widgets, then the xterm and it's app would transparently
function within the Tk window.

After searching thru the mail archives, I came up with something in
Gtk2, but it dosn't quite work.

In the code below, I can embed the xterm and mc, but it only goes into
the main Gtk2 window, and it responds to the mouse only, no keyboard
connection.

So there are 2 questions:
1. How can I connect the keyboard to the xterm?
2. Is there a container widget of some type, that will give
     an XWINDOW id independent of the parent window's id?
     So I can embed the xterm into just a portion of the main window?
     (Like the container in Tk)

#!/usr/bin/perl
use warnings;
use strict;
use Glib qw/TRUE FALSE/;
use Gtk2 '-init';

my $window = Gtk2::Window->new('toplevel');
$window->set_title('Embed test');
$window ->signal_connect( 'destroy' => \&delete_event );
$window->set_border_width(10);
$window->set_size_request(500,500);

my $vbox = Gtk2::VBox->new( FALSE, 6 );
$window->add($vbox);
$vbox->set_border_width(2);

my $hbox= Gtk2::HBox->new( FALSE, 6 );
$vbox->pack_end($hbox,FALSE,FALSE,0);
$hbox->set_border_width(2);

$vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0);

my $button = Gtk2::Button->new_from_stock('gtk-quit');
$hbox->pack_end( $button, FALSE, FALSE, 0 );
$button->signal_connect( clicked => \&delete_event );

my $button1 = Gtk2::Button->new('Get ID');
$hbox->pack_end( $button1, FALSE, FALSE, 0 );
$button1->signal_connect( clicked => \&get_id );

$window->show_all();
Gtk2->main;
#####################################
sub delete_event {
Gtk2->main_quit;
return FALSE;
}  

##########################################
sub get_id{
    my $gdkwindow = $window->window;
    print "gdkwin->$gdkwindow\n";    

    my $gdkwindow1 = $vbox->window;
    print "gdkvbox->$gdkwindow1\n";    
 
    my $xid = $gdkwindow->XWINDOW;
    print "xid->$xid\n";

    system("xterm -into $xid -e /usr/bin/mc &");

}




-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html



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