Initial version.
[techtalk-pse.git] / techtalk-pse.pl
1 #!/usr/bin/perl -w
2 # -*- perl -*-
3 # @configure_input@
4 #
5 # Tech Talk PSE
6 # Copyright (C) 2010 Red Hat Inc.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 use warnings;
23 use strict;
24 use utf8;
25
26 use Pod::Usage;
27 use Getopt::Long;
28 use Glib qw(TRUE FALSE);
29 use Gtk2 -init;
30 use Gtk2::MozEmbed;
31
32 =encoding utf8
33
34 =head1 NAME
35
36 techtalk-pse - superior technical demonstration software
37
38 =head1 SYNOPSIS
39
40  cd /path/to/talk/; techtalk-pse
41
42  techtalk-pse /path/to/talk/
43
44 =head1 DESCRIPTION
45
46 Tech Talk "Platinum Supreme Edition" (PSE) is Linux Presentation
47 Software designed by technical people to give technical software
48 demonstrations to other technical people.  It is designed to be simple
49 to use (for people who know how to use an editor and the command line)
50 and powerful, so that you can create informative, technically accurate
51 and entertaining talks and demonstrations.
52
53 Tech Talk PSE is good at opening editors at the right place, opening
54 shell prompts with preloaded history, compiling and running things
55 during the demonstration, displaying text, photos, figures and video.
56
57 Tech Talk PSE is I<bad> at slide effects, chart junk and bullet
58 points.
59
60 This manual page covers all the documentation you will need to use
61 Tech Talk PSE.  The next section covers running the tool from the
62 command line.  After that there is a L</TUTORIAL> section to get you
63 started.  Then there is a detailed L</REFERENCE> section.  Finally
64 there is a discussion on L<WHAT MAKES A GOOD TALK>.
65
66 =head1 RUNNING THE TOOL FROM THE COMMAND LINE
67
68 A Tech Talk PSE talk is not a single file, but a directory full of
69 files.  (If you want to start a new talk, see the L</TUTORIAL> section
70 below).  To display or run the talk, change into the directory
71 containing all those files and run the C<techtalk-pse> command:
72
73  cd /path/to/talk/; techtalk-pse
74
75 You can also run C<techtalk-pse> without changing directory, instead
76 specifying the path to the talk:
77
78  techtalk-pse /path/to/talk/
79
80 =head2 OPTIONS
81
82 =over 4
83
84 =cut
85
86 my $help;
87
88 =item B<--help>
89
90 Display brief help and exit.
91
92 =cut
93
94 my $last;
95
96 =item B<--last>
97
98 Start at the last slide.
99
100 You cannot use this with the B<-n> / B<--start> option.
101
102 =cut
103
104 my $start;
105
106 =item B<-n SLIDE> | B<--start SLIDE>
107
108 Start at the named slide.  I<SLIDE> is the shortest unique prefix of
109 the slide name, so to start at a slide named
110 I<00010-introduction.html>, you could use I<-n 00010> or I<-n 00010-intro>,
111 or give the full filename I<-n 00010-introduction.html>.
112
113 The default is to start at the first slide in the talk.
114
115 =cut
116
117 my $splash = 1;
118
119 =item B<--no-splash>
120
121 Don't display the initial "splash" screen which advertises Tech Talk
122 PSE to your audience.  Just go straight into the talk.
123
124 =cut
125
126 my $verbose;
127
128 =item B<--verbose>
129
130 Display verbose messages, useful for debugging or tracing
131 what the program is doing.
132
133 =cut
134
135 my $version;
136
137 =item B<--version>
138
139 Display version number and exit.
140
141 =cut
142
143 GetOptions ("help|?" => \$help,
144             "last" => \$last,
145             "n=s" => \$start,
146             "splash!" => \$splash,
147             "start=s" => \$start,
148             "verbose" => \$verbose,
149             "version" => \$version,
150     ) or pod2usage (2);
151
152 =back
153
154 =cut
155
156 pod2usage (1) if $help;
157 if ($version) {
158     print "@PACKAGE@ @VERSION@\n";
159     exit
160 }
161 die "techtalk-pse: cannot use --start and --last options together\n"
162     if defined $last && defined $start;
163
164 die "techtalk-pse: too many arguments\n" if @ARGV >= 2;
165
166 # Locate the talk.
167 if (@ARGV > 0) {
168     my $d = $ARGV[0];
169     if (-d $d) {
170         chdir $d or die "techtalk-pse: chdir: $d: $!";
171     } else {
172         # XXX In future allow people to specify an archive and unpack
173         # it for them.
174         die "techtalk-pse: argument is not a directory"
175     }
176 }
177
178 # MozEmbed initialization.
179 Gtk2::MozEmbed->set_profile_path ("$ENV{HOME}/.@PACKAGE@", "Tech Talk PSE");
180
181 # Get the files.
182 my @files;
183 my %groups;
184 sub reread_directory
185 {
186     @files = ();
187     %groups = ();
188
189     foreach (glob ("*")) {
190         if (/^(\d+)([A-Z])?(?:-.*)\.(html|sh|txt)$/) {
191             print STDERR "reading $_\n" if $verbose;
192
193             my $seq = $1;
194             my $pos = $2 || "A";
195             my $ext = $3;
196             warn "techtalk-pse: $_: command file is not executable (+x)\n"
197                 if $ext eq "sh" && ! -x $_;
198
199             my $h = { name => $_, seq => $1, pos => $2, ext => $3 };
200             push @files, $h;
201
202             $groups{$seq} = [] unless exists $groups{$seq};
203             push @{$groups{$seq}}, $h;
204         } else {
205             print STDERR "ignoring $_\n" if $verbose;
206         }
207     }
208 }
209 reread_directory ();
210 print STDERR "read ", 0+@files, " files\n" if $verbose;
211 if (@files == 0) {
212     warn "techtalk-pse: no files found, continuing anyway ...\n"
213 }
214
215 # Work out what slide we're starting on.
216 my $current;
217 if (defined $current) {
218     die "start slide not implemented yet XXX"
219 }
220 elsif (@files) {
221     $current = $files[0];
222 }
223 # else $current is undefined
224
225 if ($splash) {
226     my $w = Gtk2::AboutDialog->new;
227     $w->set_authors ("Richard W.M. Jones");
228     $w->set_comments (
229         "Superior technical demonstration software\n".
230         "\n".
231         "Keys\n".
232         "↑ — Go back one slide\n".
233         "↓ — Go forward one slide\n"
234         );
235     $w->set_program_name ("Tech Talk Platinum Supreme Edition (PSE)");
236     $w->set_version ("@VERSION@");
237     $w->set_website ("http://people.redhat.com/~rjones");
238     $w->set_license ("GNU General Public License v2 or above");
239     $w->signal_connect (destroy => sub { Gtk2->main_quit });
240     $w->show_all;
241     Gtk2->main;
242 }
243
244
245
246
247
248
249
250
251
252 1;
253
254 =head1 TUTORIAL
255
256 =head1 REFERENCE
257
258 =head1 WHAT MAKES A GOOD TALK
259
260 =head1 SEE ALSO
261
262 The Cognitive Style of PowerPoint, Tufte, Edward R.
263
264 =head1 AUTHOR
265
266 Richard W.M. Jones L<http://people.redhat.com/~rjones/>
267
268 =head1 COPYRIGHT
269
270 Copyright (C) 2010 Red Hat Inc.
271
272 This program is free software; you can redistribute it and/or modify
273 it under the terms of the GNU General Public License as published by
274 the Free Software Foundation; either version 2 of the License, or
275 (at your option) any later version.
276
277 This program is distributed in the hope that it will be useful,
278 but WITHOUT ANY WARRANTY; without even the implied warranty of
279 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
280 GNU General Public License for more details.
281
282 You should have received a copy of the GNU General Public License
283 along with this program; if not, write to the Free Software
284 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.