Exemplo n.º 1
0
def run_ninja():
    """First obtain the execution args and create the resources folder."""
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    # Change the process name only for linux yet
    if sys.platform != 'win32' and sys.platform != 'darwin':
        try:
            import ctypes
            libc = ctypes.CDLL('libc.so.6')
            procname = 'ninja-ide'
            libc.prctl(15, '%s\0' % procname, 0, 0, 0)
        except:
            print "The process couldn't be renamed'"
    #Set the application name
    filenames, projects_path, extra_plugins = cliparser.parse()
    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    if ipc.is_running() and (filenames or projects_path):
        sended = ipc.send_data(filenames, projects_path)
        if sended:
            sys.exit()
    listener = ipc.SessionListener()
    listener.start()
    # Create NINJA-IDE user folder structure for plugins, themes, etc
    resources.create_home_dir_structure()

    # Start the UI
    from ninja_ide.gui import ide
    try:
        ide.start(listener, filenames, projects_path, extra_plugins)
    finally:
        ipc.close_listener(listener)
Exemplo n.º 2
0
def run_ninja():
    """First obtain the execution args and create the resources folder."""
    # Change the process name only for linux yet
    if sys.platform != 'win32' and sys.platform != 'darwin':
        try:
            import ctypes
            libc = ctypes.CDLL('libc.so.6')
            procname = 'ninja-ide'
            libc.prctl(15, '%s\0' % procname, 0, 0, 0)
        except:
            print "The process couldn't be renamed'"
    #Set the application name
    filenames, projects_path, extra_plugins = cliparser.parse()
    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    if ipc.is_running() and (filenames or projects_path):
        sended = ipc.send_data(filenames, projects_path)
        if sended:
            sys.exit()
    listener = ipc.SessionListener()
    listener.start()
    # Create NINJA-IDE user folder structure for plugins, themes, etc
    resources.create_home_dir_structure()

    # Start the UI
    from ninja_ide.gui import ide
    try:
        ide.start(listener, filenames, projects_path, extra_plugins)
    finally:
        ipc.close_listener(listener)
Exemplo n.º 3
0
def start(filenames=None,
          projects_path=None,
          extra_plugins=None,
          linenos=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(resources.IMAGES['icon']))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    global cursor_flash_time
    cursor_flash_time = app.cursorFlashTime()
    app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = QSettings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language', language) + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    elif file_manager.file_exists(
            file_manager.create_path(resources.LANGS_DOWNLOAD, lang)):
        settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD,
                                                     lang)
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    settings.load_settings()

    #Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ('Default', 'Classic Theme'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA__THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    scheme = qsettings.value('preferences/editor/scheme', "default")
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
                                          scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ide = IDE(start_server)

    #Showing GUI
    ide.show()

    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
                       Qt.AlignRight | Qt.AlignTop, Qt.black)
    #Files in Main Tab
    main_files = qsettings.value('openFiles/mainTab', [])
    if main_files is not None:
        mainFiles = list(main_files)
    else:
        mainFiles = list()
    tempFiles = []
    for file_ in mainFiles:
        fileData = list(file_)
        tempFiles.append((fileData[0], int(fileData[1])))
    mainFiles = tempFiles
    #Files in Secondary Tab
    sec_files = qsettings.value('openFiles/secondaryTab', [])
    if sec_files is not None:
        secondaryFiles = list(sec_files)
    else:
        secondaryFiles = list()
    tempFiles = []
    for file_ in secondaryFiles:
        fileData = list(file_)
        tempFiles.append((fileData[0], int(fileData[1])))
    secondaryFiles = tempFiles
    # Recent Files
    recent = qsettings.value('openFiles/recentFiles', [])
    if recent is not None:
        recent_files = list(recent)
    else:
        recent_files = list()
    recent_files = [file_ for file_ in recent_files]
    #Current File
    current_file = qsettings.value('openFiles/currentFile', '')
    #Projects
    projects_list = qsettings.value('openFiles/projects', [])
    if projects_list is not None:
        projects = list(projects_list)
    else:
        projects = list()
    projects = [project for project in projects]
    #Include files received from console args
    file_with_nro = list(
        map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos)))
    file_without_nro = list(map(lambda f: (f, 0), filenames[len(linenos):]))
    mainFiles += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    ide.load_session_files_projects(mainFiles, secondaryFiles, projects,
                                    current_file, recent_files)
    #Load external plugins
    if extra_plugins:
        ide.load_external_plugins(extra_plugins)

    splash.finish(ide)
    ide.notify_plugin_errors()
    sys.exit(app.exec_())
Exemplo n.º 4
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(":img/icon"))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(":img/splash")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    #if not settings.IS_WINDOWS:
    #app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language',
                           defaultValue=language,
                           type='QString') + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language,
                          QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)

    #Set Stylesheet
    style_applied = False
    print(settings.NINJA_SKIN)
    if settings.NINJA_SKIN not in ('Default'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as fileaccess:
                qss = fileaccess.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as fileaccess:
                qss = fileaccess.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    scheme = qsettings.value('preferences/editor/scheme',
                             "default",
                             type='QString')
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
                                          scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    #Showing GUI
    ninjaide.show()
    #OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except:
        pass  # I really dont mind if this fails in any form
    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
                       Qt.AlignRight | Qt.AlignTop, Qt.black)

    #First check if we need to load last session files
    if qsettings.value('preferences/general/loadFiles', True, type=bool):
        #Files in Main Tab
        files = data_qsettings.value('lastSession/openedFiles', [])
        tempFiles = []
        if files:
            for file_ in files:
                fileData = tuple(file_)
                if fileData:
                    tempFiles.append(fileData)
        files = tempFiles

        # Recent Files
        recent_files = data_qsettings.value('lastSession/recentFiles', [])
        #Current File
        current_file = data_qsettings.value('lastSession/currentFile',
                                            '',
                                            type='QString')
        #Projects
        projects = data_qsettings.value('lastSession/projects', [])
    else:
        files = []
        recent_files = []
        current_file = ''
        projects = []

    #Include files received from console args
    file_with_nro = list([(f[0], (f[1] - 1, 0), 0)
                          for f in zip(filenames, linenos)])
    file_without_nro = list([(f, (0, 0), 0) for f in filenames[len(linenos):]])
    files += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT
    ninjaide.load_session_files_projects(files, projects, current_file,
                                         recent_files)
    #Load external plugins
    #if extra_plugins:
    #ninjaide.load_external_plugins(extra_plugins)

    splash.finish(ninjaide)
    ninjaide.notify_plugin_errors()
    ninjaide.show_python_detection()
Exemplo n.º 5
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(":img/icon"))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(":img/splash")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    if not settings.IS_WINDOWS:
        app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language',
        defaultValue=language, type='QString') + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language,
            QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
        Qt.black)
    settings.load_settings()

    #Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ('Default', 'Classic Theme'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA_THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value('preferences/editor/scheme', "default",
        type='QString')
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
            scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    #Showing GUI
    ninjaide.show()
    #OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except:
        pass  # I really dont mind if this fails in any form
    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
        Qt.AlignRight | Qt.AlignTop, Qt.black)

    #First check if we need to load last session files
    if qsettings.value('preferences/general/loadFiles', True, type=bool):
        #Files in Main Tab
        files = data_qsettings.value('lastSession/openedFiles', [])
        tempFiles = []
        if files:
            for file_ in files:
                fileData = tuple(file_)
                if fileData:
                    tempFiles.append(fileData)
        files = tempFiles

        # Recent Files
        recent_files = data_qsettings.value('lastSession/recentFiles', [])
        #Current File
        current_file = data_qsettings.value(
                        'lastSession/currentFile', '', type='QString')
        #Projects
        projects = data_qsettings.value('lastSession/projects', [])
    else:
        files = []
        recent_files = []
        current_file = ''
        projects = []

    #Include files received from console args
    file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)])
    file_without_nro = list([(f, 0) for f in filenames[len(linenos):]])
    files += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT
    ninjaide.load_session_files_projects(files, projects,
                                         current_file, recent_files)
    #Load external plugins
    #if extra_plugins:
        #ninjaide.load_external_plugins(extra_plugins)

    splash.finish(ninjaide)
    ninjaide.notify_plugin_errors()
    ninjaide.show_python_detection()
Exemplo n.º 6
0
def start(filenames=None, projects_path=None,
          extra_plugins=None, linenos=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(resources.IMAGES['icon']))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    global cursor_flash_time
    cursor_flash_time = app.cursorFlashTime()
    app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = QSettings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language', language) + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    elif file_manager.file_exists(file_manager.create_path(
      resources.LANGS_DOWNLOAD, lang)):
        settings.LANGUAGE = file_manager.create_path(
            resources.LANGS_DOWNLOAD, lang)
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
        Qt.black)
    settings.load_settings()

    #Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ('Default', 'Classic Theme'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA__THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value('preferences/editor/scheme', "default")
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
            scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ide = IDE(start_server)

    #Showing GUI
    ide.show()

    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    #Files in Main Tab
    main_files = qsettings.value('openFiles/mainTab', [])
    if main_files is not None:
        mainFiles = list(main_files)
    else:
        mainFiles = list()
    tempFiles = []
    for file_ in mainFiles:
        fileData = list(file_)
        tempFiles.append((fileData[0], int(fileData[1])))
    mainFiles = tempFiles
    #Files in Secondary Tab
    sec_files = qsettings.value('openFiles/secondaryTab', [])
    if sec_files is not None:
        secondaryFiles = list(sec_files)
    else:
        secondaryFiles = list()
    tempFiles = []
    for file_ in secondaryFiles:
        fileData = list(file_)
        tempFiles.append((fileData[0], int(fileData[1])))
    secondaryFiles = tempFiles
    # Recent Files
    recent = qsettings.value('openFiles/recentFiles', [])
    if recent is not None:
        recent_files = list(recent)
    else:
        recent_files = list()
    recent_files = [file_ for file_ in recent_files]
    #Current File
    current_file = qsettings.value('openFiles/currentFile', '')
    #Projects
    projects_list = qsettings.value('openFiles/projects', [])
    if projects_list is not None:
        projects = list(projects_list)
    else:
        projects = list()
    projects = [project for project in projects]
    #Include files received from console args
    file_with_nro = list(map(lambda f: (f[0], f[1] - 1),
        zip(filenames, linenos)))
    file_without_nro = list(map(lambda f: (f, 0), filenames[len(linenos):]))
    mainFiles += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    ide.load_session_files_projects(mainFiles, secondaryFiles, projects,
        current_file, recent_files)
    #Load external plugins
    if extra_plugins:
        ide.load_external_plugins(extra_plugins)

    splash.finish(ide)
    ide.notify_plugin_errors()
    sys.exit(app.exec_())
Exemplo n.º 7
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    def _add_splash(message):
        splash.showMessage(message,
                           Qt.AlignTop | Qt.AlignRight | Qt.AlignAbsolute,
                           Qt.black)
        QCoreApplication.processEvents()

    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(":img/icon"))
    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(":img/splash")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()

    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    # FIXME: handle this
    # Translator
    # language = QLocale.system().name()
    # lang = qsettings.value('preferences/interface/language',
    #                       defaultValue=language, type='QString') + '.qm'
    # lang_path = file_manager.create_path(resources.LANGS, lang)
    # if file_manager.file_exists(lang_path):
    #    settings.LANGUAGE = lang_path
    # translator = QTranslator()
    # if settings.LANGUAGE:
    #    translator.load(settings.LANGUAGE)
    #    app.installTranslator(translator)

    #    qtTranslator = QTranslator()
    #    qtTranslator.load(
    #        "qt_" + language,
    #        QLibraryInfo.location(QLibraryInfo.TranslationsPath))
    #    app.installTranslator(qtTranslator)

    # Loading Syntax
    _add_splash("Loading Syntax..")
    json_manager.load_syntax()

    load_fonts()

    # Loading Schemes
    _add_splash("Loading Schemes...")
    all_schemes = json_manager.load_editor_schemes()
    resources.COLOR_SCHEME = all_schemes["Ninja Dark"]
    # Load Services
    _add_splash("Loading IDE Services...")
    # Register tools dock service after load some settings
    # FIXME: Find a better way to do this
    import ninja_ide.gui.tools_dock.tools_dock  # noqa
    import ninja_ide.gui.tools_dock.console_widget  # noqa
    import ninja_ide.gui.tools_dock.run_widget  # noqa
    import ninja_ide.gui.tools_dock.find_in_files  # noqa

    import ninja_ide.gui.main_panel.main_container  # noqa
    import ninja_ide.gui.central_widget  # noqa
    import ninja_ide.gui.status_bar  # noqa
    import ninja_ide.gui.menus.menubar  # noqa

    # Explorer Container
    import ninja_ide.gui.explorer.explorer_container  # noqa
    from ninja_ide.gui.explorer.tabs import tree_projects_widget  # noqa
    from ninja_ide.gui.explorer.tabs import tree_symbols_widget  # noqa
    from ninja_ide.gui.explorer.tabs import bookmark_manager  # noqa
    # from ninja_ide.gui.explorer.tabs import web_inspector
    # Checkers
    from ninja_ide.gui.editor.checkers import errors_checker  # noqa
    from ninja_ide.gui.editor.checkers import pep8_checker  # noqa
    # from ninja_ide.gui.editor.checkers import not_import_checker  # noqa
    # from ninja_ide.gui.editor.checkers import migration_2to3
    # Preferences
    # from ninja_ide.gui.dialogs.preferences import preferences_general  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_execution  # noqa
    # # from ninja_ide.gui.dialogs.preferences import preferences_shortcuts
    # from ninja_ide.gui.dialogs.preferences import preferences_interface  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_editor_general  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_editor_display  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_editor_behavior  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_editor_intellisense  # noqa
    from ninja_ide.intellisensei import intellisense_registry  # noqa
    from ninja_ide.intellisensei import python_intellisense  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_editor_completion
    # from ninja_ide.gui.dialogs.preferences import preferences_plugins
    # from ninja_ide.gui.dialogs.preferences import preferences_theme
    from ninja_ide.gui.editor.checkers import errors_lists  # noqa
    from ninja_ide.gui.editor.checkers import errors_checker  # noqa
    from ninja_ide.gui.editor.checkers import pep8_checker  # noqa

    # Loading Shortcuts
    # resources.load_shortcuts()
    # Loading GUI
    _add_splash("Loading GUI...")
    ninjaide = ide.IDE(start_server)
    # Loading Session Files
    _add_splash("Loading Files and Projects...")
    # First check if we need to load last session files
    if qsettings.value('general/loadFiles', True, type=bool):
        files = data_qsettings.value('lastSession/openedFiles')
        projects = data_qsettings.value('lastSession/projects')
        current_file = data_qsettings.value('lastSession/currentFile')
        if files is None:
            files = []
        if projects is None:
            projects = []
        # Include files received from console args
        files_with_lineno = [(f[0], (f[1] - 1, 0))
                             for f in zip(filenames, linenos)]
        files_without_lineno = [(f, (0, 0)) for f in filenames[len(linenos):]]
        files += files_with_lineno + files_without_lineno
        # Include projects received from console args
        if projects_path:
            projects += projects_path
        ninjaide.load_session_files_projects(files, projects, current_file)

    # Showing GUI
    ninjaide.show()
    # OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except Exception:
        pass  # I really dont mind if this fails in any form
    # Load external plugins
    # if extra_plugins:
    #     ninjaide.load_external_plugins(extra_plugins)
    splash.finish(ninjaide)
Exemplo n.º 8
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    QCoreApplication.setOrganizationName("NINJA-IDE")
    QCoreApplication.setOrganizationDomain("NINJA-IDE")
    QCoreApplication.setApplicationName("NINJA-IDE")
    app.setWindowIcon(QIcon(resources.IMAGES["icon"]))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES["splash"])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    if not settings.IS_WINDOWS:
        app.setCursorFlashTime(0)

    # Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName("utf-8"))

    # Translator
    qsettings = QSettings(resources.SETTINGS_PATH, QSettings.IniFormat)
    language = QLocale.system().name()
    lang = qsettings.value("preferences/interface/language", defaultValue=language, type="QString") + ".qm"
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language, QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    # Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    # Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black)
    settings.load_settings()

    # Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ("Default", "Classic Theme"):
        file_name = "%s.qss" % settings.NINJA_SKIN
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == "Default":
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA_THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    # Loading Schemes
    splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value("preferences/editor/scheme", "default", type="QString")
    if scheme != "default":
        scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + ".color")
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    # Loading Shortcuts
    resources.load_shortcuts()
    # Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    # Showing GUI
    ninjaide.show()

    # Loading Session Files
    splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black)

    # First check if we need to load last session files
    if qsettings.value("preferences/general/loadFiles", True, type=bool):
        # Files in Main Tab
        main_files = qsettings.value("openFiles/mainTab", [])
        tempFiles = []
        if main_files:
            for file_ in main_files:
                fileData = list(file_)
                if fileData:
                    lineno = fileData[1]
                    tempFiles.append((fileData[0], lineno))
        main_files = tempFiles
        # Files in Secondary Tab
        sec_files = qsettings.value("openFiles/secondaryTab", [])
        tempFiles = []
        if sec_files:
            for file_ in sec_files:
                fileData = list(file_)
                if fileData:
                    lineno = fileData[1]
                    tempFiles.append((fileData[0], lineno))
        sec_files = tempFiles

        # Recent Files
        recent_files = qsettings.value("openFiles/recentFiles", [])
        # Current File
        current_file = qsettings.value("openFiles/currentFile", "", type="QString")
        # Projects
        projects = qsettings.value("openFiles/projects", [])
    else:
        main_files = []
        sec_files = []
        recent_files = []
        current_file = ""
        projects = []

    # Include files received from console args
    file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)])
    file_without_nro = list([(f, 0) for f in filenames[len(linenos) :]])
    main_files += file_with_nro + file_without_nro
    # Include projects received from console args
    if projects_path:
        projects += projects_path
    # FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT
    # ninjaide.load_session_files_projects(main_files, sec_files,
    # projects, current_file, recent_files)
    # Load external plugins
    # if extra_plugins:
    # ninjaide.load_external_plugins(extra_plugins)

    splash.finish(ninjaide)
    ninjaide.notify_plugin_errors()
    ninjaide.show_python_detection()
Exemplo n.º 9
0
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName("NINJA-IDE")
    QCoreApplication.setOrganizationDomain("NINJA-IDE")
    QCoreApplication.setApplicationName("NINJA-IDE")
    app.setWindowIcon(QIcon(resources.IMAGES["icon"]))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES["splash"])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    global cursor_flash_time
    cursor_flash_time = app.cursorFlashTime()
    app.setCursorFlashTime(0)

    # Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName("utf-8"))

    # Translator
    qsettings = QSettings()
    language = QLocale.system().language()
    lang = unicode(qsettings.value("preferences/interface/language", language).toString()) + ".qm"
    lang_path = file_manager.create_path(resources.LANGS, unicode(lang))
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    elif file_manager.file_exists(file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))):
        settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

    # Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    # Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black)
    settings.load_settings()

    # Set Stylesheet
    if settings.USE_STYLESHEET:
        with open(resources.NINJA_THEME) as f:
            qss = f.read()
            app.setStyleSheet(qss)

    # Loading Themes
    splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = unicode(qsettings.value("preferences/editor/scheme", "default").toString())
    if scheme != "default":
        scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + ".color")
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    # Loading Shortcuts
    resources.load_shortcuts()
    # Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ide = IDE(start_server)

    # Showing GUI
    ide.show()

    # Loading Session Files
    splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black)
    # Files in Main Tab
    mainFiles = qsettings.value("openFiles/mainTab", []).toList()
    tempFiles = []
    for file_ in mainFiles:
        fileData = file_.toList()
        tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0]))
    mainFiles = tempFiles
    # Files in Secondary Tab
    secondaryFiles = qsettings.value("openFiles/secondaryTab", []).toList()
    tempFiles = []
    for file_ in secondaryFiles:
        fileData = file_.toList()
        tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0]))
    secondaryFiles = tempFiles
    # Current File
    current_file = unicode(qsettings.value("openFiles/currentFile", "").toString())
    # Projects
    projects = qsettings.value("openFiles/projects", []).toList()
    projects = [unicode(project.toString()) for project in projects]
    # Include files received from console args
    file_with_nro = map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos))
    file_without_nro = map(lambda f: (f, 0), filenames[len(linenos) :])
    mainFiles += file_with_nro + file_without_nro
    # Include projects received from console args
    if projects_path:
        projects += projects_path
    mainFiles.reverse()
    secondaryFiles.reverse()
    ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file)
    # Load external plugins
    if extra_plugins:
        ide.load_external_plugins(extra_plugins)

    splash.finish(ide)
    ide.notify_plugin_errors()
    sys.exit(app.exec_())
Exemplo n.º 10
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""

    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(":img/icon"))
    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(":img/splash")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the codec for strings (QString)
    # QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    # FIXME: handle this
    # Translator
    # language = QLocale.system().name()
    # lang = qsettings.value('preferences/interface/language',
    #                       defaultValue=language, type='QString') + '.qm'
    # lang_path = file_manager.create_path(resources.LANGS, lang)
    # if file_manager.file_exists(lang_path):
    #    settings.LANGUAGE = lang_path
    # translator = QTranslator()
    # if settings.LANGUAGE:
    #    translator.load(settings.LANGUAGE)
    #    app.installTranslator(translator)

    #    qtTranslator = QTranslator()
    #    qtTranslator.load(
    #        "qt_" + language,
    #        QLibraryInfo.location(QLibraryInfo.TranslationsPath))
    #    app.installTranslator(qtTranslator)

    # Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    # Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    # Loading Schemes
    splash.showMessage("Loading Schemes...", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    all_schemes = json_manager.load_editor_schemes()
    scheme = qsettings.value("editor/scheme", "")
    # FIXME:
    resources.COLOR_SCHEME = all_schemes['Ninja Dark']
    # if scheme:
    #    color_scheme = all_schemes[scheme]
    #    resources.CUSTOM_SCHEME = color_scheme
    # if scheme != 'default':
    #    scheme = file_manager.create_path(resources.EDITOR_SKINS,
    #                                      scheme + '.color')
    #    if file_manager.file_exists(scheme):
    #        resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    # Loading Shortcuts
    # resources.load_shortcuts()
    # Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    # Style
    app.setStyle(ninja_style.NinjaStyle())

    # Showing GUI
    ninjaide.show()
    # OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except Exception:
        pass  # I really dont mind if this fails in any form
    # Loading Session Files
    splash.showMessage("Loading Files and Projects",
                       Qt.AlignRight | Qt.AlignTop, Qt.black)

    # First check if we need to load last session files
    if qsettings.value('general/loadFiles', True, type=bool):
        files = data_qsettings.value('lastSession/openedFiles')
        projects = data_qsettings.value('lastSession/projects')
        current_file = data_qsettings.value('lastSession/currentFile')
        # FIXME: recent files
        if files is None:
            files = []
        if projects is None:
            projects = []
        # Include files received from console args
        files_with_lineno = [(f[0], (f[1] - 1, 0))
                             for f in zip(filenames, linenos)]
        files_without_lineno = [(f, (0, 0)) for f in filenames[len(linenos):]]
        files += files_with_lineno + files_without_lineno
        # Include projects received from console args
        if projects_path:
            projects += projects_path
        ninjaide.load_session_files_projects(files, projects, current_file, [])
    # Load external plugins
    # if extra_plugins:
    #     ninjaide.load_external_plugins(extra_plugins)
    splash.finish(ninjaide)