Updated CODING (GPL header, macros, svn change-log, ...).
[geeqie.git] / CODING
1 GPL header, in every file, like this:
2
3 /** @file relativ/path/with/this/file/name.c
4  * Short description of this file.
5  * @author Author1
6  * @author Author2
7  *
8  * Optionaly detailed description of this file
9  * on more lines.
10  */
11                                                                                 
12 /*
13  *  This file is a part of Geeqie project (http://geeqie.sourceforge.net/).
14  *  Copyright (C) 2008 Geeqie team
15  *
16  *  This program is free software; you can redistribute it and/or modify
17  *  it under the terms of the GNU General Public License as published by
18  *  the Free Software Foundation; either version 2 of the License, or
19  *  (at your option) any later version.
20  *
21  *  This program is distributed in the hope that it will be useful,
22  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  *  GNU General Public License for more details.
25  */
26
27 --------------------------------------------------------------------------------
28
29 svn change-log:
30
31 Use whole sentences begins with Capital letter. For each modification use new line.
32 Or you can write the theme, colon and then every change on new line, begin
33 with "- ".
34
35 Example:
36
37 I done some bugfixes.
38 Library:
39 - I change the interface
40 - added some new functions
41
42 --------------------------------------------------------------------------------
43
44 sources:
45
46 Indentation: tabs
47 Names of variables & functions: small_letters
48       of defines: CAPITAL_LETTERS
49
50 Try to use explicit variable and function names.
51
52
53 Try not to use macros.
54 Use EITHER "struct foo" OR "foo"; never both
55
56 Conditions, cycles:
57
58 if (<cond>)
59         {
60         <command>;
61         ...
62         <command>;
63         }
64 else
65         {
66         <command>;
67         ...
68         <command>;
69         }
70                                                                                 
71 if (<cond_very_very_very_very_very_very_very_very_very_long> &&
72     <cond2very_very_very_very_very_very_very_very_very_long)
73     <the_only_command>;
74
75 switch (<var>)
76         {
77         case 0:
78                 <command>;
79                 <command>;
80                 break;
81         case 1:
82                 <command>; break;
83         }
84
85 for (i = 0; i <= 10; i++)
86         {
87         <command>;
88         ...
89         <command>;
90         }
91         
92
93 Functions:
94
95 int bar(<var_def>, <var_def>, <var_def>)
96 {
97         <command>;
98         ...
99         <command>;
100
101         return 0; // i.e. SUCCESS; if error, you must return minus <err_no>
102 }
103
104 void bar2(void)
105 {
106         <command>;
107         ...
108         <command>;
109 }
110
111 Pragma: (Indentation 2 spaces)
112
113 #ifdef ENABLE_NLS
114 #  undef _
115 #  define _(String) (String)
116 #endif /* ENABLE_NLS */
117
118 Headers:
119
120 #ifndef _FILENAME_H
121
122 --------------------------------------------------------------------------------
123
124 Use spaces around every operator (except ".", "->", "++" and "--");
125         unary operator '*' and '&' are missing the space from right;
126         (and also unary '-').
127 As you can see above, parentheses are closed to inside, i.e. " (blah blah) "
128     In "function(<var>)" there are no space before '('. 
129 You MAY use more tabs/spaces than you OUGHT TO (according to this CodingStyle), if
130         it makes your code nicer in being verticaly indented.
131
132 --------------------------------------------------------------------------------
133
134 Use glib types when possible (ie. gint and gchar instead of int and char).
135 Use glib functions when possible (ie. g_ascii_isspace() instead of isspace()).
136 Check if used functions are not deprecated.
137
138 --------------------------------------------------------------------------------
139
140 Documentation: use Doxygen