Blame CONTRIBUTING.md

rpm-build f53ec4
# Contributing
rpm-build f53ec4
rpm-build f53ec4
## Licensing
rpm-build f53ec4
rpm-build f53ec4
Your work is considered a derivative work of the libdazzle codebase and therefore must be licensed as GPLv3+.
rpm-build f53ec4
You may optionally grant other licensing in addition to GPLv3+ such as LGPLv2.1+ or MIT X11.
rpm-build f53ec4
However, as part of libdazzle, which is GPLv3+, the combined work will be GPLv3+.
rpm-build f53ec4
rpm-build f53ec4
You do not need to assign us copyright attribution.
rpm-build f53ec4
It is our belief that you should always retain copyright on your own work.
rpm-build f53ec4
rpm-build f53ec4
## Testing
rpm-build f53ec4
rpm-build f53ec4
When working on a new widget or tool, try to write unit tests to prove the implementation.
rpm-build f53ec4
Not everything we have in the code base has tests, and ideally that will improve, not get worse.
rpm-build f53ec4
rpm-build f53ec4
## Troubleshooting
rpm-build f53ec4
rpm-build f53ec4
If you configure the meson project with `-Denable_tracing=true` then libdazzle with be built with tracing.
rpm-build f53ec4
This allows various parts of the code to use `DZL_ENTRY`, `DZL_EXIT` and other tracing macros to log function calls.
rpm-build f53ec4
You might find this useful in tracking down difficult re-entrancy or simply learn "how does this work".
rpm-build f53ec4
rpm-build f53ec4
If you need to add additional tracing macros to debug a problem, it is probably a good idea to submit a patch to add them.
rpm-build f53ec4
Chances are someone else will need to debug stuff in the future.
rpm-build f53ec4
rpm-build f53ec4
## Code Style
rpm-build f53ec4
rpm-build f53ec4
We follow the GObject and Gtk coding style.
rpm-build f53ec4
That is often unfamiliar to those who have not been hacking on GNU projects for the past couple of decades.
rpm-build f53ec4
However, it is largely entrenched in our community, so we try to be consistent.
rpm-build f53ec4
rpm-build f53ec4
```c
rpm-build f53ec4
static gboolean
rpm-build f53ec4
this_is_a_function (GtkWidget    *param,
rpm-build f53ec4
                    const gchar  *another_param,
rpm-build f53ec4
                    guint         third_param,
rpm-build f53ec4
                    GError      **error)
rpm-build f53ec4
{
rpm-build f53ec4
  g_return_val_if_fail (GTK_IS_WIDGET (param), FALSE);
rpm-build f53ec4
  g_return_val_if_fail (third_param > 10, FALSE);
rpm-build f53ec4
rpm-build f53ec4
  if (another_param != NULL)
rpm-build f53ec4
    {
rpm-build f53ec4
      if (!do_some_more_work ())
rpm-build f53ec4
        {
rpm-build f53ec4
          g_set_error (error,
rpm-build f53ec4
                       G_IO_ERROR,
rpm-build f53ec4
                       G_IO_ERROR_FAILED,
rpm-build f53ec4
                       "Something failed");
rpm-build f53ec4
          return FALSE;
rpm-build f53ec4
        }
rpm-build f53ec4
    }
rpm-build f53ec4
rpm-build f53ec4
goto_labels_here:
rpm-build f53ec4
rpm-build f53ec4
  return TRUE;
rpm-build f53ec4
}
rpm-build f53ec4
```
rpm-build f53ec4
rpm-build f53ec4
```c
rpm-build f53ec4
void      do_something_one   (GtkWidget  *widget);
rpm-build f53ec4
void      do_something_two   (GtkWidget  *widget,
rpm-build f53ec4
                              GError    **error);
rpm-build f53ec4
gchar    *do_something_three (GtkWidget  *widget);
rpm-build f53ec4
gboolean  do_something_four  (GtkWidget  *widget);
rpm-build f53ec4
```
rpm-build f53ec4
rpm-build f53ec4
 * Notice that we use 2-space indention.
rpm-build f53ec4
 * We indent new blocks {} with 2 spaces, and braces on their own line. We understand that this is confusing at first, but it is rather nice once it becomes familiar.
rpm-build f53ec4
 * No tabs, spaces only.
rpm-build f53ec4
 * Always compare against `NULL` rather than implicit comparisons. This eases ports to other languages and readability.
rpm-build f53ec4
 * Use #define for constants. Try to avoid "magic constants".
rpm-build f53ec4
 * goto labels are fully unindented.
rpm-build f53ec4
 * Align function parameters.
rpm-build f53ec4
 * Align blocks of function declarations in the header. This vastly improves readability and scanning to find what you want.
rpm-build f53ec4
rpm-build f53ec4
If in doubt, look for examples elsewhere in the codebase.
rpm-build f53ec4