Skip to content

[Development] General structure

Pedro Pinto edited this page Aug 10, 2019 · 8 revisions

The code of Cinnamon is divided into 2 parts :

  • One part is written in C and defines the core objects used in Cinnamon and interactions with the system
  • One part is written in Javascript and defines all the elements of the user interface

Gjs is the Javascript binding library for Gnome, and it provides access to functions written inside C modules from the Javascript code. See https://gitlab.gnome.org/GNOME/gjs/wikis/Home for more details. At the beginning of each Javascript file, you'll find a list of imports. Basically all imports.ui.\* and imports.misc.\* imports are imports of modules written in Javascript, and others imports are imports of modules written in C via Gjs.

For example :

const Meta = imports.gi.Meta;

will provide access to the "meta" module of muffin, and :

const Layout = imports.ui.layout;

will provide access to the layout.js module of Cinnamon.

For now, we'll focus on the Javascript part of Cinnamon's code, since it is where the all the UI elements are defined and this is what Cinnamon is mainly about.

The main file in the JS code is main.js : it is responsible for initializing the different elements of the UI and positioning them. Everything is done in "start" function of that module. There (and in a lot of other places), we access an object called "global" which is an instance of the "CinnamonGlobal" class defined in src/cinnamon-global.c. That object provides access to a lot of core functionalities and objects, such as the screen and the window manager for example.