avoid cursor reset to show better keyboard focus

This commit is contained in:
Martin Wagner 2023-01-20 18:15:55 +01:00
parent 4c65908050
commit 1b743c96ee

View File

@ -1612,7 +1612,7 @@ class SelectionList(TreeView):
return len(self._store)-1 return len(self._store)-1
def select_path(self, path): def select_path(self, path):
self.set_cursor(path) self.set_cursor(path, None, False)
def select(self, item): def select(self, item):
row_num=len(self._store) row_num=len(self._store)
@ -2053,7 +2053,7 @@ class AlbumView(Gtk.Box):
else: else:
title_artist=f"<b>{GLib.markup_escape_text(song['title'][0])}</b> • {GLib.markup_escape_text(artist)}" title_artist=f"<b>{GLib.markup_escape_text(song['title'][0])}</b> • {GLib.markup_escape_text(artist)}"
self.songs_list.append(song["track"][0], title_artist, str(song["duration"]), song["file"], song["title"][0]) self.songs_list.append(song["track"][0], title_artist, str(song["duration"]), song["file"], song["title"][0])
self.songs_list.save_set_cursor(Gtk.TreePath(0)) self.songs_list.save_set_cursor(Gtk.TreePath(0), None, False)
self.songs_list.columns_autosize() self.songs_list.columns_autosize()
if (cover:=self._client.get_cover({"file": songs[0]["file"], "albumartist": albumartist, "album": album})) is None: if (cover:=self._client.get_cover({"file": songs[0]["file"], "albumartist": albumartist, "album": album})) is None:
size=self._settings.get_int("album-cover")*1.5 size=self._settings.get_int("album-cover")*1.5
@ -2259,11 +2259,10 @@ class PlaylistView(TreeView):
self._store.remove(self._store.get_iter(path)) self._store.remove(self._store.get_iter(path))
def _scroll_to_path(self, path): def _scroll_to_path(self, path):
self.set_cursor(path, None, False)
self.save_scroll_to_cell(path, None, True, 0.25) self.save_scroll_to_cell(path, None, True, 0.25)
def _refresh_selection(self): # Gtk.TreePath(len(self._store) is used to generate an invalid TreePath (needed to unset cursor) def _refresh_selection(self):
if not self._menu.get_visible():
self.set_cursor(Gtk.TreePath(len(self._store)), None, False)
song=self._client.status().get("song") song=self._client.status().get("song")
if song is None: if song is None:
self._unselect() self._unselect()
@ -2410,9 +2409,6 @@ class PlaylistWindow(Gtk.Overlay):
GLib.idle_add(callback) # workaround for the Gtk bug from above GLib.idle_add(callback) # workaround for the Gtk bug from above
def _on_back_to_current_song_button_clicked(self, *args): def _on_back_to_current_song_button_clicked(self, *args):
self._treeview.set_cursor(Gtk.TreePath(len(self._treeview.get_model())), None, False) # unset cursor
if self._treeview.get_property("selected-path") is not None:
self._treeview.get_selection().select_path(self._treeview.get_property("selected-path"))
self._treeview.scroll_to_selected_title() self._treeview.scroll_to_selected_title()
#################### ####################