|
|
560f4e |
#!/usr/bin/perl -w
|
|
|
560f4e |
|
|
|
560f4e |
#requires Gtk-Perl
|
|
|
560f4e |
|
|
|
560f4e |
use Gtk;
|
|
|
560f4e |
use strict;
|
|
|
560f4e |
|
|
|
560f4e |
set_locale Gtk;
|
|
|
560f4e |
init Gtk;
|
|
|
560f4e |
|
|
|
560f4e |
my $window = new Gtk::Window("toplevel");
|
|
|
560f4e |
$window->signal_connect( "delete_event", \&CloseAppWindow );
|
|
|
560f4e |
my $table = new Gtk::Table( 20, 6, 0 );
|
|
|
560f4e |
$window->border_width( 5 );
|
|
|
560f4e |
#$window->add( $button );
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
my $prompt = new Gtk::Entry( 128);
|
|
|
560f4e |
my $log = new Gtk::Text();
|
|
|
560f4e |
$log->set_usize(40,60);
|
|
|
560f4e |
$log->show();
|
|
|
560f4e |
$prompt->show();
|
|
|
560f4e |
#$prompt->set_editable (1);
|
|
|
560f4e |
$prompt->set_text("");
|
|
|
560f4e |
$table->attach( $prompt,0,4,0,4,[ 'expand', 'shrink', 'fill' ],
|
|
|
560f4e |
'shrink',
|
|
|
560f4e |
0, 0 );
|
|
|
560f4e |
|
|
|
560f4e |
$table->set_row_spacings( 5 );
|
|
|
560f4e |
$table->set_col_spacings( 5 );
|
|
|
560f4e |
|
|
|
560f4e |
my $currDir = new Gtk::Button( "Current Directory" );
|
|
|
560f4e |
$currDir->show();
|
|
|
560f4e |
$table->attach_defaults( $currDir,0,1,4,6 );
|
|
|
560f4e |
|
|
|
560f4e |
my $errorCode = new Gtk::Button( "Last Return Code" );
|
|
|
560f4e |
$errorCode->show();
|
|
|
560f4e |
$table->attach_defaults( $errorCode,1,2,4,6 );
|
|
|
560f4e |
|
|
|
560f4e |
my $currTime = new Gtk::Button( "Time" );
|
|
|
560f4e |
$currTime->show();
|
|
|
560f4e |
$table->attach_defaults( $currTime,2,3,4,6 );
|
|
|
560f4e |
|
|
|
560f4e |
my $hist = new Gtk::Button( "History Number" );
|
|
|
560f4e |
$hist->show();
|
|
|
560f4e |
$table->attach_defaults( $hist,3,4,4,6 );
|
|
|
560f4e |
|
|
|
560f4e |
my $host = new Gtk::Button( "Hostname" );
|
|
|
560f4e |
$host->show();
|
|
|
560f4e |
$table->attach_defaults( $host,0,1,6,8 );
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
my $backgroundBlue = new Gtk::Button( "Blue Background" );
|
|
|
560f4e |
$backgroundBlue->show();
|
|
|
560f4e |
$table->attach_defaults( $backgroundBlue,0,1,8,10 );
|
|
|
560f4e |
|
|
|
560f4e |
my $backgroundRed = new Gtk::Button( "Red Background" );
|
|
|
560f4e |
$backgroundRed->show();
|
|
|
560f4e |
$table->attach_defaults( $backgroundRed,1,2,8,10 );
|
|
|
560f4e |
|
|
|
560f4e |
my $backgroundGreen = new Gtk::Button( "Green Background" );
|
|
|
560f4e |
$backgroundGreen->show();
|
|
|
560f4e |
$table->attach_defaults( $backgroundGreen,2,3,8,10 );
|
|
|
560f4e |
|
|
|
560f4e |
my $backgroundYellow = new Gtk::Button( "Yellow Background" );
|
|
|
560f4e |
$backgroundYellow->show();
|
|
|
560f4e |
$table->attach_defaults( $backgroundYellow,3,4,8,10 );
|
|
|
560f4e |
|
|
|
560f4e |
my $backgroundBlack = new Gtk::Button( "Black Background" );
|
|
|
560f4e |
$backgroundBlack->show();
|
|
|
560f4e |
$table->attach_defaults( $backgroundBlack,5,6,8,10 );
|
|
|
560f4e |
|
|
|
560f4e |
my $backgroundWhite = new Gtk::Button( "White Background" );
|
|
|
560f4e |
$backgroundWhite->show();
|
|
|
560f4e |
$table->attach_defaults( $backgroundWhite,6,7,8,10 );
|
|
|
560f4e |
|
|
|
560f4e |
my $backgroundPink = new Gtk::Button( "Pink Background" );
|
|
|
560f4e |
$backgroundPink->show();
|
|
|
560f4e |
$table->attach_defaults( $backgroundPink,7,8,8,10 );
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
my $textBlue = new Gtk::Button( "Blue Text" );
|
|
|
560f4e |
$textBlue->show();
|
|
|
560f4e |
$table->attach_defaults( $textBlue,0,1,10,12 );
|
|
|
560f4e |
|
|
|
560f4e |
my $textRed = new Gtk::Button( "Red Text" );
|
|
|
560f4e |
$textRed->show();
|
|
|
560f4e |
$table->attach_defaults( $textRed,1,2,10,12 );
|
|
|
560f4e |
|
|
|
560f4e |
my $textGreen = new Gtk::Button( "Green Text" );
|
|
|
560f4e |
$textGreen->show();
|
|
|
560f4e |
$table->attach_defaults( $textGreen,2,3,10,12 );
|
|
|
560f4e |
|
|
|
560f4e |
my $textYellow = new Gtk::Button( "Yellow Text" );
|
|
|
560f4e |
$textYellow->show();
|
|
|
560f4e |
$table->attach_defaults( $textYellow,3,4,10,12 );
|
|
|
560f4e |
|
|
|
560f4e |
my $textBlack = new Gtk::Button( "Black Text" );
|
|
|
560f4e |
$textBlack->show();
|
|
|
560f4e |
$table->attach_defaults( $textBlack,5,6,10,12 );
|
|
|
560f4e |
|
|
|
560f4e |
my $textWhite = new Gtk::Button( "White Text" );
|
|
|
560f4e |
$textWhite->show();
|
|
|
560f4e |
$table->attach_defaults( $textWhite,6,7,10,12 );
|
|
|
560f4e |
|
|
|
560f4e |
my $textPink = new Gtk::Button( "Pink Text" );
|
|
|
560f4e |
$textPink->show();
|
|
|
560f4e |
$table->attach_defaults( $textPink,7,8,10,12 );
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
my $textDefault = new Gtk::Button( "Default Text" );
|
|
|
560f4e |
$textDefault->show();
|
|
|
560f4e |
$table->attach_defaults( $textDefault,0,1,12,14 );
|
|
|
560f4e |
|
|
|
560f4e |
my $backgroundDefault = new Gtk::Button( "Default Background" );
|
|
|
560f4e |
$backgroundDefault->show();
|
|
|
560f4e |
$table->attach_defaults( $backgroundDefault,1,2,12,14 );
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
my $set = new Gtk::Button( "Save Settings" );
|
|
|
560f4e |
$set->show();
|
|
|
560f4e |
$table->attach_defaults( $set,0,1,16,18 );
|
|
|
560f4e |
|
|
|
560f4e |
my $xterm = new Gtk::Button( "Test saved settings" );
|
|
|
560f4e |
$xterm->show();
|
|
|
560f4e |
$table->attach_defaults( $xterm,1,2,16,18 );
|
|
|
560f4e |
|
|
|
560f4e |
$table->attach_defaults( $log,0,6,18,20 );
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
$currDir->signal_connect( "clicked", \&insertButtonText, "%1/" );
|
|
|
560f4e |
$errorCode->signal_connect( "clicked", \&insertButtonText, "%?" );
|
|
|
560f4e |
$currTime->signal_connect( "clicked", \&insertButtonText, "%T" );
|
|
|
560f4e |
$hist->signal_connect( "clicked", \&insertButtonText, "%!" );
|
|
|
560f4e |
$host->signal_connect( "clicked", \&insertButtonText, "%m" );
|
|
|
560f4e |
|
|
|
560f4e |
$backgroundBlue->signal_connect( "clicked", \&insertButtonText, "%{\$bg[blue]%}" );
|
|
|
560f4e |
$backgroundRed->signal_connect( "clicked", \&insertButtonText, "%{\$bg[red]%}" );
|
|
|
560f4e |
$backgroundGreen->signal_connect( "clicked", \&insertButtonText, "%{\$bg[green]%}" );
|
|
|
560f4e |
$backgroundYellow->signal_connect( "clicked", \&insertButtonText, "%{\$bg[yellow]%}" );
|
|
|
560f4e |
$backgroundBlack->signal_connect( "clicked", \&insertButtonText, "%{\$bg[black]%}" );
|
|
|
560f4e |
$backgroundWhite->signal_connect( "clicked", \&insertButtonText, "%{\$bg[white]%}" );
|
|
|
560f4e |
$backgroundPink->signal_connect( "clicked", \&insertButtonText, "%{\$bg[magenta]%}" );
|
|
|
560f4e |
$backgroundDefault->signal_connect( "clicked", \&insertButtonText, "%{\$bg[default]%}" );
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
$textBlue->signal_connect( "clicked", \&insertButtonText, "%{\$fg[blue]%}" );
|
|
|
560f4e |
$textRed->signal_connect( "clicked", \&insertButtonText, "%{\$fg[red]%}" );
|
|
|
560f4e |
$textGreen->signal_connect( "clicked", \&insertButtonText, "%{\$fg[green]%}" );
|
|
|
560f4e |
$textYellow->signal_connect( "clicked", \&insertButtonText, "%{\$fg[yellow]%}" );
|
|
|
560f4e |
$textBlack->signal_connect( "clicked", \&insertButtonText, "%{\$fg[black]%}" );
|
|
|
560f4e |
$textWhite->signal_connect( "clicked", \&insertButtonText, "%{\$fg[white]%}" );
|
|
|
560f4e |
$textPink->signal_connect( "clicked", \&insertButtonText, "%{\$fg[magenta]%}" );
|
|
|
560f4e |
$textDefault->signal_connect( "clicked", \&insertButtonText, "%{\$fg[default]%}" );
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
$set->signal_connect( "clicked", \&pushEnv );
|
|
|
560f4e |
$xterm->signal_connect( "clicked", \&xterm );
|
|
|
560f4e |
|
|
|
560f4e |
sub xterm
|
|
|
560f4e |
{
|
|
|
560f4e |
my $string="xterm -e zsh -li&";
|
|
|
560f4e |
#$string.=$prompt->get_text();
|
|
|
560f4e |
|
|
|
560f4e |
#$string.="' zsh -li\"& ";
|
|
|
560f4e |
|
|
|
560f4e |
system($string);
|
|
|
560f4e |
# $prompt->append_text( $string );
|
|
|
560f4e |
$log->insert( "", "white", "black", "executing:\n $string\n");
|
|
|
560f4e |
}
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
sub pushEnv
|
|
|
560f4e |
{
|
|
|
560f4e |
chdir("~");
|
|
|
560f4e |
use Env qw(PS1);
|
|
|
560f4e |
my $pNotSet=0;
|
|
|
560f4e |
open(PROMPT, "+<", ".prompt") or $pNotSet=1;
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
if($pNotSet)
|
|
|
560f4e |
{
|
|
|
560f4e |
#$prompt->insert( "", "white", "black", "prompt is not set");
|
|
|
560f4e |
open(ZSHRC, '>>','.zshrc') or die "cannot open zshrc";
|
|
|
560f4e |
print ZSHRC ". ~/.prompt\n";
|
|
|
560f4e |
close (ZSHRC);
|
|
|
560f4e |
}
|
|
|
560f4e |
close (PROMPT);
|
|
|
560f4e |
open(PROMPT, ">", ".prompt");
|
|
|
560f4e |
print PROMPT "export PS1=\"",$prompt->get_text(),"\"\n";
|
|
|
560f4e |
|
|
|
560f4e |
#$prompt->insert( "", "white", "black", $PS1);
|
|
|
560f4e |
|
|
|
560f4e |
close(PROMPT);
|
|
|
560f4e |
close(ZSHRC);
|
|
|
560f4e |
$prompt->grab_focus();
|
|
|
560f4e |
|
|
|
560f4e |
}
|
|
|
560f4e |
$prompt->can_default(1);
|
|
|
560f4e |
$prompt->grab_default();
|
|
|
560f4e |
$table->show();
|
|
|
560f4e |
$window->add( $table );
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
$window->show();
|
|
|
560f4e |
$prompt->grab_focus();
|
|
|
560f4e |
main Gtk;
|
|
|
560f4e |
|
|
|
560f4e |
exit( 0 );
|
|
|
560f4e |
|
|
|
560f4e |
sub CloseAppWindow
|
|
|
560f4e |
{
|
|
|
560f4e |
Gtk->exit( 0 );
|
|
|
560f4e |
return 0;
|
|
|
560f4e |
}
|
|
|
560f4e |
|
|
|
560f4e |
|
|
|
560f4e |
sub insertButtonText
|
|
|
560f4e |
{
|
|
|
560f4e |
my ($widget, $txt) = @_;
|
|
|
560f4e |
$prompt->append_text( $txt );
|
|
|
560f4e |
$prompt->grab_focus();
|
|
|
560f4e |
}
|