[gnome-music/wip/mschraal/player-factor-out-gstreamer: 46/56] player: start of undoing camelcase
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/player-factor-out-gstreamer: 46/56] player: start of undoing camelcase
- Date: Fri, 16 Feb 2018 10:41:50 +0000 (UTC)
commit 75535a017e3345395d66e5eccfdc65bb4220da62
Author: Marinus Schraal <mschraal gnome org>
Date: Fri Feb 9 17:27:24 2018 +0100
player: start of undoing camelcase
gnomemusic/mpris.py | 28 +++---
gnomemusic/player.py | 188 +++++++++++++++++++--------------------
gnomemusic/views/baseview.py | 2 +-
gnomemusic/views/playlistview.py | 12 +--
gnomemusic/views/songsview.py | 2 +-
5 files changed, 115 insertions(+), 117 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index d5cda0c..2f55525 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -351,7 +351,7 @@ class MediaPlayer2Service(Server):
@log
def _get_media_from_id(self, track_id):
for track in self.player.playlist:
- media = track[self.player.playlistField]
+ media = track[self.player.playlist_field]
if track_id == self._get_media_id(media):
return media
return None
@@ -359,7 +359,7 @@ class MediaPlayer2Service(Server):
@log
def _get_track_list(self):
if self.player.playlist:
- return [self._get_media_id(track[self.player.playlistField])
+ return [self._get_media_id(track[self.player.playlist_field])
for track in self.player.playlist]
else:
return []
@@ -397,8 +397,8 @@ class MediaPlayer2Service(Server):
@log
def _get_active_playlist(self):
- playlist = self._get_playlist_from_id(self.player.playlistId) \
- if self.player.playlistType == 'Playlist' else None
+ playlist = self._get_playlist_from_id(self.player.playlist_id) \
+ if self.player.playlist_type == 'Playlist' else None
playlistName = utils.get_media_title(playlist) \
if playlist else ''
return (playlist is not None,
@@ -495,11 +495,11 @@ class MediaPlayer2Service(Server):
@log
def _on_playlist_modified(self, path=None, _iter=None, data=None):
- if self.player.currentTrack and self.player.currentTrack.valid():
- path = self.player.currentTrack.get_path()
- currentTrack = self.player.playlist[path][self.player.playlistField]
+ if self.player.current_track and self.player.current_track.valid():
+ path = self.player.current_track.get_path()
+ current_track = self.player.playlist[path][self.player.playlist_field]
track_list = self._get_track_list()
- self.TrackListReplaced(track_list, self._get_media_id(currentTrack))
+ self.TrackListReplaced(track_list, self._get_media_id(current_track))
self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_TRACKLIST_IFACE,
{
'Tracks': GLib.Variant('ao', track_list),
@@ -592,13 +592,13 @@ class MediaPlayer2Service(Server):
def GoTo(self, track_id):
for track in self.player.playlist:
- media = track[self.player.playlistField]
+ media = track[self.player.playlist_field]
if track_id == self._get_media_id(media):
- self.player.set_playlist(self.player.playlistType,
- self.player.playlistId,
+ self.player.set_playlist(self.player.playlist_type,
+ self.player.playlist_id,
self.player.playlist,
track.iter,
- self.player.playlistField)
+ self.player.playlist_field)
self.player.play()
return
@@ -689,8 +689,8 @@ class MediaPlayer2Service(Server):
'MaximumRate': GLib.Variant('d', 1.0),
'CanGoNext': GLib.Variant('b', self.player.has_next()),
'CanGoPrevious': GLib.Variant('b', self.player.has_previous()),
- 'CanPlay': GLib.Variant('b', self.player.currentTrack is not None),
- 'CanPause': GLib.Variant('b', self.player.currentTrack is not None),
+ 'CanPlay': GLib.Variant('b', self.player.current_track is not None),
+ 'CanPause': GLib.Variant('b', self.player.current_track is not None),
'CanSeek': GLib.Variant('b', True),
'CanControl': GLib.Variant('b', True),
}
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 657dd04..b678f0d 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -70,7 +70,7 @@ class DiscoveryStatus:
class Player(GObject.GObject):
- nextTrack = None
+ _next_track = None
timeout = None
_seconds_timeout = None
shuffleHistory = deque(maxlen=10)
@@ -96,20 +96,18 @@ class Player(GObject.GObject):
self._parent_window = parent_window
self.playlist = None
- self.playlistType = None
- self.playlistId = None
- self.playlistField = None
- self.currentTrack = None
- self.currentTrackUri = None
-
- self._missingPluginMessages = []
+ self.playlist_type = None
+ self.playlist_id = None
+ self.playlist_field = None
+ self.current_track = None
+ self.current_track_uri = None
Gst.init(None)
GstPbutils.pb_utils_init()
- self.discoverer = GstPbutils.Discoverer()
- self.discoverer.connect('discovered', self._on_discovered)
- self.discoverer.start()
+ self._discoverer = GstPbutils.Discoverer()
+ self._discoverer.connect('discovered', self._on_discovered)
+ self._discoverer.start()
self._discovering_urls = {}
self._settings = Gio.Settings.new('org.gnome.Music')
@@ -142,7 +140,7 @@ class Player(GObject.GObject):
self._discovering_urls[url] += [obj]
else:
self._discovering_urls[url] = [obj]
- self.discoverer.discover_uri_async(url)
+ self._discoverer.discover_uri_async(url)
def _on_discovered(self, discoverer, info, error):
try:
@@ -167,10 +165,10 @@ class Player(GObject.GObject):
@log
def _on_glib_idle(self):
- self.currentTrack = self.nextTrack
- if self.currentTrack and self.currentTrack.valid():
- self.currentTrackUri = self.playlist.get_value(
- self.playlist.get_iter(self.currentTrack.get_path()), 5).get_url()
+ self.current_track = self._next_track
+ if self.current_track and self.current_track.valid():
+ self.current_track_uri = self.playlist.get_value(
+ self.playlist.get_iter(self.current_track.get_path()), 5).get_url()
self.play()
@log
@@ -178,19 +176,19 @@ class Player(GObject.GObject):
self._sync_prev_next()
@log
- def _get_random_iter(self, currentTrack):
+ def _get_random_iter(self, current_track):
first_iter = self.playlist.get_iter_first()
- if not currentTrack:
- currentTrack = first_iter
- if not currentTrack:
+ if not current_track:
+ current_track = first_iter
+ if not current_track:
return None
if hasattr(self.playlist, "iter_is_valid") and\
- not self.playlist.iter_is_valid(currentTrack):
+ not self.playlist.iter_is_valid(current_track):
return None
- currentPath = int(self.playlist.get_path(currentTrack).to_string())
+ currentPath = int(self.playlist.get_path(current_track).to_string())
rows = self.playlist.iter_n_children(None)
if rows == 1:
- return currentTrack
+ return current_track
rand = currentPath
while rand == currentPath:
rand = randint(0, rows - 1)
@@ -198,33 +196,33 @@ class Player(GObject.GObject):
@log
def _get_next_track(self):
- if self.currentTrack and self.currentTrack.valid():
- currentTrack = self.playlist.get_iter(self.currentTrack.get_path())
+ if self.current_track and self.current_track.valid():
+ current_track = self.playlist.get_iter(self.current_track.get_path())
else:
- currentTrack = None
+ current_track = None
- nextTrack = None
+ next_track = None
if self.repeat == RepeatType.SONG:
- if currentTrack:
- nextTrack = currentTrack
+ if current_track:
+ next_track = current_track
else:
- nextTrack = self.playlist.get_iter_first()
+ next_track = self.playlist.get_iter_first()
elif self.repeat == RepeatType.ALL:
- if currentTrack:
- nextTrack = self.playlist.iter_next(currentTrack)
- if not nextTrack:
- nextTrack = self.playlist.get_iter_first()
+ if current_track:
+ next_track = self.playlist.iter_next(current_track)
+ if not next_track:
+ next_track = self.playlist.get_iter_first()
elif self.repeat == RepeatType.NONE:
- if currentTrack:
- nextTrack = self.playlist.iter_next(currentTrack)
+ if current_track:
+ next_track = self.playlist.iter_next(current_track)
elif self.repeat == RepeatType.SHUFFLE:
- nextTrack = self._get_random_iter(currentTrack)
- if currentTrack:
- self.shuffleHistory.append(currentTrack)
+ next_track = self._get_random_iter(current_track)
+ if current_track:
+ self.shuffleHistory.append(current_track)
- if nextTrack:
- return Gtk.TreeRowReference.new(self.playlist, self.playlist.get_path(nextTrack))
+ if next_track:
+ return Gtk.TreeRowReference.new(self.playlist, self.playlist.get_path(next_track))
else:
return None
@@ -241,39 +239,39 @@ class Player(GObject.GObject):
@log
def _get_previous_track(self):
- if self.currentTrack and self.currentTrack.valid():
- currentTrack = self.playlist.get_iter(self.currentTrack.get_path())
+ if self.current_track and self.current_track.valid():
+ current_track = self.playlist.get_iter(self.current_track.get_path())
else:
- currentTrack = None
+ current_track = None
previousTrack = None
if self.repeat == RepeatType.SONG:
- if currentTrack:
- previousTrack = currentTrack
+ if current_track:
+ previousTrack = current_track
else:
previousTrack = self.playlist.get_iter_first()
elif self.repeat == RepeatType.ALL:
- if currentTrack:
- previousTrack = self.playlist.iter_previous(currentTrack)
+ if current_track:
+ previousTrack = self.playlist.iter_previous(current_track)
if not previousTrack:
previousTrack = self._get_iter_last()
elif self.repeat == RepeatType.NONE:
- if currentTrack:
- previousTrack = self.playlist.iter_previous(currentTrack)
+ if current_track:
+ previousTrack = self.playlist.iter_previous(current_track)
elif self.repeat == RepeatType.SHUFFLE:
- if currentTrack:
+ if current_track:
if self.played_seconds < 10 and len(self.shuffleHistory) > 0:
previousTrack = self.shuffleHistory.pop()
# Discard the current song, which is already queued
- if self.playlist.get_path(previousTrack) == self.playlist.get_path(currentTrack):
+ if self.playlist.get_path(previousTrack) == self.playlist.get_path(current_track):
previousTrack = None
if previousTrack is None and len(self.shuffleHistory) > 0:
previousTrack = self.shuffleHistory.pop()
else:
- previousTrack = self._get_random_iter(currentTrack)
+ previousTrack = self._get_random_iter(current_track)
if previousTrack:
return Gtk.TreeRowReference.new(self.playlist, self.playlist.get_path(previousTrack))
@@ -284,12 +282,12 @@ class Player(GObject.GObject):
def has_next(self):
if not self.playlist or self.playlist.iter_n_children(None) < 1:
return False
- elif not self.currentTrack:
+ elif not self.current_track:
return False
elif self.repeat in [RepeatType.ALL, RepeatType.SONG, RepeatType.SHUFFLE]:
return True
- elif self.currentTrack.valid():
- tmp = self.playlist.get_iter(self.currentTrack.get_path())
+ elif self.current_track.valid():
+ tmp = self.playlist.get_iter(self.current_track.get_path())
return self.playlist.iter_next(tmp) is not None
else:
return True
@@ -298,12 +296,12 @@ class Player(GObject.GObject):
def has_previous(self):
if not self.playlist or self.playlist.iter_n_children(None) < 1:
return False
- elif not self.currentTrack:
+ elif not self.current_track:
return False
elif self.repeat in [RepeatType.ALL, RepeatType.SONG, RepeatType.SHUFFLE]:
return True
- elif self.currentTrack.valid():
- tmp = self.playlist.get_iter(self.currentTrack.get_path())
+ elif self.current_track.valid():
+ tmp = self.playlist.get_iter(self.current_track.get_path())
return self.playlist.iter_previous(tmp) is not None
else:
return True
@@ -378,9 +376,9 @@ class Player(GObject.GObject):
if url_ != self._player.url:
self._player.url = url_
- if self.currentTrack and self.currentTrack.valid():
- currentTrack = self.playlist.get_iter(self.currentTrack.get_path())
- self.emit('playlist-item-changed', self.playlist, currentTrack)
+ if self.current_track and self.current_track.valid():
+ current_track = self.playlist.get_iter(self.current_track.get_path())
+ self.emit('playlist-item-changed', self.playlist, current_track)
self.emit('current-changed')
self._validate_next_track()
@@ -389,24 +387,24 @@ class Player(GObject.GObject):
if error:
print("Info %s: error: %s" % (info, error))
self.playlist.set_value(_iter, self.discovery_status_field, DiscoveryStatus.FAILED)
- nextTrack = self.playlist.iter_next(_iter)
+ next_track = self.playlist.iter_next(_iter)
- if nextTrack:
- self._validate_next_track(Gtk.TreeRowReference.new(self.playlist,
self.playlist.get_path(nextTrack)))
+ if next_track:
+ self._validate_next_track(Gtk.TreeRowReference.new(self.playlist,
self.playlist.get_path(next_track)))
@log
def _validate_next_track(self, track=None):
if track is None:
track = self._get_next_track()
- self.nextTrack = track
+ self._next_track = track
if track is None:
return
- iter_ = self.playlist.get_iter(self.nextTrack.get_path())
+ iter_ = self.playlist.get_iter(self._next_track.get_path())
status = self.playlist.get_value(iter_, self.discovery_status_field)
- nextSong = self.playlist.get_value(iter_, self.playlistField)
+ nextSong = self.playlist.get_value(iter_, self.playlist_field)
url_ = self.playlist[iter_][5].get_url()
# Skip remote songs discovery
@@ -426,7 +424,7 @@ class Player(GObject.GObject):
@log
def _on_eos(self, klass):
- if self.nextTrack:
+ if self._next_track:
GLib.idle_add(self._on_glib_idle)
elif (self.repeat == RepeatType.NONE):
self.stop()
@@ -434,13 +432,13 @@ class Player(GObject.GObject):
self._progress_scale_zero()
self.progressScale.set_sensitive(False)
if self.playlist is not None:
- currentTrack = self.playlist.get_path(self.playlist.get_iter_first())
- if currentTrack:
- self.currentTrack = Gtk.TreeRowReference.new(self.playlist, currentTrack)
- self.currentTrackUri = self.playlist.get_value(
- self.playlist.get_iter(self.currentTrack.get_path()), 5).get_url()
+ current_track = self.playlist.get_path(self.playlist.get_iter_first())
+ if current_track:
+ self.current_track = Gtk.TreeRowReference.new(self.playlist, current_track)
+ self.current_track_uri = self.playlist.get_value(
+ self.playlist.get_iter(self.current_track.get_path()), 5).get_url()
else:
- self.currentTrack = None
+ self.current_track = None
self.load(self.get_current_media())
self.emit('playback-status-changed')
else:
@@ -501,11 +499,11 @@ class Player(GObject.GObject):
return True
self.stop()
- self.currentTrack = self.nextTrack
+ self.current_track = self._next_track
- if self.currentTrack and self.currentTrack.valid():
- self.currentTrackUri = self.playlist.get_value(
- self.playlist.get_iter(self.currentTrack.get_path()), 5).get_url()
+ if self.current_track and self.current_track.valid():
+ self.current_track_uri = self.playlist.get_value(
+ self.playlist.get_iter(self.current_track.get_path()), 5).get_url()
self.play()
@log
@@ -524,10 +522,10 @@ class Player(GObject.GObject):
self.stop()
- self.currentTrack = self._get_previous_track()
- if self.currentTrack and self.currentTrack.valid():
- self.currentTrackUri = self.playlist.get_value(
- self.playlist.get_iter(self.currentTrack.get_path()), 5).get_url()
+ self.current_track = self._get_previous_track()
+ if self.current_track and self.current_track.valid():
+ self.current_track_uri = self.playlist.get_value(
+ self.playlist.get_iter(self.current_track.get_path()), 5).get_url()
self.play()
@log
@@ -550,13 +548,13 @@ class Player(GObject.GObject):
if self.playlist_delete_handler:
old_playlist.disconnect(self.playlist_delete_handler)
- self.playlistType = type
- self.playlistId = id
- self.currentTrack = Gtk.TreeRowReference.new(model, model.get_path(iter))
- if self.currentTrack and self.currentTrack.valid():
- self.currentTrackUri = self.playlist.get_value(
- self.playlist.get_iter(self.currentTrack.get_path()), 5).get_url()
- self.playlistField = field
+ self.playlist_type = type
+ self.playlist_id = id
+ self.current_track = Gtk.TreeRowReference.new(model, model.get_path(iter))
+ if self.current_track and self.current_track.valid():
+ self.current_track_uri = self.playlist.get_value(
+ self.playlist.get_iter(self.current_track.get_path()), 5).get_url()
+ self.playlist_field = field
self.discovery_status_field = discovery_status_field
if old_playlist != model:
@@ -569,7 +567,7 @@ class Player(GObject.GObject):
@log
def running_playlist(self, type, id):
- if type == self.playlistType and id == self.playlistId:
+ if type == self.playlist_type and id == self.playlist_id:
return self.playlist
else:
return None
@@ -866,12 +864,12 @@ class Player(GObject.GObject):
@log
def get_current_media(self):
- if not self.currentTrack or not self.currentTrack.valid():
+ if not self.current_track or not self.current_track.valid():
return None
- currentTrack = self.playlist.get_iter(self.currentTrack.get_path())
- if self.playlist.get_value(currentTrack, self.discovery_status_field) == DiscoveryStatus.FAILED:
+ current_track = self.playlist.get_iter(self.current_track.get_path())
+ if self.playlist.get_value(current_track, self.discovery_status_field) == DiscoveryStatus.FAILED:
return None
- return self.playlist.get_value(currentTrack, self.playlistField)
+ return self.playlist.get_value(current_track, self.playlist_field)
class SelectionToolbar():
diff --git a/gnomemusic/views/baseview.py b/gnomemusic/views/baseview.py
index fb14d70..695e2e2 100644
--- a/gnomemusic/views/baseview.py
+++ b/gnomemusic/views/baseview.py
@@ -147,7 +147,7 @@ class BaseView(Gtk.Stack):
select_toolbar._add_to_playlist_button.set_sensitive(False)
else:
self._header_bar.set_selection_mode(False)
- track_playing = self.player.currentTrack is not None
+ track_playing = self.player.current_track is not None
self.player.actionbar.set_visible(track_playing)
self._selection_toolbar.actionbar.set_visible(False)
self.unselect_all()
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index 015aac6..7883edb 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -241,7 +241,7 @@ class PlaylistView(BaseView):
cell.set_property('text', utils.get_album_title(item))
def _on_list_widget_icon_render(self, col, cell, model, _iter, data):
- if not self.player.currentTrackUri:
+ if not self.player.current_track_uri:
cell.set_visible(False)
return
@@ -251,7 +251,7 @@ class PlaylistView(BaseView):
if model[_iter][11] == DiscoveryStatus.FAILED:
cell.set_property('icon-name', self._error_icon_name)
cell.set_visible(True)
- elif model[_iter][5].get_url() == self.player.currentTrackUri:
+ elif model[_iter][5].get_url() == self.player.current_track_uri:
cell.set_property('icon-name', self._now_playing_icon_name)
cell.set_visible(True)
else:
@@ -408,7 +408,7 @@ class PlaylistView(BaseView):
return
# If playing song position has changed, update player's playlist.
- if self.player.playing and not self.player.currentTrack.valid():
+ if self.player.playing and not self.player.current_track.valid():
pos = new_pos
if new_pos > prev_pos:
pos -= 1
@@ -773,9 +773,9 @@ class PlaylistView(BaseView):
def _row_is_playing(self, playlist, row):
"""Check if row is being played"""
if (self._is_current_playlist(playlist)
- and self.player.currentTrack is not None
- and self.player.currentTrack.valid()):
- track_path = self.player.currentTrack.get_path()
+ and self.player.current_track is not None
+ and self.player.current_track.valid()):
+ track_path = self.player.current_track.get_path()
track_path_str = track_path.to_string()
if (row.path is not None
and row.path.to_string() == track_path_str):
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index e52a87d..33d909d 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -219,7 +219,7 @@ class SongsView(BaseView):
cell.set_property('text', utils.get_album_title(item))
def _on_list_widget_icon_render(self, col, cell, model, itr, data):
- track_uri = self.player.currentTrackUri
+ track_uri = self.player.current_track_uri
if not track_uri:
cell.set_visible(False)
return
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]