Exemplo n.º 1
0
    def __init__(self, *args, **kargs):
        """Initialize that main app and its attributes
        @postcondition: application is created and ready to be run in mainloop

        """
        wx.App.__init__(self, *args, **kargs)
        events.AppEventHandlerMixin.__init__(self)

        # Attributes
        self._log = dev_tool.DEBUGP
        self._lock = False
        self._windows = dict()

        # Setup Locale
        locale.setlocale(locale.LC_ALL, '')
        self.locale = wx.Locale(ed_i18n.GetLangId(
            profiler.Profile_Get('LANG')))
        if self.locale.GetCanonicalName() in ed_i18n.GetAvailLocales():
            self.locale.AddCatalogLookupPathPrefix(ed_glob.CONFIG['LANG_DIR'])
            self.locale.AddCatalog(ed_glob.PROG_NAME)
        else:
            del self.locale
            self.locale = None

        # Setup Plugins after locale as they may have resource that need to
        # be loaded.
        self._pluginmgr = plugin.PluginManager()

        self._log("[app][info] Registering Editra's ArtProvider")
        wx.ArtProvider.PushProvider(ed_art.EditraArt())
Exemplo n.º 2
0
def init_locale():
    """
    Initialize the Language Settings.
    """
    the_locale = wx.Locale(ed_i18n.GetLangId(Profile_Get('LANG')))
    if the_locale.GetCanonicalName() in ed_i18n.GetAvailLocales():
        lc = ed_glob.CONFIG['LANG_DIR'] + 'defis\\'
        wx.GetApp().GetLog()('----- init_locale ----- %s' % lc)
        gettext.bindtextdomain('defis', lc)
        gettext.textdomain('defis')
Exemplo n.º 3
0
    def OnInit(self):
        """Initialize the Editor
        @note: this gets called before __init__
        @postcondition: custom artprovider and plugins are loaded

        """
        self._log = dev_tool.DEBUGP
        self._log("[app][info] Editra is Initializing")

        self._isfirst = False  # Is the first instance
        self._instance = None

        # Setup Locale
        locale.setlocale(locale.LC_ALL, '')
        self.locale = wx.Locale(ed_i18n.GetLangId(
            profiler.Profile_Get('LANG')))
        if self.locale.GetCanonicalName() in ed_i18n.GetAvailLocales():
            self.locale.AddCatalogLookupPathPrefix(ed_glob.CONFIG['LANG_DIR'])
            self.locale.AddCatalog(ed_glob.PROG_NAME)
        else:
            del self.locale
            self.locale = None

        # Check and set encoding if necessary
        if not profiler.Profile_Get('ENCODING'):
            profiler.Profile_Set('ENCODING', locale.getpreferredencoding())

        # Setup the Error Reporter
        if profiler.Profile_Get('REPORTER', 'bool', True):
            sys.excepthook = dev_tool.ExceptionHook

        #---- Bind Events ----#
        self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate)
        self.Bind(wx.EVT_MENU, self.OnNewWindow, id=ed_glob.ID_NEW_WINDOW)
        self.Bind(wx.EVT_MENU, self.OnCloseWindow)
        self.Bind(ed_event.EVT_NOTIFY, self.OnNotify)
        self.Bind(ed_ipc.EVT_COMMAND_RECV, self.OnCommandRecieved)

        return True
Exemplo n.º 4
0
                key = unicode(base64.b64encode(os.urandom(8), 'zZ'))
                key = wx.GetUserName() + key
                profiler.Profile_Set('SESSION_KEY', key)
                profiler.Profile_Set('ISBINARY', hasattr(sys, 'frozen'))
                path = profiler.Profile_Get('MYPROFILE')
                profiler.Profile().Write(path)
                self._server = ed_ipc.EdIpcServer(
                    self, profiler.Profile_Get('SESSION_KEY'))
                self._server.start()
                self._isfirst = True
        else:
            self._isfirst = True

        # Setup Locale
        locale.setlocale(locale.LC_ALL, '')
        self.locale = wx.Locale(ed_i18n.GetLangId(
            profiler.Profile_Get('LANG')))
        if self.locale.GetCanonicalName() in ed_i18n.GetAvailLocales():
            self.locale.AddCatalogLookupPathPrefix(ed_glob.CONFIG['LANG_DIR'])
            self.locale.AddCatalog(ed_glob.PROG_NAME)
        else:
            del self.locale
            self.locale = None

        # Setup the Error Reporter
        if profiler.Profile_Get('REPORTER', 'bool', True):
            sys.excepthook = dev_tool.ExceptionHook

        #---- Bind Events ----#
        self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate)
        self.Bind(wx.EVT_MENU, self.OnNewWindow, id=ed_glob.ID_NEW_WINDOW)
        self.Bind(wx.EVT_MENU, self.OnCloseWindow)
Exemplo n.º 5
0
            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()

    # 1. Create Application
    dev_tool.DEBUGP("[main_info] Initializing Application...")
    if Profile_Get('MODE') == u"GUI_DEBUG":
        editra_app = Editra(True)
    else:
        editra_app = Editra(False)

    # 2. Initialize the Language Settings
    langid = ed_i18n.GetLangId(Profile_Get('LANG'))
    the_locale = wx.Locale(langid)
    the_locale.AddCatalogLookupPathPrefix(ed_glob.CONFIG['LANG_DIR'])
    the_locale.AddCatalog(ed_glob.PROG_NAME)
    language = gettext.translation(ed_glob.PROG_NAME,
                                   ed_glob.CONFIG['LANG_DIR'],
                                   [the_locale.GetCanonicalName()],
                                   fallback=True)
    language.install()

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