[gnome-music] playlistview: Add ESC key binding to cancel rename



commit 2165bb85f8ab7b31e790428f5ba7d98c7c16b459
Author: aswinmohanme <git aswinmohan gmail com>
Date:   Mon May 14 10:35:54 2018 +0530

    playlistview: Add ESC key binding to cancel rename
    
    Currently pressing ESC inside playlist rename entry does not cancel the
    rename action.
    
    Add a key-press-event handler to Rename GtkEntry
    which matches the entered key with ESC. If it matches then the
    rename action is cancelled.
    
    Closes #188

 gnomemusic/views/playlistview.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index a68a0bc5..b3269207 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -23,7 +23,7 @@
 # delete this exception statement from your version.
 
 from gettext import gettext as _, ngettext
-from gi.repository import Gio, GLib, GObject, Gtk, Pango
+from gi.repository import Gio, GLib, GObject, Gtk, Gdk, Pango
 
 from gnomemusic import log
 from gnomemusic.grilo import grilo
@@ -76,6 +76,8 @@ class PlaylistView(BaseView):
         self._name_label = builder.get_object('playlist_name')
         self._rename_entry = builder.get_object('playlist_rename_entry')
         self._rename_entry.connect('changed', self._on_rename_entry_changed)
+        self._rename_entry.connect(
+            'key-press-event', self._on_rename_entry_key_pressed)
         self._rename_done_button = builder.get_object(
             'playlist_rename_done_button')
         self._songs_count_label = builder.get_object('songs_count')
@@ -744,6 +746,11 @@ class PlaylistView(BaseView):
     def _on_rename_entry_changed(self, selection):
         self._rename_done_button.set_sensitive(selection.get_text_length() > 0)
 
+    @log
+    def _on_rename_entry_key_pressed(self, widget, event):
+        if event.keyval == Gdk.KEY_Escape:
+            self.disable_rename_playlist()
+
     @log
     def disable_rename_playlist(self):
         """disables rename button and entry"""


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