Exemplo n.º 1
0
    def SaveCurrentSession(self):
        """Save the current session"""
        if self._ses_load:
            return

        session = Profile_Get('LAST_SESSION')
        # Compatibility with older session data
        if not isinstance(session, basestring) or not len(session):
            mgr = ed_session.EdSessionMgr()
            session = mgr.DefaultSession
            Profile_Set('LAST_SESSION', session)
        self.SaveSessionFile(session)
Exemplo n.º 2
0
    def SaveSessionFile(self, session):
        """Save the current open files to the given session file
        @param session: path to session file
        @return: tuple (error desc, error msg) or None

        """
        if self._ses_load:
            return

        try:
            mgr = ed_session.EdSessionMgr()
            flist = self.GetFileNames()
            bSaved = mgr.SaveSession(session, flist)
        except Exception, msg:
            self.LOG("[ed_pages][err] SaveSession error %s" % msg)
Exemplo n.º 3
0
    def LoadSessionFile(self, session):
        """Load files from saved session data in profile
        @param session: session filename
        @return: tuple (error desc, error msg), or None if no error

        """
        self._ses_load = True

        mgr = ed_session.EdSessionMgr()
        flist = list()
        try:
            flist = mgr.LoadSession(session)
        except Exception, msg:
            self._ses_load = False
            return (_("Session Load Error"),
                    _("Failed to load the session: %s\n\nError: %s") %
                    (session, msg))
Exemplo n.º 4
0
 def AddPage(self, page, text=u'', select=True, imgId=-1):
     """Add a page to the notebook"""
     bNewPage = False
     if not len(text):
         self.pg_num += 1
         if self.pg_num != 0:
             text = _("untitled %d") % self.pg_num
         else:
             text = _("untitled")
         bNewPage = True
     page.SetTabLabel(text)
     bmp = wx.NullBitmap
     if Profile_Get('TABICONS'):
         bmp = page.GetTabImage()
     super(EdPages, self).AddPage(page, text, select, bitmap=bmp)
     self.UpdateIndexes()
     if not self._ses_load and not bNewPage:
         # Only auto save session when using default session
         mgr = ed_session.EdSessionMgr()
         if Profile_Get('LAST_SESSION') == mgr.DefaultSession:
             self.SaveCurrentSession()