[gnome-music/wip/jfelder/playlistscontrols-cleanup: 1/2] playlistcontrols: Simplify playlist rename calls



commit d0aa1995fcbf7e9b5c5a8e121a8be53677e1af75
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Feb 26 21:00:10 2020 +0100

    playlistcontrols: Simplify playlist rename calls
    
    Everything can be done with only one function.

 gnomemusic/widgets/playlistcontrols.py | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
---
diff --git a/gnomemusic/widgets/playlistcontrols.py b/gnomemusic/widgets/playlistcontrols.py
index f3a9bb81..78ed7a7e 100644
--- a/gnomemusic/widgets/playlistcontrols.py
+++ b/gnomemusic/widgets/playlistcontrols.py
@@ -57,7 +57,7 @@ class PlaylistControls(Gtk.Grid):
         self._play_action = Gio.SimpleAction.new("playlist_play", None)
 
         self._rename_action = Gio.SimpleAction.new("playlist_rename", None)
-        self._rename_action.connect("activate", self._on_rename_action)
+        self._rename_action.connect("activate", self._enable_rename_playlist)
 
     # FIXME: This is a workaround for not being able to pass the application
     # object via init when using Gtk.Builder.
@@ -88,9 +88,6 @@ class PlaylistControls(Gtk.Grid):
         self._window.add_action(self._play_action)
         self._window.add_action(self._rename_action)
 
-    def _on_rename_action(self, menuitem, data=None):
-        self._enable_rename_playlist(self.props.playlist)
-
     def _on_delete_action(self, menutime, data=None):
         PlaylistNotification(
             self._window.notifications_popup, self._coremodel,
@@ -131,13 +128,10 @@ class PlaylistControls(Gtk.Grid):
 
         self._play_action.props.enabled = self.props.playlist.props.count > 0
 
-    def _enable_rename_playlist(self, pl_torename):
-        """Enables rename button and entry
-
-        :param Playlist pl_torename : The playlist to rename
-        """
+    def _enable_rename_playlist(self, menuitem, data=None):
         self._name_stack.props.visible_child_name = "renaming_dialog"
-        self._set_rename_entry_text_and_focus(pl_torename.props.title)
+        self._rename_entry.props.text = self.props.playlist.props.title
+        self._rename_entry.grab_focus()
 
     def _disable_rename_playlist(self):
         """Disables rename button and entry"""
@@ -153,10 +147,6 @@ class PlaylistControls(Gtk.Grid):
 
         return self._name_stack.props.visible_child_name == "renaming_dialog"
 
-    def _set_rename_entry_text_and_focus(self, text):
-        self._rename_entry.props.text = text
-        self._rename_entry.grab_focus()
-
     @GObject.Property(
         type=Playlist, default=None, flags=GObject.ParamFlags.READWRITE)
     def playlist(self):


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