Linux

“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

Contents

Introduction

“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

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.

ScreenShot after clicking button 1:
menu button screen

ToolBar Demo

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:
toolbar screen

DrawArea Demo

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.

ScreenShot:
drawarea screen

ALSA

ALSA stands for the “Advanced Linux Sound Architecture”. ALSA provides audio and MIDI functionality to the Linux operating system.

Audio Demo

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’

Audio:

  • format: raw
  • rate = 44100
  • channels = 2
  • adapted from aplay.c (package alsa-utils; usage: sudo apt-get source alsa-utils)

Files:

  • record.c — open source .c file
  • sound.c — open source .c file
  • zip file (contains record.c, sound.c, makefile, record executable, readme)

ScreenShot:
audiotest screen


FreeGeeks

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.

freegeek.org

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.

References

Some Links and Books about Linux and GTK

External Links

Books

  • Krause – Foundations of GTK+ Development
  • Warkus – The Official GNOME 2 Developer’s Guide
  • Matthew, Stones – Beginning Linux Programming
Personal tools
Toolbox