[gnome-music/wip/mschraal/window-template: 2/5] player: Move InhibitSuspend to Window



commit 8b73500ffd5d786c3c6d902e1778408b32d60a3a
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Sep 8 12:18:11 2018 +0200

    player: Move InhibitSuspend to Window

 gnomemusic/player.py | 8 +-------
 gnomemusic/window.py | 6 +++++-
 2 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index c26cb20f..ee4ce95d 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -37,7 +37,6 @@ from gi.repository import Gio, GLib, GObject, Grl, Gst, GstPbutils
 from gnomemusic import log
 from gnomemusic.gstplayer import GstPlayer, Playback
 from gnomemusic.grilo import grilo
-from gnomemusic.inhibitsuspend import InhibitSuspend
 from gnomemusic.playlists import Playlists
 from gnomemusic.scrobbler import LastFmScrobbler
 
@@ -507,11 +506,9 @@ class Player(GObject.GObject):
         return '<Player>'
 
     @log
-    def __init__(self, parent_window):
+    def __init__(self):
         super().__init__()
 
-        self._parent_window = parent_window
-
         self._playlist = PlayerPlaylist()
         self._playlist.connect('song-validated', self._on_song_validated)
 
@@ -524,9 +521,6 @@ class Player(GObject.GObject):
         self._player.connect('clock-tick', self._on_clock_tick)
         self._player.connect('eos', self._on_eos)
 
-        root_window = parent_window.get_toplevel()
-        self._inhibit_suspend = InhibitSuspend(root_window, self)
-
         self._lastfm = LastFmScrobbler()
 
     @GObject.Property(
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index cfae33bc..f2993650 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -33,6 +33,7 @@ from gi.repository import Gtk, Gdk, Gio, GLib, GObject
 from gettext import gettext as _
 
 from gnomemusic import log
+from gnomemusic.inhibitsuspend import InhibitSuspend
 from gnomemusic.mediakeys import MediaKeys
 from gnomemusic.player import Player, RepeatMode
 from gnomemusic.query import Query
@@ -94,8 +95,11 @@ class Window(Gtk.ApplicationWindow):
         self.prev_view = None
         self.curr_view = None
 
+        self._player = Player()
+
         self._setup_view()
 
+        InhibitSuspend(self, self._player)
         MediaKeys(self._player, self)
 
         grilo.connect('changes-pending', self._on_changes_pending)
@@ -125,7 +129,7 @@ class Window(Gtk.ApplicationWindow):
     @log
     def _setup_view(self):
         self._headerbar = HeaderBar()
-        self._player = Player(self)
+
         self._player_toolbar = PlayerToolbar(self._player, self)
         self.views = [None] * len(View)
 


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