Widgets are bendable, flexible slabs of fun

I’ve been hacking on another sexy GtkEntry subclass, but this time, it’s not part of libsexy. It’s part of libview, VMware’s Incredibly Exciting Widgets. One of our developers built an IP Entry widget a short while ago, but it had some issues and just felt hard to use. I’ve never liked IP entries, particularly the windows ones, as they just felt too rigid and limiting. I always felt that I had to learn how to work for the widget instead of the widget working for me.

So I set out to do this right. I created a FieldEntry widget that is a GtkEntry subclass for displaying fields and validating fields. Users see delimiters spaced out evenly across the widget, just far enough for the content they are to display. Each field is center-aligned (this will be customizable in subclasses soon). The IPEntry subclasses this.

Now, the Windows IP entry are annoying for several reasons. I would like to list them now:

  • You can’t copy or paste an IP address. You can only copy or paste one field of the IP address.
  • Typing three digits in a field automatically jumps to the next field. If you made a mistake, you have to move the cursor to the left field and retype.
  • Clicking inbetween fields causes the very first field to be selected.

I know there are others. I’m just tired.

So, I’ve addressed all of these. Copying and pasting work beautifully. When you type three characters of an IP entry field (or maxFieldWidth of whatever the FieldEntry has set) it doesn’t jump to the next field. However, if you start typing the next number (which is what you do on the Windows one) it will then jump to the next field and insert the text. Typing the delimiter (‘.’ on IP entries) will jump as well. Backspacing just works, even across fields. Clicking inbetween fields moves to the nearest field. And much more!

Bottom line: It feels natural to use. It’s there largely as a visual aid, and to allow you to easily get to fields, and such. But it doesn’t force you to type in a certain model. If you’re used to the Windows one, this will feel natural. If you’re used to just typing an IP address into an entry, this will feel natural. I’m quite happy with this one.

Now, it’s written in C++ for GTKMM, so if you want to use it in your C program, you’ll have to port it. I would love to see any ports that people wish to do, but mainly, I’d want to see this in GTK+ someday. We’ll see.

It’s available in libview cvs on SourceForge (see the link above) in the “staging” branch (as it’s pending review for inclusion in HEAD). Please, if you find any bugs or have usability issues, I’d love to know them.

Update: As requested, a screenshot!

IP Entry

12 thoughts on “Widgets are bendable, flexible slabs of fun”

  1. Excellent 🙂

    I’d love to see this and the libsexy widgets in GTK – I don’t do any GTK programming myself any more, but I can think of a few apps that could really use the widgets and aren’t likely to add Yet Another Library to their stack.

  2. mibus: this is too a specialized widget for GTK; it should go into a cut-and-paste library or an “extra” widgetry library – like libsexy. 😉

  3. It should *definately* go into libgtk IMHO.

    I also think that things like the EggTrayIcon should too.

    I think it would be great, especially since some of these widgets could have their functionality folded back into the base class (DeadEntry, the Viewport, some of the libsexy stuff).

  4. chris: the IP entry (to which I was referring to) is a little bit too specialised; a general-purpose field entry could go in, IMHO. adding general purpose field capabilities directely to GtkEntry could be even better.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top