2006-08-02 Johanes Schmid <jhs@gnome.org>
[anjuta-git-plugin.git] / HACKING
blob5ac75aab93565b405b1133821a35f48bf34dfc23
1 Notes for Developers on contributing to Anjuta:
2 ----------------------------------------------
3 (To be expanded over time. Please post submissions to the Anjuta 
4 Development mailing list or the project maintainer)
6 Getting Started:
7 ---------------
9 First thing to do is to get a build working. Anjuta can be built using jhbuild,
10 which is the recommended way to build GNOME 2.x and Anjuta. It is advisable to
11 use '--enable-warnings --enable-debug' with configure while building anjuta if
12 you want to hack on it. Anjuta can be used to hack on Anjuta, and there is a
13 anjuta.anjuta project file in CVS for this purpose.
15 Once you have got anjuta built and loaded in itself, the most important thing
16 is to decide what to work on (the TODO, as you say). There are many directions
17 you can take. I'm listing some of the more common ones in order of difficulty.
19 0. Use it, test it, report bug, request features, etc. In short, become
20 an active user. That is how most people become anjuta developers.
22 1. Documentation and translation. While this might not be a very
23 attractive option, it has many benefits for newbie developers. You get
24 to know the code and feature set better, and learn the way GNOME
25 projects are developed. Also, you will be helping a lot of people to use
26 Anjuta better. You can use the wiki or update the manuals, DAQ, etc.
27 that are supplied with the source.
29 2. Scratch your itch. This is probably the most attractive option for a
30 reasonably experienced developer. Find something which does not work for
31 you, or some feature that you want but is missing. Then report it on the
32 devel list saying that you'd want to work on it (this is essential to
33 avoid duplication). Then send us patches !
35 3. Fixing bugs and implementing feature requests. You can find our bug
36 and RFE database at http://bugzilla.gnome.org (the module is called anjuta).
37 You can also have a look at the reasonably up-to-date TODO file we maintain
38 in the source code or view it with Task Manager in Anjuta.
40 4. Working on the porting anjuta 1.2 features to anjuta2. This is a noble
41 undertaking but likely to be hard work, and probably not suitable for
42 newbie developers. Note that this is most code and plugins are ported but 
43 they might not yet be as good as in anjuta 1.2.
45 Resources:
46 ----------
47 - Homepage: http://www.anjuta.org/
48 - Project details page: http://sourceforge.net/projects/anjuta/
49 - CVS snapshots: http://www.anjuta.org/cvs/
50 - Anonymous CVS Access: cvs -z3 -d:pserver:anonymous@anoncvs.gnome.org:/cvs/gnome co anjuta
51 - Mailing Lists: http://sourceforge.net/mail/?group_id=14222
52 - Bug database: http://bugzilla.gnome.org (the module is called anjuta)
53 - Feature Requests: See Bug database above
54 - Forums: http://sourceforge.net/forum/?group_id=14222
55 - IRC: irc.gnome.org (Channel: #anjuta and #devel-apps)
57 Tools:
58 -----
59 Anjuta is written using a mixture of C and C++. You will require
60 the standard GNU tool chain and current stable GNOME libraries to 
61 build and work with the Anjuta sources.
62 New code should be in C as long as it does not touch the scintilla
63 editing component. C++ code is only allowed in the editor or if you 
64 need a library which is only availible in C++.
66 Submitting patches:
67 ------------------
68 Patches are good, and patches are always welcome! Small, self-contained 
69 patches are preferred - larger patches which touch on a large number 
70 of areas of the source tree are more complex to apply and test. 
72 Patches may be submitted to the project website, to the mailing lists, 
73 or directly to the project maintainer.
75 The six-step plan to patching happiness is as follows:
76 ------------------------------------------------------
77 1) All patches should be submitted in *unified* form, i.e. created 
78 with the command "diff -u" or "cvs diff -u"). 
80 Make your changes in all files (including the ChangeLog file) and run
81 "cvs diff -u > patch.diff" in the top level anjuta/ directory. This diff
82 file will contain patches for all of the files together.
84 Remember to run the cvs diff for the *top* project directory. It will
85 automatically recurse into the subdirectories and generate the patches.
87 We ask for patches in this format because:
88 - more often then not, patches are out of sync with current CVS. This 
89 can happen because someone is submitting a patch taken against an old 
90 version of Anjuta, or against anonymous CVS (which is usually out of 
91 sync for 24 hours). Therefore, the maintainers have to review patches 
92 manually.
93 - if a patch file is opened in Anjuta (or editors such as Nedit) in 
94 "Diff" mode, *unified* formats are more readable and errors and 
95 mis-syncs are easily detected. Non-unified formats are hard to read.
96 - unified patches are more intelligent in recognizing changed lines
97 (because by default there is a 3-line context buffer).
99 2) Diffs taken against CVS should be preceded by "cvs -z3 up" in 
100 *all* cases.
102 (Note: You can of course use the cvs plugin for all this stuff)
104 3) If the patch is big or is not high priority (i.e. things other than 
105 stability patches), then either send it to the lead developers directly 
106 (cc-ing them together is a nice idea), or file it at bugzilla.gnome.org. 
107 *Never* post big patches to the mailing lists, since they will annoy 
108 subscribers and are liable to be rejected by the list server. Send
109 a reference email to the list mentioning that you have sent a patch.
111 4) *Always* include a ChangeLog entry as part of the diff to ensure that
112 your entry is also committed directly with your name mentioned.
114 5) Name the patch with a useful filename. e.g. avoid calling your patch
115 patch.diff, anjuta.diff or something like that. It is easier to manage
116 a queue of patches named things like biswa-print-20020605.diff and 
117 bug-544912.diff as the names are more meaningful. Include the bug number
118 or your name and the date in the name of the file. Thanks!
120 Coding style:
121 --------------
122 Tab size = 4, Indentation = 4, Use tabs for indentation.
123 Autoformat style: Anjuta coding style.
124 Example code:
125 <pre>
126 gchar*
127 function (gchar *arg1, gint arg2, gint arg3, gpointer arg4, GHashTable *arg5,
128           gint arg7, gpointer arg7)
130     if (x == y)
131     {
132         switch (a)
133         {
134         case 1:
135             printf ("Hello World");
136         case 2:
137             printf ("Welcome to Anjuta");
138         default:
139             printf ("Welcome");
140         }
141     }
142     return str;
144 </pre>
146 - Try to limit the lines to 80 characters.
147 - Please try to write OO-code using GObject (or derived class) as baseclass.
148 This will lead to better design and clear module separation.
149 - If possible gnome-vfs is preferred to standard UNIX IO functions.
150 - Try to avoid forward declaration of static functions, try to keep them in 
151 order instead
152 - Use descriptive variable names like filename instead of f and cur_item instead
153 of i.
154 - If you use a "hack" please add a comment and say why this could not be done
155 cleaner.
157 General source structure:
158 ------------------------
159 When editing the code, adding new classes or methods, etc. please 
160 conform with the style already followed in the source files.
162 If a section of code will require further work, please add helpful
163 comments of the form /* FIXME: ... */, so that an external tool (such as
164 grep) can be used to identify them.
166 Separator in filename:
167 You should always use - instead of _, meaning anjuta-plugin.h
168 insted of anjuta_plugin.h
170 Key elements:
171 * libanjuta/ - Anjuta IDE framework
172 * scintilla/ - the scintilla editing component
173 * launcher/ - launcher wrapper used by the debugger
174 * tagmanager/ - the tagmanager library
175 * libegg/ - extra widgets
176 * plugins/ - plugin components (see the sample for more information)
177 * src/ - the main Anjuta IDE sources
178 * data/ - System data.
179 * mime/ - Mime related files.
180 * global-tags/ - System tags.
181 * manuals/ - All sorts of sgml documents (API and user).
183 Scintilla:
184 ---------
185 The editing component in Anjuta is Scintilla (www.scintilla.org). 
186 The Scintilla sources are imported to the scintilla/ directory in the
187 Anjuta source tree - some reorganization is required:
189 <pre>
190 Scintilla               Anjuta
191 ---------               ------
192 src/            ->      scintilla/
193 gtk/            ->      scintilla/
194 include/        ->      scintilla/include
195 </pre>
197 These are used to compile libscintilla.a, the library which provides
198 the bulk of Anjuta's editing functions.
200 The interface into Scintilla is in src/aneditor-*.cxx. This is based on
201 SciTE and a lot of care needs to be taken when merging code, since it
202 combines several different files from the SciTE source tree and is
203 quite flexible in the ways that they are used. Also, note that lexer
204 objects from Scintilla must be referenced in src/Makefile.am in order 
205 to get linked into Anjuta.
207 Messages and translations:
208 -------------------------
209 There are a few rules we ask contributors to follow when adding new
210 message strings and labels to Anjuta.
212 1. BE CONSISTENT!! 
213 - refer to the standard GNOME Word List in the GNOME Style Guide 
214 (http://developer.gnome.org/documents/style-guide/) when referencing 
215 different user interface features, and then use the same terminology 
216 throughout. Try to ensure that your use of words matches the rest of
217 the code.
218 - make sure that mixed case is only used where it makes sense to do so.
220 Example: "Unable to Start Plug in Module %s".
221 This message is not ideal since the standard terminology is "plugin" (so 
222 please do not use "Plug in", "plug-in", etc.). Also, in this case there 
223 is no reason for the words "start" and "module" to start with an uppercase 
224 letter.
226 There are a few standard terms we use - in particular:
227 - plugin
228 - Project (always with an uppercase P)
230 2. Do not use contractions (don't, can't, etc.). These can make a message 
231 difficult to translate.
233 3. Do not use colloquial expressions. They may seem cool or amusing, but 
234 actually they can be hard to translate into all languages. Also, although as 
235 developers it is OK to have fun, messages with certain language in them can be 
236 intimidating for new or inexperienced users, and are not very professional.
238 Example: "You FOOL! I can not attach to myself." 
239 This message was originally used in the debugger code, and was removed some 
240 time ago. It is quite fun, but a new user might be put off. 
242 4. Do not use the first person "I" for referring to Anjuta in messages 
243 (again, the previous message is an example of this). This is bad practice in 
244 technical writing. If you need to refer to Anjuta itself, please use the word
245 "Anjuta"! :-)
247 Documentation:
248 -------------
249 The documentation is stored in the manuals/ directory, and consists 
250 of a set of SGML sources conforming to the GNOME Documentation Project's
251 Style Guide. Please ensure that all additions also follow these guidelines.
253 Screenshots used in the manual are processed using The Gimp. Single dialogs
254 and menus are converted to RGB and the Script-Fu Drop Shadow effect applied 
255 (with the default settings). All documentation images are in PNG format.
257 Translations of application messages are stored in the standard po/ 
258 directory structure at the top level of the source tree.
260 Graphics:
261 --------
262 PNG format is preferred for application graphics.
264 The image filenames are mapped in the file src/pixmaps.h, with helper functions
265 for manipulating them in src/resources.c. Please use this method for including
266 graphics and do not use the filenames directly.
268 ARCHITECTURE:
269 -------------
271 You can find the API documentation of anjuta in the 
272 "Anjuta Developers Reference Manual" devhelp book!
274 1) Event Driven:
275 ----------------
276 When Anjuta was first designed, the primary goal was to enable the use of 
277 external unix commands in a more productive and intuitive way. Therefore,
278 anjuta follows non-blocking input/output operations aggressively. This means
279 that anjuta UI will not freeze while it performs a lengthy task. All such
280 jobs are event-driven (I am not referring to the gtk-events here) and works
281 on asynchronous basis. The example jobs are compilation, debugging, file search,
282 class updates etc. While asynchronous event-driven implementation is more
283 complex than it's synchronous counter part, it gives a smooth and non frustrative
284 operation. :-)
286 For details how to use the anjuta-launcher consult AnjutaLauncher reference
287 documentation in libanjuta.
289 2) How to add new menu/toolbar items in the Main Menu:
290 ----------------------------------------------
292 Anjuta uses GtkUIManager for creating it's UI. Libanjuta does provide
293 some wrapper functions in anjuta-ui.h. Take a look at the *.ui files in the 
294 plugins, the Plugin docs in the reference and read the GtkUIManager docs for
295 details.
297 4) Dialogs and Windows:
298 -----------------------
300 Dialogs and Windows should be build using libglade. They should be HIG compliant
301 (http://developer.gnome.org/projects/gup/hig/)
303 - All dialogs should be closable by 'ESC'
304 - All dialogs should have default action.
306 5) Property/Config management:
307 ------------------------------
309 Anjuta has a very powerful preferece management. You can read the docs of
310 AnjutaPreferences in the reference.
312 7) How to add a new project type:
313 ---------------------------------
315 FIXME: For no take a look at the project types in 
316 plugins/project-wizard/templates
318 8) Debug messages
319 ---------------------------------
321 Do not use g_message/g_warning for debug messages. Use DEBUG_PRINT instead which
322 is defined in libanjuta/anjuta-debug.h. This will assure that debug messages
323 are only presented to developers and not to normal users. Debug messages will
324 only be shown if --enable-debug is passed to configure/autogen which means that
325 DEBUG is defined.
328 9) How to correctly credit people:
329 ----------------------------------
331 New contributors must always be credited in AUTHORS file
333 You should also ensure that you submit headed ChangeLog entries with a 
334 name and e-mail address when you submit a patch.