Hi, and welcome to my Developer's guide to Elementary OS. The purpose of this website is to educate new developers of Elementary OS. I want to share my experiences so that others can learn quicker then I did. I come to the realization that there weren't many resources for development of Elementary OS or GTK3. From these ideas, this developer's guide was made. Hope you find it useful. Enjoy!

Getting Started

Head over to Elementary OS' get started guide Here. It will teach you how to set up your building environment, get started with LaunchPad and the basics on how to use Bazaar. Once you've filled your brains with all of that come on back here and I'll show you some slightly more advanced ideas.

There are three areas that this guide will focus on:

  1. Vala Programming Language - The team chose to develop the entire OS in Vala. http://elementaryos.org/journal/why-we-write-elementary-apps-in-vala
  2. GTK3 Toolkit
  3. Granite Toolkit

Assuming you have read most of the developer guide on we can now hopefully jump right into some code.

Basic Template

This is the basic template most of the examples will start from:

	public class AppWindow : Gtk.Window {
		construct AppWindow() { //This is the default constructor for the new window.	
			this.title = "My Application"; // Define the window title
			this.set_default_size(400, 400); // Define the intial size of the window.
			this.destroy.connect(Gtk.main_quit); // Clicking the close button will fully terminate the program.
			this.set_position(Gtk.WindowPosition.CENTER); // Launch the program in the center of the screen
		 * Much like other programming langauges such as Java, we will define our main 
		 * execution loop as a static method. 
		public static int main(string[] args) {
			Gtk.init(ref args);
			AppWindow window = new AppWindow();
			window.show_all(); // Tell the window to draw
			return 0;	

Viola, you should now be looking at your new application window. It won't do anything yet obviously but you should be able to maximize it, minimize it and close it (closing it should also terminate the terminal execution too). Play around with the size of the window, positioning and remove this.destroy.connect(Gtk.main_quit); to see what it does.

The template is close to the examples on with one significant different difference: the main function is a static function inside our child class 'AppWindow'. This allows us to be closer to pure Object Oriented Programming.


After going through the guide on coding you'll probably notice that this guide covers one more topic, Granite. So lets setup granite so we can compile it. The guide did mention to install an a package called granite-demo. I found that this wasn't enough to start coding with granite. In the terminal I also executed this command to install the development files:

sudo apt-get install libgranite-dev
Then when compiling the code change the command to include the granite package valac --pkg gtk+-3.0 --pkg granite like so. This will allow us to use the Elementary framework.


Resources that I deemed useful during programming and making of this guide:

comments powered by Disqus