Commit 495359ba authored by Suhas's avatar Suhas Committed by Alexandru Băluț

effects: Allow custom property widgets when auto-generating UI of effects

Differential Revision:
parent 4f9f0b07
......@@ -583,16 +583,24 @@ class EffectsPropertiesManager(GObject.Object, Loggable):
__gsignals__ = {
"create_widget": (GObject.SIGNAL_RUN_LAST, Gtk.Widget, (GstElementSettingsWidget, GES.Effect,),
"create_property_widget": (
GObject.SIGNAL_RUN_LAST, object, (GstElementSettingsWidget, GES.Effect, object, object,),
def do_create_widget(self, effect_widget, effect):
"""Creates a widget if the `create_widget` handlers did not."""
effect_name = effect.get_property("bin-description")
self.log('UI is being auto-generated for "%s"', effect_name)
effect_widget.add_widgets(create_property_widget=self.create_property_widget, with_reset_button=True)
self._postConfiguration(effect, effect_widget)
return None
def do_create_property_widget(self, effect_widget, effect, prop, prop_value):
"""Creates a widget if the `create_property_widget` handlers did not."""
widget = effect_widget.make_property_widget(prop, prop_value)
return widget
def __init__(self, app):
......@@ -659,3 +667,8 @@ class EffectsPropertiesManager(GObject.Object, Loggable):
effect.set_child_property(, value)
self._current_element_values[] = value
def create_property_widget(self, element_settings_widget, prop, prop_value):
prop_widget = self.emit("create_property_widget", element_settings_widget, element_settings_widget.element,
prop, prop_value)
return prop_widget
......@@ -30,6 +30,7 @@ CUSTOM_WIDGETS_DIR = os.path.join(configure.get_ui_dir(), "customwidgets")
def setup_custom_effect_widgets(effect_prop_manager):
"""Sets up the specified effects manager to be able to create custom UI."""
effect_prop_manager.connect("create_widget", create_custom_widget_cb)
effect_prop_manager.connect("create_property_widget", create_custom_prop_widget_cb)
def setup_from_ui_file(element_setting_widget, path):
......@@ -42,6 +43,13 @@ def setup_from_ui_file(element_setting_widget, path):
return builder
def create_custom_prop_widget_cb(unused_effect_prop_manager, effect_widget, effect, prop, prop_value):
"""Creates custom effect property UI."""
effect_name = effect.get_property("bin-description")
if effect_name == "alpha":
return create_custom_alpha_prop_widget(effect_widget, effect, prop, prop_value)
def create_custom_widget_cb(unused_effect_prop_manager, effect_widget, effect):
"""Creates custom effect UI."""
effect_name = effect.get_property("bin-description")
......@@ -58,4 +66,11 @@ def create_custom_widget_cb(unused_effect_prop_manager, effect_widget, effect):
def create_alpha_widget(unused_element_setting_widget, unused_element):
"""Not implemented yet."""
# Main alpha widget would go here
return None
def create_custom_alpha_prop_widget(unused_element_setting_widget, unused_element, unused_prop, unused_prop_value):
"""Not implemented yet."""
# In the auto-generated UI, replace a property widget with a custom one
return None
......@@ -813,7 +813,7 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
props = GObject.list_properties(self.element)
return [prop for prop in props if not in self.ignore]
def add_widgets(self, values={}, with_reset_button=False):
def add_widgets(self, create_property_widget, values={}, with_reset_button=False):
"""Prepares a Gtk.Grid containing the property widgets of an element.
Each property is on a separate row.
......@@ -822,6 +822,7 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
If there are no properties, returns a "No properties" label.
create_property_widget (function): The function that gets the widget for an effect property.
values (dict): The current values of the element props, by name.
If empty, the default values will be used.
with_reset_button (bool): Whether to show a reset button for each
......@@ -869,7 +870,7 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
prop_value = values[]
prop_widget = self._makePropertyWidget(prop, prop_value)
prop_widget = create_property_widget(self, prop, prop_value)
element_name = None
if isinstance(self.element, Gst.Element):
element_name = self.element.get_factory().get_name()
......@@ -1038,7 +1039,7 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
values[] = value
return values
def _makePropertyWidget(self, prop, value=None):
def make_property_widget(self, prop, value=None):
"""Creates a widget for the specified element property."""
type_name = GObject.type_name(prop.value_type.fundamental)
if type_name == "gchararray":
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment