[gtkmm-documentation] Add make_screenshots.
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Add make_screenshots.
- Date: Sat, 9 Jun 2012 08:58:06 +0000 (UTC)
commit 7b31117da789541571334b7eac0c6cf0a26506f3
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Sat Jun 9 10:54:19 2012 +0200
Add make_screenshots.
* tools/make_screenshots/make_screenshots.sh:
* tools/make_screenshots/make_screenshots.pl:
* tools/make_screenshots/progs-and-figs.txt:
* tools/make_screenshots/README: New files. Bug #677292.
ChangeLog | 9 ++
tools/make_screenshots/README | 31 +++++++
tools/make_screenshots/make_screenshots.pl | 105 ++++++++++++++++++++++++
tools/make_screenshots/make_screenshots.sh | 11 +++
tools/make_screenshots/progs-and-figs.txt | 119 ++++++++++++++++++++++++++++
5 files changed, 275 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5250885..8a05616 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-06-09 Kjell Ahlstedt <kjell ahlstedt bredband net>
+
+ Add make_screenshots.
+
+ * tools/make_screenshots/make_screenshots.sh:
+ * tools/make_screenshots/make_screenshots.pl:
+ * tools/make_screenshots/progs-and-figs.txt:
+ * tools/make_screenshots/README: New files. Bug #677292.
+
2012-06-01 Kjell Ahlstedt <kjell ahlstedt bredband net>
Update some screenshots.
diff --git a/tools/make_screenshots/README b/tools/make_screenshots/README
new file mode 100644
index 0000000..9cb6dd5
--- /dev/null
+++ b/tools/make_screenshots/README
@@ -0,0 +1,31 @@
+gtkmm-documentation/tools/make_screenshots/README
+
+2012-06-09 Kjell Ahlstedt
+
+See also bug https://bugzilla.gnome.org/show_bug.cgi?id=677292
+"Semi-automatic generation of screenshots for the gtkmm tutorial"
+
+-- make_screenshots.pl is a Perl script which is a first attempt at an automatic
+screenshot generator. It's not fully automatic, though. It generates
+screenshots by starting an example program and saving a screenshot of the
+program's window as it looks just after start-up.
+
+63 screenshots are shown in the tutorial. 47 of them will be correctly
+generated in this simple way. The other 16 screenshots require some kind of
+user input or a specific location of the cursor before they are saved.
+
+Most example programs must be built before make_screenshots.pl is executed.
+'make check' does that.
+
+The screenshots are saved by gnome-screenshot.
+The gnome-screenshot bugs https://bugzilla.gnome.org/show_bug.cgi?id=129768 and
+https://bugzilla.gnome.org/show_bug.cgi?id=594141 must have been implemented
+(added in the git repository 2012-05-23 and 2012-05-24).
+
+-- make_screenshots.sh is a shell script that calls make_screenshots.pl with
+appropriate parameters.
+
+-- progs-and-figs.txt is input data to make_screenshots.pl.
+
+At present make_screenshots.sh is not called from any Makefile.
+
diff --git a/tools/make_screenshots/make_screenshots.pl b/tools/make_screenshots/make_screenshots.pl
new file mode 100755
index 0000000..49b00c9
--- /dev/null
+++ b/tools/make_screenshots/make_screenshots.pl
@@ -0,0 +1,105 @@
+#!/usr/bin/perl
+
+# Generate screenshots for the gtkmm tutorial.
+#
+# This Perl script starts one or more programs, one at a time. The started
+# programs are assumed to open a window. The script catches a screenshot of
+# each started program's window.
+# The script can't correctly generate screenshots that require some kind of
+# user input before or after the program has been started.
+#
+# Which programs to start and where to save the screenshots is read from a
+# file, where each line contains
+# program [parameter-to-program...] figure [delay-in-seconds] [# comment]
+# Lines that don't contain both 'program' and 'figure' are ignored.
+
+# The screenshots are saved by gnome-screenshot.
+# The gnome-screenshot bugs https://bugzilla.gnome.org/show_bug.cgi?id=129768 and
+# https://bugzilla.gnome.org/show_bug.cgi?id=594141 must have been implemented.
+
+use strict;
+use warnings;
+
+use Getopt::Long qw(:config no_ignore_case);
+use POSIX qw(:sys_wait_h); # waitpid
+use File::Basename;
+
+my $help = 0;
+my $program_prefix = "";
+my $figure_prefix = "";
+
+my $optResult = GetOptions(
+ 'help' => \$help,
+ 'program-prefix=s' => \$program_prefix,
+ 'figure-prefix=s'=> \$figure_prefix);
+
+if (!$optResult or $help or @ARGV != 1)
+{
+ my $prog_name = basename($0);
+ print "$prog_name [--program-prefix=program-prefix] [--figure-prefix=figure-prefix] listfile\n";
+ print "Format of each line in listfile:\n";
+ print " program [parameter-to-program...] figure [delay-in-seconds] [# comment]\n";
+ exit !$optResult;
+}
+
+open(LISTFILE, $ARGV[0]) or die "Can't open $ARGV[0]: $!\n";
+
+while (defined(my $line = <LISTFILE>))
+{
+ chomp $line;
+
+ # Remove comments.
+ $line =~ s/#.*//;
+
+ my @fields = split ' ', $line;
+
+ # Skip lines with less than two fields.
+ # These are blank lines, comment lines, and lines with the name of a program
+ # from which no screenshot is required.
+ next if @fields < 2;
+
+ my $delay = 2;
+ if (@fields >= 3 and $fields[-1] =~ /^\d+$/)
+ {
+ # The last field consists of only digits. It's the required delay.
+ $delay = pop(@fields);
+ }
+
+ my $program = $program_prefix . $fields[0];
+ my ($program_filename, $program_directory, $dummy_suffix) = fileparse($program);
+
+ my $figure = $figure_prefix . $fields[-1];
+ my @cmd_par = ();
+ if (@fields > 2)
+ {
+ @cmd_par = @fields[1 .. $#fields-1];
+ }
+
+ defined(my $pid = fork) or die "Can't fork: $!\n";
+ if (!$pid)
+ {
+ # Child process.
+ # Execute the program in its own directory.
+ # Some programs will find necessary data files only if they are executed in
+ # their own directory.
+ chdir $program_directory or die "Can't chdir to $program_directory: $!\n";
+ exec "./$program_filename", @cmd_par;
+ die "Can't exec $program: $!\n";
+ }
+
+ # Parent process.
+ # Wait for the child process to show its main window.
+ sleep $delay;
+
+ # Reap the child process, if it has become a zombie.
+ waitpid $pid, WNOHANG;
+ # Check if the child process still exists.
+ die "Could not start program from line: $line\n" if kill(0, $pid) == 0;
+
+ my $result = system("gnome-screenshot --window --file=$figure");
+ kill 9, $pid;
+ die "Can't save screenshot from line: $line\n" if $result != 0;
+}
+close LISTFILE;
+exit 0;
+
diff --git a/tools/make_screenshots/make_screenshots.sh b/tools/make_screenshots/make_screenshots.sh
new file mode 100755
index 0000000..b6dcbea
--- /dev/null
+++ b/tools/make_screenshots/make_screenshots.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# gtkmm-documentation/tools/make_screenshots/make_screenshots.sh
+
+SCREENSHOT_DIR=newfigures
+if [ ! -d $SCREENSHOT_DIR ]
+then
+ mkdir -p $SCREENSHOT_DIR
+fi
+./make_screenshots.pl --program-prefix=../../examples/ --figure-prefix=$SCREENSHOT_DIR/ progs-and-figs.txt
+
diff --git a/tools/make_screenshots/progs-and-figs.txt b/tools/make_screenshots/progs-and-figs.txt
new file mode 100644
index 0000000..075c3f1
--- /dev/null
+++ b/tools/make_screenshots/progs-and-figs.txt
@@ -0,0 +1,119 @@
+# check_PROGRAMS in gtkmm-documentation/examples and corresponding screenshots
+#
+# A program with neither a screenshot name nor a comment is not shown in the
+# gtkmm tutorial.
+# Some comments, e.g. 'after user input' and 'with pointer', indicate that
+# screenshots will not be correctly generated by the Perl script make_screenshots.pl.
+# 2012-05-28
+
+book/alignment/example alignment.png
+book/application/simple/example
+book/application/command_line_handling/example
+book/application/app_menu/example
+book/aspectframe/example aspectframe.png
+book/assistant/example assistant.png # after user input
+book/base/base # no screenshot
+book/box/example 1 box_packing1.png
+book/box/example 2 box_packing2.png
+book/builder/basic/example # no screenshot
+book/builder/derived/example # no screenshot
+book/buttonbox/example buttonbox.png
+book/buttons/button/buttons buttons.png
+book/buttons/checkbutton/example checkbutton.png
+book/buttons/filechooserbutton/example
+book/buttons/radiobutton/radiobuttons radiobuttons.png
+book/buttons/togglebutton/example
+book/clipboard/ideal/example clipboard_ideal.png
+book/clipboard/simple/example clipboard_simple.png
+book/combobox/complex/example combobox_complex.png
+book/combobox/text/example combobox_text.png
+book/combobox/entry_complex/example comboboxentry_complex.png
+book/combobox/entry_text/example comboboxentry_text.png
+book/custom/custom_container/example custom_container.png
+book/custom/custom_widget/example custom_widget.png
+book/dialogs/aboutdialog/example
+book/dialogs/colorchooserdialog/example dialogs_colorchooserdialog.png # after user input
+book/dialogs/filechooserdialog/example dialogs_filechooser.png # after user input
+book/dialogs/fontchooserdialog/example dialogs_fontchooserdialog.png # after user input
+book/dialogs/messagedialog/example dialogs_messagedialog.png # after user input
+book/dialogs/simple/example
+book/drag_and_drop/drag_and_drop drag_and_drop.png
+book/drawingarea/arcs/drawingareaarcs drawingarea_arcs.png
+book/drawingarea/clock/cairoclock cairo_clock.png
+book/drawingarea/curve/drawingareacurve drawingarea_curve.png
+book/drawingarea/image/drawingareaimage drawingarea_image.png
+book/drawingarea/joins/cairojoins cairo_joins.png # modified screenshot
+book/drawingarea/pango_text/example drawingarea_pango_text.png
+book/drawingarea/simple/drawingarea drawingarea_lines.png
+book/drawingarea/thin_lines/example drawingarea_thin_lines.png
+book/entry/completion/example entry_completion.png # after user input, with pointer
+book/entry/icon/example entry_icon.png # with unnecessary pointer
+book/entry/progress/example entry_progress.png 7 # with unnecessary pointer
+book/entry/simple/example entry.png
+book/eventbox/example eventbox.png
+book/expander/example
+book/frame/example frame.png
+book/giomm/directory_list/example
+book/giomm/getline/getline
+book/giomm/monitor_directory/monitor_directory
+book/giomm/read_file/example
+book/giomm/read_file_async/example
+book/giomm/usage/usage
+book/giomm/volumes/example
+book/giomm/write_file/example
+book/grid/example grid.png
+book/helloworld/helloworld helloworld.png
+book/helloworld2/helloworld2 helloworld2.png
+book/iconview/example
+book/idle/idle # no screenshot
+book/infobar/example infobar.png # after user input, with unnecessary pointer
+book/input/example # no screenshot
+book/keyboard_events/simple/example keyboardevents_simple.png
+book/keyboard_events/propagation/example keyboardevents_propagation.png
+book/label/example label.png
+book/menus/main_menu/main_menu main_menu.png
+book/menus/popup/popup menu_popup.png # after user input
+book/menus_and_toolbars/example
+book/notebook/example notebook.png
+book/paned/example paned.png # after user input
+book/printing/advanced/example
+book/printing/simple/example printing.png
+book/progressbar/example progressbar.png 3
+book/range_widgets/example range_widgets.png
+book/recent_files/example recentchooserdialog.png # after user input
+book/scrolledwindow/example scrolledwindow.png
+book/signals/custom/example # no screenshot
+book/socket/plug
+book/socket/socket socket.png # after plug has been started
+book/socket/socket socket-fail.png
+book/spinbutton/example spinbutton.png
+book/statusicon/example
+book/textview/example textview.png
+book/timeout/timeout # no screenshot
+book/toolbar/example
+book/toolpalette/example toolpalette.png 3 # with pointer
+book/tooltips/example tooltip.png # ought to be with pointer
+book/treeview/combo_renderer/example
+book/treeview/drag_and_drop/example treeview_draganddrop.png # after user input
+book/treeview/editable_cells/example treeview_editablecells.png # after unnecessary user input
+book/treeview/filter/example
+book/treeview/filter_modify/example
+book/treeview/list/example treeview_list.png
+book/treeview/listviewtext/example
+book/treeview/modelsort/example
+book/treeview/popup/example treeview_popup.png # after user input
+book/treeview/tree/example treeview_tree.png # after user input
+book/update_ui/example
+others/arrow/arrow
+others/arrow/direction
+others/calendar/calendar
+others/cellrenderercustom/cellrenderertoggle
+others/cellrenderercustom/testpopup
+others/dnd/testdnd
+others/exception/exceptiontest
+others/idle/idle
+others/statusbar/statusbar
+others/stock/stock
+others/tictactoe/ttt_test
+others/treemodelcustom/example
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]