# $Id: Import.pm,v 1.3 2001/02/03 16:22:54 muhri Exp $
# -*- perl -*-
package Pronto::Import;
use strict;
use SelfLoader;
1;
__DATA__
sub init_import_win {
 
 	my ($listwidget,$flag)=@_ ;
 	my ($fs_window);
 	$fs_window = new Gtk::FileSelection _("Choose MBOX file to import...");
     
     	if (defined $flag and $flag eq "recursive") {
         	$fs_window->set_title(_("Choose Directory to import ..."));
	 	$fs_window->file_list->set_sensitive(0);
	}

 	$fs_window->position(-mouse);
 	$fs_window->signal_connect("destroy", sub {$fs_window->destroy;});
 	$fs_window->signal_connect("delete_event" => \&Gtk::false);
 
        if (defined $flag and $flag eq "recursive") { 
              	$fs_window->ok_button->signal_connect("clicked", sub {
	        my $dir = $fs_window->get_filename;
	        $fs_window->destroy;
		opendir IMPORTDIR,$dir;
	        my @folderlist=grep !/^\.\.?$/, readdir(IMPORTDIR);
	        close IMPORTDIR;
	        foreach (@folderlist) { my $dirfile = "$_"; &main::import_from_mbox( undef, undef, undef, $main::conn, $dir, $dirfile); }
		});
	}
		
 	$fs_window->ok_button->signal_connect("clicked",
\&main::import_from_mbox, $fs_window, $listwidget, $main::conn);
 	$fs_window->cancel_button->signal_connect("clicked", sub {$fs_window->destroy;});
 	$fs_window->show;
 
 return 1;
}
