[pitivi] Use virtual methods instead of connecting to signals
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Use virtual methods instead of connecting to signals
- Date: Wed, 14 Sep 2016 09:57:16 +0000 (UTC)
commit 51c94ab3331e45796b425e4e843bb3b166f81276
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Tue Aug 30 16:49:11 2016 +0200
Use virtual methods instead of connecting to signals
This can be done when the signal is always connected. Saves one line of
code and one parameter and makes a bit more clear that the handler
reacts to something happening to `self`.
Differential Revision: https://phabricator.freedesktop.org/D1293
pitivi/mediafilespreviewer.py | 5 ++---
pitivi/tabsmanager.py | 5 ++---
pitivi/viewer/overlay_stack.py | 4 ++--
pitivi/viewer/viewer.py | 4 ++--
4 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/pitivi/mediafilespreviewer.py b/pitivi/mediafilespreviewer.py
index 4b0be04..5bc55fa 100644
--- a/pitivi/mediafilespreviewer.py
+++ b/pitivi/mediafilespreviewer.py
@@ -80,8 +80,6 @@ class PreviewWidget(Gtk.Grid, Loggable):
Loggable.__init__(self)
self.log("Init PreviewWidget")
- self.connect('destroy', self._destroy_cb)
-
self.settings = settings
self.error_message = None
@@ -455,7 +453,8 @@ class PreviewWidget(Gtk.Grid, Loggable):
dialog.run()
dialog.destroy()
- def _destroy_cb(self, widget):
+ def do_destroy(self):
+ """Handles the destruction of the widget."""
self.player.release()
self.is_playing = False
diff --git a/pitivi/tabsmanager.py b/pitivi/tabsmanager.py
index d0420b2..3a9063e 100644
--- a/pitivi/tabsmanager.py
+++ b/pitivi/tabsmanager.py
@@ -40,7 +40,6 @@ class BaseTabs(Gtk.Notebook, Loggable):
Loggable.__init__(self)
self.set_border_width(SPACING)
self.set_scrollable(True)
- self.connect("create-window", self.__create_window_cb)
self.settings = app.settings
notebook_widget_settings = self.get_settings()
notebook_widget_settings.props.gtk_dnd_drag_threshold = 1
@@ -79,8 +78,8 @@ class BaseTabs(Gtk.Notebook, Loggable):
self.insert_page(child, label, original_position)
self._set_child_properties(child, label)
- def __create_window_cb(self, unused_notebook, child, unused_x, unused_y):
- """Creates a window for the detached page.
+ def do_create_window(self, child, unused_x, unused_y):
+ """Handles the detachment of a page.
Args:
child (Gtk.Widget): The detached page.
diff --git a/pitivi/viewer/overlay_stack.py b/pitivi/viewer/overlay_stack.py
index 6880416..689ac76 100644
--- a/pitivi/viewer/overlay_stack.py
+++ b/pitivi/viewer/overlay_stack.py
@@ -45,9 +45,9 @@ class OverlayStack(Gtk.Overlay, Loggable):
Gdk.EventMask.LEAVE_NOTIFY_MASK |
Gdk.EventMask.ALL_EVENTS_MASK)
self.add(sink_widget)
- self.connect("size-allocate", self.__on_size_allocate)
- def __on_size_allocate(self, widget, rectangle):
+ def do_size_allocate(self, rectangle):
+ """Handles size allocation."""
self.window_size = numpy.array([rectangle.width,
rectangle.height])
for overlay in self.__overlays.values():
diff --git a/pitivi/viewer/viewer.py b/pitivi/viewer/viewer.py
index e02b012..1235a95 100644
--- a/pitivi/viewer/viewer.py
+++ b/pitivi/viewer/viewer.py
@@ -519,12 +519,12 @@ class PlayPauseButton(Gtk.Button, Loggable):
self.add(self.image)
self.playing = False
self.setPlay()
- self.connect('clicked', self._clickedCb)
def set_sensitive(self, value):
Gtk.Button.set_sensitive(self, value)
- def _clickedCb(self, unused):
+ def do_clicked(self):
+ """Handles the click events to toggle playback."""
self.playing = not self.playing
self.emit("play", self.playing)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]