From: Daniel Kahn Gillmor Date: Tue, 12 Oct 2010 03:36:10 +0000 (-0400) Subject: Make the marginal UI conditional on the presence of the Gtk2 perl module (closes... X-Git-Tag: msva-perl_debian/0.5-1~1^2~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ca50b5f6f80d9ca06d68556446abb46f2ba76d39;p=monkeysphere-validation-agent.git Make the marginal UI conditional on the presence of the Gtk2 perl module (closes MS #2514) --- diff --git a/Changelog b/Changelog index 478d8e5..d885931 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,9 @@ msva-perl (0.5~pre) unstable; urgency=low from ${GNUPGHOME}/gpg.conf if that file exists. (addresses MS #2080) * Under Linux, report details about the requesting process if we can learn them from /proc (closes MS #2005) + * Conditionally rely on Gtk2 perl module -- no marginal UI without it, + but you can also install the MSVA now without needing to pull in a + bunch of Gtk libs (closes MS #2514) -- Daniel Kahn Gillmor Mon, 11 Oct 2010 16:02:22 -0400 diff --git a/Crypt/Monkeysphere/MSVA/MarginalUI.pm b/Crypt/Monkeysphere/MSVA/MarginalUI.pm index f49d58a..f840c24 100755 --- a/Crypt/Monkeysphere/MSVA/MarginalUI.pm +++ b/Crypt/Monkeysphere/MSVA/MarginalUI.pm @@ -26,9 +26,9 @@ use strict; use warnings; - use Gtk2; use Crypt::Monkeysphere::MSVA qw( msvalog ); use IO::File; + use Module::Load::Conditional; sub ask_the_user { my $self = shift; @@ -39,6 +39,13 @@ my @subvalid_key_fprs = @{$fprs}; msvalog('debug', "%d subvalid_key_fprs\n", $#subvalid_key_fprs+1); + + if (! Module::Load::Conditional::can_load('modules' => { 'Gtk2' => undef })) { + msvalog('info', "Gtk2 Perl module is unavailable, so no marginal UI presented\n"); + return 0; + } + + foreach my $keyfpr (@subvalid_key_fprs) { my $fprx = sprintf('0x%.40s', $keyfpr->{fpr}->as_hex_string); msvalog('debug', "checking on %s\n", $fprx); @@ -164,6 +171,7 @@ GnuPG calculated validity for the peer: %s", my $labeltxt = shift; my $tip = shift; + require Gtk2; Gtk2->init(); # create a new dialog with some buttons - one stock, one not. my $dialog = Gtk2::Dialog->new(sprintf('Monkeysphere validation agent [%s]', $peer),