mirror of
				https://github.com/fspc/gbootroot.git
				synced 2025-10-30 23:25:36 -04:00 
			
		
		
		
	This adds the New Template function.
This commit is contained in:
		
							parent
							
								
									39adac66a8
								
							
						
					
					
						commit
						0867ee47fb
					
				| @ -1184,7 +1184,7 @@ sub saved { | |||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
|     elsif ($whoami == 101 || $whoami == 103) { |     elsif ($whoami == 101 || $whoami == 103) { | ||||||
| 	save_as(); | 	save_as($whoami); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } # end sub saved | } # end sub saved | ||||||
| @ -1587,7 +1587,8 @@ my $write_over; | |||||||
| sub save_as { | sub save_as { | ||||||
| 
 | 
 | ||||||
| # Will just use a dialog box. | # Will just use a dialog box. | ||||||
|     my ($error,$count,$pattern) = @_; |     my ($whoami) = @_; | ||||||
|  |     my $error; | ||||||
| 
 | 
 | ||||||
|     if (not defined $save_as) { |     if (not defined $save_as) { | ||||||
|     $save_as = Gtk::Dialog->new(); |     $save_as = Gtk::Dialog->new(); | ||||||
| @ -1602,7 +1603,9 @@ sub save_as { | |||||||
| 	} | 	} | ||||||
|     }, |     }, | ||||||
| 			     ); | 			     ); | ||||||
|     $save_as->set_title("Save As"); |      | ||||||
|  |     $whoami == 101 ? $save_as->set_title("Save As") :  | ||||||
|  | 	$save_as->set_title("New Template"); | ||||||
|     $save_as->border_width(12); |     $save_as->border_width(12); | ||||||
|     $save_as->set_position('center'); |     $save_as->set_position('center'); | ||||||
| 
 | 
 | ||||||
| @ -1630,25 +1633,31 @@ sub save_as { | |||||||
| 	# check | 	# check | ||||||
| 	my $new = "$template_dir$new_template" if $new_template; | 	my $new = "$template_dir$new_template" if $new_template; | ||||||
| 
 | 
 | ||||||
| 	if (!$new_template) { | 	if ( $whoami == 101 ) { | ||||||
| 	    if ( file_mode("$template_dir$template") =~ /l/ ) { | 
 | ||||||
| 		error_window("gBootRoot: ERROR: " .  | 	    if (!$new_template) { | ||||||
| 			     "$template_dir$template is not " . | 		if ( file_mode("$template_dir$template") =~ /l/ ) { | ||||||
| 			     "writable.\nUse [ File->Save As ] or " . | 		    error_window("gBootRoot: ERROR: " .  | ||||||
| 			     "[Alt-S] with the yard suffix.");		      | 				 "$template_dir$template is not " . | ||||||
| 		$save_as->destroy; | 				 "writable.\nUse [ File->Save As ] or " . | ||||||
| 		return; | 				 "[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; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 	    } | 	    } | ||||||
| 	    elsif ( file_mode("$template_dir$template") !~ /w/ ) { | 
 | ||||||
| 		error_window("gBootRoot: ERROR: " .  | 	} # $whoami == 101  | ||||||
| 			     "$template_dir$template is not " . |  | ||||||
| 			     "writable.\nUse [ File->Save As ] or " . |  | ||||||
| 			     "[Alt-S] with the yard suffix.");		      |  | ||||||
| 		$save_as->destroy; |  | ||||||
| 		return; |  | ||||||
| 		#save_as(); |  | ||||||
| 	    } |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	# An open template should just be saved not saved_as. | 	# An open template should just be saved not saved_as. | ||||||
| 	if (!$new_template) { | 	if (!$new_template) { | ||||||
| @ -1665,7 +1674,15 @@ sub save_as { | |||||||
| 	    open(NEW,">$new") or  | 	    open(NEW,">$new") or  | ||||||
| 		($error = error("Can't create $new")); | 		($error = error("Can't create $new")); | ||||||
| 	    return if $error && $error eq "ERROR";     | 	    return if $error && $error eq "ERROR";     | ||||||
| 	    print NEW $changed_text_from_template; | 	    if ( $whoami == 101 ) { | ||||||
|  | 		print NEW $changed_text_from_template; | ||||||
|  | 	    } | ||||||
|  | 	    elsif ( $whoami == 103 ) { | ||||||
|  | 		my $text_length = $text->get_length(); | ||||||
|  | 		$text->set_point($text_length); | ||||||
|  | 		$text->backward_delete($text->get_length()); | ||||||
|  | 		print NEW ""; | ||||||
|  | 	    } | ||||||
| 	    close(NEW); | 	    close(NEW); | ||||||
| 	    $template = $new_template; | 	    $template = $new_template; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user