[pitivi] effects: Integrate setElement method in constructor



commit 4327e4decd24f11b0efd76c989b67e99d2b6670c
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sat Jan 26 17:28:44 2019 +0100

    effects: Integrate setElement method in constructor

 pitivi/effects.py              |  3 +--
 pitivi/utils/widgets.py        | 14 ++++----------
 tests/test_custom_effect_ui.py |  3 +--
 3 files changed, 6 insertions(+), 14 deletions(-)
---
diff --git a/pitivi/effects.py b/pitivi/effects.py
index face6bfd..20cb2441 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -649,8 +649,7 @@ class EffectsPropertiesManager(GObject.Object, Loggable):
             GstElementSettingsWidget: A container for configuring the effect.
         """
         if effect not in self.cache_dict:
-            effect_widget = GstElementSettingsWidget()
-            effect_widget.setElement(effect, PROPS_TO_IGNORE)
+            effect_widget = GstElementSettingsWidget(effect, PROPS_TO_IGNORE)
             widget = self.emit("create_widget", effect_widget, effect)
             # The default handler of `create_widget` handles visibility
             # itself and returns None
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 6a915a87..adcbd955 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -675,11 +675,11 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
         "x264enc": {"profile": Gst.ValueList(["high", "main", "baseline"])}
     }
 
-    def __init__(self, controllable=True):
+    def __init__(self, element, props_to_ignore=["name"], controllable=True):
         Gtk.Box.__init__(self)
         Loggable.__init__(self)
-        self.element = None
-        self.ignore = []
+        self.element = element
+        self.ignore = props_to_ignore
         self.properties = {}
         # Maps caps fields to the corresponding widgets.
         self.caps_widgets = {}
@@ -702,11 +702,6 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
                 # There can be only one active keyframes button.
                 break
 
-    def setElement(self, element, ignore=['name']):
-        """Sets the element to be edited."""
-        self.element = element
-        self.ignore = ignore
-
     def show_widget(self, widget):
         self.pack_start(widget, True, True, 0)
         self.show_all()
@@ -1149,7 +1144,7 @@ class GstElementSettingsDialog(Loggable):
         self.ok_btn = self.builder.get_object("okbutton1")
 
         self.window = self.builder.get_object("dialog1")
-        self.elementsettings = GstElementSettingsWidget(controllable=False)
+        self.elementsettings = GstElementSettingsWidget(self.element, self.properties, controllable=False)
         self.builder.get_object("viewport1").add(self.elementsettings)
 
         # set title and frame label
@@ -1167,7 +1162,6 @@ class GstElementSettingsDialog(Loggable):
                     val = caps[0][field]
                     if val is not None and Gst.value_is_fixed(val):
                         caps_values[field] = val
-        self.elementsettings.setElement(self.element, self.properties)
         self.elementsettings.add_widgets(GstElementSettingsWidget.make_property_widget,
                                          with_reset_button=True,
                                          caps_values=caps_values)
diff --git a/tests/test_custom_effect_ui.py b/tests/test_custom_effect_ui.py
index d03bfb26..e73f9131 100644
--- a/tests/test_custom_effect_ui.py
+++ b/tests/test_custom_effect_ui.py
@@ -50,8 +50,7 @@ class TestCustomEffectUI(common.TestCase):
 
         self.effects_prop_manager = EffectsPropertiesManager(self.app)
         self.effects_prop_manager.connect("create-widget", self.create_alpha_widget_cb, widgets)
-        self.element_settings_widget = GstElementSettingsWidget()
-        self.element_settings_widget.setElement(self.alpha_effect, PROPS_TO_IGNORE)
+        self.element_settings_widget = GstElementSettingsWidget(self.alpha_effect, PROPS_TO_IGNORE)
 
         self.effects_prop_manager.emit("create-widget", self.element_settings_widget, self.alpha_effect)
         self.effects_prop_manager._connectAllWidgetCallbacks(self.element_settings_widget, self.alpha_effect)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]