[gnome-music/wip/mschraal/playlistcontrols-actions-rework: 9/10] playlistcontrols: Move rename actions here
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/playlistcontrols-actions-rework: 9/10] playlistcontrols: Move rename actions here
- Date: Sun, 5 Jan 2020 00:01:33 +0000 (UTC)
commit 8b51f1e832c47876ff53cfcfd583450b4bd368e3
Author: Marinus Schraal <mschraal gnome org>
Date: Sat Jan 4 00:09:18 2020 +0100
playlistcontrols: Move rename actions here
Moved from PlaylistsView.
gnomemusic/views/playlistsview.py | 18 ------------------
gnomemusic/widgets/playlistcontrols.py | 28 ++++++++++++----------------
2 files changed, 12 insertions(+), 34 deletions(-)
---
diff --git a/gnomemusic/views/playlistsview.py b/gnomemusic/views/playlistsview.py
index bc133426..a37c0e25 100644
--- a/gnomemusic/views/playlistsview.py
+++ b/gnomemusic/views/playlistsview.py
@@ -90,8 +90,6 @@ class PlaylistsView(BaseView):
self._playlist_rename_action = Gio.SimpleAction.new(
'playlist_rename', None)
- self._playlist_rename_action.connect(
- 'activate', self._stage_playlist_for_renaming)
self._window.add_action(self._playlist_rename_action)
self._pl_ctrls = PlaylistControls(application)
@@ -208,15 +206,11 @@ class PlaylistsView(BaseView):
"""Update view with content from selected playlist"""
playlist = row.props.playlist
- if self.rename_active:
- self._pl_ctrls.disable_rename_playlist()
-
self._view.bind_model(
playlist.props.model, self._create_song_widget, playlist)
self._pl_ctrls.props.playlist = playlist
- self._playlist_rename_action.set_enabled(not playlist.props.is_smart)
self._playlist_delete_action.set_enabled(not playlist.props.is_smart)
self._remove_song_action.set_enabled(not playlist.props.is_smart)
@@ -302,18 +296,6 @@ class PlaylistsView(BaseView):
"""Indicate if renaming dialog is active"""
return self._pl_ctrls.props.rename_active
- @log
- def _stage_playlist_for_renaming(self, menuitem, data=None):
- selection = self._sidebar.get_selected_row()
- pl_torename = selection.props.playlist
- self._pl_ctrls.enable_rename_playlist(pl_torename)
-
- @log
- def _on_playlist_renamed(self, arguments, new_name):
- selection = self._sidebar.get_selected_row()
- pl_torename = selection.props.playlist
- pl_torename.rename(new_name)
-
@log
def _stage_playlist_for_deletion(self, menutime, data=None):
selected_row = self._sidebar.get_selected_row()
diff --git a/gnomemusic/widgets/playlistcontrols.py b/gnomemusic/widgets/playlistcontrols.py
index c4f915b6..a6f12de4 100644
--- a/gnomemusic/widgets/playlistcontrols.py
+++ b/gnomemusic/widgets/playlistcontrols.py
@@ -55,6 +55,11 @@ class PlaylistControls(Gtk.Grid):
self._window = application.props.window
self._play_action = self._window.lookup_action("playlist_play")
+ self._rename_action = self._window.lookup_action("playlist_rename")
+ self._rename_action.connect("activate", self._on_rename_action)
+
+ def _on_rename_action(self, menuitem, data=None):
+ self._enable_rename_playlist(self.props.playlist)
@Gtk.Template.Callback()
@log
@@ -67,7 +72,7 @@ class PlaylistControls(Gtk.Grid):
def _on_rename_entry_key_pressed(self, widget, event):
(_, keyval) = event.get_keyval()
if keyval == Gdk.KEY_Escape:
- self.disable_rename_playlist()
+ self._disable_rename_playlist()
@Gtk.Template.Callback()
@log
@@ -78,7 +83,7 @@ class PlaylistControls(Gtk.Grid):
return
self.props.playlist.props.title = new_name
- self.disable_rename_playlist()
+ self._disable_rename_playlist()
@log
def _on_songs_count_changed(self, klass, data=None):
@@ -88,17 +93,15 @@ class PlaylistControls(Gtk.Grid):
self._play_action.props.enabled = self.props.playlist.props.count > 0
- @log
- def enable_rename_playlist(self, pl_torename):
+ def _enable_rename_playlist(self, pl_torename):
"""Enables rename button and entry
- :param Grl.Media pl_torename : The playlist to rename
+ :param Playlist pl_torename : The playlist to rename
"""
self._name_stack.props.visible_child_name = "renaming_dialog"
self._set_rename_entry_text_and_focus(pl_torename.props.title)
- @log
- def disable_rename_playlist(self):
+ def _disable_rename_playlist(self):
"""Disables rename button and entry"""
self._name_stack.props.visible_child = self._name_label
@@ -112,15 +115,6 @@ class PlaylistControls(Gtk.Grid):
return self._name_stack.props.visible_child_name == "renaming_dialog"
- @GObject.Property
- def rename_entry_text(self):
- """Gets the value of the rename entry input
-
- :return: Contents of rename entry field
- :rtype: string
- """
- return self._rename_entry.props.text
-
@log
def _set_rename_entry_text_and_focus(self, text):
self._rename_entry.props.text = text
@@ -148,6 +142,8 @@ class PlaylistControls(Gtk.Grid):
self._binding_count.unbind()
self._playlist = new_playlist
+ self._disable_rename_playlist()
+ self._rename_action.props.enabled = not self._playlist.props.is_smart
self._binding_count = self._playlist.bind_property(
"title", self._name_label, "label",
GObject.BindingFlags.SYNC_CREATE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]