def _on_document_added(self, model, idx, content):
     
     view = View()
     view.show()
 
     lang = self._language_manager.get_language("gobject-creator")
     buf = Buffer(language=lang)
     buf.set_highlight_syntax(True)
     view.set_buffer(buf)
     
     view.set_auto_indent(True)
     view.set_show_line_numbers(Settings.get().show_line_numbers)
     
     font_desc = pango.FontDescription(Settings.get().font_name)
     view.modify_font(font_desc)
     
     doc_container = gtk.ScrolledWindow()
     doc_container.show()
     doc_container.add(view)
         
     hbox = gtk.HBox()
     hbox.show()
         
     label = gtk.Label("")
     label.show()
     hbox.pack_start(label)
         
     close_button = gtk.Button()
     image = gtk.Image()
     image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
     close_button.set_image(image)
     close_button.set_relief(gtk.RELIEF_NONE)
     close_button.show()
     hbox.pack_start(close_button)
     
     self._notebook.insert_page(doc_container,
                                hbox,
                                idx
                                )
     self._notebook.set_current_page(idx)
     
     view.connect("button_press_event",
                  self._on_button_pressed
                  )
         
     close_button.connect(
         "clicked", 
         self._on_close_button_clicked
     )
   
     buf = view.get_buffer()
     buf.connect(
         "changed",
         self._on_buffer_changed
         )
     
     self._set_document_title(idx)
     
     buf.set_text(content)
 def __init__(self, model):
     
     self._model = model
     self._model.connect(
         "document-added",
         self._on_document_added
         )
     self._model.connect(
         "document-refreshed",
         self._on_document_refreshed
         )
     self._model.connect(
         "document-changed",
         self._on_document_changed
         )
     
     Settings.get().connect("settings-changed",
                            self._on_settings_changed
                            )
             
     self._language_manager = LanguageManager()
     language_path = os.path.dirname(__file__)
     language_path = os.path.abspath(language_path)
     language_path += os.sep + "resources"
     search_path = self._language_manager.get_search_path()
     search_path.insert(0, language_path)
     self._language_manager.set_search_path(search_path)
     
     self._notebook = gtk.Notebook()
     self._notebook.set_property("scrollable", True)
     
     self._clipboard = gtk.Clipboard()
     
     self._popup = None
     self._create_popup_menu()
     
     self._num_new_docs = 0