[pitivi] app: Remove directly called callback methods



commit 7a8d23ba2b0f92be0d2b23cc901a30a88cef19ca
Author: HarishFulara07 <harish14143 iiitd ac in>
Date:   Fri Jun 22 13:47:32 2018 +0530

    app: Remove directly called callback methods

 pitivi/dialogs/prefs.py     |  9 ++++++---
 pitivi/editorperspective.py | 21 +++++++++------------
 pitivi/project.py           |  2 +-
 pitivi/render.py            |  9 ++++++---
 pitivi/timeline/timeline.py | 21 ++++++++++++---------
 5 files changed, 34 insertions(+), 28 deletions(-)
---
diff --git a/pitivi/dialogs/prefs.py b/pitivi/dialogs/prefs.py
index 9635535e..17c524d9 100644
--- a/pitivi/dialogs/prefs.py
+++ b/pitivi/dialogs/prefs.py
@@ -252,7 +252,7 @@ class PreferencesDialog(Loggable):
             revert.set_tooltip_text(_("Reset to default value"))
             revert.set_relief(Gtk.ReliefStyle.NONE)
             revert.set_sensitive(not self.settings.isDefault(attrname))
-            revert.connect("clicked", self._resetOptionCb, attrname)
+            revert.connect("clicked", self.__reset_option_cb, attrname)
             revert.show_all()
             self.resets[attrname] = revert
             row_widgets = (label_widget, widget, revert)
@@ -408,7 +408,7 @@ class PreferencesDialog(Loggable):
         """Resets all settings to the defaults."""
         for section in self.prefs.values():
             for attrname in section:
-                self._resetOptionCb(self.resets[attrname], attrname)
+                self.__reset_option(self.resets[attrname], attrname)
         self.app.shortcuts.reset_accels()
 
     def _revertButtonCb(self, unused_button):
@@ -420,7 +420,10 @@ class PreferencesDialog(Loggable):
         self.revert_button.set_sensitive(False)
         self.factory_settings.set_sensitive(self._canReset())
 
-    def _resetOptionCb(self, button, attrname):
+    def __reset_option_cb(self, button, attrname):
+        self.__reset_option(button, attrname)
+
+    def __reset_option(self, button, attrname):
         """Resets a particular setting to the factory default."""
         if not self.settings.isDefault(attrname):
             self.settings.setDefault(attrname)
diff --git a/pitivi/editorperspective.py b/pitivi/editorperspective.py
index 5104b163..d89947f5 100644
--- a/pitivi/editorperspective.py
+++ b/pitivi/editorperspective.py
@@ -342,14 +342,14 @@ class EditorPerspective(Perspective, Loggable):
         self.headerbar.insert_action_group("editor", group)
 
         self.save_action = Gio.SimpleAction.new("save", None)
-        self.save_action.connect("activate", self._saveProjectCb)
+        self.save_action.connect("activate", self.__save_project_cb)
         group.add_action(self.save_action)
         self.app.shortcuts.add("editor.save", ["<Primary>s"],
                                _("Save the current project"), group="win")
         self.save_button.set_action_name("editor.save")
 
         self.save_as_action = Gio.SimpleAction.new("save-as", None)
-        self.save_as_action.connect("activate", self._saveProjectAsCb)
+        self.save_as_action.connect("activate", self.__save_project_as_cb)
         group.add_action(self.save_as_action)
         self.app.shortcuts.add("editor.save-as", ["<Primary><Shift>s"],
                                _("Save the current project as"), group="win")
@@ -403,20 +403,17 @@ class EditorPerspective(Perspective, Loggable):
         """Closes the current project."""
         self.app.project_manager.closeRunningProject()
 
-    def _saveProjectCb(self, action, unused_param):
-        if not self.app.project_manager.current_project.uri or self.app.project_manager.disable_save:
-            self.saveProjectAs()
-        else:
-            self.app.project_manager.saveProject()
+    def __save_project_cb(self, unused_action, unused_param):
+        self.saveProject()
 
-    def _saveProjectAsCb(self, unused_action, unused_param):
+    def __save_project_as_cb(self, unused_action, unused_param):
         self.saveProjectAs()
 
     def saveProject(self):
-        self._saveProjectCb(None, None)
-
-    def saveProjectAsDialog(self):
-        self._saveProjectAsCb(None, None)
+        if not self.app.project_manager.current_project.uri or self.app.project_manager.disable_save:
+            self.saveProjectAs()
+        else:
+            self.app.project_manager.saveProject()
 
     def _revertToSavedProjectCb(self, unused_action):
         return self.app.project_manager.revertToSavedProject()
diff --git a/pitivi/project.py b/pitivi/project.py
index bb14abf1..b49e82e4 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -213,7 +213,7 @@ class ProjectManager(GObject.Object, Loggable):
         dialog.destroy()
 
         if response == 1:
-            self.app.gui.editor.saveProjectAsDialog()
+            self.app.gui.editor.saveProjectAs()
         elif response == 2:
             self.app.gui.editor.saveProject()
 
diff --git a/pitivi/render.py b/pitivi/render.py
index f902a2f0..24f5227b 100644
--- a/pitivi/render.py
+++ b/pitivi/render.py
@@ -873,9 +873,9 @@ class RenderDialog(Loggable):
         self._pipeline.set_mode(GES.PipelineFlags.RENDER)
         encodebin = self._pipeline.get_by_name("internal-encodebin")
         self._gstSigId[encodebin] = encodebin.connect(
-            "element-added", self._elementAddedCb)
+            "element-added", self.__element_added_cb)
         for element in encodebin.iterate_recurse():
-            self._elementAddedCb(encodebin, element)
+            self.__set_properties(element)
         self._pipeline.set_state(Gst.State.PLAYING)
         self._is_rendering = True
         self._time_started = time.time()
@@ -1137,7 +1137,10 @@ class RenderDialog(Loggable):
             self._filesizeEstimateTimer = GLib.timeout_add_seconds(
                 5, self._updateFilesizeEstimateCb)
 
-    def _elementAddedCb(self, unused_bin, gst_element):
+    def __element_added_cb(self, unused_bin, gst_element):
+        self.__set_properties(gst_element)
+
+    def __set_properties(self, gst_element):
         """Sets properties on the specified Gst.Element."""
         factory = gst_element.get_factory()
         settings = {}
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 94db5983..834769be 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -419,8 +419,8 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
                 self.ges_timeline.disconnect_by_func(self._durationChangedCb)
                 self.ges_timeline.disconnect_by_func(self._layer_added_cb)
                 self.ges_timeline.disconnect_by_func(self._layer_removed_cb)
-                self.ges_timeline.disconnect_by_func(self._snapCb)
-                self.ges_timeline.disconnect_by_func(self._snapEndedCb)
+                self.ges_timeline.disconnect_by_func(self.__snapping_started_cb)
+                self.ges_timeline.disconnect_by_func(self.__snapping_ended_cb)
                 for ges_layer in self.ges_timeline.get_layers():
                     self._remove_layer(ges_layer)
 
@@ -446,8 +446,8 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
         self.ges_timeline.connect("notify::duration", self._durationChangedCb)
         self.ges_timeline.connect("layer-added", self._layer_added_cb)
         self.ges_timeline.connect("layer-removed", self._layer_removed_cb)
-        self.ges_timeline.connect("snapping-started", self._snapCb)
-        self.ges_timeline.connect("snapping-ended", self._snapEndedCb)
+        self.ges_timeline.connect("snapping-started", self.__snapping_started_cb)
+        self.ges_timeline.connect("snapping-ended", self.__snapping_ended_cb)
 
         self.connect("button-press-event", self._button_press_event_cb)
         self.connect("button-release-event", self._button_release_event_cb)
@@ -498,13 +498,16 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
         if not pipeline.playing():
             self.update_visible_overlays()
 
-    def _snapCb(self, unused_timeline, unused_obj1, unused_obj2, position):
+    def __snapping_started_cb(self, unused_timeline, unused_obj1, unused_obj2, position):
         """Handles a clip snap update operation."""
         self.layout.snap_position = position
         self.layout.queue_draw()
 
-    def _snapEndedCb(self, *unused_args):
-        """Handles a clip snap end."""
+    def __snapping_ended_cb(self, *unused_args):
+        self.__end_snap()
+
+    def __end_snap(self):
+        """Updates the UI to reflect the snap has ended."""
         self.layout.snap_position = 0
         self.layout.queue_draw()
 
@@ -734,7 +737,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
                 clicked_layer, click_pos = self.get_clicked_layer_and_pos(event)
                 self.set_selection_meta_info(clicked_layer, click_pos, SELECT)
 
-        self._snapEndedCb()
+        self.__end_snap()
         self.update_visible_overlays()
 
         return False
@@ -1284,7 +1287,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
 
     def dragEnd(self):
         if self.editing_context:
-            self._snapEndedCb()
+            self.__end_snap()
 
             if self.__on_separators and self.__got_dragged and not self.__clickedHandle:
                 priority = self.separator_priority(self.__on_separators[1])


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