How to get units consistent across all applications?

We have a units policy in Ubuntu, which we have to implement in lucid+1 (Ubuntu 10.10). Correcting all applications to conform to this policy is not an easy task. The first attempt to patch glib, which provides the g_format_size_for_display() function, failed. We need a library that can handle input and output formatted sizes. Take transmission as example: I want to set the bandwidth limit in the same unit as it displays me the limit. We have to introduce a set of new functions.

Should I create a new library (named libbyteunits or similar) or add a bunch of new functions to glib (as replacement for g_format_size_for_display)? Is glib the right place for ten or more functions handling units?

Pros for a separate library:

  • the library can be used by non-glib application without depending on glib
  • it can be made user configurable (for example by an text file), because some user prefer base-10, others base-2.


  • one more dependency for glib applications

I like to hear as many opinions as possible. Please let me also know, if you are glib developer, a g_format_size_for_display() using developer, a developer, or a user.

6 thoughts on “How to get units consistent across all applications?

  1. As a packager for another distribution, having a separate library would be generally ok… of course, it has to make sense (I still fail to see most of the point of libpaper for instance).

    What I’d be afraid of would be another bundled (or copied-over) library…

    Oh and rather than a file, what about an env var?It would reduce the general overhead, I’d say.

  2. Are you asking for input on the gtk-devel-list mailinglist to make sure you catch the glib developers who might not be reading this blog?

    That seems like the most appropriate place to have a discussion about the suitability of how to patch in this functionality into glib.


  3. Separate library, and dependency! Configuration, configuration, configuration. I would definitely like to be able to choose whether I would like it in base-2 or -10. Absolutely.

  4. What we really need is a general units conversion library. We already have GNU units; it just isn’t available via a library API.

    I’m not sure I agree this should be done at a GUI toolkit level; this is something that all programs need to do. If we have a general units library, then the default unit for /any/ given dimension could be customised by the system or a user.

  5. I don’t think a single global preference will suffice. Personally, I use base 2 units for RAM, base 10 for everything else.

    Good luck with the project, you’re gonna need it. There are enough programs that still don’t obey locale…

Comments are closed.