[gnome-music/wip/mschraal/window-cleanup: 3/5] window: Mark variables private
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/window-cleanup: 3/5] window: Mark variables private
- Date: Wed, 12 Sep 2018 11:56:01 +0000 (UTC)
commit a05e0aaeafbaddcc5097cae40e185a7a1221e873
Author: Marinus Schraal <mschraal gnome org>
Date: Tue Sep 4 23:20:23 2018 +0200
window: Mark variables private
gnomemusic/mpris.py | 4 +--
gnomemusic/views/baseview.py | 1 -
gnomemusic/window.py | 67 ++++++++++++++++++++++----------------------
3 files changed, 35 insertions(+), 37 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 252ca90a..97183942 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -221,7 +221,7 @@ class MediaPlayer2Service(Server):
super().__init__(self.con, '/org/mpris/MediaPlayer2')
self.app = app
- self.player = app.get_active_window().player
+ self.player = app.get_active_window()._player
self.player.connect(
'song-changed', self._on_current_song_changed)
self.player.connect('playback-status-changed', self._on_playback_status_changed)
@@ -230,7 +230,7 @@ class MediaPlayer2Service(Server):
self.player.connect('prev-next-invalidated', self._on_prev_next_invalidated)
self.player.connect('seeked', self._on_seeked)
self.player.connect('playlist-changed', self._on_playlist_changed)
- self.player_toolbar = app.get_active_window().player_toolbar
+ self.player_toolbar = app.get_active_window()._player_toolbar
self.player_toolbar.connect(
'thumbnail-updated', self._on_thumbnail_updated)
playlists = Playlists.get_default()
diff --git a/gnomemusic/views/baseview.py b/gnomemusic/views/baseview.py
index d47a9cc2..91f94f3a 100644
--- a/gnomemusic/views/baseview.py
+++ b/gnomemusic/views/baseview.py
@@ -81,7 +81,6 @@ class BaseView(Gtk.Stack):
self._star_handler = StarHandlerWidget(self, 9)
self._window = window
self._headerbar = window._headerbar
- self._selection_toolbar = window.selection_toolbar
self.name = name
self.title = title
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index b4a4f314..12b6564f 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -90,7 +90,7 @@ class Window(Gtk.ApplicationWindow):
self.notifications_popup = NotificationsPopup()
self._overlay.add_overlay(self.notifications_popup)
- MediaKeys(self.player, self)
+ MediaKeys(self._player, self)
grilo.connect('changes-pending', self._on_changes_pending)
@@ -121,9 +121,9 @@ class Window(Gtk.ApplicationWindow):
self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self._headerbar = HeaderBar()
self._searchbar = Searchbar()
- self.player = Player(self)
- self.player_toolbar = PlayerToolbar(self.player, self)
- self.selection_toolbar = SelectionToolbar()
+ self._player = Player(self)
+ self._player_toolbar = PlayerToolbar(self._player, self)
+ selection_toolbar = SelectionToolbar()
self.views = [None] * len(View)
self._stack = Gtk.Stack(
transition_type=Gtk.StackTransitionType.CROSSFADE,
@@ -144,14 +144,13 @@ class Window(Gtk.ApplicationWindow):
self.bind_property(
'selected-items-count', self._headerbar, 'selected-items-count')
self.bind_property(
- 'selected-items-count', self.selection_toolbar,
- 'selected-items-count')
+ 'selected-items-count', selection_toolbar, 'selected-items-count')
self.bind_property(
'selection-mode', self._headerbar, 'selection-mode',
GObject.BindingFlags.BIDIRECTIONAL |
GObject.BindingFlags.SYNC_CREATE)
self.bind_property(
- 'selection-mode', self.selection_toolbar, 'visible',
+ 'selection-mode', selection_toolbar, 'visible',
GObject.BindingFlags.SYNC_CREATE)
# Create only the empty view at startup
# if no music, switch to empty view and hide stack
@@ -171,19 +170,19 @@ class Window(Gtk.ApplicationWindow):
self.set_titlebar(self._headerbar)
self._box.pack_start(self._searchbar, False, False, 0)
self._box.pack_start(self._overlay, True, True, 0)
- self._box.pack_start(self.player_toolbar, False, False, 0)
- self._box.pack_start(self.selection_toolbar, False, False, 0)
+ self._box.pack_start(self._player_toolbar, False, False, 0)
+ self._box.pack_start(selection_toolbar, False, False, 0)
self.add(self._box)
self._headerbar._search_button.connect(
'toggled', self._on_search_toggled)
- self.selection_toolbar.connect(
+ selection_toolbar.connect(
'add-to-playlist', self._on_add_to_playlist)
self._headerbar.props.state = HeaderBar.State.MAIN
self._headerbar.show()
self._overlay.show()
- self.player_toolbar.show_all()
+ self._player_toolbar.show_all()
self._box.show()
self.show()
@@ -239,11 +238,11 @@ class Window(Gtk.ApplicationWindow):
self._headerbar.props.stack = self._stack
self._searchbar.show()
- self.views[View.ALBUM] = AlbumsView(self, self.player)
- self.views[View.ARTIST] = ArtistsView(self, self.player)
- self.views[View.SONG] = SongsView(self, self.player)
- self.views[View.PLAYLIST] = PlaylistView(self, self.player)
- self.views[View.SEARCH] = SearchView(self, self.player)
+ self.views[View.ALBUM] = AlbumsView(self, self._player)
+ self.views[View.ARTIST] = ArtistsView(self, self._player)
+ self.views[View.SONG] = SongsView(self, self._player)
+ self.views[View.PLAYLIST] = PlaylistView(self, self._player)
+ self.views[View.SEARCH] = SearchView(self, self._player)
selectable_views = [View.ALBUM, View.ARTIST, View.SONG, View.SEARCH]
for view in selectable_views:
@@ -305,25 +304,25 @@ class Window(Gtk.ApplicationWindow):
self._searchbar.toggle()
# Play / Pause on Ctrl + SPACE
if keyval == Gdk.KEY_space:
- self.player.play_pause()
+ self._player.play_pause()
# Play previous on Ctrl + B
if keyval == Gdk.KEY_b:
- self.player.previous()
+ self._player.previous()
# Play next on Ctrl + N
if keyval == Gdk.KEY_n:
- self.player.next()
+ self._player.next()
# Toggle repeat on Ctrl + R
if keyval == Gdk.KEY_r:
- if self.player.props.repeat_mode == RepeatMode.SONG:
- self.player.props.repeat_mode = RepeatMode.NONE
+ if self._player.props.repeat_mode == RepeatMode.SONG:
+ self._player.props.repeat_mode = RepeatMode.NONE
else:
- self.player.props.repeat_mode = RepeatMode.SONG
+ self._player.props.repeat_mode = RepeatMode.SONG
# Toggle shuffle on Ctrl + S
if keyval == Gdk.KEY_s:
- if self.player.props.repeat_mode == RepeatMode.SHUFFLE:
- self.player.props.repeat_mode = RepeatMode.NONE
+ if self._player.props.repeat_mode == RepeatMode.SHUFFLE:
+ self._player.props.repeat_mode = RepeatMode.NONE
else:
- self.player.props.repeat_mode = RepeatMode.SHUFFLE
+ self._player.props.repeat_mode = RepeatMode.SHUFFLE
# Ctrl+Shift+<KEY>
elif modifiers == shift_ctrl_mask:
if keyval == Gdk.KEY_A:
@@ -346,16 +345,16 @@ class Window(Gtk.ApplicationWindow):
else:
if (keyval == Gdk.KEY_AudioPlay
or keyval == Gdk.KEY_AudioPause):
- self.player.play_pause()
+ self._player.play_pause()
if keyval == Gdk.KEY_AudioStop:
- self.player.stop()
+ self._player.stop()
if keyval == Gdk.KEY_AudioPrev:
- self.player.previous()
+ self._player.previous()
if keyval == Gdk.KEY_AudioNext:
- self.player.next()
+ self._player.next()
child = self._stack.get_visible_child()
if (keyval == Gdk.KEY_Delete
@@ -392,7 +391,7 @@ class Window(Gtk.ApplicationWindow):
@log
def _notify_mode_disconnect(self, data=None):
- self.player.stop()
+ self._player.stop()
self.notifications_popup.terminate_pending()
self._stack.disconnect(self._on_notify_model_id)
@@ -475,9 +474,9 @@ class Window(Gtk.ApplicationWindow):
@log
def _on_selection_mode_changed(self, widget, data=None):
if self.props.selection_mode:
- self.player_toolbar.hide()
- elif self.player.props.playing:
- self.player_toolbar.show()
+ self._player_toolbar.hide()
+ elif self._player.props.playing:
+ self._player_toolbar.show()
if not self.props.selection_mode:
self._on_changes_pending()
@@ -506,4 +505,4 @@ class Window(Gtk.ApplicationWindow):
:param bool visible: actionbar visibility
"""
- self.player_toolbar.set_visible(visible)
+ self._player_toolbar.set_visible(visible)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]