#!/usr/bin/perl

# archway - GNU Arch GUI, Copyright (C) 2004 Mikhael Goikhman, Enno Cramer
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

use 5.006;
use strict;
use warnings;

use Gtk2 -init;
use Glib qw(TRUE FALSE);

my $dialog = Gtk2::Dialog->new(
	'Please enter your ssh passphrase',
	undef,
	[ ],
	'gtk-cancel' => 'reject',
	'gtk-ok'     => 'accept',
);

my $label = Gtk2::Label->new;
my $entry = Gtk2::Entry->new;
my $hbox = Gtk2::HBox->new;

$label->set_markup('<b>Password or passphrase: </b>');
$entry->set_visibility(FALSE);
$entry->set_activates_default(TRUE);
$hbox->pack_start($label, FALSE, FALSE, 0);
$hbox->pack_start($entry, TRUE, TRUE, 0);

my $text = Gtk2::Label->new;
$text->set_markup(<<END);

Please consider installing a real ssh-askpass
program, or using public key authentication.
END

$dialog->vbox->pack_start($hbox, FALSE, FALSE, 0);
$dialog->vbox->pack_start($text, FALSE, FALSE, 0);
$dialog->set_resizable(FALSE);
$dialog->set_default_response('accept');
$dialog->show_all;

if ($dialog->run eq 'accept') {
	print $entry->get_text, "\n";
	exit 0;

} else {
	exit 1;
}
