GTK+ has seen a fair bit of new development over the last year. We’ve gained new containers such as list box and flow box and stack and new widgets like the search bar, places sidebar, header bar and action bar. The Wayland backend has come a long way, and we’ve gotten hi-dpi support and client-side decorations.
One feature that we haven’t gotten until today, and that has been on the wishlist for a while is popovers.
Popovers are transient views that are somewhat in the middle between menus and dialogs. The are transient like menus – you don’t expect to keep them open for more than a single action. On the other hand, they can display arbitrary information and allow input and interaction like a dialog. One big advantage of popovers over menus is that they are much easier to interact with using touch.
These are of course very popular in mobile UIs, but it makes a lot of sense to have them available on the desktop as well.
Inside GTK+, we’ve had some nascent support for this style of UI with the touch selection work that Carlos Garnacho merged almost exactly a year ago.
Carlos has now generalized this work and turned it into a full-blown GtkPopover implementation. Since the work has only been merged today, I can’t really link to API documentation yet. But the API is very easy: you create a popover with gtk_popover_new(). It is a container like any other, so can just pack your content as usual. And you control its visibility with gtk_widget_show(). The direction of the ‘tail’ that points to the parent widget can be set with gtk_popover_set_position().
popover = gtk_popover_new (parent_widget); gtk_container_add (GTK_CONTAINER (popover), my_content); gtk_widget_show (popover);
We don’t yet have any users of popovers inside GTK+ apart from touch selections, but I expect that to change soon.
Many thanks to Carlos for getting this done!