[gnome-music/wip/jfelder/repeatmode-player-simplify] player: Only instanciate gsettings once
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/repeatmode-player-simplify] player: Only instanciate gsettings once
- Date: Thu, 11 Apr 2019 06:45:25 +0000 (UTC)
commit 3ee08886d4bc3dbe67f142c721195a466f567396
Author: Jean Felder <jfelder src gnome org>
Date: Thu Apr 11 08:31:30 2019 +0200
player: Only instanciate gsettings once
gnomemusic/gstplayer.py | 10 ++++++++--
gnomemusic/player.py | 14 ++++++++------
gnomemusic/window.py | 2 +-
3 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index 16435c15..421d312d 100644
--- a/gnomemusic/gstplayer.py
+++ b/gnomemusic/gstplayer.py
@@ -61,7 +61,13 @@ class GstPlayer(GObject.GObject):
return '<GstPlayer>'
@log
- def __init__(self):
+ def __init__(self, gsettings):
+ """Gstreamer player
+
+ :param Gio.Settings gsettings: GSettings instance to use
+ :returns:
+ :rtype:
+ """
super().__init__()
Gst.init(None)
@@ -69,7 +75,7 @@ class GstPlayer(GObject.GObject):
self._duration = -1.
self._missing_plugin_messages = []
- self._settings = Gio.Settings.new('org.gnome.Music')
+ self._settings = gsettings
self._player = Gst.ElementFactory.make('playbin3', 'player')
self._bus = self._player.get_bus()
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 24d47eed..78a01dc6 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -543,14 +543,16 @@ class Player(GObject.GObject):
return '<Player>'
@log
- def __init__(self, parent_window):
+ def __init__(self, parent_window, gsettings):
+ """Main player
+
+ :param Gtk.Window window: Main window
+ :param Gio.Settings gsettings: GSettings instance to use
+ """
super().__init__()
self._parent_window = parent_window
-
- self._settings = Gio.Settings.new('org.gnome.Music')
- self._settings.connect(
- 'changed::repeat', self._on_repeat_setting_changed)
+ self._settings = gsettings
self._repeat = self._settings.get_enum('repeat')
self._playlist = PlayerPlaylist()
@@ -563,7 +565,7 @@ class Player(GObject.GObject):
Gst.init(None)
GstPbutils.pb_utils_init()
- self._gst_player = GstPlayer()
+ self._gst_player = GstPlayer(self._settings)
self._gst_player.connect('clock-tick', self._on_clock_tick)
self._gst_player.connect('eos', self._on_eos)
self._gst_player.bind_property(
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 904ebfcd..9dd8fa3d 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -134,7 +134,7 @@ class Window(Gtk.ApplicationWindow):
"state", self._searchbar, "search-state",
GObject.BindingFlags.SYNC_CREATE)
- self._player = Player(self)
+ self._player = Player(self, self._settings)
self._player_toolbar = PlayerToolbar(self._player, self)
selection_toolbar = SelectionToolbar()
self.views = [None] * len(View)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]