예제 #1
0
from ctypes import *

import pyglet.lib
from pyglet.window.carbon import _create_cfstring, carbon, _oscheck
from pyglet.window.carbon.constants import *
from pyglet.window.carbon.types import *

carbon = pyglet.lib.load_library(
    framework='/System/Library/Frameworks/Carbon.framework')

PasteboardRef = c_void_p
PasteboardItemID = c_void_p
CFArrayRef = c_void_p
CFDataRef = c_void_p
ItemCount = c_int32
kPasteboardClipboard = _create_cfstring("com.apple.pasteboard.clipboard")
kPasteboardModified = 1 << 0
kPasteboardClientIsOwner = 1 << 1
utf16_plain_text = _create_cfstring("public.utf16-plain-text")
traditional_mac_plain_text = _create_cfstring(
    "com.apple.traditional-mac-plain-text")

carbon.CFDataGetBytePtr.restype = POINTER(c_char)


class CarbonPasteboard(object):
    def __init__(self):
        self.pasteboard = PasteboardRef()
        carbon.PasteboardCreate(kPasteboardClipboard, byref(self.pasteboard))

    def get_text(self):
예제 #2
0
    def _create_movie(self):
        if self.file is not None:
            raise NotImplementedError('TODO: file object loading')

        filename = _create_cfstring(self.filename)

        movie = Movie()

        if corevideo is None or True: 
            # corevideo: set visualcontext to nil, then to the texture
            # context -- avoids having to use FromProperties.
            fileid = ctypes.c_short(0)
            data_ref = ctypes.c_void_p()
            data_ref_type = ctypes.c_ulong()
            result = quicktime.QTNewDataReferenceFromFullPathCFString(filename,
                -1, 0, ctypes.byref(data_ref), ctypes.byref(data_ref_type))
            _oscheck(result) 
            result = quicktime.NewMovieFromDataRef(
                ctypes.byref(movie),
                newMovieActive,
                ctypes.byref(fileid),
                data_ref, data_ref_type)
            if result == -2048:
                return None
            _oscheck(result)
        else:
            # use newer QT7 API
            true = Boolean(1)

            filePathRef = CFStringRef()
            filePathRef.value = filename

            # XXX this really wants the context passed to it - and there's
            # really not reason not to AFAICT. We pass a NULL context so that
            # it's not set up using the default GWorld.
            no_context = c_void_p(0)

            properties = (QTNewMoviePropertyElement * 5)(
                (kQTPropertyClass_DataLocation,
                kQTDataLocationPropertyID_CFStringPosixPath,
                ctypes.sizeof(filePathRef), 
                ctypes.cast(ctypes.pointer(filePathRef), ctypes.c_void_p), 0),
                (kQTPropertyClass_Context,
                kQTContextPropertyID_VisualContext,
                ctypes.sizeof(c_void_p), 
                ctypes.cast(ctypes.pointer(no_context), ctypes.c_void_p), 0),
                (kQTPropertyClass_NewMovieProperty,
                kQTNewMoviePropertyID_Active,
                ctypes.sizeof(Boolean),
                ctypes.cast(ctypes.pointer(true), ctypes.c_void_p), 0),
                (kQTPropertyClass_NewMovieProperty,
                kQTNewMoviePropertyID_DontInteractWithUser,
                ctypes.sizeof(Boolean),
                ctypes.cast(ctypes.pointer(true), ctypes.c_void_p), 0),
                (kQTPropertyClass_MovieInstantiation,
                kQTMovieInstantiationPropertyID_DontAskUnresolvedDataRefs,
                ctypes.sizeof(Boolean),
                ctypes.cast(ctypes.pointer(true), ctypes.c_void_p), 0),
            )
            quicktime.NewMovieFromProperties(len(properties), properties,
                0, None, ctypes.byref(movie))

        carbon.CFRelease(filename)

        return movie
예제 #3
0
__docformat__ = 'restructuredtext'
__version__ = '$Id: $'

import ctypes
import sys
import time

from pyglet.window.carbon import _create_cfstring, _oscheck
from pyglet.window.carbon import carbon
from pyglet.window.carbon import quicktime

quicktime.EnterMovies()

filename = sys.argv[1]
filename = _create_cfstring(filename)
data_ref = ctypes.c_void_p()
data_ref_type = ctypes.c_ulong()
result = quicktime.QTNewDataReferenceFromFullPathCFString(filename,
    -1, 0, ctypes.byref(data_ref), ctypes.byref(data_ref_type))
_oscheck(result)

sound = ctypes.c_void_p()
fileid = ctypes.c_short(0)
quicktime.NewMovieFromDataRef.argtypes = (
    ctypes.POINTER(ctypes.c_void_p),
    ctypes.c_short,
    ctypes.POINTER(ctypes.c_short),
    ctypes.c_void_p,
    ctypes.c_ulong)
    
예제 #4
0
파일: carbon.py 프로젝트: rougier/pyglet
import sys
from ctypes import *

import pyglet.lib
from pyglet.window.carbon import _create_cfstring, carbon, _oscheck
from pyglet.window.carbon.constants import *
from pyglet.window.carbon.types import *

carbon = pyglet.lib.load_library(framework="/System/Library/Frameworks/Carbon.framework")

PasteboardRef = c_void_p
PasteboardItemID = c_void_p
CFArrayRef = c_void_p
CFDataRef = c_void_p
ItemCount = c_int32
kPasteboardClipboard = _create_cfstring("com.apple.pasteboard.clipboard")
kPasteboardModified = 1 << 0
kPasteboardClientIsOwner = 1 << 1
utf16_plain_text = _create_cfstring("public.utf16-plain-text")
traditional_mac_plain_text = _create_cfstring("com.apple.traditional-mac-plain-text")

carbon.CFDataGetBytePtr.restype = POINTER(c_char)


class CarbonPasteboard:
    def __init__(self):
        self.pasteboard = PasteboardRef()
        carbon.PasteboardCreate(kPasteboardClipboard, byref(self.pasteboard))

    def get_text(self):
        # get pasteboard item count
예제 #5
0
__docformat__ = 'restructuredtext'
__version__ = '$Id: $'

import ctypes
import sys
import time

from pyglet.window.carbon import _create_cfstring, _oscheck
from pyglet.window.carbon import carbon
from pyglet.window.carbon import quicktime

quicktime.EnterMovies()

filename = sys.argv[1]
filename = _create_cfstring(filename)
data_ref = ctypes.c_void_p()
data_ref_type = ctypes.c_ulong()
result = quicktime.QTNewDataReferenceFromFullPathCFString(
    filename, -1, 0, ctypes.byref(data_ref), ctypes.byref(data_ref_type))
_oscheck(result)

sound = ctypes.c_void_p()
fileid = ctypes.c_short(0)
quicktime.NewMovieFromDataRef.argtypes = (ctypes.POINTER(ctypes.c_void_p),
                                          ctypes.c_short,
                                          ctypes.POINTER(ctypes.c_short),
                                          ctypes.c_void_p, ctypes.c_ulong)

newMovieActive = 1