* src/modest-mail-operation.c:
[modest] / HACKING
1 HACKING
2 =======
3
4 When hacking on modest, please honour these time-tested coding guidelines.
5 First, please follow the Linux CodingStyle guidelines
6 (/usr/src/linux/Documentation/CodingStyle); for naming, follow the
7 Gtk/GObject guidelines.
8     
9 Here are some additional notes.
10
11 Your editor may help you with this, for example for emacs:
12
13         (c-set-style "K&R")
14         (setq tab-width 8)
15         (setq indent-tabs-mode t)
16         (setq c-basic-offset 8)
17       
18 Or the equivalent for your favourite editor.
19
20 Lines must not exceed 100 characters.
21
22 Functions should do one thing, and do it well. In general, functions
23 should not be much longer than 20-30 lines (except for, say, handling
24 many different cases in a 'switch'-statement). Files should not get to
25 big either; if there are more than, say,1000 lines, it's a sign that
26 some refactoring should take place.
27
28 Code should compile cleanly with gcc's -Wall compile option. Of course this
29 might not always be possible due to problems in dependent libraries and/or
30 compiler version. Therefore, do not include -Werror in the standard compile
31 options; but do use it when building / testing things yourself.
32
33 Code should also run cleanly. GTK+/GLib warnings and errors must be
34 taken very seriously.
35     
36 Global functions (the ones in .h-files) must be commented using the gtk-doc
37 system. This way, we generate nice documentation. After installing
38 (under /usr/local), we can browse the results with DevHelp. Just
39 add /usr/local/share/gtk-doc/html to the DEVHELP_SEARCH_PATH-environment variable.  
40
41 g_signal callback function start with 'on_', ie. for a signal "foo-actived",
42 the corresponding callback function will be called on_foo activated. (if
43 needed, an namespace prefixes)
44
45 global (non-static) functions check their arguments with g_return_if_fail/
46 g_return_val if_fail. This will give runtime warnings, and point to bugs in
47 the code. Non-bug problems however, should be reported with g_printerr. 
48        g_printerr ("modest: cannot find icon\n")
49
50 Furthermore, please follow 'conventional wisdom' for programming with 
51 GLib/GTK+/GObject. Some things to remember:
52
53 * g_new, g_malloc and friends never return NULL. They terminate
54   the application if it happens (normally).  Therefore, no need to check
55   for NULL returns;
56 * g_return_if_fail, g_return_if_reached and friends may be 'turned off', 
57   ie. they are to be used for error checking,  but not for your programming logic