[gnome-music/gbsneto/untangle-player-window-mpris: 4/6] gstplayer: Use active window for missing codecs dialog



commit cbd7619e2d06686c0a9631a7e451441bb727563d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Apr 10 12:02:11 2019 -0300

    gstplayer: Use active window for missing codecs dialog
    
    GstPlayer was introduced by 84edf8832 as a factoring of
    Player, isolating the GStreamer-specific logic. However,
    it tries to access Player._parent_window to display the
    missing codecs page, a field that naturally does not
    exist anymore.
    
    Fix that by receiving the application at construction time,
    and using its active window when displaying the missing
    codecs dialog.

 gnomemusic/gstplayer.py | 6 ++++--
 gnomemusic/player.py    | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index 16435c15..4bc3ee09 100644
--- a/gnomemusic/gstplayer.py
+++ b/gnomemusic/gstplayer.py
@@ -61,11 +61,12 @@ class GstPlayer(GObject.GObject):
         return '<GstPlayer>'
 
     @log
-    def __init__(self):
+    def __init__(self, application):
         super().__init__()
 
         Gst.init(None)
 
+        self._application = application
         self._duration = -1.
 
         self._missing_plugin_messages = []
@@ -344,7 +345,8 @@ class GstPlayer(GObject.GObject):
     @log
     def _show_codec_confirmation_dialog(
             self, install_helper_name, missing_plugin_messages):
-        dialog = MissingCodecsDialog(self._parent_window, install_helper_name)
+        active_window = self._application.props.active_window
+        dialog = MissingCodecsDialog(active_window, install_helper_name)
 
         def on_dialog_response(dialog, response_type):
             if response_type == Gtk.ResponseType.ACCEPT:
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index f9c7963e..7335a383 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -96,6 +96,7 @@ class PlayerPlaylist(GObject.GObject):
 
     @log
     def __init__(self):
+        """Initialize the player playlist"""
         super().__init__()
         self._songs = []
         self._shuffle_indexes = []
@@ -582,7 +583,7 @@ class Player(GObject.GObject):
         Gst.init(None)
         GstPbutils.pb_utils_init()
 
-        self._gst_player = GstPlayer()
+        self._gst_player = GstPlayer(application)
         self._gst_player.connect('clock-tick', self._on_clock_tick)
         self._gst_player.connect('eos', self._on_eos)
         self._gst_player.bind_property(


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