Gnome is the desktop environment of choice on my home Linux system, because it’s feature-packed and user friendly. Gnome is also flexible, and thanks to the Gtk-Perl module and associated desktop toolkit bindings, I can use my favorite programming language to further customize and extend my Gnome environment.
This article shows how a useful Gnome tool can be be built in an afternoon. It is also an example of some common techniques one employs when doing this sort of GUI programming, including widget creation, signal handling, timers, and event loops. It also reviews some Perl basics. Read on, and you may be inspired with notions of your own.
On a Gnome desktop, the panel contains a variety of buttons and other widgets that launch applications, display menus, and so on. It’s standard desktop fare, just like the Microsoft Windows Start menu.
An applet is a particular kind of Gnome application that resides within and operates on the panel itself. The Gnome distribution comes with several of these, such as a variety of clocks, the game of Life, and system resource utilization monitors. The Gtk-Perl module enables a Perl programmer to create custom Gnome panel applets.
The Gnome panel applet we’ll build finds the local host’s default TCP/IP gateway and affixes the gateway’s status to the label of a button. When the button is in an off position, the gateway is not polled (Figure 31-1).
When the button is on, the ...