# # # patch "lib/perl/Common.pm" # from [37679826b5a267078ecc14a5b47eb42eb6733f33] # to [8e650608a7fa05dbb21d3d4d1cc290df238244f8] # # patch "lib/perl/History.pm" # from [6ebebca72639a26c112139b03876edd543ab7c9d] # to [a29e79c181fc8de7480d32eb3dd530a5fdad9c5d] # # patch "mtn-browse" # from [8d3222fb76959b757890b771b73c1db6ab922714] # to [881f0a6488e4f5b6fa0962fe0d438245e29a0b05] # ============================================================ --- lib/perl/Common.pm 37679826b5a267078ecc14a5b47eb42eb6733f33 +++ lib/perl/Common.pm 8e650608a7fa05dbb21d3d4d1cc290df238244f8 @@ -87,6 +87,7 @@ sub open_database($$$); sub handle_comboxentry_history($$;$); sub hex_dump($); sub open_database($$$); +sub program_valid($;$); sub register_help_callbacks($@); sub run_command($@); sub save_as_file($$$); @@ -1220,6 +1221,71 @@ sub file_glob_to_regexp($) # ############################################################################## # +# Routine - program_valid +# +# Description - Validate the specified program by seeing if it can be +# found. If a parent window is provided and the specified +# program cannot be found then display a dialog window +# telling the user about the problem. +# +# Data - $program : The name of the program or the full path to +# the program that is to be validated. +# $parent : The parent window for any dialogs that are +# to be displayed. This is optional. +# Return Value : True if the program is valid, otherwise +# false if it is not. +# +############################################################################## + + + +sub program_valid($;$) +{ + + my($program, $parent) = @_; + + my $found; + + if (File::Spec->file_name_is_absolute($program)) + { + $found = 1 if (-x $program || -f ($program . ".exe")); + } + else + { + foreach my $dir (File::Spec->path()) + { + if (-x File::Spec->catfile($dir, $program) + || -f File::Spec->catfile($dir, $program . ".exe")) + { + $found = 1; + last; + } + } + } + + # Tell the user that the program can't be found if that is the case and the + # caller wants us to inform the user. + + if (! $found && defined($parent)) + { + my $dialog = Gtk2::MessageDialog->new + ($parent, + ["modal"], + "info", + "close", + __x("The program `{program_name}' cannot be found.\n" + . "Is it installed?", + program_name => $program)); + WindowManager->instance()->allow_input(sub { $dialog->run(); }); + $dialog->destroy(); + } + + return $found; + +} +# +############################################################################## +# # Routine - handle_comboxentry_history # # Description - Handle comboboxentry histories. Histories are limited to a ============================================================ --- lib/perl/History.pm 6ebebca72639a26c112139b03876edd543ab7c9d +++ lib/perl/History.pm a29e79c181fc8de7480d32eb3dd530a5fdad9c5d @@ -1954,6 +1954,10 @@ sub external_diffs($$$$$$) $dialog->destroy(); return; } + return unless (program_valid((split(/[[:blank:]]/, + $user_preferences->{diffs_application}) + )[0], + $parent)); # Generate temporary disk file names. ============================================================ --- mtn-browse 8d3222fb76959b757890b771b73c1db6ab922714 +++ mtn-browse 881f0a6488e4f5b6fa0962fe0d438245e29a0b05 @@ -119,12 +119,13 @@ use constant MLS_MANIFEST_ENTRY_COLUMN = use constant MLS_AUTHOR_COLUMN => 3; use constant MLS_MANIFEST_ENTRY_COLUMN => 4; -# Constants for various file paths. +# Constants for various program names and file paths. -use constant UI_DIR => File::Spec->catfile(PREFIX_DIR, - "share", - APPLICATION_NAME, - "glade"); +use constant MONOTONE_VIZ => "monotone-viz"; +use constant UI_DIR => File::Spec->catfile(PREFIX_DIR, + "share", + APPLICATION_NAME, + "glade"); # The type of window that is going to be managed by this module. @@ -970,10 +971,14 @@ sub monotone_viz_button_clicked_cb($$) $db_name, @revision_ids); + # Make sure we have monotone-viz installed first. + + return unless (program_valid(MONOTONE_VIZ, $browser->{window})); + # Build up the monotone-viz command, we need the database name and then # optionally the branch and revision ids. - $cmd = "monotone-viz "; + $cmd = MONOTONE_VIZ . " "; if (! defined($db_name = $browser->{mtn}->get_db_name())) { $browser->{mtn}->get_option(\$db_name, "database"); @@ -1215,6 +1220,7 @@ sub view_button_clicked_cb($$) ($browser->{window}, ["modal"], "warning", + "close", __x("Cannot generate temporary file name:\n{error_message}.", error_message => $!)); $dialog->run(); @@ -1257,10 +1263,12 @@ sub view_button_clicked_cb($$) if (defined($mime_details) && $mime_details->{helper_application} ne "") { - # Use the specified helper application, replacing `{file}' with the - # real file name. + # Use the specified helper application (having validated it first), + # replacing `{file}' with the real file name. $helper = $mime_details->{helper_application}; + return unless (program_valid((split(/[[:blank:]]/, $helper))[0], + $browser->{window})); if ($helper =~ m/\{file\}/) { $helper =~ s/\{file\}/$file_name/g; @@ -3050,7 +3058,7 @@ sub sigchld_handler() # If it is an mtn process then close down the relevant object so # that it will automatically restart when needed. - WindowManager->instance()->cond_find + $wm->cond_find (undef, sub { my $instance = $_[0];