Ximba Radio: Developing a GTK+/Glade GUI to XM Satellite Radio

They say Glade can make desktop application prototyping a quick and painless process. To scratch my own itch with XM Satellite Radio on my PC, I decided to see exactly how fast and painless.

As American TV slowly sinks into the abyss of fictional reality, you may find yourself, like me, returning to the roots of electronic entertainment—radio. Satellite radio is the latest incarnation of this medium, offering a wide range of stations accessible from nearly anywhere you can drive your car.

Because I spend more of my time in front of a monitor than behind a steering wheel, I was fortunate to find a PC-based solution for satellite radio. XMPCR is a USB-connected receiver for the XM Radio satellite system that is sold primarily for Microsoft Windows systems. The device is supported under Linux by the OpenXM Project, a set of Perl scripts that acts as a network dæmon for controlling the device. Unfortunately, the only user interface for the dæmon is a limited text-based tool.

A Preview of the Project Results

Figure 1. The main window, channels listings and preferences. The second version shows the minimalist form, with the channel listings hidden.

Ximba Radio was born as a graphical front end to OpenXM. The application provides a minimalist main window with current channel information that can be expanded to show channel listings and user favorites. A button bar across the top offers easy management of the radio and station navigation as well as quick access to configuration options. The menu bar gives users the comfort of a traditional desktop application.

Channel listings are shown in multiple formats. A main channel listing window shows all channels, and category-specific tabs show related channels. Separate tabs provide access to user-selectable artist and channel favorites along with a current session history. Category tabs can be hidden using the Preferences dialog, which also allows a user to set performance settings and favorites notices.

On the back side of Ximba Radio is the OpenXM dæmon. This Perl script and associated Perl module drive the connection to the USB port. The dæmon reads from a configuration file or can take command-line arguments. Communication with the dæmon occurs on a configurable TCP port with a list of acceptable clients. The dæmon also can run on Windows systems.

Design Goals

My goals for this application were to match the functionality of the Windows version, provide a minimalist interface and be simple to configure. Also, implementation would need to be completed in less than one man-week (40 hours).

Another goal was to keep the user-interface code as independent of the application code as possible. Application code should be able to be used with any suitable user interface, so a good design could have a curses or Web interface dropped on top with little additional work. This goal is in line with GNOME development guidelines as well as future plans for Glade.

To meet these goals, I planned to use a single header file and a single C module. To speed the implementation and solve some time-consuming problems, I opted to use global variables. Remember, this is a prototype of a simple desktop application, not an enterprise-ready 24/7 fault-tolerant behemoth. If managed correctly, the use of globals can be removed with future updates.

Getting Familiar with Glade

With goals in hand, I started working with Glade to sculpt the user interface; I cover specific code details in the next section. I configured Glade to generate C code and took the default settings for everything else in the Options dialog. Most important here are the source and header files that hold the user-interface definitions (interface.c) and the widget callbacks (callbacks.c), along with the option to generate a main.c file.

Glade generates a complete build environment for building an application. This includes the source directory (src) and a directory for image files (pixmaps). Image files used in GtkImage widgets need to be in .xpm format. Other generated files include autoconf and automake templates and pot files for internationalized strings.

Figure 2. The Options dialog for Glade allows you to generate code, specify filenames and choose support for internationalized text.

Internationalization is optional and handled with GNU gettext support. The interface.c file, for example, has gettext-enabled strings. Even with this option enabled, you don't have to create pot files for any language; Glade simply uses any text strings you provide as the default language.

I found that prototyping Ximba Radio with Glade required hand-editing only two of the generated files, main.c and callbacks.c. The former required only minor additions for initialization options related to configuration handling for the application. The callbacks.c file was modified mostly to pass calls to my C module, utils.c.

As I edited my project in Glade and regenerated the C code, the callbacks.c file was appended with new functions. Fortunately, Glade does a good job of knowing when a callback already exists and didn't destroy any of my changes. Unfortunately, it sometimes re-adds an existing function. It was necessary to pull out those extra functions manually from time to time. When using libGlade, which processes the Glade XML file directly instead of using generated C code, this problem does not exist. Discussion of libGlade is beyond the scope of this article.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

XM Satellite Radio

medium readings's picture

In a little under four years, his show went from 47 stations to more than 200 (it's now at 350) and XM satellite radio. In 2006, when he began a TV gig on ...

Re: Ximba Radio: Developing a GTK+/Glade GUI to XM Satellite Rad

Anonymous's picture

Is it possible to download the sourcecode for Ximba? I'm a current subscriber to XM Radio for my car and would like to have this for my PC in the future. Thanks!!

Re: Ximba Radio: Developing a GTK+/Glade GUI to XM Satellite Rad

Anonymous's picture

Try going to the Authors website

Usability and design of Gnome Applications

Anonymous's picture

some suggestions on how to make your application fit in better with other Gnome applications.

a menubar with only two top level menus is a waste of prime real estate

if at all possible add in some more menus like perhaps
an edit menu with undo, redo, cut, copy, paste, select all, preferences
a view menu, with ...
a Radio menu with ...

a row of buttons! you really should use a real toolbar.
not only will it look better but it will allow users to choose to have text labels or not

the Ximba Radio graphic is nice but wouldn't it be better to save it for the About Dialog rather (with useful version and author information) than having such loud branding?

good luck

- Alan