File: NEW_TESTS

package info (click to toggle)
screentest 2.0-2.2
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 1,652 kB
  • ctags: 149
  • sloc: sh: 8,940; ansic: 802; makefile: 65
file content (117 lines) | stat: -rw-r--r-- 5,163 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
WHAT TO DO IF YOU WANT TO ADD A NEW TEST MODE
=============================================

The process of adding new modes to screentest is not very complicated.
Follow these steps (let's assume you want to add a test called "circle").

1. Create the new test's source file, circle_test.c. You should copy
the top of the file with copyright notice and #include statements
from another source file (say text_test.c), so it looks like this:
[...]
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */

  #ifdef HAVE_CONFIG_H
  #  include <config.h>
  #endif

  #include <gtk/gtk.h>
  #include <stdio.h>

  #include "callbacks.h"
  #include "interface.h"
  #include "support.h"

2. Add the source file name (circle_test.c) to the screentest_SOURCES
variable in Makefile.am.

3. In circle_test.c you have to define the (non-static!) structure
	struct test_ops circle_ops
Make sure the name of the structure ends in "_ops". This structure, which have
four member functions, defines the basic operations of your test mode. The
structure members are:

	void circle_init(GtkWidget *widget);
This function is called when screentest is switched to your "circle" test.
The argument is GtkWidget of type DrawingArea, which covers the whole screen.
This function is optional, you can set it to NULL.

	void circle_draw(GtkWidget *widget, gboolean clear);
This function is called when screentest decides to redraw the screen
(either when mode/fgcolor/bgcolor changes, or the Expose event from
the X server is received). The first argument is the same
DrawingArea as above, the second one is True, when the screentest
wants you to clear the window before you start drawing. This function
is not optional. You must define it (after all, your test wants
to draw something, doesn't it?).

	void circle_cycle(GtkWidget *widget);
Screentest calls this function when user presses the left mouse button.
You can use it to cycle through values of some parameter (let's say,
the circle diameter). You don't need to redraw the screen. The circle_draw()
function will be called afterwards. This function is optional, you can
set the "cycle" member of circle_ops to NULL. The widget argument
is the same as above.

	void circle_close(GtkWidget *widget);
This function is called when screentest wants to switch to another mode
(and is called before the new mode's init() function). You can use it to
deallocate fonts, colors, timers or other resources you have allocated
(for example in circle_init() function).  This function is optional, you can
set the "cycle" member of circle_ops to NULL. The widget argument
is the same as above.

4. You can use the following global variables in the above functions:

	GdkGC *gc, *backgc;
These are two graphic contexts. The first one has the foreground color set to
the current foregronund color (defafult white) and background color to the
current background color (default black). The second one has its foreground
color set to the current background color (default black) and the background
color to the current foreground color (default white). So you can use the
first to draw with the foreground color and the second to draw with the
background color. You can (ab)use these contexts for your own colors,
but remember to set the color back to its original value before your return
from the circle_* function.

	GdkColor fgcolors[COLOR_MAX];
The GdkColor array with preinitialized color values (see the enum test_color
in callbacks.h).

	GdkColor grays[GRAYS_MAX];
The GdkColor array with pixels preinitialized to the shades of gray.
grays[0] is black, grays[GRAYS_MAX-1] is white. Currently the
GRAYS_MAX is #defined to COLOR_MAX, but do not depend on it.

5. Use glade to add the new mode to the menu (alternatively, edit
screentest.glade by hand). Make sure the name of the menu item is the name of
your "<test>_ops" struct without the "_ops" ending.

6. Run automake, autoconf, ./configure and make.

7. If you want to distribute the resulting program:
Beware this program is under the GNU General Public License, so if you
distribute the modified version, you have to distribute the source code
of all your modifications. See the file COPYING for details.

You must make the circle_test.c available, but you don't have to send it
to the author of this program. However, author of this program kindly asks
you to contribute any modifications. Please send your modifications
to the author of screentest, Tobias Gruetzmacher <tobias@portfolio16.de>.
The preferred form of the contribution is an unified diff (see the diff(1)
manual page. To make a unified diff, follow these steps:

- rename your directory with modified sources (for example
	mv screentest-1.0 screentest-1.0-circle).
- run "make distclean" in this directory.
- unpack the clean sources again:
	zcat screentest-1.0.tar.gz | tar xvf -
- create the patch with the following command:
	diff -uNr screentest-1.0 screentest-1.0-circle >screentest-circle.patch
- mail the screentest-circle.patch to the author.

	Thanks,

- Tobias Gruetzmacher <tobias@portfolio16.de> (current maintainer)
- Jan "Yenya" Kasprzak <kas@fi.muni.cz> (previous maintainer)