| 1 | # Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2015, 2016, 2017, 2018, 2019, 2020 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 = 269; | ||
| 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__ | ||
| 96 | |||
| 97 | =for stopwords AboutDialog | ||
| 98 | |||
| 99 | =head1 NAME | ||
| 100 | |||
| 101 | App::Chart::Gtk2::AboutDialog -- about dialog module | ||
| 102 | |||
| 103 | =head1 SYNOPSIS | ||
| 104 | |||
| 105 | use App::Chart::Gtk2::AboutDialog; | ||
| 106 | my $dialog = App::Chart::Gtk2::AboutDialog->new; | ||
| 107 | $dialog->present; | ||
| 108 | |||
| 109 | =head1 WIDGET HIERARCHY | ||
| 110 | |||
| 111 | C<App::Chart::Gtk2::AboutDialog> is a subclass of C<Gtk2::AboutDialog>. | ||
| 112 | |||
| 113 | Gtk2::Widget | ||
| 114 | Gtk2::Container | ||
| 115 | Gtk2::Bin | ||
| 116 | Gtk2::Window | ||
| 117 | Gtk2::Dialog | ||
| 118 | Gtk2::AboutDialog | ||
| 119 | App::Chart::Gtk2::AboutDialog | ||
| 120 | |||
| 121 | =head1 FUNCTIONS | ||
| 122 | |||
| 123 | =over 4 | ||
| 124 | |||
| 125 | =item C<< $dialog = App::Chart::Gtk2::AboutDialog->new() >> | ||
| 126 | |||
| 127 | Create and return a new AboutDialog. The dialog close button or window | ||
| 128 | manager delete event destroys the dialog. | ||
| 129 | |||
| 130 | =back | ||
| 131 | |||
| 132 | =head1 SEE ALSO | ||
| 133 | |||
| 134 | L<chart>, | ||
| 135 | L<Gtk2::AboutDialog> | ||
| 136 | |||
| 137 | =head1 HOME PAGE | ||
| 138 | |||
| 139 | L<http://user42.tuxfamily.org/chart/index.html> | ||
| 140 | |||
| 141 | =head1 LICENCE | ||
| 142 | |||
| 143 | Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Kevin Ryde | ||
| 144 | |||
| 145 | Chart is free software; you can redistribute it and/or modify it under the | ||
| 146 | terms of the GNU General Public License as published by the Free Software | ||
| 147 | Foundation; either version 3, or (at your option) any later version. | ||
| 148 | |||
| 149 | Chart is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 150 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 151 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 152 | details. | ||
| 153 | |||
| 154 | You should have received a copy of the GNU General Public License along with | ||
| 155 | Chart; see the file F<COPYING>. Failing that, see | ||
| 156 | L<http://www.gnu.org/licenses/>. | ||
| 157 | |||
| 158 | =cut |