Making Granite a Better Library

Strap on your dev helmets, squeeze down into a dev cannon, and fire off into dev land!

We recently released Granite 0.4.1, the first step of many in a journey towards making Granite much, much better. I’d like to take this time to not only talk about the work that went into this release, but also address some issues that were discovered and the work we’re doing to resolve these issues.

If you’re not already familiar with it, Granite is a library that provides several widgets and convenience functions that build on what is already provided by Gtk+. It is not meant to be a replacement for Gtk+, but rather an extension with elements that adhere to elementary and Pantheon-specific design patterns.

Toasts

A Granite Toast in the presentations app Spice-Up

One of the largest visible changes in Granite 0.4.1 is the addition of the new Granite.Widgets.Toast . Toasts are small, unobtrusive, in-app notifications. They notify the user inside the context of the app, without trying to distract them from tasks they are doing outside of it. One of the most common cases for Toasts is as an “undo” pattern as commonly seen in web apps like Gmail. This new widget makes that popular design pattern available to developers on elementary OS.

The API for Granite Toasts has been designed to mimic GLib.Notification so it should feel familiar to create and send new toasts.

Granite Demo

The redesigned SourceList demo in Granite 0.4.1

Our demo app has been updated with new examples and several of the existing examples have been rewritten to better reflect real-world usage. The new code uses GObject-style and adheres to elementary best practices. Granite Demo serves not only as a sort of test to ensure that widgets in Granite are working properly and don’t break API unexpectedly, but it also needs to provide clean code samples for developers looking to make use of the library.