Using GTK+/X as an Embedded GUI
Consumer embedded devices require a graphical user interface (GUI) tailored to specific device characteristics. To offer a handful of examples:
Touchscreens should use large buttons to accommodate the width of fingers and inaccurate measurements.
Softkeys require a dedicated on-screen softkey region.
A keyboard-centric device should organize data into vertical lists, whereas a mouse-centric device should organize data by geographic space.
Devices with low-contrast screens should avoid swaths of gray.
A major factor in the success of Palm Pilots is a user interface (UI) paradigm designed to fit the Palm device. The plain widget look provides on-screen simplicity, the menu system offers a good compromise between offering user options and optimizing screen real estate, and the applications are designed around stylus input. One of the reasons why WinCE and Palm-sized PC devices have not done very well is that a general-purpose GUI design borrowed from desktop paradigms is not appropriate for embedded devices.
There are several embeddable GUIs for Linux, including Qt/Embedded, FLTK and GTK+. Which toolkit should a developer use? How much engineering effort is needed to tweak to spec? What footprint will this require?
This article describes our experience designing and implementing a custom GUI for a consumer Linux device. We decided to use GTK+ running on the X Window System. It took five engineer-months to produce our rock-stable, customized and reduced-footprint GUI totaling 2.9MB (including X).
We designed a custom UI to match our device's I/O characteristics. Our device has a small, low-quality screen and no mouse. A row of softkeys under the screen provides primary user input (see Figure 1). The bottom 14 pixel region of the screen is reserved for displaying monikers above softkeys; this is the softkey bar.
Rather than create new paradigms that would confuse users, the rest of the UI is drawn as a typical point-and-click interface, complete with buttons and scrollbars. We maintain the user's control metaphor of physically "pushing" widgets by substituting push-via-softkey for point-and-click. Each button is arranged horizontally with an arrow dropped under it that extends across the window border into the softkey bar. Figures 2-5 show the elements of our UI design, including buttons.

Figure 2. Buttons extend an arrow into the softkey bar. While pressed, the button and its arrow are filled with gray.

Figure 3. Text-entry fields use a boldface font for the label and a plain-face font for the user's text. This uses minimal screen real estate to differentiate between the two elements.

Figure 4. Scrollbars visually fit into the scrolled panes they control, giving an uncluttered look.

Figure 5. Application windows and dialogs are shaped and drawn with different title bar designs. The topmost window gets the softkey bar.
After hammering out this draft UI design and testing innumerable mockups, we heaved a collective sigh of relief. Our device would be usable. Our glee was cut short with thoughts of actually putting the UI together. We conscientiously had avoided considering implementation when drafting this UI. What programmer in his or her right mind would want shaped windows, arrows spanning different widgets and a myriad of fonts? Now it was time to pick a GUI, roll up our sleeves and get to work.
We chose to use GTK+ 1.2.8 running on the X Window System, in turn running on a framebuffer. While both GTK+ and X are often considered to be bulky desktop-only solutions, they are sensible choices for embedded devices for the following reasons:
X and GTK+ are reliable. X has seen aeons of development. GTK+ has a well-established and (hyper)active development community.
X has a robust client/server model. An application crash does not affect the rest of the GUI. This is an important feature for a device allowing third-party add-on applications.
GTK+ has two well-designed helper libraries: Gdk and Glib. Gdk abstracts low-level windowing functions. To port GTK+ to a different windowing system, we simply need to port Gdk. Glib is a toolkit of data types, macros, type conversions, string utilities and a lexical scanner. Any application can link against Glib and use its types and methods to avoid re-inventing the wheel and reduce the footprint.
It was easy to reduce GTK+/X. They have well-selected configuration options and clean codebases that enable safe removal of large chunks of code.
GTK+ has a large application base.
X is under a non-copyleft free license, and GTK+ is licensed under the LGPL. This allows proprietary third-party software to link against either one.
Both are written in C (see Sidebar "C vs. C++ on Embedded Devices").
GTK+ implements an object-oriented architecture in C.
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |
- Search
2 hours 15 min ago - Question
2 hours 38 min ago - for the record
2 hours 41 min ago - That's disappointing. Thanks
5 hours 4 min ago - Well spotted. I've corrected
6 hours 33 min ago - This is a great program. We
9 hours 33 min ago - No Air for Linux
11 hours 23 min ago - HEWLETT PACKARD created
11 hours 33 min ago - HEWLETT PACKARD created
11 hours 35 min ago - very helpful :)
11 hours 57 min ago






Comments
Excellent work. Can you share your customization for the libs?
I am intending to use GTK+ for my embedded application. This article is great. I wonder if the customization for GTK+ mentioned in this article has been published?
theme-engine
I wanted to change the shape of widgets like round buttons. is it possible to change using themes?