MailFolder

 view release on metacpan or  search on metacpan

examples/xmailfolder.pl  view on Meta::CPAN

			   weight => 'medium');

my $foldersinfo;
my $foldersidx;
my $counter = 0;

my %Options = (
	       ShowAllHeaders => 0,
	       DefaultSignature => 'short',
	       DefaultComposeTemplate => 'NONE',
	       Debug => 0,
	      );
%fieldcolors = ();

@ignore_headers = ();

@folders = ();
foreach my $dir (qw(/var/spool/mail /usr/spool/mail /usr/mail)) {
  if (-e "$dir/$username") {
    @folders = "$dir/$username";
    last;
  }
}

%signatures = (
	       NONE => '',
	       long => '~/.signature',
	      );

%composetemplates = (
		    NONE => ''
		    );
###############################################################################
do "$homedir/.xmailfolderrc"
  if (-e "$homedir/.xmailfolderrc");

{
  my $i = 0;
  foreach my $folder (@folders) {
    next if defined($foldersinfo->{$folder});
    $foldersinfo->{$folder}{Status} = 'closed';
    $foldersinfo->{$folder}{Idx} = $i;
    $foldersidx->{$i} = $folder;
    $i++;
  }
}
###############################################################################
my $menu = $top->Menubar;
my $file = $menu->Menubutton(-text => "~File");
#------------------------------------------------------------------------------
$file->command(-label => "~Quit", -command => \&CleanQuit);
$file->pack(-side => "left");
$top->protocol('WM_DELETE_WINDOW' => \&CleanQuit);
#------------------------------------------------------------------------------
my $options = $menu->Menubutton(-text => '~Options');
$options->checkbutton(-label => 'Show All Headers',
		      -variable => \$Options{ShowAllHeaders});
$options->separator;
$options->command(-label => 'Preferences...',
		  -command => sub { Preferences($options) });
$options->cascade(-label => 'UI Preferences');
$options->separator;
$options->command(-label => 'Save Options (stub)');
$options->command(-label => 'Restore Options (stub)');
$options->pack(-side => 'left');
my $uim = $options->cget('-menu')->Menu;
$uim->checkbutton(-label => 'Strict Motif',
		  -variable => 'Tk::strictMotif');
$options->menu->entryconfigure('UI Preferences', -menu => $uim);
#------------------------------------------------------------------------------
my $help = $menu->Menubutton(-text => "~Help");
$help->pack(-side => 'right');
$help->command(-label => 'On Context');
$help->command(-label => 'On Help');
$help->command(-label => 'On Window');
$help->command(-label => 'On Keys');
$help->command(-label => 'On Version', -command => [\&ShowVersion, $top]);
###############################################################################
sub Preferences {
  my $top = shift;
  my $db = $top->DialogBox(-title => 'Preferences',
			   -buttons => ['OK', 'Cancel']);
  my $n = $db->add('NoteBook', -ipadx => 6, -ipady => 6);
  my $fl = $n->add('folderlist', -label => 'FolderList');
  my $fv = $n->add('folderview', -label => 'FolderView');
  my $m = $n->add('messages', -label => 'Messages');

  $fv->Checkbutton(-text => 'Automove on Delete')->pack;
  $m->Checkbutton(-text => 'Show All Headers')->pack;

  $n->pack(-expand => 'yes',
	  -fill => 'both',
	  -padx => 5, -pady => 5,
	  -side => 'top');
  my $button = $db->Show;
  # do actual option update processing here...
}
###############################################################################
my $list = createMyListbox($top,
			     -scrollbars => 'sw',
			     -relief => 'sunken',
			     -width => 80, -height => 5,
			     -setgrid => 'yes',
			     -selectmode => 'browse',
			     -font => $fixedfont,
			    );
$list->pack(-side => 'left', -fill => 'both', -expand => 'yes');
PopulateFolderListSummary();
$list->bind('<Double-ButtonRelease-1>' => sub {
	      OpenFolder($foldersidx->{$list->index('active')});
	    });
$list->bind('<Return>' => sub {
	      OpenFolder($foldersidx->{$list->index('active')});
	    });
$list->bind('<KeyPress-m>' => sub { Compose(); });
$list->bind('<KeyPress-q>' => sub { CleanQuit(); });
$list->bind('<KeyPress-g>' => sub { PopulateFolderListSummary(); });
$list->bind('<Control-l>' => sub { PopulateFolderListSummary(); });
$list->Subwidget('listbox')->focus;
$list->Subwidget('yscrollbar')->configure(-takefocus => 0);
$list->Subwidget('xscrollbar')->configure(-takefocus => 0);



( run in 0.816 second using v1.01-cache-2.11-cpan-df04353d9ac )