reparenting into another window

View: New views
2 Messages — Rating Filter:   Alert me  

reparenting into another window

by zentara-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: reparenting into another window

by muppet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jul 13, 2008, at 1:41 PM, zentara wrote:

> 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?

Hrm.  Embedding windows from other apps involves a bit of X11 black  
magic that isn't specific to perl (aside from the fact that little  
tidbits like gdk_window_add_filter() are not bound).  Did you look at  
GtkPlug and GtkSocket?  You might ask on #gtk+ or gtk-app-devel-list.


--
Leia/Lois:  Aren't you a little fat for a stormtrooper?
Luke/Chris: Well, stay here and rot, you stuck-up bitch.
   -- Family Guy, "Blue Harvest" (A "Star Wars" parody)

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
LightInTheBox - Buy quality products at wholesale price