def register_client(self, client, give_focus=True):
        """Register new client"""
        client.configure_shellwidget(give_focus=give_focus)

        # Local vars
        shellwidget = client.shellwidget
        control = shellwidget._control
        page_control = shellwidget._page_control

        # Create new clients with Ctrl+T shortcut
        shellwidget.new_client.connect(self.create_new_client)

        # For tracebacks
        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))

        # To handle %edit magic petitions
        shellwidget.custom_edit_requested.connect(self.edit_file)

        # Set shell cwd according to preferences
        cwd_path = ''
        if CONF.get('workingdir', 'console/use_project_or_home_directory'):
            cwd_path = get_home_dir()
            if (self.main.projects is not None and
                    self.main.projects.get_active_project() is not None):
                cwd_path = self.main.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:
                # Syncronice cwd with explorer and cwd widget
                shellwidget.get_cwd()

        # Connect text widget to Help
        if self.main.help is not None:
            control.set_help(self.main.help)
            control.set_help_enabled(CONF.get('help', 'connect/ipython_console'))

        # Connect client to our history log
        if self.main.historylog is not None:
            self.main.historylog.add_history(client.history_filename)
            client.append_to_history.connect(
                self.main.historylog.append_to_history)
        
        # Set font for client
        client.set_font( self.get_plugin_font() )
        
        # Connect focus signal to client's control widget
        control.focus_changed.connect(lambda: self.focus_changed.emit())
        
        shellwidget.sig_change_cwd.connect(self.set_working_directory)

        # Update the find widget if focus changes between control and
        # page_control
        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)
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 ) ) shellwidget . custom_edit_requested . connect ( self . edit_file ) cwd_path = '' if CONF . get ( 'workingdir' , 'console/use_project_or_home_directory' ) : cwd_path = get_home_dir ( ) if ( self . main . projects is not None and self . main . projects . get_active_project ( ) is not None ) : cwd_path = self . main . 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 . main . help is not None : control . set_help ( self . main . help ) control . set_help_enabled ( CONF . get ( 'help' , 'connect/ipython_console' ) ) if self . main . historylog is not None : self . main . historylog . add_history ( client . history_filename ) client . append_to_history . connect ( self . main . 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 )
Register new client