Ticket #40139: patch-frescobaldi_app-main.py.diff

File patch-frescobaldi_app-main.py.diff, 2.0 KB (added by dliessi (Davide Liessi), 11 years ago)
  • frescobaldi_app/main.py

    old new  
    143143    import autocomplete     # auto-complete input
    144144    import wordboundary     # better wordboundary behaviour for the editor
    145145   
     146    # on Mac OS X, handle FileOpen requests (e.g. double-clicking a file in the
     147    # Finder), these events also can occur right on application start.
     148    # We do this just before creating the window, so that when multiple files
     149    # are opened on startup (I don't know whether that really could happen),
     150    # they are not made the current document, as that slows down loading
     151    # multiple documents drastically.
     152    if sys.platform.startswith('darwin'):
     153        import file_open_eventhandler
     154   
    146155    if app.qApp.isSessionRestored():
    147156        # Restore session, we are started by the session manager
    148157        session.restoreSession()
    149158        return
    150159
    151     # load specified session
     160    # load specified session?
    152161    doc = None
    153162    if options.session and options.session != "-":
    154163        doc = sessions.loadSession(options.session)
    155        
     164   
    156165    # Just create one MainWindow
    157166    win = mainwindow.MainWindow()
    158167    win.show()
    159168   
    160     if urls:
    161         for u in urls:
    162             doc = win.openUrl(u, options.encoding)
    163     elif not options.session:
    164         # no docs, load default session
    165         doc = sessions.loadDefaultSession()
     169    # load documents given as arguments
     170    for u in urls:
     171        doc = win.openUrl(u, options.encoding)
     172   
     173    # were documents loaded?
     174    if not doc:
     175        if app.documents:
     176            doc = app.documents[-1]
     177        elif not options.session:
     178            # no docs, load default session
     179            doc = sessions.loadDefaultSession()
     180   
    166181    win.setCurrentDocument(doc or document.Document())
     182   
    167183    if urls and options.line is not None:
    168184        # set the last loaded document active and apply navigation if requested
    169185        pos = doc.findBlockByNumber(options.line - 1).position() + options.column