#
#
# add_dir "locale/help/C/images"
#
# add_file "locale/help/C/images/caution.png"
# content [b7d8431fb832070168d2c7369d783f25297dd515]
#
# add_file "locale/help/C/images/important.png"
# content [e0557e51a70412391c4cde14e75cc8248e30971c]
#
# add_file "locale/help/C/images/note.png"
# content [85385c314453cd6979cbba3b6a264318153da318]
#
# add_file "locale/help/C/images/tip.png"
# content [980c1610e1d5726da980a558e7e3fd234c7c2797]
#
# add_file "locale/help/C/images/warning.png"
# content [36fc12c7fcca90ae7d6e0010362bedb19478b970]
#
# patch "lib/perl/Common.pm"
# from [eb11c91dc157322174dace83836d130f7d673519]
# to [cd5d8e4b016961e3bd6ffd1af9655bd0fe792578]
#
# patch "mtn-browse"
# from [8b69c0e2912d4e5221192c0fe1e9acd760756d28]
# to [583eaaeaa5e61aa39763208a3c4ffbb4e98f9cd7]
#
# set "locale/help/C/images/caution.png"
# attr "mtn:manual_merge"
# value "true"
#
# set "locale/help/C/images/important.png"
# attr "mtn:manual_merge"
# value "true"
#
# set "locale/help/C/images/note.png"
# attr "mtn:manual_merge"
# value "true"
#
# set "locale/help/C/images/tip.png"
# attr "mtn:manual_merge"
# value "true"
#
# set "locale/help/C/images/warning.png"
# attr "mtn:manual_merge"
# value "true"
#
============================================================
# locale/help/C/images/caution.png is binary
============================================================
# locale/help/C/images/important.png is binary
============================================================
# locale/help/C/images/note.png is binary
============================================================
# locale/help/C/images/tip.png is binary
============================================================
# locale/help/C/images/warning.png is binary
============================================================
--- lib/perl/Common.pm eb11c91dc157322174dace83836d130f7d673519
+++ lib/perl/Common.pm cd5d8e4b016961e3bd6ffd1af9655bd0fe792578
@@ -57,6 +57,11 @@ my %file_chooser_dir_locations;
my %file_chooser_dir_locations;
+# A map for converting Gnome help references into valid file based URLs for the
+# HTML help mode (used when yelp is not available).
+
+my %help_ref_to_url_map;
+
# ***** FUNCTIONAL PROTOTYPES *****
# Public routines.
@@ -65,6 +70,7 @@ sub data_is_binary($);
sub colour_to_string($);
sub create_format_tags($);
sub data_is_binary($);
+sub display_help(;$);
sub file_glob_to_regexp($);
sub generate_tmp_path($);
sub get_branch_revisions($$$$$);
@@ -81,6 +87,10 @@ sub treeview_setup_search_column_selecti
sub set_label_value($$);
sub treeview_column_searcher($$$$);
sub treeview_setup_search_column_selection($@);
+
+# Private routines.
+
+sub build_help_ref_to_url_map();
#
##############################################################################
#
@@ -1205,13 +1215,97 @@ sub handle_comboxentry_history($$;$)
#
##############################################################################
#
+# Routine - display_help
+#
+# Description - Displays the specified help section either in Gnome's
+# native help browser or the desktop's HTML viewer, depending
+# upon installation settings.
+#
+# Data - $section - The help section to display. If undef is given
+# then the content page is displayed. This is
+# optional.
+#
+##############################################################################
+
+
+
+sub display_help(;$)
+{
+
+ my $section = $_[0];
+
+ if (HELP_VIEWER_CMD eq "")
+ {
+
+ # Simply let Gnome handle it using yelp.
+
+ if (defined($section))
+ {
+ Gnome2::Help->display("mtn-browse.xml", $section);
+ }
+ else
+ {
+ Gnome2::Help->display("mtn-browse.xml");
+ }
+
+ }
+ else
+ {
+
+ my($cmd,
+ $url);
+
+ # Use the specified HTML viewer to display the help section.
+
+ $section = "index" unless defined($section);
+ if (exists($help_ref_to_url_map{$section}))
+ {
+ $url = $help_ref_to_url_map{$section};
+ }
+ else
+ {
+ $url = $help_ref_to_url_map{"index"};
+ }
+ if (! defined($url) || $url eq "")
+ {
+ my $dialog = Gtk2::MessageDialog->new
+ (undef,
+ ["modal"],
+ "warning",
+ "close",
+ __("The requested help section\n"
+ . "cannot be found or is not known."));
+ WindowManager->instance()->allow_input(sub { $dialog->run(); });
+ $dialog->destroy();
+ return;
+ }
+ $cmd = HELP_VIEWER_CMD;
+ if ($cmd =~ m/\{url\}/)
+ {
+ $cmd =~ s/\{url\}/$url/g;
+ }
+ else
+ {
+ $cmd .= " " . $url;
+ }
+
+ # Launch it.
+
+ system($cmd . " &");
+
+ }
+
+}
+#
+##############################################################################
+#
# Routine - register_help_callbacks
#
# Description - Register all of the context sensitive help callbacks for
# the specified window instance.
#
# Data - $instance : The window instance.
-# $details : A list of records containing the widget and
+# $details : A list of records containing the widget and the
# help reference for that widget. If a widget is
# set to undef then that entry represents the
# default help callback for that entire window.
@@ -1227,6 +1321,9 @@ sub register_help_callbacks($@)
my $wm = WindowManager->instance();
+ build_help_ref_to_url_map()
+ if (HELP_VIEWER_CMD ne "" && keys(%help_ref_to_url_map) == 0);
+
foreach my $entry (@details)
{
my $help_ref = $entry->{help_ref};
@@ -1238,8 +1335,7 @@ sub register_help_callbacks($@)
my($widget, $instance) = @_;
return if ($instance->{in_cb});
local $instance->{in_cb} = 1;
- Gnome2::Help->display("mtn-browse.xml",
- $help_ref);
+ display_help($help_ref);
});
}
@@ -1519,5 +1615,146 @@ sub glade_signal_autoconnect($$)
$client_data);
}
+#
+##############################################################################
+#
+# Routine - build_help_ref_to_url_map
+#
+# Description - Build up a map that translates an HTML help file link name
+# into a fully qualified URL.
+#
+# Data - None.
+#
+##############################################################################
+
+
+sub build_help_ref_to_url_map()
+{
+
+ my($dir,
+ $dir_path,
+ $fname,
+ $locale,
+ @lparts,
+ $nr_parts,
+ $prog,
+ $tmp);
+
+ # Ask Gnome where the based help directory is.
+
+ return unless (defined($prog = Gnome2::Program->get_program()));
+ ($dir_path) = $prog->locate_file("app-help", "mtn-browse.xml", FALSE);
+ $dir_path = dirname($dir_path);
+
+ # Work out the locale component, going from the most specific to the least.
+ # If a specific locale directory isn't found then fall back onto the
+ # POSIX/C locale.
+
+ $locale = setlocale(LC_MESSAGES);
+ @lparts = split(/address@hidden/, $locale);
+ $nr_parts = scalar(@lparts);
+ if (-d ($tmp = File::Spec->catfile($dir_path, $locale)))
+ {
+ $dir_path = $tmp;
+ }
+ elsif ($nr_parts >= 3
+ && -d ($tmp = File::Spec->catfile($dir_path,
+ $lparts[0] . "_"
+ . $lparts[1] . "."
+ . $lparts[2])))
+ {
+ $dir_path = $tmp;
+ }
+ elsif ($nr_parts >= 2
+ && -d ($tmp = File::Spec->catfile($dir_path,
+ $lparts[0] . "_" . $lparts[1])))
+ {
+ $dir_path = $tmp;
+ }
+ elsif ($nr_parts >= 1
+ && -d ($tmp = File::Spec->catfile($dir_path, $lparts[0])))
+ {
+ $dir_path = $tmp;
+ }
+ elsif (-d ($tmp = File::Spec->catfile($dir_path, "POSIX")))
+ {
+ $dir_path = $tmp;
+ }
+ elsif (-d ($tmp = File::Spec->catfile($dir_path, "C")))
+ {
+ $dir_path = $tmp;
+ }
+ else
+ {
+ return;
+ }
+
+ # Now open the directory and scan all HTML files for links.
+
+ return unless (defined($dir = IO::Dir->new($dir_path)));
+ while (defined($fname = $dir->read()))
+ {
+ my($file,
+ $full_name);
+ $full_name = File::Spec->catfile($dir_path, $fname);
+ $full_name = File::Spec->rel2abs($full_name);
+
+ # Only scan HTML files.
+
+ if ($fname =~ m/^.*\.html$/
+ && defined($file = IO::File->new($full_name, "r")))
+ {
+ my $line;
+ while (defined($line = $file->getline()))
+ {
+
+ my($dir_string,
+ @dirs,
+ $file_name,
+ @list,
+ $url,
+ $volume);
+
+ # Mangle the file name into a URL.
+
+ ($volume, $dir_string, $file_name) =
+ File::Spec->splitpath($full_name);
+ @dirs = File::Spec->splitdir($dir_string);
+ $url = "file://";
+ $url .= "/" . $volume . "/" if ($volume ne "");
+ $url .= join("/", @dirs);
+ $url .= "/" if ($url =~ m/.*[^\/]$/);
+ $url .= $file_name;
+
+ # Process each link of the form but filter out
+ # the internally generated ones (used for all figures).
+
+ @list = ($line =~ m//g);
+ foreach my $link (@list)
+ {
+ $help_ref_to_url_map{$link} = $url . "#" . $link
+ if ($link !~ m/^id\d+$/);
+ }
+
+ # Special case the contents page making sure that it has
+ # appropiate default entries pointing to it.
+
+ if ($fname eq "monotone-browse.html")
+ {
+ $help_ref_to_url_map{""} = $url;
+ $help_ref_to_url_map{"contents"} = $url;
+ $help_ref_to_url_map{"index"} = $url;
+ }
+
+ }
+ $file->close();
+ }
+ }
+ $dir->close();
+
+ return;
+
+}
+
1;
============================================================
--- mtn-browse 8b69c0e2912d4e5221192c0fe1e9acd760756d28
+++ mtn-browse 583eaaeaa5e61aa39763208a3c4ffbb4e98f9cd7
@@ -44,9 +44,10 @@ BEGIN
BEGIN
{
- use constant LIB_DIR => "@INST:LIB_DIR@";
- use constant MIME_GLOB_FILE => "@INST:GLOBS_FILE@";
- use constant PREFIX_DIR => "@INST:PREFIX_DIR@";
+ use constant HELP_VIEWER_CMD => "@INST:HELP_VIEWER_CMD@";
+ use constant LIB_DIR => "@INST:LIB_DIR@";
+ use constant MIME_GLOB_FILE => "@INST:GLOBS_FILE@";
+ use constant PREFIX_DIR => "@INST:PREFIX_DIR@";
}
use locale;
use strict;
@@ -72,6 +73,7 @@ use Locale::TextDomain ("mtn-browse",
use Gtk2::SourceView;
use Locale::TextDomain ("mtn-browse",
File::Spec->catfile(PREFIX_DIR, "share", "locale"));
+use IO::Dir;
use IO::File;
use IPC::Open3;
use POSIX qw(:errno_h :locale_h :sys_wait_h strftime);
@@ -353,8 +355,9 @@ sub view_button_clicked_cb($$);
# Setup the callback for the accelerator key for all windows.
- WindowManager->instance()->help_connect
- (undef, undef, sub { Gnome2::Help->display("mtn-browse.xml"); });
+ WindowManager->instance()->help_connect(undef,
+ undef,
+ sub { display_help(); });
# Hand control over to Gtk2.
@@ -790,7 +793,7 @@ sub help_toolbutton_clicked_cb($$)
return if ($browser->{in_cb});
local $browser->{in_cb} = 1;
- Gnome2::Help->display("mtn-browse.xml");
+ display_help();
}
#