[pitivi] widgets: Move function to the class where it's used



commit 22c3e1d9c3d51f64a1f04e8b71c6d6ad33cbf757
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sun Jan 12 17:56:58 2014 +0100

    widgets: Move function to the class where it's used

 pitivi/utils/widgets.py |   70 +++++++++++++++++++++++-----------------------
 1 files changed, 35 insertions(+), 35 deletions(-)
---
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 271a0ca..e399605 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -631,40 +631,6 @@ if __name__ == '__main__':
     Gtk.main()
 
 
-def make_property_widget(unused_element, prop, value=None):
-    """ Creates a Widget for the given element property """
-    # FIXME : implement the case for flags
-    type_name = GObject.type_name(prop.value_type.fundamental)
-
-    if value is None:
-        value = prop.default_value
-    if type_name == "gchararray":
-        widget = TextWidget(default=prop.default_value)
-    elif type_name in ['guint64', 'gint64', 'guint', 'gint', 'gfloat', 'gulong', 'gdouble']:
-        maximum, minimum = None, None
-        if hasattr(prop, "minimum"):
-            minimum = prop.minimum
-        if hasattr(prop, "maximum"):
-            maximum = prop.maximum
-        widget = NumericWidget(default=prop.default_value, upper=maximum, lower=minimum)
-    elif type_name == "gboolean":
-        widget = ToggleWidget(default=prop.default_value)
-    elif type_name == "GEnum":
-        choices = []
-        for key, val in prop.enum_class.__enum_values__.iteritems():
-            choices.append([val.value_name, int(val)])
-        widget = ChoiceWidget(choices, default=prop.default_value)
-    elif type_name == "GstFraction":
-        widget = FractionWidget(None, presets=["0:1"], default=prop.default_value)
-    else:
-        widget = DefaultWidget(type_name)
-
-    if value is not None and type_name != "GFlags":
-        widget.setWidgetValue(value)
-
-    return widget
-
-
 class GstElementSettingsWidget(Gtk.VBox, Loggable):
     """
     Widget to view/modify properties of a Gst.Element
@@ -771,7 +737,7 @@ class GstElementSettingsWidget(Gtk.VBox, Loggable):
                 else:
                     prop_value = properties.get(prop.name)
 
-            widget = make_property_widget(self.element, prop, prop_value)
+            widget = self._makePropertyWidget(prop, prop_value)
             if isinstance(widget, ToggleWidget):
                 widget.set_label(prop.nick)
                 table.attach(widget, 0, 2, y, y + 1, yoptions=Gtk.AttachOptions.FILL)
@@ -901,6 +867,40 @@ class GstElementSettingsWidget(Gtk.VBox, Loggable):
                 d[prop.name] = value
         return d
 
+    @staticmethod
+    def _makePropertyWidget(prop, value=None):
+        """ Creates a Widget for the given element property """
+        # FIXME : implement the case for flags
+        type_name = GObject.type_name(prop.value_type.fundamental)
+
+        if value is None:
+            value = prop.default_value
+        if type_name == "gchararray":
+            widget = TextWidget(default=prop.default_value)
+        elif type_name in ['guint64', 'gint64', 'guint', 'gint', 'gfloat', 'gulong', 'gdouble']:
+            maximum, minimum = None, None
+            if hasattr(prop, "minimum"):
+                minimum = prop.minimum
+            if hasattr(prop, "maximum"):
+                maximum = prop.maximum
+            widget = NumericWidget(default=prop.default_value, upper=maximum, lower=minimum)
+        elif type_name == "gboolean":
+            widget = ToggleWidget(default=prop.default_value)
+        elif type_name == "GEnum":
+            choices = []
+            for key, val in prop.enum_class.__enum_values__.iteritems():
+                choices.append([val.value_name, int(val)])
+            widget = ChoiceWidget(choices, default=prop.default_value)
+        elif type_name == "GstFraction":
+            widget = FractionWidget(None, presets=["0:1"], default=prop.default_value)
+        else:
+            widget = DefaultWidget(type_name)
+
+        if value is not None and type_name != "GFlags":
+            widget.setWidgetValue(value)
+
+        return widget
+
 
 class GstElementSettingsDialog(Loggable):
     """


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