DateTime Utilities

Speaking of DateTime , this release includes a few new tricks:

get_relative_datetime () : A way to compare a GLib.DateTime with “now” which returns a compact, localized, natural-language string like “in 5m”, “3h ago” or “Yesterday”. This is great for any app that deals with messaging or scheduling.

is_same_day () : A way to compare two GLib.DateTime s which returns true if they are the same day of the same year.

seconds_to_time () : which converts an integer number of seconds to an ISO 8601 standard time, for example “100” to “1:40". Very useful for media apps.

AsyncImage

Granite.AsyncImage is a Gtk.Image subclass that loads icons and images without blocking the main Gtk thread. This is a tremendous performance booster if your UI has a large image grid like an album or cover art view.

HeaderLabel

A very minor widget but one we use all the time in forms, settings UIs, and sidebars. Granite.HeaderLabel is simply a left aligned label with the h4 style class. Save a bit of typing, DRY, and go from this:

var label = new Gtk.Label ("foo");

label.halign = Gtk.Align.START;

label.xalign = 0;

label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL);

to this:

var label = new Granite.HeaderLabel ("foo");

MessageDialog

The new Granite.MessageDialog

Creating a HIG-compliant dialog can be tedious and Gtk.MessageDialog is… special. Now you can easily create a good looking dialog without having to fiddle around with margins and spacing by using Granite.MessageDialog .

SettingsPage & SettingsSidebar

Granite.SettingsSidebar and Granite.SimpleSettingsPage

Originally developed for System Settings but useful for any app with complex settings, these two widgets work hand-in-hand to build views like the Network or Sharing settings pages.

SimpleSettingsPage is divided into three sections: an automatically generated header, a Gtk.Grid content area, and a Gtk.ButtonBox action area.

SettingsSidebar is a Gtk.Stack switcher that reads the properties of a SettingsPage to automatically populate itself with headers, labels, icons, and status badges (if necessary).

SeekBar

This widget provides a standard Granite.SeekBar for use in media apps like audio and video players.

Style Class Constants

A showcase of special style classes provided by the elementary OS CSS stylesheet

The entire Granite.StyleClass namespace has been deprecated in favor of a more Gtk-like Granite.STYLE_CLASS_FOO naming convention. Some of these class names (like popover and title ) are now covered by Gtk+ itself. Others, (like back-button and card ) have been added and are now used by Granite. We highly recommend using these new constants in your code. This ensures that the compiler is aware if these class names are ever deprecated in the future and keeps your app looking the way you designed it. Check out the Granite namespace in Valadoc for more info.

Other Deprecations

When something is deprecated in a library that means that it has been marked as obsolete and it will be removed in a future version. You can still use that thing for now, but we recommend updating your code ASAP. In Granite, things can become deprecated when they’ve been superseded by new functionality in Gtk+ or GLib or just when there becomes a new, better way to do something. If your code is using deprecated functionality, the compiler will throw a warning and let you know what the problem is and what replaces it. Here’s a list of the deprecations in this version of Granite:

Granite’s AboutDialog has been deprecated in favor of providing this information in your appdata.xml file. We wrote more about this in a July blog post. If you’d like your app to continue having an about dialog, you can still use Gtk.AboutDialog instead.

apply_text_style_to_label () was deprecated since it’s a one-liner to add style classes already. Instead of this method, you can do something like foo.get_style_context ().add_class ("bar");

create_app_menu () has been deprecated since Gtk introduced a handy Gtk.MenuButton .

OverlayBar’s status property has been deprecated in favor of a more Gtk-like label property.

Removals

In addition to deprecations, we’ve finally removed some very old (and in some cases broken) widgets from Granite.

HCollapsablePaned and VCollapsablePaned have been removed since their functionality is covered by Granite.Widgets.CollapsiblePaned .

The SortFunc in SourceList has been removed as it was replaced by compare .

LightWindow and DecoratedWindow were removed since in modern Gtk+ all windows are decorated client-side and can easily be styled. For an easy flat-styled window you can now add Gtk.STYLE_CLASS_FLAT to your Gtk.Headerbar . See our October updates post for more info.

Some very old Contractor widgets which don’t work with the current version of Contractor have also been removed.

Many old Granite widgets have been replaced by new Gtk+ widgets as the toolkit has evolved and improved over the last few years. This is the full list of those removals:

Granite SearchBar has been replaced by Gtk.SearchEntry .

. HintedEntry has been replaced by the placeholder_text property in Gtk.Entry .

property in . SidebarPaned and ThinPaned were replaced by Gtk.Paned .

. Granite Popover was replaced by Gtk.Popover

StaticNotebook was replaced by Gtk.Stack and Gtk.StackSwitcher .

and . StatusBar was replaced by Gtk.ActionBar .

. ToolButtonWithMenu was replaced by Gtk.MenuButton .

. WrapLabel was replaced by the wrap property of Gtk.Label .

Other Bug Fixes & Enhancements

Toasts now automatically disappear after a timeout. OverlayBar has a new property active that adds a Gtk.Spinner. Avatar now reloads and resizes when the display’s DPI changes. TimePicker now has better input parsing and will understand values like “6am”, “1230”, or “7” in addition to the standard “12:30”. Also, translations have been updated.

OverlayBar with the new optional progress indicator

Many widgets now have updated and more thorough documentation in Valadoc, but we would appreciate any pull requests to help make these docs better, especially with code examples! As with everything we do, Granite is an Open Source library and we’d love your help improving it.

For the full commit log for this release, you can check out the handy compare view on GitHub. You can also see full API documentation on Valadoc.org.