#!/usr/bin/perl -w use Gtk; use Date::Simple; use strict; set_locale Gtk; init Gtk; my $false = 0; my $true = 1; ##########README digicam.pl V0.2############# # By Will O'Brien 2003. Please feel free to distribute and use this code. #Both my camera and my CF adapter mount via USB as /dev/sda. In my case, I mount /dev/sda1 on /mnt/cfcard #I added the following entry to my /etc/fstab: "/dev/sda1 /mnt/cfcard vfat user 1 2" #This allows the normal users to mount the cf card. #I put my photos in /home/photos. #In my camera, my photos are alway in dcim/100nikon so I copy the images right out of that directory. ### Configuration Options ### my $mount_command = "mount /mnt/cfcard &"; my $unmount_command = "umount /mnt/cfcard &"; my $photo_album_script = "/home/willo/bin/mkalbum.sh &"; my $photo_album_viewer = "/usr/bin/galeon"; my $photos = "/home/photos"; my $card_dir = "/mnt/cfcard/dcim/100nikon"; ### End of Configuration Options ### 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( "\nMount CF\n" ); $button->signal_connect( "clicked", \& MountButtonEvent ); $bbox->add( $button ); $button = new Gtk::Button( "\nUnmount CF\n" ); $button->signal_connect( "clicked", \& UnmountButtonEvent ); $bbox->add( $button ); $button = new Gtk::Button( "\nExit Utilites\n" ); $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( "\nCopy to Disk\n" ); $button->signal_connect( "clicked", \& CopyToDiskButtonEvent ); $bbox->add( $button ); $button = new Gtk::Button( "\nGenerate Album\n" ); $button->signal_connect( "clicked", \& GenerateAlbumButtonEvent ); $bbox->add( $button ); $button = new Gtk::Button( "\nView Album\n" ); $button->signal_connect( "clicked", \& ViewAlbumButtonEvent ); $bbox->add( $button ); return ( $frame ); } sub MountButtonEvent { # Mount the cf card. system( $mount_command ); } sub UnmountButtonEvent { # Unmount the CF card system( $unmount_command ); } sub ExitButtonEvent { exit (0); } sub CopyToDiskButtonEvent { my $today = Date::Simple->new; my $year = $today->year; system( "mkdir $photos/$year" ); system( "mkdir $photos/$year/$today" ); system( "cp $card_dir/* $photos/$year/$today" ); } sub GenerateAlbumButtonEvent { # Generate the ablum system( $photo_album_script ); } sub ViewAlbumButtonEvent { # View the Album system( $photo_album_viewer ); } # END EXAMPLE PROGRAM