#!/usr/bin/perl -w
use Gtk;
use Gtk::GladeXML;
use Data::Dumper;
eval {
	require Gnome;
	init Gnome('sendmailcheck.pl', '1.0');
};
init Gtk if $@;
Gtk::GladeXML->init;

$g = new Gtk::GladeXML("sendmailcheck.glade");
$g->signal_autoconnect_from_package('main');
$w = $g->get_widget('app1');
$clist = $g->get_widget('clist1');

main Gtk;

### Callbacks and Stuff
sub gtk_main_quit {
	print "Exiting\n";
	main_quit Gtk;
}

sub gtk_widget_hide {
	shift->hide();
}

sub gtk_widget_show {
	my ($w) = shift;
	$w->show;
}

sub on_run_clicked {
	# just something to do here for now
	@hostlist = ("www.perl.com", "www.slashdot.org", 
		     "www.drudgereport.com");
	foreach $host(@hostlist) {
		open (PING, "ping -c 3 $host|");
		while (<PING>) {
			if (/max = (.*)/) {
				$stat = $1;
			}
		}
		close PING;
		@status = ($host, $stat);	
		$clist->append(@status);
	}
}
