Example #1
0
    def InstallComponents(self, mainw):
        """Install extra menu components
        param mainw: MainWindow Instance

        """
        # Delete obsolete configuration from older versions
        profiler.Profile_Del('Mpy.Prefs')  # New config is Mpy.Config2
Example #2
0
    def InstallComponents(self, mainw):
        """Install extra menu components
        param mainw: MainWindow Instance

        """
        # Delete obsolete configuration from older versions
        profiler.Profile_Del('Launch.Prefs')  # New config is Launch.Config2
        tmenu = mainw.GetMenuBar().GetMenuByName("tools")
        tmenu.Insert(0, ed_glob.ID_RUN_LAUNCH, _("Run") + \
                     EdMenuBar.keybinder.GetBinding(ed_glob.ID_RUN_LAUNCH),
                     _("Run the file associated with the current buffer in Launch"))
        mainw.AddMenuHandler(ed_glob.ID_RUN_LAUNCH, OnRequestHandler)
        mainw.AddUIHandler(ed_glob.ID_RUN_LAUNCH, OnUpdateMenu)
        tmenu.Insert(1, ed_glob.ID_LAUNCH_LAST, _("Run last executed") + \
                     EdMenuBar.keybinder.GetBinding(ed_glob.ID_LAUNCH_LAST),
                     _("Re-run the last run program"))
        mainw.AddMenuHandler(ed_glob.ID_LAUNCH_LAST, OnLaunchLast)
        mainw.AddUIHandler(ed_glob.ID_LAUNCH_LAST, OnUpdateMenu)
        tmenu.Insert(2, wx.ID_SEPARATOR)
Example #3
0
def Main():
    """Configures and Runs an instance of Editra
    @summary: Parses command line options, loads the user profile, creates
              an instance of Editra and starts the main loop.

    """
    opts, args = ProcessCommandLine()

    # We are ready to run so fire up the config and launch the app
    profile_updated = InitConfig()

    # Put extern subpackage on path so that bundled external dependancies
    # can be found if needed.
    if not hasattr(sys, 'frozen'):
        epath = os.path.join(os.path.dirname(__file__), 'extern')
        if os.path.exists(epath):
            sys.path.append(epath)

    # Create Application
    dev_tool.DEBUGP("[main][app] Initializing application...")
    editra_app = Editra(False)

    # Print ipc server authentication info
    if '--auth' in opts:
        opts.remove('--auth')
        print "port=%d,key=%s" % (ed_ipc.EDPORT,
                                  profiler.Profile_Get('SESSION_KEY'))

    # Check if this is the only instance, if its not exit since
    # any of the opening commands have already been passed to the
    # master instance
    if not editra_app.IsOnlyInstance():
        dev_tool.DEBUGP("[main][info] Second instance exiting...")
        editra_app.Destroy()
        os._exit(0)

    if profile_updated:
        # Make sure window iniliazes to default position
        profiler.Profile_Del('WPOS')
        wx.MessageBox(_("Your profile has been updated to the latest "
                        "version") + u"\n" + \
                      _("Please check the preferences dialog to check "
                        "your preferences"),
                      _("Profile Updated"))

    # Splash a warning if version is not a final version
    if profiler.Profile_Get('APPSPLASH'):
        import edimage
        splash_img = edimage.splashwarn.GetBitmap()
        splash = wx.SplashScreen(splash_img, wx.SPLASH_CENTRE_ON_PARENT | \
                                 wx.SPLASH_NO_TIMEOUT, 0, None, wx.ID_ANY)
        splash.Show()

    if profiler.Profile_Get('SET_WSIZE'):
        wsize = profiler.Profile_Get('WSIZE')
    else:
        wsize = (700, 450)
    frame = ed_main.MainWindow(None, wx.ID_ANY, wsize, ed_glob.PROG_NAME)
    frame.Maximize(profiler.Profile_Get('MAXIMIZED'))
    editra_app.RegisterWindow(repr(frame), frame, True)
    editra_app.SetTopWindow(frame)
    frame.Show(True)

    # Load Session Data
    # But not if there are command line args for files to open
    if profiler.Profile_Get('SAVE_SESSION', 'bool', False) and not len(args):
        frame.GetNotebook().LoadSessionFiles()

    # Unlike wxMac/wxGTK Windows doesn't post an activate event when a window
    # is first shown, so do it manually to make sure all event handlers get
    # pushed.
    if wx.Platform == '__WXMSW__':
        wx.PostEvent(frame, wx.ActivateEvent(wx.wxEVT_ACTIVATE, True))

    if 'splash' in locals():
        splash.Destroy()

    # Do update check, only check if its been more than a day since the last
    # check
    if profiler.Profile_Get('CHECKUPDATE', default=True):
        uthread = updater.UpdateThread(editra_app, ID_UPDATE_CHECK)
        uthread.start()

    for arg in args:
        try:
            arg = os.path.abspath(arg)
            fname = ed_txt.DecodeString(arg, sys.getfilesystemencoding())
            frame.DoOpen(ed_glob.ID_COMMAND_LINE_OPEN, fname)
        except IndexError:
            dev_tool.DEBUGP("[main][err] IndexError on commandline args")

    # 3. Start Applications Main Loop
    dev_tool.DEBUGP("[main][info] Starting MainLoop...")
    editra_app.MainLoop()
    dev_tool.DEBUGP("[main][info] MainLoop finished exiting application")
    os._exit(0)
Example #4
0
def InitConfig():
    """Initializes the configuration data
    @postcondition: all configuration data is set

    """
    ed_glob.CONFIG['PROFILE_DIR'] = util.ResolvConfigDir("profiles")
    profile_updated = False
    if util.HasConfigDir():
        if profiler.ProfileIsCurrent():
            profiler.Profile().Load(profiler.GetProfileStr())
        else:
            dev_tool.DEBUGP(
                "[InitConfig][info] Updating Profile to current version")

            # Load and update profile
            pstr = profiler.GetProfileStr()
            profiler.Profile().Load(pstr)
            profiler.Profile().Update()

            #---- Temporary Profile Adaptions ----#

            # GUI_DEBUG mode removed in 0.2.5
            mode = profiler.Profile_Get('MODE')
            if mode == 'GUI_DEBUG':
                profiler.Profile_Set('MODE', 'DEBUG')

            profiler.Profile_Del('LASTCHECK')
            #---- End Temporary Profile Adaptions ----#

            # Write out updated profile
            profiler.Profile().Write(pstr)

            # When upgrading from an older version make sure all
            # config directories are available.
            for cfg in ["cache", "styles", "plugins", "profiles"]:
                if not util.HasConfigDir(cfg):
                    util.MakeConfigDir(cfg)

            profile_updated = True
    else:
        # Fresh install
        util.CreateConfigDir()

        # Set default eol for windows
        if wx.Platform == '__WXMSW__':
            profiler.Profile_Set('EOL', 'Windows (\\r\\n)')

    # Set debug mode
    if 'DEBUG' in profiler.Profile_Get('MODE'):
        ed_glob.DEBUG = True

    # Resolve resource locations
    ed_glob.CONFIG['CONFIG_DIR'] = util.ResolvConfigDir("")
    ed_glob.CONFIG['SYSPIX_DIR'] = util.ResolvConfigDir("pixmaps", True)
    ed_glob.CONFIG['PLUGIN_DIR'] = util.ResolvConfigDir("plugins")
    ed_glob.CONFIG['THEME_DIR'] = util.ResolvConfigDir(
        os.path.join("pixmaps", "theme"))
    ed_glob.CONFIG['LANG_DIR'] = util.ResolvConfigDir("locale", True)
    ed_glob.CONFIG['STYLES_DIR'] = util.ResolvConfigDir("styles")
    ed_glob.CONFIG['SYS_PLUGIN_DIR'] = util.ResolvConfigDir("plugins", True)
    ed_glob.CONFIG['SYS_STYLES_DIR'] = util.ResolvConfigDir("styles", True)
    ed_glob.CONFIG['TEST_DIR'] = util.ResolvConfigDir(
        os.path.join("tests", "syntax"), True)
    if not util.HasConfigDir("cache"):
        util.MakeConfigDir("cache")
    ed_glob.CONFIG['CACHE_DIR'] = util.ResolvConfigDir("cache")

    return profile_updated
Example #5
0
                                                    ed_glob.VERSION)
            os._exit(0)

        if True in [x[0] in ['-d', '--debug'] for x in opts]:
            ed_glob.DEBUG = True

    # We are ready to run so fire up the config and launch the app
    profile_updated = InitConfig()

    # Create Application
    dev_tool.DEBUGP("[main][info] Initializing Application...")
    editra_app = Editra(False)

    if profile_updated:
        # Make sure window iniliazes to default position
        profiler.Profile_Del('WPOS')
        wx.MessageBox(_("Your profile has been updated to the latest "
                        "version") + u"\n" + \
                      _("Please check the preferences dialog to reset "
                        "your preferences"),
                      _("Profile Updated"))

    # Splash a warning if version is not a final version
    if profiler.Profile_Get('APPSPLASH') and int(ed_glob.VERSION[0]) < 1:
        import edimage
        splash_img = edimage.splashwarn.GetBitmap()
        splash = wx.SplashScreen(splash_img, wx.SPLASH_CENTRE_ON_PARENT | \
                                 wx.SPLASH_NO_TIMEOUT, 0, None, wx.ID_ANY)
        splash.Show()

    if profiler.Profile_Get('SET_WSIZE'):
Example #6
0
def InitConfig():
    """Initializes the configuration data
    @postcondition: all configuration data is set

    """
    # Look for a profile directory on the system level. If this directory exists
    # Use it instead of the user one. This will allow for running Editra from
    # a portable drive or for system administrators to enforce settings on a
    # system installed version.
    config_base = util.ResolvConfigDir(u'.Editra', True)
    if os.path.exists(config_base):
        ed_glob.CONFIG['CONFIG_BASE'] = config_base
        ed_glob.CONFIG['PROFILE_DIR'] = os.path.join(config_base, u"profiles")
        ed_glob.CONFIG['PROFILE_DIR'] += os.sep
    else:
        ed_glob.CONFIG['PROFILE_DIR'] = util.ResolvConfigDir("profiles")

    # Check for if config directory exists and if profile is from the current
    # running version of Editra.
    profile_updated = False
    if util.HasConfigDir() and os.path.exists(ed_glob.CONFIG['PROFILE_DIR']):
        if profiler.ProfileIsCurrent():
            profiler.Profile().Load(profiler.GetProfileStr())
        else:
            dev_tool.DEBUGP(
                "[InitConfig][info] Updating Profile to current version")

            # Load and update profile
            pstr = profiler.GetProfileStr()
            profiler.Profile().Load(pstr)
            profiler.Profile().Update()

            #---- Temporary Profile Adaptions ----#

            # GUI_DEBUG mode removed in 0.2.5
            mode = profiler.Profile_Get('MODE')
            if mode == 'GUI_DEBUG':
                profiler.Profile_Set('MODE', 'DEBUG')

            # This key has been removed so clean it from old profiles
            profiler.Profile_Del('LASTCHECK')

            # Print modes don't use strings anymore
            if isinstance(profiler.Profile_Get('PRINT_MODE'), basestring):
                profiler.Profile_Set('PRINT_MODE', ed_glob.PRINT_BLACK_WHITE)
            #---- End Temporary Profile Adaptions ----#

            # Write out updated profile
            profiler.Profile().Write(pstr)

            # When upgrading from an older version make sure all
            # config directories are available.
            for cfg in ["cache", "styles", "plugins", "profiles"]:
                if not util.HasConfigDir(cfg):
                    util.MakeConfigDir(cfg)

            profile_updated = True
    else:
        # Fresh install
        util.CreateConfigDir()

        # Set default eol for windows
        if wx.Platform == '__WXMSW__':
            profiler.Profile_Set('EOL', 'Windows (\\r\\n)')

    # Set debug mode
    if 'DEBUG' in profiler.Profile_Get('MODE'):
        ed_glob.DEBUG = True

    # Resolve resource locations
    ed_glob.CONFIG['CONFIG_DIR'] = util.ResolvConfigDir("")
    ed_glob.CONFIG['SYSPIX_DIR'] = util.ResolvConfigDir("pixmaps", True)
    ed_glob.CONFIG['PLUGIN_DIR'] = util.ResolvConfigDir("plugins")
    ed_glob.CONFIG['THEME_DIR'] = util.ResolvConfigDir(
        os.path.join("pixmaps", "theme"))
    ed_glob.CONFIG['LANG_DIR'] = util.ResolvConfigDir("locale", True)
    ed_glob.CONFIG['STYLES_DIR'] = util.ResolvConfigDir("styles")
    ed_glob.CONFIG['SYS_PLUGIN_DIR'] = util.ResolvConfigDir("plugins", True)
    ed_glob.CONFIG['SYS_STYLES_DIR'] = util.ResolvConfigDir("styles", True)
    ed_glob.CONFIG['TEST_DIR'] = util.ResolvConfigDir(
        os.path.join("tests", "syntax"), True)
    if not util.HasConfigDir("cache"):
        util.MakeConfigDir("cache")
    ed_glob.CONFIG['CACHE_DIR'] = util.ResolvConfigDir("cache")

    return profile_updated
Example #7
0
def InitConfig():
    """Initializes the configuration data
    @postcondition: all configuration data is set

    """
    # Look for a profile directory on the system level. If this directory exists
    # Use it instead of the user one. This will allow for running Editra from
    # a portable drive or for system administrators to enforce settings on a
    # system installed version.
    config_base = util.ResolvConfigDir(u'.Editra', True)
    if os.path.exists(config_base):
        ed_glob.CONFIG['CONFIG_BASE'] = config_base
        ed_glob.CONFIG['PROFILE_DIR'] = os.path.join(config_base, u"profiles")
        ed_glob.CONFIG['PROFILE_DIR'] += os.sep
    else:
        config_base = wx.StandardPaths.Get().GetUserDataDir()
        ed_glob.CONFIG['PROFILE_DIR'] = util.ResolvConfigDir("profiles")

    # Check for if config directory exists and if profile is from the current
    # running version of Editra.
    profile_updated = False
    if util.HasConfigDir() and os.path.exists(ed_glob.CONFIG['PROFILE_DIR']):
        if profiler.ProfileIsCurrent():
            profiler.Profile().Load(profiler.GetProfileStr())
        else:
            dev_tool.DEBUGP(
                "[InitConfig][info] Updating Profile to current version")

            # Load and update profile
            pstr = profiler.GetProfileStr()
            profiler.Profile().Load(pstr)
            profiler.Profile().Update()

            #---- Temporary Profile Adaptions ----#

            # GUI_DEBUG mode removed in 0.2.5
            mode = profiler.Profile_Get('MODE')
            if mode == 'GUI_DEBUG':
                profiler.Profile_Set('MODE', 'DEBUG')

            # This key has been removed so clean it from old profiles
            profiler.Profile_Del('LASTCHECK')

            # Print modes don't use strings anymore
            if isinstance(profiler.Profile_Get('PRINT_MODE'), basestring):
                profiler.Profile_Set('PRINT_MODE', ed_glob.PRINT_BLACK_WHITE)

            # Simplifications to eol mode persistance (0.4.0)
            TranslateEOLMode()

            #---- End Temporary Profile Adaptions ----#

            # Write out updated profile
            profiler.Profile().Write(pstr)

            # When upgrading from an older version make sure all
            # config directories are available.
            for cfg in ["cache", "styles", "plugins", "profiles"]:
                if not util.HasConfigDir(cfg):
                    util.MakeConfigDir(cfg)

            profile_updated = True
    else:
        # Fresh install
        util.CreateConfigDir()

        # Check and upgrade installs from old location
        success = True
        try:
            success = UpgradeOldInstall()
        except Exception, msg:
            dev_tool.DEBUGP("[InitConfig][err] %s" % msg)
            success = False

        if not success:
            old_cdir = u"%s%s.%s%s" % (wx.GetHomeDir(), os.sep,
                                       ed_glob.PROG_NAME, os.sep)
            msg = (
                "Failed to upgrade your old installation\n"
                "To retain your old settings you may need to copy some files:\n"
                "\nFrom: %s\n\nTo: %s") % (old_cdir, config_base)
            wx.MessageBox(msg, "Upgrade Failed", style=wx.ICON_WARNING | wx.OK)

        # Set default eol for windows
        if wx.Platform == '__WXMSW__':
            profiler.Profile_Set('EOL', 'CRLF')
            profiler.Profile_Set('ICONSZ', (16, 16))