App/Chart/Gtk2/AboutDialog.pm untested

filter: Statementstmt 0.0% 0 / 51 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 70 CC 2 SCAR 9.3
CC
2
Cov
0%
_do_response
6.0
INIT_INSTANCE
2.0
_do_url_hook
2.0
CRAP 2.5
1 # Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2023, 2024 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::Gtk2::AboutDialog;
18 use 5.010;
19 use strict;
20 use warnings;
21 use Glib;
22 use Gtk2;
23 use Software::License::GPL_3;
24 use Locale::TextDomain ('App-Chart');
25  
26 use App::Chart;
27 use App::Chart::Database;
28 use App::Chart::Gtk2::GUI;
29  
30 use Glib::Object::Subclass 'Gtk2::AboutDialog';
31  
32 our $VERSION = 275;
33  
34 # this applies to the whole program
35 my $copyright_string
36 = __('Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Kevin Ryde');
37  
38 sub INIT_INSTANCE {
39 my ($self) = @_;
40  
41 # Per Gtk docs, this must be before set_website() etc.
42 # Had thought the default in Gtk 2.16 up was gtk_show_uri, needing no
43 # setting here, but that doesn't seem to be so.
44 # ENHANCE-ME: Maybe this belongs with global GUI inits.
45 Gtk2::AboutDialog->set_url_hook (\&_do_url_hook);
46  
47 # "authors" comes out as a separate button and dialog, don't need that
48 # $self->set_authors (__('Kevin Ryde'));
49  
50 $self->set_version ($self->VERSION);
51 $self->set_copyright ($copyright_string);
52 $self->set_website ('http://user42.tuxfamily.org/chart/index.html');
53  
54 # the same as COPYING in the sources
55 my $sl = Software::License::GPL_3->new({ holder => 'Kevin Ryde' });
56 $self->set_license ($sl->license);
57  
58 $self->set_comments
59 (__x("Chart is Free Software, distributed under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Click on the License button below for the full text.
60  
61 Chart is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more.
62  
63 You are running under: Perl {perlver}, Gtk2-Perl {gtkperlver}, Gtk {gtkver}, Glib-Perl {glibperlver}, Glib {glibver}
64 ",
65 perlver => sprintf('%vd', $^V),
66 gtkver => (Gtk2::major_version() . '.' . Gtk2::minor_version()
67 . '.' . Gtk2::micro_version()),
68 glibver => (Glib::major_version() . '.' . Glib::minor_version()
69 . '.' . Glib::micro_version()),
70 gtkperlver => Gtk2->VERSION,
71 glibperlver => Glib->VERSION));
72  
73 # connect to self rather than class closure for "response" since bad
74 # $response enum interpretation as of Perl-Gtk2 1.220
75 $self->signal_connect (response => \&_do_response);
76 }
77  
78 sub _do_response {
79 my ($self, $response) = @_;
80  
81 if ($response eq 'cancel') {
82 # "Close" button gives GTK_RESPONSE_CANCEL.
83 # Emit 'close' same as a keyboard Esc to close, and that signal defaults
84 # to raising 'delete-event', which in turn defaults to a destroy
85 $self->signal_emit ('close');
86 }
87 }
88  
89 sub _do_url_hook {
90 my ($self, $url) = @_;
91 App::Chart::Gtk2::GUI::browser_open ($url, $self);
92 }
93  
94 1;
95 __END__