#!/usr/bin/perl -w
use strict;
use warnings;
use Glib qw/TRUE FALSE/;
use Gtk2 '-init';
use threads;
use threads::shared;
#shared Variables
my $uasposition_local: shared = "/home/deadpickle/Desktop/project_downloads/uasposition";
my $uasposition_remote: shared = "/home/uas/Scripts/COORDS/uasposition";
my $waytemp_local: shared = "/home/deadpickle/Desktop/project_downloads/waytemp";
my $waytemp_remote: shared = "/home/uas/Scripts/WP/waytemp";
my $wayfinal_local: shared = "/home/deadpickle/Desktop/project_downloads/wayfinal";
my $wayfinal_remote: shared = "/home/uas/Scripts/WP/wayfinal";
my $uaspf_local: shared = "/home/deadpickle/Desktop/project_downloads/uavpf.txt";
my $uaspf_remote: shared = "/home/uas/public_html/uas/uavpf.txt";
my $username: shared = 'uas';
my $server: shared = 'updraft.unl.edu';
#loads the default.cfg file on starup
open_file( my $default = 'default.cfg');
#create a new window
my $window_config = Gtk2::Window->new( 'toplevel');
$window_config->set_position( 'center');
$window_config->set_title( "Configuration");
#spacers
my $spacer5 = Gtk2::Label->new();
my $spacer6 = Gtk2::Label->new();
my $spacer7 = Gtk2::Label->new();
my $spacer8 = Gtk2::Label->new();
#create the container
my $table_interface = Gtk2::Table->new( 3,2, FALSE);
#create the notebook interface
my $notebook_interface = Gtk2::Notebook->new;
$notebook_interface->set_tab_pos( 'top');
#create the pages
#config file
my $table_file = Gtk2::Table->new( 3, 2, FALSE);
my $label_file = Gtk2::Label->new();
$label_file->set_markup( 'CONFIG FILE');
my $button_open = Gtk2::Button->new( 'Open');
$table_file->attach_defaults( $label_file, 0, 2, 0, 1);
$table_file->attach_defaults( $button_open, 0, 1, 1, 2);
$button_open->signal_connect( 'clicked' => sub {
my $filechooser_open = Gtk2::FileChooserDialog->new( 'Open Config File', undef, 'open', 'gtk-ok' => 'ok', 'gtk-cancel' => 'cancel');
if ( 'ok' eq $filechooser_open->run) {
my $filename = $filechooser_open->get_filename;
open_file( $filename);
}
$filechooser_open->destroy;
});
#connection variables
my $table_sftp = Gtk2::Table->new( 3, 2, FALSE);
my $label_sftp = Gtk2::Label->new();
$label_sftp->set_markup( 'SFTP CONNECTION');
my $label_sftp_username = Gtk2::Label->new( 'Username');
my $label_sftp_server = Gtk2::Label->new( 'Server');
my $entry_sftp_username = Gtk2::Entry->new();
$entry_sftp_username->set_text( $username);
my $entry_sftp_server = Gtk2::Entry->new();
$entry_sftp_server->set_text( $server);
$table_sftp->attach_defaults( $label_sftp, 0, 2, 0, 1);
$table_sftp->attach_defaults( $label_sftp_username, 0, 1, 1, 2);
$table_sftp->attach_defaults( $entry_sftp_username, 1, 2, 1, 2);
$table_sftp->attach_defaults( $label_sftp_server, 0, 1, 2, 3);
$table_sftp->attach_defaults( $entry_sftp_server, 1, 2, 2, 3);
#uasposition
my $table_uas = Gtk2::Table->new( 3, 2, FALSE);
my $label_uas = Gtk2::Label->new();
$label_uas->set_markup( 'UASPOSITION');
my $label_uas_local = Gtk2::Label->new( 'local');
my $label_uas_remote = Gtk2::Label->new( 'remote');
my $entry_uas_local = Gtk2::Entry->new();
$entry_uas_local->set_text( $uasposition_local);
my $entry_uas_remote = Gtk2::Entry->new();
$entry_uas_remote->set_text( $uasposition_remote);
$label_uas_local->set_label( 'Local');
$label_uas_remote->set_label( 'Remote');
$table_uas->attach_defaults( $label_uas, 0, 2, 0, 1);
$table_uas->attach_defaults( $label_uas_local, 0, 1, 1, 2);
$table_uas->attach_defaults( $entry_uas_local, 1, 2, 1, 2);
$table_uas->attach_defaults( $label_uas_remote, 0, 1, 2, 3);
$table_uas->attach_defaults( $entry_uas_remote, 1, 2, 2, 3);
#waytemp
my $table_waytemp = Gtk2::Table->new( 3, 2, FALSE);
my $label_waytemp = Gtk2::Label->new();
$label_waytemp->set_markup( 'WAYTEMP');
my $label_waytemp_local = Gtk2::Label->new( 'local');
my $label_waytemp_remote = Gtk2::Label->new( 'remote');
my $entry_waytemp_local = Gtk2::Entry->new();
$entry_waytemp_local->set_text( $waytemp_local);
my $entry_waytemp_remote = Gtk2::Entry->new();
$entry_waytemp_remote->set_text( $waytemp_remote);
$label_waytemp_local->set_label( 'Local');
$label_waytemp_remote->set_label( 'Remote');
$table_waytemp->attach_defaults( $label_waytemp, 0, 2, 0, 1);
$table_waytemp->attach_defaults( $label_waytemp_local, 0, 1, 1, 2);
$table_waytemp->attach_defaults( $entry_waytemp_local, 1, 2, 1, 2);
$table_waytemp->attach_defaults( $label_waytemp_remote, 0, 1, 2, 3);
$table_waytemp->attach_defaults( $entry_waytemp_remote, 1, 2, 2, 3);
#wayfinal
my $table_wayfinal = Gtk2::Table->new( 3, 2, FALSE);
my $label_wayfinal = Gtk2::Label->new();
$label_wayfinal->set_markup( 'WAYFINAL');
my $label_wayfinal_local = Gtk2::Label->new( 'local');
my $label_wayfinal_remote = Gtk2::Label->new( 'remote');
my $entry_wayfinal_local = Gtk2::Entry->new();
$entry_wayfinal_local->set_text( $wayfinal_local);
my $entry_wayfinal_remote = Gtk2::Entry->new();
$entry_wayfinal_remote->set_text( $wayfinal_remote);
$label_wayfinal_local->set_label( 'Local');
$label_wayfinal_remote->set_label( 'Remote');
$table_wayfinal->attach_defaults( $label_wayfinal, 0, 2, 0, 1);
$table_wayfinal->attach_defaults( $label_wayfinal_local, 0, 1, 1, 2);
$table_wayfinal->attach_defaults( $entry_wayfinal_local, 1, 2, 1, 2);
$table_wayfinal->attach_defaults( $label_wayfinal_remote, 0, 1, 2, 3);
$table_wayfinal->attach_defaults( $entry_wayfinal_remote, 1, 2, 2, 3);
#uaspf.txt
my $table_uaspf = Gtk2::Table->new( 3, 2, FALSE);
my $label_uaspf = Gtk2::Label->new();
$label_uaspf->set_markup( 'UASPF.TXT');
my $label_uaspf_local = Gtk2::Label->new( 'local');
my $label_uaspf_remote = Gtk2::Label->new( 'remote');
my $entry_uaspf_local = Gtk2::Entry->new();
$entry_uaspf_local->set_text( $uaspf_local);
my $entry_uaspf_remote = Gtk2::Entry->new();
$entry_uaspf_remote->set_text( $uaspf_remote);
$label_uaspf_local->set_label( 'Local');
$label_uaspf_remote->set_label( 'Remote');
$table_uaspf->attach_defaults( $label_uaspf, 0, 2, 0, 1);
$table_uaspf->attach_defaults( $label_uaspf_local, 0, 1, 1, 2);
$table_uaspf->attach_defaults( $entry_uaspf_local, 1, 2, 1, 2);
$table_uaspf->attach_defaults( $label_uaspf_remote, 0, 1, 2, 3);
$table_uaspf->attach_defaults( $entry_uaspf_remote, 1, 2, 2, 3);
#add pages to the notebook
$notebook_interface->append_page( $table_file, "config file");
$notebook_interface->append_page( $table_sftp, "sftp connection");
$notebook_interface->append_page( $table_uas, "uasposition");
$notebook_interface->append_page( $table_waytemp, "waytemp");
$notebook_interface->append_page( $table_wayfinal, "wayfinal");
$notebook_interface->append_page( $table_uaspf, "uaspf.txt");
#add buttons
my $button_cancel = Gtk2::Button->new( 'Cancel');
#add to the window
$table_interface->attach_defaults( $notebook_interface, 0, 2, 0, 1);
$table_interface->attach_defaults( $spacer5, 0, 2, 1, 2);
#$table_interface->attach_defaults( $button_save, 0, 1, 2, 3);
$table_interface->attach_defaults( $button_cancel, 1, 2, 2, 3);
$window_config->add( $table_interface);
$window_config->show_all;
$button_cancel->signal_connect( 'button-press-event' => sub { Gtk2->main_quit});
Gtk2->main;
#opens the file containing the config options
sub open_file {
if ( defined (open FILE, '<', "$_[0]")) {
#open the default.cfg file a nd load the variables
my @file = ;
chomp @file;
$username = $file[0];
$server = $file[1];
$uasposition_local = $file[2];
$uasposition_remote = $file[3];
$waytemp_local = $file[4];
$waytemp_remote = $file[5];
$wayfinal_local= $file[6];
$wayfinal_remote= $file[7];
$uaspf_local= $file[8];
$uaspf_remote= $file[9];
}
close FILE;
return 1;
}