#!/usr/bin/perl -w package FileOp; use strict; use Gtk; sub new { my ($self,@args) = @_ ; my $data; $data->{file} = ""; return bless $data,$self; } sub set_file { my ($self,$f) = @_ ; print "Set file $f \n"; $self->{file}=$f; } sub get_file { my ($self) = @_ ; return $self->{file}; } # action for open button sub open_file { my ($self,$file) = @_ ; # Create a new file selection widget my $file_dialog = new Gtk::FileSelection( "Ouvrir un fichier XML" ); my $filename; $file_dialog->signal_connect( "destroy", sub { Gtk->main_quit() } ); # Connect the ok_button to file_ok_sel function $file_dialog->ok_button->signal_connect( "clicked", sub { $filename=$file_dialog->get_filename(); $file_dialog->destroy(); set_file ($self,$filename); $file_dialog->destroy(); }, $self ); # Connect the cancel_button to destroy the widget $file_dialog->cancel_button->signal_connect( "clicked", sub { $filename=undef; $file_dialog->destroy(); } ); # Lets set the filename, as if this were a save dialog, and we are giving # a default filename $file_dialog->set_filename( $file ); $file_dialog->set_modal(1); $file_dialog->set_position('center'); $file_dialog->show(); Gtk->main(); } 1; package main; use Gtk; Gtk->init(); my $logfile; my $fileop=new FileOp(); $fileop->open_file($logfile); my $filename=$fileop->get_file(); print "Get $filename\n"; __END__ #It works fine, but you know that i have a problem ! When i call this class, like it: #create object my $fileop=new XMLProject::FileOp(); #open fileselection $fileop->open_file($logfile); # get file my $filename=$fileop->get_file(); # print output print "Get $filename\n"; It prints: $ Get $ Set file /home/greg/toto.xml "It's normal" we can say. It print "Set file..." after i press the "valid" button, so my question is how to determine when a window/file selection is destroy, or how to wait for it to return a value. Thanks for your help. -- Greg _______________________________________________ gtk-perl-list mailing list gtk-perl-list gnome org http://mail.gnome.org/mailman/listinfo/gtk-perl-list