[pitivi] pipeline: Rename getState and setState



commit 18fbdea23426349c2fc170018444606d3b6f6218
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Mon Nov 4 01:59:04 2019 +0100

    pipeline: Rename getState and setState

 pitivi/mediafilespreviewer.py | 14 +++++++-------
 pitivi/timeline/elements.py   |  2 +-
 pitivi/utils/pipeline.py      | 30 +++++++++++++++---------------
 pitivi/viewer/viewer.py       | 10 +++++-----
 tests/test_pipeline.py        |  2 +-
 5 files changed, 29 insertions(+), 29 deletions(-)
---
diff --git a/pitivi/mediafilespreviewer.py b/pitivi/mediafilespreviewer.py
index d7f7b464..2fd25899 100644
--- a/pitivi/mediafilespreviewer.py
+++ b/pitivi/mediafilespreviewer.py
@@ -254,7 +254,7 @@ class PreviewWidget(Gtk.Grid, Loggable):
                 self.current_preview_type = 'video'
                 self.preview_image.hide()
                 self.player.uri = self.current_selected_uri
-                self.player.setState(Gst.State.PAUSED)
+                self.player.set_simple_state(Gst.State.PAUSED)
                 self.pos_adj.props.upper = duration
                 video_width = video.get_natural_width()
                 video_height = video.get_natural_height()
@@ -288,9 +288,9 @@ class PreviewWidget(Gtk.Grid, Loggable):
             self.description = "\n".join([
                 beautify_stream(audio),
                 _("<b>Duration</b>: %s") % pretty_duration])
-            self.player.setState(Gst.State.NULL)
+            self.player.set_simple_state(Gst.State.NULL)
             self.player.uri = self.current_selected_uri
-            self.player.setState(Gst.State.PAUSED)
+            self.player.set_simple_state(Gst.State.PAUSED)
             self.play_button.show()
             self.seeker.show()
             self.b_zoom_in.hide()
@@ -311,7 +311,7 @@ class PreviewWidget(Gtk.Grid, Loggable):
             # The content played once already and the pipeline is at the end.
             self.at_eos = False
             self.player.simple_seek(0)
-        self.player.setState(Gst.State.PLAYING)
+        self.player.set_simple_state(Gst.State.PLAYING)
         self.is_playing = True
         self.play_button.set_icon_name("media-playback-pause")
         GLib.timeout_add(250, self._update_position)
@@ -319,7 +319,7 @@ class PreviewWidget(Gtk.Grid, Loggable):
 
     def pause(self, state=Gst.State.PAUSED):
         if state is not None:
-            self.player.setState(state)
+            self.player.set_simple_state(state)
         self.is_playing = False
         self.play_button.set_icon_name("media-playback-start")
         self.log("Preview paused")
@@ -349,14 +349,14 @@ class PreviewWidget(Gtk.Grid, Loggable):
         if event.type == Gdk.EventType.BUTTON_PRESS:
             self.countinuous_seek = True
             if self.is_playing:
-                self.player.setState(Gst.State.PAUSED)
+                self.player.set_simple_state(Gst.State.PAUSED)
         elif event.type == Gdk.EventType.BUTTON_RELEASE:
             self.countinuous_seek = False
             value = int(widget.get_value())
             self.player.simple_seek(value)
             self.at_eos = False
             if self.is_playing:
-                self.player.setState(Gst.State.PLAYING)
+                self.player.set_simple_state(Gst.State.PLAYING)
             # Now, allow gobject timeout to continue updating the slider pos:
             self.slider_being_used = False
 
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 21b735a6..b53f803d 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -768,7 +768,7 @@ class TimelineElement(Gtk.Layout, Zoomable, Loggable):
 
         if self.keyframe_curve and self.keyframe_curve.is_drawable():
             project = self.timeline.app.project_manager.current_project
-            if project.pipeline.getState() != Gst.State.PLAYING:
+            if project.pipeline.get_simple_state() != Gst.State.PLAYING:
                 self.propagate_draw(self.keyframe_curve, cr)
 
     # Callbacks
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index 386d4883..16eba321 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -142,7 +142,7 @@ class SimplePipeline(GObject.Object, Loggable):
         self._bus = None
 
     def flushSeek(self):
-        if self.getState() == Gst.State.PLAYING:
+        if self.get_simple_state() == Gst.State.PLAYING:
             self.debug("Playing, no need to flush here!")
             return
 
@@ -151,7 +151,7 @@ class SimplePipeline(GObject.Object, Loggable):
         except PipelineError as e:
             self.warning("Could not flush because: %s", e)
 
-    def setState(self, state):
+    def set_simple_state(self, state):
         """Sets the low-level pipeline to the specified state.
 
         Raises:
@@ -161,7 +161,7 @@ class SimplePipeline(GObject.Object, Loggable):
         """
         self.debug("Setting state to: %r", state)
         if state >= Gst.State.PAUSED:
-            cstate = self.getState()
+            cstate = self.get_simple_state()
             if cstate < Gst.State.PAUSED:
                 if cstate == Gst.State.NULL:
                     timeout = MAX_BRINGING_TO_PAUSED_DURATION
@@ -179,7 +179,7 @@ class SimplePipeline(GObject.Object, Loggable):
             raise PipelineError(
                 "Failure changing state of the Gst.Pipeline to %r, currently reset to NULL" % state)
 
-    def getState(self):
+    def get_simple_state(self):
         """Queries the low-level pipeline for the current state.
 
         This will do an actual query to the underlying GStreamer Pipeline.
@@ -195,18 +195,18 @@ class SimplePipeline(GObject.Object, Loggable):
 
     def play(self):
         """Sets the state to Gst.State.PLAYING."""
-        self.setState(Gst.State.PLAYING)
+        self.set_simple_state(Gst.State.PLAYING)
 
     def pause(self):
         """Sets the state to Gst.State.PAUSED."""
-        self.setState(Gst.State.PAUSED)
+        self.set_simple_state(Gst.State.PAUSED)
 
     def stop(self):
         """Sets the state to Gst.State.READY."""
-        self.setState(Gst.State.READY)
+        self.set_simple_state(Gst.State.READY)
 
     def playing(self):
-        return self.getState() == Gst.State.PLAYING
+        return self.get_simple_state() == Gst.State.PLAYING
 
     def togglePlayback(self):
         if self.playing():
@@ -268,7 +268,7 @@ class SimplePipeline(GObject.Object, Loggable):
         self._listening = True
         self._listening_interval = interval
         # if we're in playing, switch it on
-        self._listenToPosition(self.getState() == Gst.State.PLAYING)
+        self._listenToPosition(self.get_simple_state() == Gst.State.PLAYING)
         return True
 
     def deactivatePositionListener(self):
@@ -346,7 +346,7 @@ class SimplePipeline(GObject.Object, Loggable):
         Raises:
             PipelineError: When the seek fails.
         """
-        if self._busy_async or self.getState() < Gst.State.PAUSED:
+        if self._busy_async or self.get_simple_state() < Gst.State.PAUSED:
             self._next_seek = position
             self.info("Setting next seek to %s", self._next_seek)
             return
@@ -474,7 +474,7 @@ class SimplePipeline(GObject.Object, Loggable):
         self._attempted_recoveries += 1
         self.error("Resetting pipeline because error detected during playback. "
                    "Try %d", self._attempted_recoveries)
-        self.setState(Gst.State.NULL)
+        self.set_simple_state(Gst.State.NULL)
         self._recovery_state = self.RecoveryState.STARTED_RECOVERING
         self.pause()
 
@@ -616,7 +616,7 @@ class Pipeline(GES.Pipeline, SimplePipeline):
             raise PipelineError("Trying to seek while rendering")
 
         st = Gst.Structure.new_empty("seek")
-        if self.getState() == Gst.State.PLAYING:
+        if self.get_simple_state() == Gst.State.PLAYING:
             st.set_value("playback_time", float(
                 self.getPosition()) / Gst.SECOND)
         st.set_value("start", float(position / Gst.SECOND))
@@ -653,7 +653,7 @@ class Pipeline(GES.Pipeline, SimplePipeline):
             self.commit_timeline()
 
     def commit_timeline(self):
-        if self._prevent_commits > 0 or self.getState() == Gst.State.NULL:
+        if self._prevent_commits > 0 or self.get_simple_state() == Gst.State.NULL:
             # No need to commit. NLE will do it automatically when
             # changing state from READY to PAUSED.
             return
@@ -668,8 +668,8 @@ class Pipeline(GES.Pipeline, SimplePipeline):
             self.debug("Committing right now")
             self._was_empty = is_empty
 
-    def setState(self, state):
-        SimplePipeline.setState(self, state)
+    def set_simple_state(self, state):
+        SimplePipeline.set_simple_state(self, state)
         if state >= Gst.State.PAUSED and self.props.timeline.is_empty():
             self.debug("No ASYNC_DONE will be emitted on empty timelines")
             self._was_empty = True
diff --git a/pitivi/viewer/viewer.py b/pitivi/viewer/viewer.py
index 8b0b8633..acea8484 100644
--- a/pitivi/viewer/viewer.py
+++ b/pitivi/viewer/viewer.py
@@ -427,7 +427,7 @@ class ViewerContainer(Gtk.Box, Loggable):
         if self.project:
             self.overlay_stack.enable_resize_status(False)
             position = self.project.pipeline.getPosition()
-            self.project.pipeline.setState(Gst.State.NULL)
+            self.project.pipeline.set_simple_state(Gst.State.NULL)
             self.remove(self.target)
             self.__createNewViewer()
         self.buttons_container.set_margin_bottom(SPACING)
@@ -471,7 +471,7 @@ class ViewerContainer(Gtk.Box, Loggable):
         if self.project:
             self.overlay_stack.enable_resize_status(False)
             position = self.project.pipeline.getPosition()
-            self.project.pipeline.setState(Gst.State.NULL)
+            self.project.pipeline.set_simple_state(Gst.State.NULL)
             self.external_vbox.remove(self.target)
             self.__createNewViewer()
 
@@ -516,8 +516,8 @@ class ViewerContainer(Gtk.Box, Loggable):
             self.log("Not previewing trim for image or title clip: %s", clip)
             return
 
-        if self.project.pipeline.getState() == Gst.State.PLAYING:
-            self.project.pipeline.setState(Gst.State.PAUSED)
+        if self.project.pipeline.get_simple_state() == Gst.State.PLAYING:
+            self.project.pipeline.set_simple_state(Gst.State.PAUSED)
 
         uri = clip.props.uri
         if self.trim_pipeline and uri != self.trim_pipeline.uri:
@@ -540,7 +540,7 @@ class ViewerContainer(Gtk.Box, Loggable):
             self.hidden_chest.add(sink_widget)
             sink_widget.show()
             self.trim_pipeline.connect("state-change", self._state_change_cb)
-            self.trim_pipeline.setState(Gst.State.PAUSED)
+            self.trim_pipeline.set_simple_state(Gst.State.PAUSED)
 
         self.trim_pipeline.simple_seek(position)
 
diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py
index ee235295..f5f9dc8d 100644
--- a/tests/test_pipeline.py
+++ b/tests/test_pipeline.py
@@ -140,7 +140,7 @@ class TestPipeline(common.TestCase):
         timeline = GES.Timeline()
         pipe.set_timeline(timeline)
 
-        with mock.patch.object(pipe, "getState") as get_state:
+        with mock.patch.object(pipe, "get_simple_state") as get_state:
             get_state.return_value = (0, Gst.State.PAUSED, 0)
             with mock.patch.object(timeline, "commit") as commit:
                 with pipe.commit_timeline_after():


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