reparenting into another window



Hi,
Nothing to do on a hot summer Sunday than to pursue stupid
code tricks. :-)

What I want to do is emulate this Tk code, in Gtk2, but nothing works.
Start an xterm, get it's id with xwininfo, and feed it as argv[0] to the Tk
script.  The Tk window appears in the xterm's window.

##################################################
#!/usr/bin/perl
use warnings;
use strict;
use Tk;

# use xwininfo to get the window id of the target
# then pass it to this script as ARGV[0]

my $mw = MainWindow->new(-use => $ARGV[0] );
$mw ->overrideredirect(1);

my $l = $mw->Label(-text=>"foobar\nfoobar\nfoobar",
                   -background => 'yellow',

                        )->pack;
my $b = $mw->Button(-text=>'Exit', -command => sub{Tk::exit})->pack;
MainLoop;
__END__
##############################################

I've searched thru the Gtk2 docs and tried all the methods that
seem to apply, like set_parent_window, set_parent, reparent.

None seem to work. Can it be done with Gtk2
This is similar code, but dosn't work
#######################################
#!/usr/bin/perl
use warnings;
use strict;
use Gtk2 -init;

# use xwininfo to get the window id of the target
# then pass it to this script as ARGV[0]
# with Tk it will put it in an xterm

my $xid = shift;
my $gdkwindow = Gtk2::Gdk::Window->foreign_new(hex $xid); 

my $window = Gtk2::Window->new;

# dosn't work
#$window->set_parent($gdkwindow);
#$window->set_parent_window($gdkwindow);

$window->add( Gtk2::Label->new("I'm a banana!") );
$window->show_all;

$window->signal_connect(
    delete_event => sub {
           Gtk2->main_quit;
           return 0; 
         }
);

Gtk2->main;
__END__
########################################


Thanks for any clues,
zentara


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



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