#!/usr/bin/perl
# Basic Includes
use 5.6.1;
#use strict;
use warnings;
use Getopt::Long;
use Date::Calc qw(:all);
# DB Includes
use DBI qw(:sql_types);
use vars qw( @stores $filename $noopen $db $techemail );
# GUI Includes
use Gtk2;
use Glib qw/TRUE FALSE/;
my $DataBlock;
sub CreateAppWindow {
# Initialize Gtk2
Gtk2->init;
# Create Application Window
my $ApplicationWindow = Gtk2::Window->new('toplevel');
# Store Application window in Datablock
$DataBlock->{'GUI'}->{'AppWindow'}=$ApplicationWindow;
# When the window is given the "delete_event" signal (this is given
# by the window manager, usually by the "close" option, or on the
# titlebar), we ask it to call the delete_event () functio
# as defined above. No data is passed to the callback function.
$ApplicationWindow->signal_connect(delete_event => \&delete_event);
# Here we connect the "destroy" event to a signal handler.
# This event occurs when we call Gtk2::Widget::destroy on the window,
# or if we return FALSE in the "delete_event" callback. Perl supports
# anonymous subs, so we can use one of them for one line callbacks.
$ApplicationWindow->signal_connect(destroy => sub { Gtk2->main_quit; });
# Show Application Window
$ApplicationWindow->show;
}
sub delete_event
{
# If you return FALSE in the "delete_event" signal handler,
# GTK will emit the "destroy" signal. Returning TRUE means
# you don't want the window to be destroyed.
# This is useful for popping up 'are you sure you want to quit?'
# type dialogs.
print "delete event occurred\n";
# Change TRUE to FALSE and the main window will be destroyed with
# a "delete_event".
return FALSE;
}
{ # Main
CreateAppWindow();
Gtk2->main;
}
0;