Add another tab when opening file

I’m writing editor using FXRuby but I’ve got a problem. FXTabItems are
only visible if i add them in initialize method of my class. How to
connect add_tab method with position in menu to show FXTabItem? This is
code:

#! /usr/bin/ruby

require ‘fox16’
include Fox

class Editor < FXMainWindow

def initialize(app)
super(app, “Editor - #{@filename}” ,:width => 200, :height => 100)
self.icon = FXJPGIcon.new(app,File.open(“pbr.jpg”, “rb”).read)
add_menu_bar

contents =

FXHorizontalFrame.new(self,LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH)
@tabbook = FXTabBook.new(contents,:opts =>
LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT)

add_file_edit

end

def create
super
show(PLACEMENT_SCREEN)
end

def add_file_edit(app)
FXTabItem.new(@tabbook, “List”, nil)
frame = FXHorizontalFrame.new(@tabbook, FRAME_THICK|FRAME_RAISED)
FXText.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
end

def add_menu_bar
menu_bar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)

file_menu = FXMenuPane.new(self)
FXMenuTitle.new(menu_bar, "File" , :popupMenu => file_menu)

edit_menu = FXMenuPane.new(self)
FXMenuTitle.new(menu_bar, "Edit" , :popupMenu => edit_menu)

search_menu = FXMenuPane.new(self)
FXMenuTitle.new(menu_bar, "Search" , :popupMenu => search_menu)

help_menu = FXMenuPane.new(self)
FXMenuTitle.new(menu_bar, "Help" , :popupMenu => help_menu)

new_cmd = FXMenuCommand.new(file_menu, "New" )
new_cmd.connect(SEL_COMMAND) do
  @text.text = ""
end

open_cmd = FXMenuCommand.new(file_menu, "Open" )
open_cmd.connect(SEL_COMMAND) do
  dialog = FXFileDialog.new(self, "Import Photos" )
  dialog.selectMode = SELECTFILE_MULTIPLE
  dialog.patternList = ["C/C++ files (*.c, *.cpp, *.h, *.hh)" ]
  if dialog.execute != 0
    dialog.filenames.each do |filename|
      add_file_edit
    end
  end
end

save_cmd = FXMenuCommand.new(file_menu, "Save" )
save_cmd.connect(SEL_COMMAND) do
  @text.text = ""
end

saveas_cmd = FXMenuCommand.new(file_menu, "Save as..." )
saveas_cmd.connect(SEL_COMMAND) do
  @text.text = ""
end

FXMenuSeparator.new(file_menu)

exit_cmd = FXMenuCommand.new(file_menu, "Exit" )
exit_cmd.connect(SEL_COMMAND) do
  exit
end

end

end

FXApp.new do |app|
Editor.new(app)
app.create
app.run
end

Fixed