#!/usr/bin/perl -w use Gtk; use strict; set_locale Gtk; init Gtk; my $false = 0; my $true = 1; my $window; my $main_vbox; my $vbox; my $hbox; my $frame_horizontal; my $frame_vertical; $window = new Gtk::Window( "toplevel" ); $window->set_title( "KarKomp Camera Utilites" ); $window->signal_connect( "destroy", sub { Gtk->exit( 0 ); } ); $window->border_width( 10 ); $main_vbox = new Gtk::VBox( $false, 0 ); $window->add( $main_vbox ); $frame_horizontal = new Gtk::Frame( "Digital Camera Operations" ); $main_vbox->pack_start( $frame_horizontal, $true, $true, 10 ); $vbox = new Gtk::VBox( $false, 0 ); $vbox->border_width( 10 ); $frame_horizontal->add( $vbox ); $vbox->pack_start( create_bbox_cf( $true, "CF Card Utilities", 30, 85, 20, 'spread' ), $true, $true, 0 ); $vbox->pack_start( create_bbox_album( $true, "Album Utilities", 30, 85, 20, 'spread' ), $true, $true, 0 ); $window->show_all(); main Gtk; exit( 0 ); ### Subroutines # Create a Button Box with the specified parameters sub create_bbox_cf { my ( $horizontal, $title, $spacing, $child_w, $child_h, $layout ) = @_; my $frame; my $bbox; my $button; $frame = new Gtk::Frame( $title ); if ( $horizontal ) { $bbox = new Gtk::HButtonBox(); } else { $bbox = new Gtk::VButtonBox(); } $bbox->border_width( 5 ); $frame->add( $bbox ); # Set the appearance of the Button Box $bbox->set_layout( $layout ); $bbox->set_spacing( $spacing ); $bbox->set_child_size( $child_w, $child_h ); $button = new Gtk::Button( "Mount CF" ); $button->signal_connect( "clicked", \& MountButtonEvent ); $bbox->add( $button ); $button = new Gtk::Button( "Unmount CF" ); $button->signal_connect( "clicked", \& UnmountButtonEvent ); $bbox->add( $button ); $button = new Gtk::Button( "Exit Utilites" ); $button->signal_connect( "clicked", \& ExitButtonEvent ); $bbox->add( $button ); return ( $frame ); } sub create_bbox_album { my ( $horizontal, $title, $spacing, $child_w, $child_h, $layout ) = @_; my $frame; my $bbox; my $button; $frame = new Gtk::Frame( $title ); if ( $horizontal ) { $bbox = new Gtk::HButtonBox(); } else { $bbox = new Gtk::VButtonBox(); } $bbox->border_width( 5 ); $frame->add( $bbox ); # Set the appearance of the Button Box $bbox->set_layout( $layout ); $bbox->set_spacing( $spacing ); $bbox->set_child_size( $child_w, $child_h ); $button = new Gtk::Button( "Generate Album" ); $button->signal_connect( "clicked", \& GenerateAlbumButtonEvent ); $bbox->add( $button ); $button = new Gtk::Button( "View Album" ); $button->signal_connect( "clicked", \& ViewAlbumButtonEvent ); $bbox->add( $button ); return ( $frame ); } sub MountButtonEvent { # Mount the cf card. system("mount /mnt/cfcard &"); } sub UnmountButtonEvent { # Unmount the CF card system("umount /mnt/cfcard &"); } sub ExitButtonEvent { exit (0); } sub GenerateAlbumButtonEvent { # Generate the ablum } sub ViewAlbumButtonEvent { # View the Album } # END EXAMPLE PROGRAM