1. Herbert Breunung
  2. Kephra

Commits

Herbert Breunung  committed effa397

clean up addpage of doc bar

  • Participants
  • Parent commits d638ede
  • Branches default

Comments (0)

Files changed (1)

File lib/Kephra/App/Bar/Document.pm

View file
  • Ignore whitespace
 
 sub add_page {
 	my ($self, $label, $position, $set_active, $panel ) = @_;
-
-	$label         = ''   unless defined $label;
+	return unless $panel and $panel->isa('Wx::Panel');
 	my $pages      = $self->GetPageCount;
 	my $active_pos = $self->GetSelection;
-	# my $active_ed  = $self->GetPage($active_pos);
-	$position = 'right'                 if $position eq 'default' or $position == -1;
-	$position = $pages                  if $position eq 'rightmost';
-	$position = $self->GetSelection + 1 if $position eq 'right';
-	$position = $self->GetSelection     if $position eq 'left';
-	$position = 0                       if $position eq 'leftmost';
-	$set_active = 1       unless defined $set_active;
-	#my $ed = defined $panel
-		#? $panel
-		#: Kephra::App::Editor->new($self);
+
+	$label    = ''              unless defined $label;
+	$position = 'right'         if $position eq 'default' or $position == -1;
+	$position = $pages          if $position eq 'rightmost';
+	$position = $active_pos + 1 if $position eq 'right';
+	$position = $active_pos     if $position eq 'left';
+	$position = 0               if $position eq 'leftmost';
+	$set_active = 1             unless defined $set_active;
 
 	$self->InsertPage( $position, $panel, $label, $set_active );
 	$self->set_title( $position, $label);