Пример #1
0
    def open_file(self, fn):
        filename = filename_type_to_os_filename(fn)
        ws = NSWorkspace.sharedWorkspace()
        # Let's only open files that are of content type - we don't want to
        # automatically launch executables here.
        typ, error = ws.typeOfFile_error_(filename, None)
        if not typ or error:
            logging.warn('Cannot determine UTI of file %s' % fn)
            return

        if ws.type_conformsToType_(typ, 'public.executable'):
            logging.warn('Not opening executable file %s' % fn)
            return

        ok, externalApp, movieType = ws.getInfoForFile_application_type_(
            filename, None, None)
        if ok:
            if externalApp == bundle.getBundlePath():
                logging.warn('trying to play movie externally with ourselves.')
                ok = False
            else:
                ok = ws.openFile_withApplication_andDeactivate_(
                    filename, nil, YES)
        if not ok:
            logging.warn("movie %s could not be externally opened" % fn)
Пример #2
0
 def open_file(self, fn):
     filename = filename_type_to_os_filename(fn)
     ws = NSWorkspace.sharedWorkspace()
     ok, externalApp, movieType = ws.getInfoForFile_application_type_(filename, None, None)
     if ok:
         if externalApp == bundle.getBundlePath():
             logging.warn('trying to play movie externally with ourselves.')
             ok = False
         else:
             ok = ws.openFile_withApplication_andDeactivate_(filename, nil, YES)
     if not ok:
         logging.warn("movie %s could not be externally opened" % fn)
Пример #3
0
 def get_movie_from_file(self, path):
     osfilename = utils.filename_type_to_os_filename(path)
     url = NSURL.fileURLWithPath_(osfilename)
     attributes = NSMutableDictionary.dictionary()
     # XXX bz:15481.  This shouldn't be synchronous.
     no = NSNumber.alloc().initWithBool_(NO)
     attributes['QTMovieURLAttribute'] = url
     attributes['QTMovieOpenAsyncOKAttribute'] = no
     qtmovie, error = QTMovie.movieWithAttributes_error_(attributes, None)
     if qtmovie is None or error is not None:
         return None
     if not self.can_open_file(qtmovie):
         return None
     return qtmovie
Пример #4
0
 def get_movie_from_file(self, path):
     osfilename = utils.filename_type_to_os_filename(path)
     try:
         url = NSURL.URLWithString_(path.urlize())
     except AttributeError:
         url = NSURL.fileURLWithPath_(osfilename)
     attributes = NSMutableDictionary.dictionary()
     no = NSNumber.alloc().initWithBool_(NO)
     yes = NSNumber.alloc().initWithBool_(YES)
     attributes['QTMovieURLAttribute'] = url
     attributes['QTMovieOpenAsyncOKAttribute'] = yes
     # FIXME: Can't use yet qtmovie.tracks() not accessible.
     #attributes['QTMovieOpenForPlaybackAttribute'] = yes
     qtmovie, error = QTMovie.movieWithAttributes_error_(attributes, None)
     if error is not None:
         logging.debug(unicode(error).encode('utf-8'))
     if qtmovie is None or error is not None:
         return None
     return qtmovie
Пример #5
0
 def get_movie_from_file(self, path):
     osfilename = utils.filename_type_to_os_filename(path)
     try:
         url = NSURL.URLWithString_(path.urlize())
     except AttributeError:
         url = NSURL.fileURLWithPath_(osfilename)
     attributes = NSMutableDictionary.dictionary()
     no = NSNumber.alloc().initWithBool_(NO)
     yes = NSNumber.alloc().initWithBool_(YES)
     attributes['QTMovieURLAttribute'] = url
     attributes['QTMovieOpenAsyncOKAttribute'] = yes
     # FIXME: Can't use yet qtmovie.tracks() not accessible.
     #attributes['QTMovieOpenForPlaybackAttribute'] = yes
     qtmovie, error = QTMovie.movieWithAttributes_error_(attributes, None)
     if error is not None:
         logging.debug(unicode(error).encode('utf-8'))
     if qtmovie is None or error is not None:
         return None
     return qtmovie
Пример #6
0
    def open_file(self, fn):
        filename = filename_type_to_os_filename(fn)
        ws = NSWorkspace.sharedWorkspace()
        # Let's only open files that are of content type - we don't want to
        # automatically launch executables here.
        typ, error = ws.typeOfFile_error_(filename, None)
        if not typ or error:
            logging.warn('Cannot determine UTI of file %s' % fn)
            return

        if ws.type_conformsToType_(typ, 'public.executable'):
            logging.warn('Not opening executable file %s' % fn)
            return

        ok, externalApp, movieType = ws.getInfoForFile_application_type_(filename, None, None)
        if ok:
            if externalApp == bundle.getBundlePath():
                logging.warn('trying to play movie externally with ourselves.')
                ok = False
            else:
                ok = ws.openFile_withApplication_andDeactivate_(filename, nil, YES)
        if not ok:
            logging.warn("movie %s could not be externally opened" % fn)
Пример #7
0
 def reveal_file(self, fn):
     filename = filename_type_to_os_filename(fn)
     NSWorkspace.sharedWorkspace().selectFile_inFileViewerRootedAtPath_(filename, nil)
Пример #8
0
 def reveal_file(self, fn):
     filename = filename_type_to_os_filename(fn)
     NSWorkspace.sharedWorkspace().selectFile_inFileViewerRootedAtPath_(filename, nil)