'Register plugin in Spyder\'s main window'

def register_plugin(self):

    self.editor = self.main.editor
    self.workingdirectory = self.main.workingdirectory
    ipyconsole = self.main.ipyconsole
    treewidget = self.explorer.treewidget
    self.main.add_dockwidget(self)
    self.explorer.sig_open_file.connect(self.main.open_file)
    treewidget.sig_edit.connect(self.editor.load)
    treewidget.sig_removed.connect(self.editor.removed)
    treewidget.sig_removed_tree.connect(self.editor.removed_tree)
    treewidget.sig_renamed.connect(self.editor.renamed)
    treewidget.sig_create_module.connect(self.editor.new)
    treewidget.sig_new_file.connect((lambda t: self.main.editor.new(text=t)))
    treewidget.sig_open_interpreter.connect(ipyconsole.create_client_from_path)
    treewidget.redirect_stdio.connect(self.main.redirect_internalshell_stdio)
    treewidget.sig_run.connect((lambda fname: ipyconsole.run_script(fname, osp.dirname(fname), '', False, False, False, True)))
    self.sig_project_loaded.connect((lambda v: self.workingdirectory.chdir(v)))
    self.sig_project_loaded.connect((lambda v: self.main.update_window_title()))
    self.sig_project_loaded.connect((lambda v: self.editor.setup_open_files()))
    self.sig_project_loaded.connect(self.update_explorer)
    self.sig_project_closed[object].connect((lambda v: self.workingdirectory.chdir(self.get_last_working_dir())))
    self.sig_project_closed.connect((lambda v: self.main.update_window_title()))
    self.sig_project_closed.connect((lambda v: self.editor.setup_open_files()))
    self.recent_project_menu.aboutToShow.connect(self.setup_menu_actions)
    self.main.pythonpath_changed()
    self.main.restore_scrollbar_position.connect(self.restore_scrollbar_position)
    self.pythonpath_changed.connect(self.main.pythonpath_changed)
    self.editor.set_projects(self)
