“What happens when you read some doc and either it doesn’t answer your question or is demonstrably wrong? In Linux, you say “Linux sucks” and go read the code. In Windows you say “Windows sucks” and start banging your head against the wall.” — Denis Vlasenko
“One Demo is worth a thousand words.”
Here are a few open-source demo programs I’ve been working on with GTK under Ubuntu (8.04) Linux. These are simple programs to test making menus, buttons, toolbars, and so forth. Also tested how to interface to ALSA to record and playback audio.
Hopefully, some may find these useful.
Also some stuff about FreeGeeks…
GTK is a cross-platform widget toolkit for creating graphical user interfaces, as for example, the GNOME graphical user interface used by Ubuntu Linux. GNOME is part of the GNU Project.
Menu and Button Demo
Here’s a simple demo program (adapted from Foundations of GTK+ Development) that shows how to add menus and buttons to your application. Includes callback functions. Clicking on a button or menu item causes a message window to appear.
- menu_button_test.c — open source .c file
- zip file (contains test.c, makefile, test executable, readme)
ScreenShot after clicking button 1:
This program continues from the previous demo by adding toolbars, toolTips and stock images (again adapted from Foundations of GTK+ Development) Includes callback functions. Clicking on a button or menu item or toolbar item causes a message window to appear.
ScreenShot after clicking ‘Select All’ on the toolbar:
This program continues from the previous demos by adding a drawarea, timeouts and horizontal scale. Adapted from “Scribble”, A simple Example Drawing Program:
Includes callback functions. Clicking on a button or menu item or toolbar item causes a message window to appear.
Note: when running from a terminal window, moving the horizontal scale slider will print out the current position to the terminal.
ALSA stands for the “Advanced Linux Sound Architecture”. ALSA provides audio and MIDI functionality to the Linux operating system.
This demo is a simple GTK human interface combined with a low-level audio interface. The program plays sounds (from a .raw audio file) or records sounds (to a .raw audio file) and displays the sound in a window. Demonstrates menu, toolbar, tooltips, stock icons, and drawing area. Also demonstrates a background thread, ALSA audio play/record.
Currently Save and Open menu items are not implemented. Programs automatically plays from a file ‘foo.raw’ or records to ‘foo.raw’
- format: raw
- rate = 44100
- channels = 2
- adapted from aplay.c (package alsa-utils; usage: sudo apt-get source alsa-utils)
- record.c — open source .c file
- sound.c — open source .c file
- zip file (contains record.c, sound.c, makefile, record executable, readme)
FreeGeek is a non-profit community organization here in Portland Oregon that recycles and refurbishes used technology (aka computers). Folks donate their used computers to FreeGeeks. Older computers are recycled but newer computers are refurbished and reinstalled with Ubuntu Linux. These computers are then “granted” to schools or charitable organizations or given free to volunteers or sold in the FreeGeek store.
- http://www.freegeek.org/ — FreeGeek Home Page
For example, here’s a project I was involved in for students in the TRIO program at Mount Hood Community College receiving “grant” computers from FreeGeek…
Mt Hood CC New Users Guide and FAQ for Ubuntu
Here is the FreeGeek/Ubuntu New Users Guide and FAQ for the Grant Program for Mt Hood CC. A quick guide to setting up your computer, getting familiar with Ubuntu Linux, configuring programs, learning about installing plug-ins and packages.
- Mount Hood CC Ubuntu Linux Startup Guide
- Mount Hood CC Ubuntu Linux FAQ (Frequently Asked Questions)
- Blog — Still more questions? Ask them on the Blog!
- Media Test Files for Ubuntu Linux
Some Links and Books about Linux and GTK
- Ubuntu Home Page
- GTK Documentation Page
With links to API, FAQ, Books, Tutorials and more…
- GTK+ API Reference Manual
- Gnome Developer’s Home Page