'Register new client'

def register_client(self, client, give_focus=True):

    client.configure_shellwidget(give_focus=give_focus)
    shellwidget = client.shellwidget
    control = shellwidget._control
    page_control = shellwidget._page_control
    shellwidget.new_client.connect(self.create_new_client)
    control.go_to_error.connect(self.go_to_error)
    shellwidget.sig_pdb_step.connect((lambda fname, lineno, shellwidget=shellwidget: self.pdb_has_stopped(fname, lineno, shellwidget)))
    cwd_path = ''
    if CONF.get('workingdir', 'console/use_project_or_home_directory'):
        cwd_path = get_home_dir()
        if ((self.projects is not None) and (self.projects.get_active_project() is not None)):
            cwd_path = self.projects.get_active_project_path()
    elif CONF.get('workingdir', 'console/use_fixed_directory'):
        cwd_path = CONF.get('workingdir', 'console/fixed_directory')
    if (osp.isdir(cwd_path) and (self.main is not None)):
        shellwidget.set_cwd(cwd_path)
        if give_focus:
            shellwidget.get_cwd()
    if (self.help is not None):
        control.set_help(self.help)
        control.set_help_enabled(CONF.get('help', 'connect/ipython_console'))
    if (self.historylog is not None):
        self.historylog.add_history(client.history_filename)
        client.append_to_history.connect(self.historylog.append_to_history)
    client.set_font(self.get_plugin_font())
    control.focus_changed.connect((lambda : self.focus_changed.emit()))
    shellwidget.sig_change_cwd.connect(self.set_working_directory)
    self.find_widget.set_editor(control)
    if page_control:
        page_control.focus_changed.connect((lambda : self.focus_changed.emit()))
        control.visibility_changed.connect(self.refresh_plugin)
        page_control.visibility_changed.connect(self.refresh_plugin)
        page_control.show_find_widget.connect(self.find_widget.show)
