From ca50b5f6f80d9ca06d68556446abb46f2ba76d39 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Mon, 11 Oct 2010 23:36:10 -0400 Subject: [PATCH] Make the marginal UI conditional on the presence of the Gtk2 perl module (closes MS #2514) --- Changelog | 3 +++ Crypt/Monkeysphere/MSVA/MarginalUI.pm | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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), -- 2.26.2