Source

Kephra / lib / Kephra / File.pm

Diff from to

File lib/Kephra/File.pm

 sub new  {
 	my $doc = Kephra::Document->new();
 	my $docbar = Kephra::API::docbar();
-	$_->add_page( $doc->panel->{$_},'rightmost','',1 ) for Kephra::API::all_docbars();
+	$_->add_page( $doc->panel->{$_}, 'rightmost', $doc->title, 0 )
+		for Kephra::API::all_docbars();
 	my $content_ref = $doc->editor->{$docbar}->GetDocPointer();
 	$doc->editor->{$_}->SetDocPointer( $content_ref ) for Kephra::API::passive_docbars();
 }
 			$db->set_page_title( $doc->file_name, $doc->panel->{$db} );
 		}
 		Kephra::API::app()->Yield;
-		#$ed->unmount_events();
 		Kephra::File::Local::read( $doc, $file );
+		$ed = Kephra::API::editor();
 		$ed->EmptyUndoBuffer;
 		#$ed->mount_events();
 	}
 
 sub save {
 	$_[0] = Kephra::API::document() unless @_;
+	my $docbar = Kephra::API::docbar();
+
 	for my $doc (@_){
 		next unless ref $doc eq 'Kephra::Document';
-		next unless $doc->editor->GetModify;
+		next unless $doc->editor->{$docbar}->GetModify;
 		if ($doc->file_path){
 			Kephra::File::Local::write($doc);
 		} else {
 
 sub close {
 	$_[0] = Kephra::API::document() unless @_;
+	my $active_bar = Kephra::API::docbar();
 
 	for my $doc (@_) {
 		next unless ref $doc eq 'Kephra::Document';
-		my $ed = $doc->editor;
+		my $ed = $doc->editor->{ $active_bar };
 		if ($ed->GetModify) {
 			my $save_answer = Kephra::App::Dialog::yes_no_cancel (
 				'close unsaved file', 'do you want to save it before?'
 			next if $save_answer == &Wx::wxCANCEL;
 			save($doc) if $save_answer == &Wx::wxYES;
 		}
-		my $bar = Kephra::API::docbar();
-		if ($bar->GetPageCount > 1){
-			$bar->remove_page( $doc->panel );
+		if ($active_bar->GetPageCount > 1){
+			$_->remove_page( $doc->panel->{$_} ) for Kephra::API::all_docbars();
 			$doc->DESTROY;
 		} else {
 			next unless $ed->GetLength;
 			$ed->ClearAll();
 			$ed->SetSavePoint;
 			$ed->EmptyUndoBuffer;
-			$bar->set_page_title('');
+			$active_bar->set_page_title('');
 		}
 		Kephra::API::main_window()->refresh_title();
 	}