File Coverage

blib/lib/App/Chart/Manual.pm
Criterion Covered Total %
statement 9 11 81.8
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 13 15 86.6


line stmt bran cond sub pod time code
1             # Copyright 2007, 2008, 2009, 2010, 2011, 2016 Kevin Ryde
2              
3             # This file is part of Chart.
4             #
5             # Chart is free software; you can redistribute it and/or modify it under the
6             # terms of the GNU General Public License as published by the Free Software
7             # Foundation; either version 3, or (at your option) any later version.
8             #
9             # Chart is distributed in the hope that it will be useful, but WITHOUT ANY
10             # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11             # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12             # details.
13             #
14             # You should have received a copy of the GNU General Public License along
15             # with Chart. If not, see <http://www.gnu.org/licenses/>.
16              
17             package App::Chart::Manual;
18 1     1   580 use 5.008;
  1         6  
19 1     1   9 use strict;
  1         2  
  1         34  
20 1     1   7 use warnings;
  1         4  
  1         47  
21             # use Locale::TextDomain ('App-Chart');
22              
23 1     1   392 use App::Chart;
  0            
  0            
24              
25             sub open {
26             my ($class, $node, $parent_widget) = @_;
27             my $uri;
28             if (defined $node && $node =~ /^http:/) {
29             $uri = $node;
30             } else {
31             require URI::file;
32             $uri = URI::file->new (App::Chart::datafilename('doc', 'chart.html'));
33             if (defined $node) {
34             require App::Chart::Texinfo::Util;
35             $uri->fragment (App::Chart::Texinfo::Util::node_to_html_anchor($node));
36             }
37             }
38             require App::Chart::Gtk2::GUI;
39             App::Chart::Gtk2::GUI::browser_open ($uri, $parent_widget);
40             }
41              
42             sub open_for_symbol {
43             my ($class, $symbol, $parent_widget) = @_;
44             my $node = App::Chart::symbol_source_help ($symbol);
45             if (defined $node) {
46             $class->open ($node, $parent_widget);
47             } else {
48             if ($parent_widget) {
49             $parent_widget->error_bell;
50             } elsif (Gtk2::Gdk::Display->can('get_default')) {
51             Gtk2::Gdk::Display->get_default->beep;
52             }
53             }
54             }
55              
56             1;
57             __END__
58              
59             =for stopwords undef
60              
61             =head1 NAME
62              
63             App::Chart::Manual -- open the Chart manual
64              
65             =for test_synopsis my ($node)
66              
67             =head1 SYNOPSIS
68              
69             use App::Chart::Manual;
70             App::Chart::Manual->open; # start of manual
71             App::Chart::Manual->open ($node); # particular node
72              
73             =head1 FUNCTIONS
74              
75             =over 4
76              
77             =item C<< App::Chart::Manual->open () >>
78              
79             =item C<< App::Chart::Manual->open ($node) >>
80              
81             =item C<< App::Chart::Manual->open ($node, $parent_widget) >>
82              
83             Open the Chart manual. Optional C<$node> is a node name like "Main Window",
84             or if undef or omitted then open the manual at the start.
85              
86             C<$parent_widget> (if given, and not undef) is used as the parent window for
87             an error bell or dialog if a help browser can't be opened. Or at least
88             that's the intention.
89              
90             =back
91              
92             =head1 SEE ALSO
93              
94             L<App::Chart>,
95             L<App::Chart::Gtk2::GUI>,
96             L<App::Chart::Texinfo::Util>
97              
98             =head1 HOME PAGE
99              
100             L<http://user42.tuxfamily.org/chart/index.html>
101              
102             =head1 LICENCE
103              
104             Copyright 2007, 2008, 2009, 2010, 2011, 2016 Kevin Ryde
105              
106             Chart is free software; you can redistribute it and/or modify it under the
107             terms of the GNU General Public License as published by the Free Software
108             Foundation; either version 3, or (at your option) any later version.
109              
110             Chart is distributed in the hope that it will be useful, but WITHOUT ANY
111             WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
112             FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
113             details.
114              
115             You should have received a copy of the GNU General Public License along with
116             Chart; see the file F<COPYING>. Failing that, see
117             L<http://www.gnu.org/licenses/>.
118              
119             =cut