mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
python: Fix GES.Timelineset_child_property
Implementing it in the overrides as PyGObject won't be able to properly convert python values to GValues in some cases. Using g_object_set_property works as some logic is implemented inside PyGObject for that particular case. This is a "regression" due to https://bugzilla.gnome.org/review?bug=769789&attachment=348766 were we end up with an OverflowError while setting G_TYPE_UINT children properties.
This commit is contained in:
parent
2a190557cf
commit
db827dbd00
8 changed files with 112 additions and 7 deletions
|
@ -28,6 +28,7 @@ import sys
|
|||
from ..overrides import override
|
||||
from ..importer import modules
|
||||
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
_basestring = str
|
||||
_callable = lambda c: hasattr(c, '__call__')
|
||||
|
@ -50,6 +51,30 @@ python module to use with GES 0.10"
|
|||
warnings.warn(warn_msg, RuntimeWarning)
|
||||
|
||||
|
||||
class TrackElement(GES.TrackElement):
|
||||
def set_child_property(self, prop_name, prop_value):
|
||||
return TimelineElement.set_child_property(self, prop_name, prop_value)
|
||||
|
||||
|
||||
TrackElement = override(TrackElement)
|
||||
__all__.append('TrackElement')
|
||||
|
||||
|
||||
class TimelineElement(GES.TimelineElement):
|
||||
def set_child_property(self, prop_name, prop_value):
|
||||
res, child, unused_pspec = self.lookup_child(prop_name)
|
||||
if not res:
|
||||
print("No found any child")
|
||||
return res
|
||||
|
||||
child.set_property(prop_name, prop_value)
|
||||
return res
|
||||
|
||||
|
||||
TimelineElement = override(TimelineElement)
|
||||
__all__.append('TimelineElement')
|
||||
|
||||
|
||||
try:
|
||||
from gi.repository import Gst
|
||||
Gst
|
||||
|
|
1
bindings/python/meson.build
Normal file
1
bindings/python/meson.build
Normal file
|
@ -0,0 +1 @@
|
|||
install_data(['gi/overrides/GES.py'], install_dir: pygi_override_dir)
|
45
meson.build
45
meson.build
|
@ -160,6 +160,50 @@ subdir('pkgconfig')
|
|||
subdir('tests')
|
||||
subdir('examples')
|
||||
|
||||
override_detector = '''
|
||||
import sys
|
||||
import os
|
||||
|
||||
prefix = sys.argv[1]
|
||||
version = sys.version_info
|
||||
|
||||
# If we are installing in the same prefix as PyGobject
|
||||
# make sure to install in the right place.
|
||||
import gi.overrides
|
||||
|
||||
overrides_path = os.path.dirname(gi.overrides.__file__)
|
||||
if os.path.commonprefix([overrides_path, prefix]) == prefix:
|
||||
print(overrides_path)
|
||||
exit(0)
|
||||
|
||||
# Otherwise follow python's way of install site packages inside
|
||||
# the provided prefix
|
||||
if os.name == 'posix':
|
||||
print(os.path.join(
|
||||
prefix, 'lib', 'python%d.%d' % (version.major, version.minor),
|
||||
'site-packages', 'gi', 'overrides'))
|
||||
else:
|
||||
print(os.path.join(
|
||||
prefix, 'Lib', 'Python%d%d' % (version.major, version.minor),
|
||||
'site-packages', 'gi', 'overrides'))
|
||||
'''
|
||||
python3 = import('python3').find_python()
|
||||
pygi_override_dir = get_option('pygi-overrides-dir')
|
||||
if pygi_override_dir == ''
|
||||
cres = run_command(python3, '-c', override_detector, get_option('prefix'))
|
||||
if cres.returncode() == 0
|
||||
pygi_override_dir = cres.stdout().strip()
|
||||
endif
|
||||
if cres.stderr() != ''
|
||||
message(cres.stderr())
|
||||
endif
|
||||
endif
|
||||
|
||||
if pygi_override_dir != ''
|
||||
message('pygobject overrides directory ' + pygi_override_dir)
|
||||
subdir('bindings/python')
|
||||
endif
|
||||
|
||||
if build_machine.system() == 'windows'
|
||||
message('Disabling gtk-doc while building on Windows')
|
||||
elif not get_option('gtk_doc')
|
||||
|
@ -172,5 +216,4 @@ else
|
|||
endif
|
||||
endif
|
||||
|
||||
python3 = import('python3').find_python()
|
||||
run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')
|
||||
|
|
|
@ -2,3 +2,5 @@ option('introspection', type : 'boolean', value : true, yield : true,
|
|||
description : 'Generate gobject-introspection bindings')
|
||||
option('gtk_doc', type : 'boolean', value : true, yield : true,
|
||||
description : 'Build API documentation with gtk-doc')
|
||||
option('pygi-overrides-dir', type : 'string', value : '',
|
||||
description: 'Path to pygobject overrides directory')
|
25
tests/check/python/overrides_hack.py
Normal file
25
tests/check/python/overrides_hack.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import os
|
||||
import gi.overrides
|
||||
|
||||
LOCAL_OVERRIDE_PATH = "gst-editing-services/bindings/python/gi/overrides/"
|
||||
FILE = os.path.realpath(__file__)
|
||||
if not gi.overrides.__path__[0].endswith(LOCAL_OVERRIDE_PATH):
|
||||
local_overrides = None
|
||||
# our overrides don't take precedence, let's fix it
|
||||
for i, path in enumerate(gi.overrides.__path__):
|
||||
if path.endswith(LOCAL_OVERRIDE_PATH):
|
||||
local_overrides = path
|
||||
|
||||
if local_overrides:
|
||||
gi.overrides.__path__.remove(local_overrides)
|
||||
else:
|
||||
local_overrides = os.path.abspath(os.path.join(FILE, "../../../../../", LOCAL_OVERRIDE_PATH))
|
||||
|
||||
gi.overrides.__path__.insert(0, local_overrides)
|
||||
|
||||
# Execute previously set sitecustomize.py script if it existed
|
||||
if os.environ.get("GST_ENV"):
|
||||
old_sitecustomize = os.path.join(os.path.dirname(__file__),
|
||||
"old.sitecustomize.gstuninstalled.py")
|
||||
if os.path.exists(old_sitecustomize):
|
||||
exec(compile(open(old_sitecustomize).read(), old_sitecustomize, 'exec'))
|
|
@ -17,22 +17,20 @@
|
|||
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
|
||||
import gi
|
||||
from . import overrides_hack
|
||||
|
||||
import gi
|
||||
gi.require_version("Gst", "1.0")
|
||||
gi.require_version("GES", "1.0")
|
||||
|
||||
from gi.repository import Gst # noqa
|
||||
Gst.init(None) # noqa
|
||||
from gi.repository import GES # noqa
|
||||
GES.init()
|
||||
|
||||
import unittest # noqa
|
||||
|
||||
|
||||
|
||||
Gst.init(None)
|
||||
GES.init()
|
||||
|
||||
|
||||
class TestCopyPaste(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -72,6 +70,13 @@ class TestCopyPaste(unittest.TestCase):
|
|||
|
||||
class TestTitleClip(unittest.TestCase):
|
||||
|
||||
def testSetColor(self):
|
||||
timeline = GES.Timeline.new_audio_video()
|
||||
clip = GES.TitleClip.new()
|
||||
timeline.append_layer().add_clip(clip )
|
||||
self.assertTrue(clip.set_child_property('color', 1))
|
||||
self.assertTrue(clip.set_child_property('color', 4294967295))
|
||||
|
||||
def testGetPropertyNotInTrack(self):
|
||||
title_clip = GES.TitleClip.new()
|
||||
self.assertEqual(title_clip.props.text, "")
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
|
||||
from . import overrides_hack
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gst", "1.0")
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
|
||||
from . import overrides_hack
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gst", "1.0")
|
||||
|
|
Loading…
Reference in a new issue