From f815864df2cbd2f268946970335a1f23d44d3bd5 Mon Sep 17 00:00:00 2001 From: freesource Date: Tue, 31 Jul 2001 20:54:50 +0000 Subject: [PATCH] Made yard_window global, update $main::combo .. should note that yard box can only have 1 instance now that yard_window is global and is handled in gbootroot. --- BootRoot/YardBox.pm | 87 ++++++++++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 28 deletions(-) diff --git a/BootRoot/YardBox.pm b/BootRoot/YardBox.pm index 33748cc..79a4d6a 100644 --- a/BootRoot/YardBox.pm +++ b/BootRoot/YardBox.pm @@ -29,8 +29,9 @@ use strict; use BootRoot::Yard; use BootRoot::Error; use BootRoot::lsMode; +use File::Basename; -my $yard_window; +#my $main::yard_window; my $item_factory; my $true = 1; my $false = 0; @@ -81,7 +82,7 @@ my @menu_items = ( { path => '/File', type => '' }, { path => '/File/Close', accelerator => 'W', - callback => sub { destroy $yard_window; }}, + callback => sub { destroy $main::yard_window; }}, { path => '/_Edit', type => '' }, @@ -211,6 +212,7 @@ sub yard { # Yard: kernel,kernel version # Becomes $ENV{'RELEASE'} return if $error && $error eq "ERROR"; + } open(CONTENTS, "<$changed_text") or ($error = error("$changed_text: $!")); return "ERROR"if $error && $error eq "ERROR"; @@ -219,11 +221,11 @@ sub yard { $changed_text = join("",@template); yard_box(); - } - else { - error_window("Kernel Selection required"); - return; - } + #} + #else { + ##error_window("Kernel Selection required"); + ##return; + #} } # end sub yard @@ -648,18 +650,18 @@ my $start_length; sub yard_box { - $yard_window = new Gtk::Window "toplevel"; - $yard_window->signal_connect("destroy", \&destroy_window, - \$yard_window); - $yard_window->signal_connect("delete_event", \&destroy_window, - \$yard_window); - $yard_window->set_usize( 525, 450 ); - $yard_window->set_policy( $true, $true, $false ); - $yard_window->set_title( "Yard Box" ); - $yard_window->border_width(0); + $main::yard_window = new Gtk::Window "toplevel"; + $main::yard_window->signal_connect("destroy", \&destroy_window, + \$main::yard_window); + $main::yard_window->signal_connect("delete_event", \&destroy_window, + \$main::yard_window); + $main::yard_window->set_usize( 525, 450 ); + $main::yard_window->set_policy( $true, $true, $false ); + $main::yard_window->set_title( "Yard Box" ); + $main::yard_window->border_width(0); my $main_vbox = new Gtk::VBox( $false, 0 ); - $yard_window->add( $main_vbox ); + $main::yard_window->add( $main_vbox ); $main_vbox->show(); my $vbox = new Gtk::VBox( $false, 0 ); @@ -669,7 +671,7 @@ sub yard_box { #_______________________________________ # Item::Factory - my $menubar = yard_menu($yard_window); + my $menubar = yard_menu($main::yard_window); $vbox->pack_start( $menubar, $false, $true, 0 ); $menubar->show(); @@ -956,7 +958,7 @@ sub yard_box { $close_button = new Gtk::Button( "Close" ); $close_button->signal_connect( 'clicked', - sub { destroy $yard_window; } ); + sub { destroy $main::yard_window; } ); $vbox->pack_start( $close_button, $true, $true, 0 ); $close_button->show(); @@ -966,7 +968,7 @@ sub yard_box { $vbox->pack_start( $save_button, $true, $true, 0 ); $save_button->show(); - show $yard_window; + show $main::yard_window; } # end sub yard_box @@ -979,7 +981,12 @@ sub saved { # It's not necessary to use lsMode, but it's a cool program by MJD. if ($whoami == 100 || $whoami == 102 ) { - if ( file_mode("$template_dir$template") !~ /w/ ) { + if ( file_mode("$template_dir$template") =~ /l/ ) { + error_window("gBootRoot: ERROR: $template_dir$template is not " . + "writable.\nUse [ File->Save As ] or " . + "[Alt-S] with the yard suffix."); + } + elsif ( file_mode("$template_dir$template") !~ /w/ ) { error_window("gBootRoot: ERROR: $template_dir$template is not " . "writable.\nUse [ File->Save As ] or " . "[Alt-S] with the yard suffix."); @@ -1063,14 +1070,38 @@ sub save_as { $button->signal_connect("clicked", sub { # Here's where we get to undef Yard variable and start over at # check - my $new = "$template_dir$new_template"; - open(NEW,">$new") or + my $new = "$template_dir$new_template"; + print "$new && $template_dir$template\n"; + if (!basename($new)) { + if ( file_mode("$template_dir$template") =~ /l/ ) { + error_window("gBootRoot: ERROR: $template_dir$template is not " . + "writable.\nUse [ File->Save As ] or " . + "[Alt-S] with the yard suffix."); + $save_as->destroy; + return; + } + elsif ( file_mode("$template_dir$template") !~ /w/ ) { + error_window("gBootRoot: ERROR: $template_dir$template is not " . + "writable.\nUse [ File->Save As ] or " . + "[Alt-S] with the yard suffix."); + $save_as->destroy; + return; + } + } + open(NEW,">$new") or ($error = error("gBootRoot: ERROR: Can't create $new")); - return if $error && $error eq "ERROR"; - print NEW $changed_text; - close(NEW); - $template = $new_template; - $save_as->destroy + return if $error && $error eq "ERROR"; + print NEW $changed_text; + close(NEW); + $template = $new_template; + + opendir(DIR,$template_dir) if -d $template_dir; + my @templates = grep { m,\.yard$, } readdir(DIR) if $template_dir; + closedir(DIR); + $main::combo->set_popdown_strings( @templates ) if @templates; + $main::combo->entry->set_text($new_template); + + $save_as->destroy; }); $button->can_default(1); $save_as->action_area->pack_start($button, $false, $false,0);