#!/usr/bin/perl

#ledmanager.pl

# Simple demo GUI
# Peter Walsh July 2011


$| = 1; # flush output buffers

use Gtk2;
use Gtk2::GladeXML;

use Glib;

Gtk2->init;
$ledState="OFF";
$progressFractionValue=0;

sub on_toggle0_clicked {if ($ledState eq "ON") {
                           $ledState="OFF";
                           $progressFractionValue=0;
                        } else {
                           $ledState="ON";
                           $progressFractionValue=1;
                        }
                        #$entry0_widget->set_text($ledState);
                        $led0_widget->set_fraction($progressFractionValue);
                       }

sub on_window1_destroy {Gtk2->main_quit}



$gui =Gtk2::GladeXML->new('./ledmanager.glade');
$gui->signal_autoconnect_from_package('main');

#$entry0_widget = $gui->get_widget('entry0');
$led0_widget = $gui->get_widget('led0');
$image0_widget = $gui->get_widget('image0');

#$entry0_widget->set_text($ledState);
$led0_widget->set_fraction($progressFractionValue);
$image0_widget->set_from_file('/home/pwalshr/Gb/fgrabber.jpeg');

Glib::Timeout->add(1000, sub {
   `streamer -c /dev/video0 -b 16 -o fgrabber.jpeg 2> /dev/null`;
    $image0_widget->set_from_file('/home/pwalshr/Gb/fgrabber.jpeg');
    print "\0";
});

Gtk2->main;

