Difference between revisions of "Developer manual"

From Inkscape Wiki
Jump to navigation Jump to search
(Update string management)
 
(38 intermediate revisions by 21 users not shown)
Line 1: Line 1:
= Inkscape Developer's Manual =
= Inkscape Developer’s Manual =
 
 
 
 
'''Please first read the short introduction:'''
 
 
'''Getting started with development  ---> https://inkscape.org/develop/getting-started/'''
 
 


== Introduction ==
== Introduction ==


For those of you just joining us, or who have been with us but are just
For those of you just joining us, or who have been with us but are just
now getting the itch to work on Inkscape, I thought I'd give some tips
now getting the itch to work on Inkscape, I thought I’d give some tips
for how to get started working in the codebase based on our own
for how to get started working in the codebase based on our own
experiences.
experiences.


One of the first things most people wonder is "what should I work on".
One of the first things most people wonder is “What should I work on?”.
As you may have already noticed, we generally don't "assign" projects.
As you may have already noticed, we generally don’t “assign” projects.
We figure there's plenty more work to do than people to do it, so you
We figure there’s plenty more work to do than people to do it, so you
may as well work on something that you're either interested in or that
may as well work on something that you’re either interested in or that
adds something of benefit to you; that's extra motivation to get your
adds something of benefit to you; that’s extra motivation to get your
own itches scratched.
own itches scratched.


If you're really stumped though, we keep a detailed roadmap in wiki that
If you’re really stumped though, we keep a detailed [[Roadmap]] in wiki that
you're welcome to browse through to look for ideas of things to work
you’re welcome to browse through to look for ideas of things to work
on.  Tasks that do not have names beside them are open for anyone to
on.  Tasks that do not have names beside them are open for anyone to
take; if you want to take ownership of a task, just put your name beside
take; if you want to take ownership of a task, just put your name beside
it.  Feel free to add or reword tasks as needed, although try not to
it.  Feel free to add or reword tasks as needed, although try not to
load up the current milestone with tasks that aren't critical for the
load up the current milestone with tasks that aren’t critical for the
release.  Feel free to work on stuff that is several milestones down the
release.  Feel free to work on stuff that is several milestones down the
road; there's rarely any problem with getting stuff done sooner than
road; there’s rarely any problem with getting stuff done sooner than
planned.  ;-)
planned.  ;-)


We have a process for gaining CVS commit access.  The reason is that
We have a process for gaining GitLab Developer access.  The reason is that
while it is important that we keep access to the codebase open, we don't
while it is important that we keep access to the codebase open, we don’t
want to be crazy and leave it wide open to any random passer-by.  The
want to be crazy and leave it wide open to any random passer-by.  The
process is that we require that the person make two contributions
process is that we require that the person make two contributions
Line 32: Line 42:
to get account access.
to get account access.


In general you won't need CVS commit access in order to start doing
In general you won’t need Developer role in order to start doing
development, because you can work from an anonymous checkout and create
development, because you can create merge requests with only a regular account. Due to GitLab constraints however, you won't be able to run Windows or MacOS CI - but we can always do that for you.
patches. If you've not done this before, you'll need to learn this
skill first (basically see docs for `cvs diff`).


When you first start hacking on Inkscape code, I wouldn't recommend
When you first start hacking on Inkscape code, I wouldn’t recommend
taking an objective of implementing a specific feature, because you will
taking an objective of implementing a specific feature, because you will
need some time to familiarize yourself with the codebase, and because
need some time to familiarize yourself with the codebase, and because
you won't really know what features are going to be straightforward to
you won’t really know what features are going to be straightforward to
implement and which will be highly challenging.  Of course, if you have
implement and which will be highly challenging.  Of course, if you have
the time and love adventures, this might be fun way to go.
the time and love adventures, this might be a fun way to go.


There are four approaches that I've seen people effectively use in
There are four approaches that I’ve seen people effectively use in
getting into the codebase:
getting into the codebase:


<ul>
<ul>
<li>Write code documentation.  Some people who don't mind adding
<li><strong>Write code documentation.</strong> Some people who don’t mind adding
comments to code or writing docs find it useful to just go through
comments to code or writing docs find it useful to just go through
code they're interested in working on and writing up what it does.
code they’re interested in working on and writing up what it does.
The codebase is in dire need of better docs, so this approach pays
The codebase is in dire need of better docs, so this approach pays
dividends well into the future.
dividends well into the future.
</li>
</li>


<li>Fix bugs.  Tracing down the cause of reported bugs is an effective
<li><strong>Fix bugs.</strong> Tracing down the cause of reported bugs is an effective
way to gain understanding of the codebase in small chunks.  Many
way to gain understanding of the codebase in small chunks.  Many
common bugs can be traced down and fixed in a matter of hours, and
common bugs can be traced down and fixed in a matter of hours, and
often will identify some bit of code in need of refactoring or
often will identify some bit of code in need of refactoring or
extension.  Note that some of our older bugs are in the system
extension.  Note that some of our older bugs are in the system
because they're hard to fix, so you'll want to work on the more
because they’re hard to fix, so you’ll want to work on the more
recent ones.
recent ones.
</li>
</li>


<li>Chip in on a group effort.  Occasionally we identify a major
<li><strong>Chip in on a group effort.</strong> Occasionally we identify a major
refactoring effort (such as when we converted from C to C++), that
refactoring effort (such as when we converted from C to C++), that
we encourage lots of people to help on, in the philosophy that many
we encourage lots of people to help on, in the philosophy that many
hands makes short work.  This work tends to be pretty rote so is
hands make light work.  This work tends to be pretty rote so is
not hard for new folks to get involved with; just takes time.  We
not hard for new folks to get involved with; it just takes time.  We
generally have one of these kinds of efforts per release.  It
generally have one of these kinds of efforts per release.  It
usually isn't glamorous work, but in aggregate moves the codebase
usually isn’t glamorous work, but in aggregate moves the codebase
forward in a major way.
forward in a major way.
</li>
</li>


<li>Subsystem/module work.  Some people want to get their hands in the
<li><strong>Subsystem/module work.</strong> Some people want to get their hands in the
details quick, so take the approach of developing new code separate
details quick, so take the approach of developing new code separate
from the codebase, to be integrated in later.  This generally tends
from the codebase, to be integrated in later.  This generally tends
to take a larger time commitment than the other approaches, but can
to take a larger time commitment than the other approaches, but can be
an effective approach in some circumstances.  We have a CVS module
an effective approach in some circumstances.  We have a SVN module
called 'experimental' that you're welcome to house your work until
called <code>experimental</code> that you’re welcome to house your work until
it's ready for prime time.
it’s ready for prime time.
</li>
</li>
</ul>
</ul>


Beyond that, you're going to find the documentation for the Inkscape
Beyond that, you’re going to find the documentation for the Inkscape
code is pretty scarce.  We've worked on bits and pieces but
code is pretty scarce.  We’ve worked on bits and pieces but
unfortunately the vast majority of the code is undocumented.  On the
unfortunately the vast majority of the code is undocumented.  On the
plus side, often you can implement the stuff you care about after
plus side, often you can implement the stuff you care about after
learning only a limited portion of the codebase.
learning only a limited portion of the codebase.


I think you'd find Inkscape an enjoyable Open Source project to work on.
I think you’d find Inkscape an enjoyable Open Source project to work on.
There's a huge range of interesting and useful skills that can be
There’s a huge range of interesting and useful skills that can be
learned from it, plus the developers are great guys to participate with.
learned from it, plus the developers are great guys to participate with.
The project itself runs smoothly and puts a premium on keeping things
The project itself runs smoothly and puts a premium on keeping things
friendly and low-stress, so heated arguments are rare.  The users have
friendly and low-stress, so heated arguments are rare.  The users have
been great to work with and very appreciative of even small new features
been great to work with and very appreciative of even small new features
and fixes.  Plus, since Inkscape is so visual in nature, it's very cool
and fixes.  Plus, since Inkscape is so visual in nature, it’s very cool
to see how your little changes make noticeable improvements to the app
to see how your little changes make noticeable improvements to the app
overall.
overall.


== C++ Help ==
== C++ Reference ==
We strongly recommend that everyone read this site thoroughly and bookmark it for reference:


http://www.parashift.com/c++-faq-lite/
*The C++ Core Guidelines. A set of rules for using modern C++ well, emphasizing safety and simplicity.<p>https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines</p>


It's actually more in-depth than the name FAQ warrants.  Many experienced C++ programmers would benefit from it.
*The C++ FAQ (with answers). We strongly recommend that everyone read this site comprehensively. You should not need to bookmark it, it should already be at the top of your autocomplete list!<p>[https://isocpp.org/wiki/faq/ https://isocpp.org/wiki/faq]<br/>[http://www.parashift.com/c++-faq-lite/ http://www.parashift.com/c++-faq-lite] (previous version)</p><p>It is actually more in-depth than the name FAQ suggests.  Many experienced C++ programmers would benefit from it.</p>


*C++ Reference. Documentation of all features of the language and standard library.<p>https://cppreference.com</p>


== Strings ==
== Please use const ==
Please make sure any user-visible strings are localizable.  This requires wrapping them with "_(" and ")", like so:


"Select object"
Please be very aggressive in adding ''const'' to any code you write. It will help us understand code better and will prevent bugs from creeping in. It is very easy to remove ''const'' later on, but very hard to add it.
becomes
_("Select object")


In case, the the interpretation of the string may be ambiguous or differ according different context, you can add a context prefix (that won't be displayed) in order to eliminate the ambiguity.  
''const'' can go on either side of a type. However once you get into references and pointers and such with C++, you generally read those from right-to-left. So it makes the code a little more legible if the ''const'' comes between the variable type and name.
"Ambiguous string"
can then become
Q_("Context|Ambiguous string")


For more complex things, please check the gettext/localization documentation.
int const foo;
See also http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html
// RTL reading gives "foo is a constant int".


== Standards Compliance - Extension Namespaces ==
And then:


* Only elements and attributes from our extension namespaces that ''do not affect rendering'' may be saved in SVG documents.
int const & foo;
* Generally, this means that extension elements and attributes should only be used to provide UI hints.
// RTL reading gives "foo is a reference to a constant int"
* Extension elements and attributes should ''only'' be used where an existing facility provided by XML or SVG is not sufficient.


== Global Verbs ==
int const * foo;
// RTL reading gives "foo is a pointer to a constant int"


Here's a readers' digest summary of how Inkscape accelerators work:
whereas:


A global mapping between key combinations and integer verb IDs
int * const foo;
(sp_verb_t) is maintained in shortcuts.cpp; these are registered using
// RTL reading gives "foo is a constant pointer to an int"
sp_shortcut_set().


Given an sp_verb_t and an SPView, you can get an SPAction which
Read also:
represents that action in that view. These mappings are currently
* [http://www.cprogramming.com/tutorial/const_correctness.html Const Correctness]
hard-coded in verbs.cpp.
* [http://yosefk.com/c++fqa/const.html Const Correctness]


SPActions derive from NRActiveObject, which putatively provides a
== Strings ==
"lightweight" method of doing callbacks, versus GObject signals.  I
Please make sure any user-visible strings are localizable.  This requires wrapping them with "_(" and ")", like so:
don't completely understand how it works.


SPActions also contain the label, image, etc, used for buttons and
<code>"Select object"</code>
menuitems.
becomes
<code>_("Select object")</code>


sp_shortcut_invoke() looks up the SPAction for a keypress and SPView and
In case the interpretation of the string may be ambiguous or may differ according to context, you can add a context prefix (that won't be displayed) in order to eliminate the ambiguity.
invokes it automatically. SPEventContexts call it for keypresses that
  <code>"Ambiguous string"</code>
they do not handle themselves.
can then become
<code>C_("Context", "Ambiguous string")</code>


== Garbage collection ==
For more complex things, please check the gettext/localization documentation.
See also http://library.gnome.org/devel/glib/unstable/glib-I18N.html


== Implementing User Interface Changes ==


As you know, many automatic garbage collectors (like libgc) only
[[UI improvements]] are enjoyable to work on because they produce visible changes in how Inkscape worksThese improvements are one of the most tangible ways to help improve how Inkscape works; thus, we strongly support new developers wishing to work in these areas.
free and recycle memory periodicallyThis means you may have some
extra slush that could be freed, but hasn't yet.


There are other forces at work, though...
It is also very important to us that Inkscape presents an organized, productive, and easily discoverable interface to users.  Because of this it is important that new Inkscape UI developers work to ensure changes make Inkscape’s UI *more* consistent, *more* flexible, *more* cohesive, and so on. We don’t have firm rules about what can and cannot done, in order to ensure plenty of freedom for innovation. However, we can outline some general principles and guidelines that are important to keep in mind:


Pretty much all allocators, whether automatic or not, whether the
<strong>Don’t please the artist—BE the artist.</strong>  Many times UI is designed and created by programmers who “understand what the user wants”.  But in Inkscape we believe that the best requirements list is the list inside the user’s head. Requirements docs, usability studies, and so on are very indirect ways of transferring this gut-level understanding from user to programmer.  We believe the best way to ensure this information is communicated clearly is for the user to BE the programmer.  Or, alternatively, for the programmer to BECOME a user.
system malloc() or some custom allocator like libgc's, work the
same way: they request large blocks of memory from the operating
system, then divvy those blocks into smaller ones internally to
satisfy application allocation requests.


When an application frees memory, that memory is usually recycled
This is why we so strongly encourage users to get involved in coding, and why we so strongly encourage programmers to focus on the features that are most important to them personallyThis is also why it is absolutely critical to pay close attention to what users report when using a new feature—often they can tip you off to alternate designs that achieve the same result in a better way.
internally rather than returned to the OS immediatelyThe reason
for this is that the large memory blocks acquired from the OS must
be completely unused before they can actually be freed.


Let's say for example that an allocator acquires 16 8MB blocks from
<strong>Eliminate limitations.</strong> Commercial software is often developed to fulfill feature requirement lists from a marketing department.  As such, it’s common to see the feature implemented to meet the requirement exactly, and no more.  However, especially with artistic software, art is often found outside what seems reasonable.  So when putting in a new feature, avoid the temptation to limit it to what you expect people to use it for—instead generalize it and open as many parameters as possible for tweaking, and let the artist decide what is reasonable. That’s their job.
the OS in response to 32768 4k application allocations...


In a worst-case scenario, it's possible that the application could
As an example, a drawing program might want to support the features “feather” and “drop shadow”.  Obviously, users need these important features.  Commercial software may well implement these as distinct features, each with their own UI controls.  However, these features are just special cases of the more general gaussian blur, and in Inkscape we implemented *that*.  With that in place, artists can do feathering and blur, <em>and</em> a variety of other effects.
free 32752 of those 4k blocks but the remaining 16 4k just happen
to be distributed across the 16 8MB blocks requested from the OS.


If that happens, from the application's point of view it may only
It is interesting to note that, as an open collaborative standard, SVG
have 64k allocated, but as far as the OS is concerned, it's still
necessarily has the same goals as Inkscape: a minimum set of
using 128MB!
universal, well thought-out building blocks that can accommodate the
widest possible range of graphics and applications. Thus, simply by
following the SVG philosophy, Inkscape scores quite a few important
points over commercial software. Live clones, patterns that can be contain any
objects, layers that are essentially groups and can be easily
converted to/from groups.  These are all examples where the underlying
universality of SVG directly translates into extremely valuable user
features.


Note that this applies to nearly all allocators in common use.
== Implementing New SVG Features ==


While it's unusual for things to get quite that bad, memory
The most important way to help Inkscape is to implement a new SVG feature in it.  Our hope is to eventually support ALL SVG features, so if you can help check one off the list, it brings us close to the nirvana of 100% SVG compliance.  :-)
fragmentation is common enough that many popular allocators (for
example Perl's) simply don't bother trying to return memory to the
OS at all (the memory will still get forcibly reclaimed by the OS
when the process exits).


[ FWIW, libgc's allocator is one of the ones that _does_ make an
Generally we find that implementation of an SVG feature goes through three discrete stages:
effort to release memory to the OS, but it is limited by
fragmentation like any other ]


Also note that for various reasons, the statistics you get from the
<ol>
OS aren't going to directly reflect the amount of heap-allocated
    <li>Find the appropriate tags and attributes in the SVG spec</li>
memory.  Be careful drawing conclusions from only looking at e.g.
    <li>Implement support for rendering files with these tags</li>
the output of top(1)...
    <li>Implement support for UI controls to edit the tags</li>
</ol>


(the worst thing is that due to the modern practice of
Step 1 is mostly a research project.  Start by reading the SVG spec so you
overcommitting memory, the OS may literally lie to an application
can learn about the tag, the attributes that go with it, and so forth.
about the amount of memory it is being given, hoping the
It is good practice to set up a page in the Wiki for storing your notes
application won't really try to use it all)
as you do this process, so that in case you don’t make it to steps 2 and
3, then maybe someone else can benefit from your research.


The best approach to evaluating memory usage is if you can ask the
Step 2 is the fun part.  It helps to be comfortable with Inkscape internals
allocator for information on memory usage directly, as that matches
for this part.  Depending on the feature, it may require advanced
the world from the point of view of the application.
knowledge of transformation, rendering, document management, and so on.
For this part, just hand-edit an SVG file to put the tags in that you
found in step #1, and keep plugging away at the code until Inkscape
displays things as the specification dictates.  It can help to compare
your work with Batik, as we use that program as our reference
implementation.


Step 3 is the most important stage. It is the point at which the
feature becomes available for users.  This step often requires knowledge
of Gtk+, for creating dialogs, widgets, menus, etc. for allowing the
user to edit the characteristics of the feature.  Be sure to listen to
feedback from other developers and users—especially if there are
different opinions.  It is hard to come up with UI that everyone can
agree on, but it is worth the work to achieve this—the more critique
your UI survives, the better loved the feature will be for future users.


Looking through Inkscape’s history, these stages are often done by different people.  If you’re new to Inkscape, you may find working on stages 1 and 3 easiest, but there are many developers who can answer questions when you’re ready to dig into the internals, so don’t be afraid to ask questions!


== Standards Compliance - Extension Namespaces ==


leftover gradients/markers/patterns
* Only elements and attributes from our extension namespaces that ''do not affect rendering'' may be saved in SVG documents.
will get automatically cleaned up when the objects that use them are
* Generally, this means that extension elements and attributes should only be used to provide UI hints.
deleted.
* Extension elements and attributes should ''only'' be used where an existing facility provided by XML or SVG is not sufficient.
 
Caveats:
 
* this only applies to such objects created with a build of Inkscape which post-dates this commit (June 7)
 
* not all automatically-created objects will necessarily be collected; the code that creates them needs to be updated to set the correct collection policy
 
* paint objects won't get collected until another editing operation takes place, since NRArenaShape currently holds onto an SPStyle for too long
 
Technical details:
 
Assuming its collection policy permits it, an object will be collected
if neither it nor its descendants have any outstanding inter-document
URI references (nonzero SPObject::hrefcount).
 
There are two "policies" for collecting orphans:
 
* "with-parent" - the object will only be collected if one of its ancestors is collected
 
* "always" - the object is always collected if unused
 
(a third policy might be "never", which would necessarily also prevent
that object's ancestors from ever being collected; I do not plan on
implementing it)
 
The policy in effect is determined by the inkscape:collect attribute.
 
Be careful with the "always" policy; it really only makes sense for
"private" objects that are indirectly created behind the scenes (e.g. by
selecting a fill or marker option in the GUI).
 
SPDocument manages a queue of objects to collect; SPObject handles the machinery for actually queueing them when their hrefcount falls (based on policy), and performing the actual collection (delete).
SPDocument::collectObjects() performs a collection pass; it's currently only called from sp_document_maybe_done().
 
== Inkscape Experimental CVS ==
 
The 'experimental' module in Inkscape CVS is provided as a kind of "scratchpad" for
working up new ideas that aren't quite ready for folding into the main codebase.
This includes architectural sketches, examples, experimental patchsets, tools & utilities, or
whatever else strikes the developer's fancy.
 
Please create a subdirectory within experimental/ for your work. You're welcome to either post
the stuff at the top level or create a subdirectory for yourself.  Things linked in at the top level
should be considered fair game for other developers to collaborate on; items posted under
a developer's username should be considered ask-first.  Same sort of idea as wiki.
 
One of the principles behind this module is the idea of a shared working space.  Other developers
working in experimental can fairly easily see what others are working on in the tree, and perhaps
borrow or contribute ideas back and forth.  Since it is by definition not 'production' code, the
work may be incomplete or in a non-compileable state, and thats O-K.
 
When an experiment has matured to the point of being actually useful, please move it out of
the experimental module to someplace more appropriate.  Or alternatively if the experimental
work has become obsolete or irrelevant, please remove it so we can avoid having the
experimental tree get too bulky.
 
 
== Directory Organization ==
== Directory Organization ==


=== Distribution / Packaging Files ===
=== Distribution / Packaging Files ===


Files related to generation of distribution packages should go under inkscape/packaging, as follows:
Files related to generation of distribution packages should go under /packaging.
                                                                                     
    inkscape/packaging/
                      common/
                      debian/
                      fedora/
                      fink/
                      mandrake/
                      suse/
 
=== "Share" Collateral ===
=== "Share" Collateral ===


A variety of items are installed in addition to the program itself, and placed into a 'share' directory structured as follows:
A variety of items are installed in addition to the program itself, and placed into a <code>share</code> directory structured as follows:
                                                                                        
                                                                                        
     AUTHORS
     AUTHORS
Line 307: Line 251:
     tutorials/
     tutorials/
                                                                                        
                                                                                        
In the CVS codebase, all of these are placed in inkscape/share/ (except AUTHORS and NEWS which will be copied to share during installation.  The idea is that in theory, this entire tree structure can be copied into place on the user's machine.   
In the codebase, all of these are placed in <code>inkscape/share/</code>.  The idea is that in theory, this entire tree structure can be copied into place on the user’s machine.   
 
 
= See Also =
* [[DirectoryReorgProposal]]
* [[InkscapeJanitors]]
* [[CompilingInkscape]]


However, we need to provide the user some level of control over the installation.  They may wish to exclude some items, or may wish to augment the default install with some items external to the Inkscape package.  For example, they may wish to incorporate external clipart collections.  One approach would be to install symlinks in the given component directory to the external collection.  For example, if the flags package were to install into /usr/share/flags-svg/, we'd just symlink there.
= Links =
[http://advogato.org/article/51.html Software Quality]


See Also:
[[Category:Developer Documentation]]
* DirectoryReorgProposal
* InkscapeJanitors

Latest revision as of 15:07, 26 May 2025

Inkscape Developer’s Manual

Please first read the short introduction:


Getting started with development ---> https://inkscape.org/develop/getting-started/


Introduction

For those of you just joining us, or who have been with us but are just now getting the itch to work on Inkscape, I thought I’d give some tips for how to get started working in the codebase based on our own experiences.

One of the first things most people wonder is “What should I work on?”. As you may have already noticed, we generally don’t “assign” projects. We figure there’s plenty more work to do than people to do it, so you may as well work on something that you’re either interested in or that adds something of benefit to you; that’s extra motivation to get your own itches scratched.

If you’re really stumped though, we keep a detailed Roadmap in wiki that you’re welcome to browse through to look for ideas of things to work on. Tasks that do not have names beside them are open for anyone to take; if you want to take ownership of a task, just put your name beside it. Feel free to add or reword tasks as needed, although try not to load up the current milestone with tasks that aren’t critical for the release. Feel free to work on stuff that is several milestones down the road; there’s rarely any problem with getting stuff done sooner than planned.  ;-)

We have a process for gaining GitLab Developer access. The reason is that while it is important that we keep access to the codebase open, we don’t want to be crazy and leave it wide open to any random passer-by. The process is that we require that the person make two contributions (patches, documentation, web collateral, etc.) and then make a request to get account access.

In general you won’t need Developer role in order to start doing development, because you can create merge requests with only a regular account. Due to GitLab constraints however, you won't be able to run Windows or MacOS CI - but we can always do that for you.

When you first start hacking on Inkscape code, I wouldn’t recommend taking an objective of implementing a specific feature, because you will need some time to familiarize yourself with the codebase, and because you won’t really know what features are going to be straightforward to implement and which will be highly challenging. Of course, if you have the time and love adventures, this might be a fun way to go.

There are four approaches that I’ve seen people effectively use in getting into the codebase:

  • Write code documentation. Some people who don’t mind adding comments to code or writing docs find it useful to just go through code they’re interested in working on and writing up what it does. The codebase is in dire need of better docs, so this approach pays dividends well into the future.
  • Fix bugs. Tracing down the cause of reported bugs is an effective way to gain understanding of the codebase in small chunks. Many common bugs can be traced down and fixed in a matter of hours, and often will identify some bit of code in need of refactoring or extension. Note that some of our older bugs are in the system because they’re hard to fix, so you’ll want to work on the more recent ones.
  • Chip in on a group effort. Occasionally we identify a major refactoring effort (such as when we converted from C to C++), that we encourage lots of people to help on, in the philosophy that many hands make light work. This work tends to be pretty rote so is not hard for new folks to get involved with; it just takes time. We generally have one of these kinds of efforts per release. It usually isn’t glamorous work, but in aggregate moves the codebase forward in a major way.
  • Subsystem/module work. Some people want to get their hands in the details quick, so take the approach of developing new code separate from the codebase, to be integrated in later. This generally tends to take a larger time commitment than the other approaches, but can be an effective approach in some circumstances. We have a SVN module called experimental that you’re welcome to house your work until it’s ready for prime time.

Beyond that, you’re going to find the documentation for the Inkscape code is pretty scarce. We’ve worked on bits and pieces but unfortunately the vast majority of the code is undocumented. On the plus side, often you can implement the stuff you care about after learning only a limited portion of the codebase.

I think you’d find Inkscape an enjoyable Open Source project to work on. There’s a huge range of interesting and useful skills that can be learned from it, plus the developers are great guys to participate with. The project itself runs smoothly and puts a premium on keeping things friendly and low-stress, so heated arguments are rare. The users have been great to work with and very appreciative of even small new features and fixes. Plus, since Inkscape is so visual in nature, it’s very cool to see how your little changes make noticeable improvements to the app overall.

C++ Reference

  • The C++ FAQ (with answers). We strongly recommend that everyone read this site comprehensively. You should not need to bookmark it, it should already be at the top of your autocomplete list!

    https://isocpp.org/wiki/faq
    http://www.parashift.com/c++-faq-lite (previous version)

    It is actually more in-depth than the name FAQ suggests. Many experienced C++ programmers would benefit from it.

Please use const

Please be very aggressive in adding const to any code you write. It will help us understand code better and will prevent bugs from creeping in. It is very easy to remove const later on, but very hard to add it.

const can go on either side of a type. However once you get into references and pointers and such with C++, you generally read those from right-to-left. So it makes the code a little more legible if the const comes between the variable type and name.

int const foo;
// RTL reading gives "foo is a constant int".

And then:

int const & foo;
// RTL reading gives "foo is a reference to a constant int"
int const * foo;
// RTL reading gives "foo is a pointer to a constant int"

whereas:

int * const foo;
// RTL reading gives "foo is a constant pointer to an int"

Read also:

Strings

Please make sure any user-visible strings are localizable. This requires wrapping them with "_(" and ")", like so:

"Select object"

becomes

_("Select object")

In case the interpretation of the string may be ambiguous or may differ according to context, you can add a context prefix (that won't be displayed) in order to eliminate the ambiguity.

"Ambiguous string"

can then become

C_("Context", "Ambiguous string")

For more complex things, please check the gettext/localization documentation. See also http://library.gnome.org/devel/glib/unstable/glib-I18N.html

Implementing User Interface Changes

UI improvements are enjoyable to work on because they produce visible changes in how Inkscape works. These improvements are one of the most tangible ways to help improve how Inkscape works; thus, we strongly support new developers wishing to work in these areas.

It is also very important to us that Inkscape presents an organized, productive, and easily discoverable interface to users. Because of this it is important that new Inkscape UI developers work to ensure changes make Inkscape’s UI *more* consistent, *more* flexible, *more* cohesive, and so on. We don’t have firm rules about what can and cannot done, in order to ensure plenty of freedom for innovation. However, we can outline some general principles and guidelines that are important to keep in mind:

Don’t please the artist—BE the artist. Many times UI is designed and created by programmers who “understand what the user wants”. But in Inkscape we believe that the best requirements list is the list inside the user’s head. Requirements docs, usability studies, and so on are very indirect ways of transferring this gut-level understanding from user to programmer. We believe the best way to ensure this information is communicated clearly is for the user to BE the programmer. Or, alternatively, for the programmer to BECOME a user.

This is why we so strongly encourage users to get involved in coding, and why we so strongly encourage programmers to focus on the features that are most important to them personally. This is also why it is absolutely critical to pay close attention to what users report when using a new feature—often they can tip you off to alternate designs that achieve the same result in a better way.

Eliminate limitations. Commercial software is often developed to fulfill feature requirement lists from a marketing department. As such, it’s common to see the feature implemented to meet the requirement exactly, and no more. However, especially with artistic software, art is often found outside what seems reasonable. So when putting in a new feature, avoid the temptation to limit it to what you expect people to use it for—instead generalize it and open as many parameters as possible for tweaking, and let the artist decide what is reasonable. That’s their job.

As an example, a drawing program might want to support the features “feather” and “drop shadow”. Obviously, users need these important features. Commercial software may well implement these as distinct features, each with their own UI controls. However, these features are just special cases of the more general gaussian blur, and in Inkscape we implemented *that*. With that in place, artists can do feathering and blur, and a variety of other effects.

It is interesting to note that, as an open collaborative standard, SVG necessarily has the same goals as Inkscape: a minimum set of universal, well thought-out building blocks that can accommodate the widest possible range of graphics and applications. Thus, simply by following the SVG philosophy, Inkscape scores quite a few important points over commercial software. Live clones, patterns that can be contain any objects, layers that are essentially groups and can be easily converted to/from groups. These are all examples where the underlying universality of SVG directly translates into extremely valuable user features.

Implementing New SVG Features

The most important way to help Inkscape is to implement a new SVG feature in it. Our hope is to eventually support ALL SVG features, so if you can help check one off the list, it brings us close to the nirvana of 100% SVG compliance.  :-)

Generally we find that implementation of an SVG feature goes through three discrete stages:

  1. Find the appropriate tags and attributes in the SVG spec
  2. Implement support for rendering files with these tags
  3. Implement support for UI controls to edit the tags

Step 1 is mostly a research project. Start by reading the SVG spec so you can learn about the tag, the attributes that go with it, and so forth. It is good practice to set up a page in the Wiki for storing your notes as you do this process, so that in case you don’t make it to steps 2 and 3, then maybe someone else can benefit from your research.

Step 2 is the fun part. It helps to be comfortable with Inkscape internals for this part. Depending on the feature, it may require advanced knowledge of transformation, rendering, document management, and so on. For this part, just hand-edit an SVG file to put the tags in that you found in step #1, and keep plugging away at the code until Inkscape displays things as the specification dictates. It can help to compare your work with Batik, as we use that program as our reference implementation.

Step 3 is the most important stage. It is the point at which the feature becomes available for users. This step often requires knowledge of Gtk+, for creating dialogs, widgets, menus, etc. for allowing the user to edit the characteristics of the feature. Be sure to listen to feedback from other developers and users—especially if there are different opinions. It is hard to come up with UI that everyone can agree on, but it is worth the work to achieve this—the more critique your UI survives, the better loved the feature will be for future users.

Looking through Inkscape’s history, these stages are often done by different people. If you’re new to Inkscape, you may find working on stages 1 and 3 easiest, but there are many developers who can answer questions when you’re ready to dig into the internals, so don’t be afraid to ask questions!

Standards Compliance - Extension Namespaces

  • Only elements and attributes from our extension namespaces that do not affect rendering may be saved in SVG documents.
  • Generally, this means that extension elements and attributes should only be used to provide UI hints.
  • Extension elements and attributes should only be used where an existing facility provided by XML or SVG is not sufficient.

Directory Organization

Distribution / Packaging Files

Files related to generation of distribution packages should go under /packaging.

"Share" Collateral

A variety of items are installed in addition to the program itself, and placed into a share directory structured as follows:

   AUTHORS
   NEWS
   clipart/
   examples/
   extensions/
   fonts/
   gradients/
   icons/
   keyboards/
   markers/
   palettes/
   patterns/
   screens/
       about.svg
   templates/
   tutorials/
                                                                                     

In the codebase, all of these are placed in inkscape/share/. The idea is that in theory, this entire tree structure can be copied into place on the user’s machine.


See Also

Links

Software Quality