wiki:HackingGtk

Version 3 (modified by alp@atoker.com, 16 years ago) (diff)

Mention the build bots

Hacker's guide to WebKit/GTK+

Code layout

The GTK+ port targets the cross-platform GLib and GTK+ APIs as well as related libraries. This means that it can be built against any of the windowing systems supported by GTK+ and Cairo without modification -- those tested so far are X11 and DirectFB. Windows should work too.

Code specific to any one backend should be conditionally compiled only when that windowing system is available. One examples of this kind of feature might be direct X11/Win32 use for plugin support. This can be done at configure time or with a switch passed to the build system, or even just using the definitions provided by the gdk headers.

The main components of the port:

Gtk+-specific modules

  • Public API: WebKit/gtk
    • Api -- The actual public GObject API and header files.
    • WebCoreSupport -- These are conceptually partial classes for the implementations in "Api". The two might merge at some point.

There may be other gtk-port related directories which have yet to be listed here.

Shared code modules

While the Gtk+ port is the primary consumer of these backends, we aim to keep them portable, avoiding even ifdef'd sections specific to the Gtk+ port:

Working on WebCore

  • The GTK+ elements of WebCore follow the WebKit coding style.
  • There is no API stability in this layer. If an abstraction does not fit GTK+/Cairo/GStreamer/CURL concepts, feel free to seek advice on how to generalise the abstraction layer. This should not be necessary too often though.
  • Documentation is generally avoided in favour of clear, self-explanatory code and good variable names.

Working on the public API

  • Document new additions with GtkDoc. It is OK to base GTK+ API documentation on the Objective-C documentation, but remember that "the receiver" will be "@this" or similar in GTK+ terminology, and a "method" translates to a "function" etc.
  • If you find mistakes in the Objective-C API documentation, take notes and add them in the comments of your bug report.
  • Check function parameters with g_return_if_fail() and g_return_val_if_fail()
  • Try to cover implement several functions at the same time to get a better understanding of how they work together and to improve consistency. This is more effective than just implementing functions and signals one by one as needed.
  • Avoid drawing inspiration from ports other than Mac and Win, since they might have decided to follow their own interpretation. This is like going for the primary sources in a research project.
  • If a method looks strange or out of place, ask awkward questions until someone explains why it is the way it is. The Mac port may contain deprecated/bad API that exists only for the sake of compatibility -- we want to learn form those mistakes rather than copying them.

The build bots

There is a build bot available for most ports including GTK+. The waterfall view is particularly useful.

This helps keep all the ports buildable. There is also compile output provided which is helpful for understanding the build environments and compiler flags used by other ports and tracking down compiler warnings.