2008-10-11 05:27:52 +00:00
This file is licensed under the terms of the expat license, see the file EXPAT.
2010-04-20 16:11:25 +00:00
+ Hacking guide for Midori +
- How to contribute
- Coding style
- Source files in the project
- Examplary source code
+++ How to contribute +++
There are several ways to contribute to the project:
For translating, have a look at the file TRANSLATE.
For helping with testing and triaging bug reports, you should registers with the bug tracker at http://www.twotoasts.de/bugs and join #midori on irc.freenode.net where a lot of problems are discussed. You can start right away by trying to reproduce bug reports and comment with your findings.
If you are interested in contributing code, there are a few options. You can join #midori to discuss a particular problem you would like to look into, or a feature you would want to implement. Opening a bug report or feature request if there isn't already one is the next step. To attract some attention, if you attached a patch or have questions, ask in #midori.
+++ Coding style +++
2007-12-16 22:20:24 +00:00
2010-01-26 21:24:29 +00:00
Indentation is 4 spaces, no tabs, preferrably at 80 to 120 columns per line to
avoid automated line-breaks. Trailing whitespace is not desirable.
2007-12-16 22:20:24 +00:00
2010-01-29 22:21:36 +00:00
Declarations go to the beginning of a block, not inline. Variables of one plain
type may be grouped in one declaration, pointer types may not be grouped. The
asterisk goes next to the type.
2010-02-06 16:31:03 +00:00
Variables should be ordered in the order they are used.
2010-01-29 22:21:36 +00:00
Comments explain functionality, they should not state facts. The appropriate
style is always C style /* */, not C++ style.
2010-01-26 21:24:29 +00:00
Variable and function names should be animal, animal_shelter or animalsc in
case it would otherwise be very long. Loop counters may be single letters.
2010-02-06 16:31:03 +00:00
Type names should be Animal, AnimalShelter or AnimalSC. No prefixes from third
party projects should be used, such as GTK or WebKit, while underlines may be
used but do not have a particular meaning.
2010-01-26 21:24:29 +00:00
There is a space between functions or keywords and round brackets, and curly
brackets always go on separate lines, at the indentation level of the
2010-01-29 22:21:36 +00:00
function, conditional or loop expression. Curly brackets are left out for single
statement conditionals and loops unless they notably help readability.
2010-01-26 21:24:29 +00:00
The type of a function goes on a separate line before the function.
Preprocessor instructions are indented with the code they relate to.
Code history is precious, so one should avoid renaming a lot of functions at
once or moving whole paragraphs only to add or remove a level of indentation.
Moving blocks of code around is also undesriable because it makes patches less
readable since the result looks like new code.
+++ Source files in the project +++
Core:
Files prefixed with "midori-" in the folder "midori" make up the core. They
are essential to running the browser and mostly tailored to the browser.
All header files prefixed with "midori-" are considered supported API and
can be used to implement extensions.
"sokoke" is a collection of very specialized helper functions which change
from time to time as needed. In the past some of the code was moved to
"katze" when it was considered generally useful.
"socket" is a socket implementation with no dependency on other parts of
the core, which is used if Midori is built without an external single
instance support library.
Panels:
Files in the "panels" folder are classes that implement MidoriViewable and
which are loaded into the MidoriPanel at startup. These panels are in
principle optional.
Katze:
Re-usable classes and utility functions that don't depend on the core and
some of that code indeed found its way into other projects.
Extensions:
These are extensions, written in C, which are loaded optionally if the user
so chooses. Extensions can use API from "midori-" and "katze-" headers. Each
module consists of either a single .c file or a folder with .c files.
Tests:
Unit tests are run regularly to verify possible regressions or measure
performance of implementations. Except for select cases code changes should
not cause failure of unit tests.
+++ Examplary source code +++
2007-12-16 22:20:24 +00:00
/*
Copyright
LICENSE TEXT
*/
#include "foo.h"
#include "bar.h"
#include <glib.h>
2008-04-16 23:39:07 +00:00
void
foobar (FooEnum bar, const gchar* foo)
2007-12-16 22:20:24 +00:00
{
2008-07-27 05:43:30 +00:00
gint n, i;
if (!foo)
2007-12-16 22:20:24 +00:00
return;
#ifdef BAR_STRICT
2008-03-10 21:26:09 +00:00
if (bar == FOO_N)
2007-12-16 22:20:24 +00:00
{
2008-03-10 21:26:09 +00:00
g_print ("illegal value for 'bar'.\n");
2007-12-16 22:20:24 +00:00
return;
}
#endif
2008-07-27 05:43:30 +00:00
/* this is an example */
2008-03-10 21:26:09 +00:00
switch (bar)
2007-12-16 22:20:24 +00:00
{
case FOO_FOO:
n = bar + 1;
break;
case FOO_BAR:
n = bar + 10;
break;
default:
n = 1;
}
2008-03-10 21:26:09 +00:00
for (i = 0; i < n; i++)
2007-12-16 22:20:24 +00:00
{
2008-03-10 21:26:09 +00:00
g_print ("%s\n", foo);
2007-12-16 22:20:24 +00:00
}
}
Header file example:
/*
Copyright
LICENSE TEXT
*/
#ifndef __FOO_H__
#define __FOO_H__ 1
#ifdef HAVE_BAR_H
#define BAR_STRICT
#endif
2008-07-27 05:43:30 +00:00
/* Types */
2007-12-16 22:20:24 +00:00
typedef enum
{
FOO_FOO,
FOO_BAR,
FOO_N
} FooEnum;
typedef struct
{
2008-03-10 21:26:09 +00:00
FooEnum foo_bar;
2007-12-16 22:20:24 +00:00
} FooStruct;
2008-07-27 05:43:30 +00:00
/* Declarations */
2007-12-16 22:20:24 +00:00
void
2008-03-10 21:26:09 +00:00
foo_bar (FooEnum bar,
const gchar* foo);
const gchar*
foo_foo (FooStruct foo_struct,
guint number,
gboolean flag);
2007-12-16 22:20:24 +00:00
#endif /* !__FOO_H__ */