added key binding to 'SearchWindow' and 'AlbumDialog'

This commit is contained in:
Martin Wagner 2020-03-30 18:18:43 +02:00
parent 16a8909d98
commit 8a51014fdd

View File

@ -889,6 +889,7 @@ class AlbumDialog(Gtk.Dialog):
#connect #connect
self.treeview.connect("row-activated", self.on_row_activated) self.treeview.connect("row-activated", self.on_row_activated)
self.treeview.connect("button-press-event", self.on_button_press_event) self.treeview.connect("button-press-event", self.on_button_press_event)
self.key_press_event=self.treeview.connect("key-press-event", self.on_key_press_event)
#packing #packing
scroll.add(self.treeview) scroll.add(self.treeview)
@ -909,6 +910,14 @@ class AlbumDialog(Gtk.Dialog):
except: except:
pass pass
def on_key_press_event(self, widget, event):
self.treeview.handler_block(self.key_press_event)
if event.keyval == 43 or event.keyval == 65451: #+
treeview, treeiter=self.selection.get_selected()
if not treeiter == None:
self.client.add(self.store.get_value(treeiter, 4))
self.treeview.handler_unblock(self.key_press_event)
def populate_treeview(self, album, artist, year): def populate_treeview(self, album, artist, year):
songs=self.client.find("album", album, "date", year, self.settings.get_artist_type(), artist) songs=self.client.find("album", album, "date", year, self.settings.get_artist_type(), artist)
if not songs == []: if not songs == []:
@ -2739,6 +2748,7 @@ class SearchWindow(Gtk.Window):
#connect #connect
self.treeview.connect("row-activated", self.on_row_activated) self.treeview.connect("row-activated", self.on_row_activated)
self.treeview.connect("button-press-event", self.on_button_press_event) self.treeview.connect("button-press-event", self.on_button_press_event)
self.key_press_event=self.treeview.connect("key-press-event", self.on_key_press_event)
self.search_entry.connect("search-changed", self.on_search_changed) self.search_entry.connect("search-changed", self.on_search_changed)
#packing #packing
@ -2766,6 +2776,14 @@ class SearchWindow(Gtk.Window):
except: except:
pass pass
def on_key_press_event(self, widget, event):
self.treeview.handler_block(self.key_press_event)
if event.keyval == 43 or event.keyval == 65451: #+
treeview, treeiter=self.selection.get_selected()
if not treeiter == None:
self.client.add(self.store.get_value(treeiter, 5))
self.treeview.handler_unblock(self.key_press_event)
def on_search_changed(self, widget): def on_search_changed(self, widget):
self.store.clear() self.store.clear()
for song in self.client.search("any", self.search_entry.get_text()): for song in self.client.search("any", self.search_entry.get_text()):