Skip to content

That’s quite a view you’ve got there

As a happy coincidence, on the same day that GNOME 2.12 is being released, we’ve managed to get everything sorted out over here to push out the initial release of VIEW, VMware’s Incredibly Exciting Widgets; so named by Christian without a hint of irony. Honest. :-)

VIEW is a collection of widgets that we developed while working on Workstation 5 that we felt were general purpose enough to have value to the community. Our intention is for the VIEW sourceforge project to be the one place where these widgets are developed and maintained; so we’re not going to have a parallel internal tree which we push updates out from. We’re also planning to move a number of other widgets into the library in due course. Most of them are written in C++ on top of gtkmm but a couple of them are in C. I know that this is probably going to limit initial interest because the overwhelming majority of GTK+ applications are not written in C++, but if nothing else, someone may like some of them enough to rewrite them in C for wider consumption, or maybe Inkscape will want to use one. :-)

Doxygen docs are available in the tarball and can be regenerated out of the sourcetree, but we currently don’t have a nice summary of the widgets in the library anywhere else (the web page is on the way), so it’ll be useful to put a quick one together here:

C++ Widgets and Objects

  • view::ActionGroup: A very simple wrapper around gtk::ActionGroup that allows the group to carry it’s merge position around with it.
  • view::BaseBGBox: A somewhat inaccurately named widget for historical reasons. This is a container that paints itself using its current state’s base colour. We use this to provide the background for the summary pages in Workstation. The BG is in the name because it used to always use the BG state’s colour. This implements the painting technique I described before to work around the way some themes treat event boxes.
  • view::Header: A creative use of menuitems as a header for the sections of Workstation’s summary pages and About dialog. We originally hard-coded a silver/grey gradient for this but that’s obviously not very theme friendly, so this was the alternative I came up with, and it works surprisingly well. A small workaround is required to get the text right with a couple of themes, otherwise a separate widget wouldn’t really have been justified.
  • view::MenuToggleAction: An action that provides a toggle action with a secondary menu. So, on a toolbar you get a toggle button with a context menu and in a menu, you get an item with a submenu with the actual toggle item as the first entry. It’s a little suboptimal as one would prefer to use a MenuToolButton in the toolbar but we can’t depend on GTK+ 2.6 yet.
  • view::MotionTracker: Now this one’s pretty neat. It’s a specialised signal object that fires whenever a target widget moves. I was really surprised to find that GTK/GDK didn’t provide this information already – and in fact, GDK actually filters out the necessary X events early on, so we have to listen at a very low level to make this work.
  • view::Reparenter: A helper object to aid in achieving flicker-free reparenting of children. Unfortuntately, the code you see here only works correctly with GTK+ 2.4. The reparenting mechanism changed in 2.6 and an additional workaround is needed, but this requires intimate knowledge of the widget being reparented because the map operation has to be blocked at a particular point. We plan to have the additional steps documented.
  • view::Spinner:A subclass of Gtk::Image that holds a set of frames and knows how to advance through them. The mechanism of obtaining the frames and timing the animation is left to the user of the widget.
  • view::SpinnerAction:An Action that provides a spinner using the Spinner widget. It can drive multiple spinner proxies and handles the tedious task of chopping up a multi-frame-single-image style spinner like the default gnome-spinner. Again, the precise animation timing is left up to the consumer or subclass.
  • view::ToolTip: An actual tooltip widget! I’m sure most people are aware of what you can and can’t do with GtkTooltips, and one of the things you can’t do is programmtically make a tooltip appear when you want it, so I wrote this widget to fill that gap. As a bonus, it uses the MotionTracker so that it maintains its relative position to its ‘parent’ widget while its on the screen. The timeout is currently hardcoded but I intend to fix that.
  • view::UIGroup: One thing that I always felt was missing from GtkUIManager and friends was an easy way to programmatically modify the UI definition, so I wrote this object to be broadly analogous to the ActionGroup, in that it encapsulates a UI definition fragment that can be merged and unmerged in the same way that ActionGroups can be inserted and removed. This allows us to use a pattern where an object, such as a virtual machine, provides its own UI definition and actions. This is particularly useful for dynamic menus, such as the list of virtual devices in a VM.
  • view::Viewport: A subclass of Gtk::Viewport that works around an oddity (bug?) in how GtkViewport handles a size_request.
  • view::VisibilityBox: Ever been annoyed at how you find that even though you have a visible container, like a GtkFrame, with no visible children, the container still has a non-zero size_request? Well, Régis was, so he wrote this to fix the problem. It’s a container that hides itself if it has no visible non-layout-providing children. So you stick your GtkFrame inside it and if the frame’s children happen to be hidden, the VisibilityBox will make sure that the Frame is hidden too.
  • view::WeakPtr: A weak pointer template class. I’d really like to see this go into gtkmm. Hopefully Murray is interested :-)
  • view::WidthHeight: A very low level widget that is essentially a generalisation of the AspectFrame. It is configured so that one dimension is normally allocated causing a signal to be emitted. The callback then calculates what the other dimension should be and then sets it. If you think this is rather obscure, you’re right :-)
  • view::WrapLabel: A label widget that intelligently wraps onto new lines if it runs out of horizontal space, courtesy of Christian.

C Widgets

  • ViewOvBox: A container with two children that can overlap. The foundation of the ViewDrawer widget.
  • ViewDrawer: A subclass of ViewOvBox that can smoothly slide the one child over the other. We use this to implement the auto-hide toolbar in Workstation; it looks really nice and might be useful for the gnome-panel in auto-hide mode.

And where would we be without a screenshot? Here’s one of the new VM summary page (now theme compliant!) using the BaseBGBox and Header widgets. (And the theme is XFCE-Stellar):

Workstation screenshot

{ 1 } Comments

  1. Murray Cumming | 8th September 2005 at 02:48 | Permalink

    Fantastic. I already see a couple of things I could use in Glom to replace my hacks.