ca55a2399569f78c5e3fb6fb1199e1c72e50f2fe
[geeqie.git] / CODING
1 Log Window:
2
3 DEBUG_0()
4 Use DEBUG_0() only for temporary debugging i.e. not in code in the repository.
5 The user will then not see irrelevant debug output when the default
6 debug level = 0 is used.
7
8 log_printf()
9 If the first word of the message is "error" or "warning" (case insensitive)
10 the message will be color-coded appropriately.
11
12 --------------------------------------------------------------------------------
13
14 GPL header, in every file, like this:
15
16 /** \file
17  * \short Short description of this file.
18  * \author Author1
19  * \author Author2
20  *
21  * Optionaly detailed description of this file
22  * on more lines.
23  */
24
25 /*
26  *  This file is a part of Geeqie project (http://www.geeqie.org/).
27  *  Copyright (C) 2008 - 2016 The Geeqie Team
28  *
29  *  This program is free software; you can redistribute it and/or modify it
30  *  under the terms of the GNU General Public License as published by the Free
31  *  Software Foundation; either version 2 of the License, or (at your option)
32  *  any later version.
33  *
34  *  This program is distributed in the hope that it will be useful, but WITHOUT
35  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
37  *  more details.
38  */
39
40 --------------------------------------------------------------------------------
41
42 svn change-log:
43
44 Start with a short summary in the first line (without a dot at the end) followed
45 by a empty line. Use whole sentences begins with Capital letter. For each
46 modification use new line. Or you can write the theme, colon and then every
47 change on new line, begin with "- ".
48
49 See also: http://www.tpope.net/node/106
50
51 Example:
52
53    I did some bugfixes
54
55    There was the bug that something was wrong. I fixed it.
56
57    Library:
58    - the interface was modified
59    - new functions were added
60
61 --------------------------------------------------------------------------------
62
63 sources:
64
65 Indentation: tabs
66 Names of variables & functions:  small_letters
67       of defines:                CAPITAL_LETTERS
68
69 Try to use explicit variable and function names.
70
71 Try not to use macros.
72 Use EITHER "struct foo" OR "foo"; never both
73
74
75 Conditions, cycles:
76
77 if (<cond>)
78         {
79         <command>;
80         ...
81         <command>;
82         }
83 else
84         {
85         <command>;
86         ...
87         <command>;
88         }
89
90 if (<cond_very_very_very_very_very_very_very_very_very_long> &&
91     <cond2very_very_very_very_very_very_very_very_very_long>)
92     <the_only_command>;
93
94 switch (<var>)
95         {
96         case 0:
97                 <command>;
98                 <command>;
99                 break;
100         case 1:
101                 <command>; break;
102         }
103
104 for (i = 0; i <= 10; i++)
105         {
106         <command>;
107         ...
108         <command>;
109         }
110
111
112 Functions:
113
114 gint bar(<var_def>, <var_def>, <var_def>)
115 {
116         <command>;
117         ...
118         <command>;
119
120         return 0; // i.e. SUCCESS; if error, you must return minus <err_no>
121 }
122
123 void bar2(void)
124 {
125         <command>;
126         ...
127         <command>;
128 }
129
130 Pragma: (Indentation 2 spaces)
131
132 #ifdef ENABLE_NLS
133 #  undef _
134 #  define _(String) (String)
135 #endif /* ENABLE_NLS */
136
137 Headers:
138
139 #ifndef _FILENAME_H
140
141 --------------------------------------------------------------------------------
142
143 Use spaces around every operator (except ".", "->", "++" and "--");
144         unary operator '*' and '&' are missing the space from right;
145         (and also unary '-').
146 As you can see above, parentheses are closed to inside, i.e. " (blah blah) "
147     In "function(<var>)" there are no space before '('.
148 You MAY use more tabs/spaces than you OUGHT TO (according to this CodingStyle), if
149         it makes your code nicer in being verticaly indented.
150 Variables declarations should be followed by a blank line and should always be
151 at the start of the block.
152
153 --------------------------------------------------------------------------------
154
155 Use glib types when possible (ie. gint and gchar instead of int and char).
156 Use glib functions when possible (ie. g_ascii_isspace() instead of isspace()).
157 Check if used functions are not deprecated.
158
159 --------------------------------------------------------------------------------
160
161 Documentation:
162
163 To document the code use the following rules to allow extraction with doxygen.
164 Do not save with comments. Not all comments have to be doxygen comments.
165
166 - Use C comments in plain C files and use C++ comments in C++ files for one line
167   comments.
168 - Use '/**' (note the two asterisks) to start comments to be extracted by
169   doxygen and start every following line with " *".
170 - Use '\' to indicate doxygen keywords/commands (see below).
171 - Use the '\deprecated' command to tell if the function is subject to be deleted
172   or to a  complete rewrite.
173
174 Example:
175
176 To document functions or big structures:
177    /**
178     * \brief This is a short description of the function.
179     *
180     * This function does ...
181     *
182     * \param x1 This is the first parameter named x1
183     * \param y1 This is the second parameter named y1
184     * \return What the function returns
185     *    You can extend that return description (or anything else) by indenting the
186     *    following lines until the next empty line or the next keyword/command.
187     * \see Cross reference
188     */
189
190 To document members of a structure that have to be documented (use it at least
191 for big structures) use the '/**<' format:
192    int counter; /**< This counter counts images */
193
194 For further documentation about doxygen see
195 http://www.stack.nl/~dimitri/doxygen/manual.html. For the possible commands you
196 can use see http://www.stack.nl/~dimitri/doxygen/commands.html.
197
198 But in case just think about that the documentation is for other developers not
199 for the end user. So keep the focus.