def OpenNewWindow(self, fname=u'', caller=None): """Open a new window @keyword fname: Open a file in the new window """ frame = ed_main.MainWindow(None, wx.ID_ANY, Profile_Get('WSIZE'), ed_glob.PROG_NAME) if caller: pos = caller.GetPosition() frame.SetPosition((pos.x + 22, pos.y + 22)) self.RegisterWindow(repr(frame), frame, True) self.SetTopWindow(frame) if isinstance(fname, basestring) and fname != u'': frame.DoOpen(ed_glob.ID_COMMAND_LINE_OPEN, fname) frame.Show(True) # Ensure frame gets an Activate event when shown # this doesn't happen automatically on windows wx.PostEvent(frame, wx.ActivateEvent(wx.wxEVT_ACTIVATE, True))
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)
"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'): 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))
Profile_Del('WPOS') wx.MessageBox(_("Your profile has been updated to the latest " "version") + u"\n" + \ _("Please check the preferences dialog to reset " "you preferences"), _("Profile Updated")) # Splash a warning if version is not a final version if Profile_Get('APPSPLASH') and int(ed_glob.VERSION[0]) < 1: import edimage splash_img = edimage.getsplashwarnBitmap() splash = wx.SplashScreen(splash_img, wx.SPLASH_CENTRE_ON_PARENT | \ wx.SPLASH_NO_TIMEOUT, 0, None, wx.ID_ANY) splash.Show() frame = ed_main.MainWindow(None, wx.ID_ANY, Profile_Get('WSIZE'), ed_glob.PROG_NAME) editra_app.RegisterWindow(repr(frame), frame, True) editra_app.SetTopWindow(frame) # Load Session Data # But not if there are command line args for files to open if Profile_Get('SAVE_SESSION', 'bool', False) and not len(args): frame.nb.LoadSessionFiles() frame.Show(True) wx.PostEvent(frame, wx.ActivateEvent(wx.wxEVT_ACTIVATE, True)) if 'splash' in locals(): splash.Destroy() for arg in args: