[pitivi] effects: Allow custom property widgets when auto-generating UI of effects
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] effects: Allow custom property widgets when auto-generating UI of effects
- Date: Tue, 5 Sep 2017 22:54:31 +0000 (UTC)
commit 495359ba15749d781292e62deae91565c72f285f
Author: Suhas Nayak <suhas2go gmail com>
Date: Thu Jul 6 03:21:22 2017 +0530
effects: Allow custom property widgets when auto-generating UI of effects
Differential Revision: https://phabricator.freedesktop.org/D1777
pitivi/effects.py | 15 ++++++++++++++-
pitivi/utils/custom_effect_widgets.py | 15 +++++++++++++++
pitivi/utils/widgets.py | 7 ++++---
3 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/effects.py b/pitivi/effects.py
index 6897051..29d2f86 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -583,16 +583,24 @@ class EffectsPropertiesManager(GObject.Object, Loggable):
__gsignals__ = {
"create_widget": (GObject.SIGNAL_RUN_LAST, Gtk.Widget, (GstElementSettingsWidget, GES.Effect,),
create_widget_accumulator),
+ "create_property_widget": (
+ GObject.SIGNAL_RUN_LAST, object, (GstElementSettingsWidget, GES.Effect, object, object,),
+ create_widget_accumulator),
}
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(with_reset_button=True)
+ 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):
GObject.Object.__init__(self)
Loggable.__init__(self)
@@ -659,3 +667,8 @@ class EffectsPropertiesManager(GObject.Object, Loggable):
toplevel=True):
effect.set_child_property(prop.name, value)
self._current_element_values[prop.name] = 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
diff --git a/pitivi/utils/custom_effect_widgets.py b/pitivi/utils/custom_effect_widgets.py
index 3b34b5d..ebcdb14 100644
--- a/pitivi/utils/custom_effect_widgets.py
+++ b/pitivi/utils/custom_effect_widgets.py
@@ -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
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 09465e4..2d35724 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -813,7 +813,7 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
props = GObject.list_properties(self.element)
return [prop for prop in props if prop.name 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.
Args:
+ 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):
else:
prop_value = values[prop.name]
- 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[prop.name] = 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":
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]