And now, popovers

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.

Touch selection

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!

10 thoughts on “And now, popovers”

  1. Nice Idea,
    It’s will be usefull to many people to use it on the connect to server as all people don’t necessary known how to use it.
    most of people (not me) don’t known how to use it (same way as via command line, like ssh username@servername)

  2. I’ve used Gnome/GTK for almost as long as it’s been around. I’ve been skeptical of many of the recent changes… but these look great! Can’t wait to try them out.

  3. This looks like exactly what I need for several of my projects. It’s been top-five on my wishlist for years. Fantastic!

    1. It is a screenshot. We only use this popover when you have a touchscreen. You can force it by putting GTK_TEST_TOUCHSCREEN=1 in the environment.

Comments are closed.