Fixed issues with selection on albums list

This commit is contained in:
Sumner Evans
2019-08-29 17:14:19 -06:00
parent fc94557f2c
commit 86a0f9f6dc

View File

@@ -193,9 +193,7 @@ class CoverArtGrid(Gtk.ScrolledWindow):
else: else:
top_diff = len(self.list_store_top) - entries_before_fold top_diff = len(self.list_store_top) - entries_before_fold
if top_diff == 0: if top_diff < 0:
return
elif top_diff < 0:
# Move entries from the bottom store. # Move entries from the bottom store.
for e in self.list_store_bottom[:-top_diff]: for e in self.list_store_bottom[:-top_diff]:
self.list_store_top.append(e) self.list_store_top.append(e)
@@ -210,10 +208,14 @@ class CoverArtGrid(Gtk.ScrolledWindow):
for _ in range(top_diff): for _ in range(top_diff):
del self.list_store_top[-1] del self.list_store_top[-1]
if self.selected_list_store_index: if self.selected_list_store_index is not None:
self.grid_top.select_child( self.grid_top.select_child(
self.grid_top.get_child_at_index( self.grid_top.get_child_at_index(
self.selected_list_store_index)) self.selected_list_store_index))
self.detail_box.show_all()
else:
self.grid_top.unselect_all()
self.detail_box.hide()
# Virtual Methods # Virtual Methods
# ========================================================================= # =========================================================================
@@ -246,8 +248,13 @@ class CoverArtGrid(Gtk.ScrolledWindow):
# ========================================================================= # =========================================================================
def on_child_activated(self, flowbox, child): def on_child_activated(self, flowbox, child):
click_top = flowbox == self.grid_top click_top = flowbox == self.grid_top
self.selected_list_store_index = ( selected = (child.get_index() +
child.get_index() + (0 if click_top else len(self.list_store_top))) (0 if click_top else len(self.list_store_top)))
if selected == self.selected_list_store_index:
self.selected_list_store_index = None
else:
self.selected_list_store_index = selected
self.reflow_grids() self.reflow_grids()