Run black on entire project
This commit is contained in:
@@ -2,7 +2,8 @@ import datetime
|
||||
from typing import Any, Callable, Iterable, Optional, Tuple, Union
|
||||
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gdk, Gio, GLib, GObject, Gtk, Pango
|
||||
|
||||
from sublime.cache_manager import CacheManager
|
||||
@@ -16,12 +17,12 @@ Album = Union[Child, AlbumWithSongsID3]
|
||||
|
||||
class AlbumsPanel(Gtk.Box):
|
||||
__gsignals__ = {
|
||||
'song-clicked': (
|
||||
"song-clicked": (
|
||||
GObject.SignalFlags.RUN_FIRST,
|
||||
GObject.TYPE_NONE,
|
||||
(int, object, object),
|
||||
),
|
||||
'refresh-window': (
|
||||
"refresh-window": (
|
||||
GObject.SignalFlags.RUN_FIRST,
|
||||
GObject.TYPE_NONE,
|
||||
(object, bool),
|
||||
@@ -37,18 +38,18 @@ class AlbumsPanel(Gtk.Box):
|
||||
actionbar = Gtk.ActionBar()
|
||||
|
||||
# Sort by
|
||||
actionbar.add(Gtk.Label(label='Sort'))
|
||||
actionbar.add(Gtk.Label(label="Sort"))
|
||||
self.sort_type_combo = self.make_combobox(
|
||||
(
|
||||
('random', 'randomly'),
|
||||
('byGenre', 'by genre'),
|
||||
('newest', 'by most recently added'),
|
||||
('highest', 'by highest rated'),
|
||||
('frequent', 'by most played'),
|
||||
('recent', 'by most recently played'),
|
||||
('alphabetical', 'alphabetically'),
|
||||
('starred', 'by starred only'),
|
||||
('byYear', 'by year'),
|
||||
("random", "randomly"),
|
||||
("byGenre", "by genre"),
|
||||
("newest", "by most recently added"),
|
||||
("highest", "by highest rated"),
|
||||
("frequent", "by most played"),
|
||||
("recent", "by most recently played"),
|
||||
("alphabetical", "alphabetically"),
|
||||
("starred", "by starred only"),
|
||||
("byYear", "by year"),
|
||||
),
|
||||
self.on_type_combo_changed,
|
||||
)
|
||||
@@ -56,10 +57,7 @@ class AlbumsPanel(Gtk.Box):
|
||||
|
||||
# Alphabetically how?
|
||||
self.alphabetical_type_combo = self.make_combobox(
|
||||
(
|
||||
('name', 'by album name'),
|
||||
('artist', 'by artist name'),
|
||||
),
|
||||
(("name", "by album name"), ("artist", "by artist name"),),
|
||||
self.on_alphabetical_type_change,
|
||||
)
|
||||
actionbar.pack_start(self.alphabetical_type_combo)
|
||||
@@ -70,23 +68,20 @@ class AlbumsPanel(Gtk.Box):
|
||||
|
||||
next_decade = datetime.datetime.now().year + 10
|
||||
|
||||
self.from_year_label = Gtk.Label(label='from')
|
||||
self.from_year_label = Gtk.Label(label="from")
|
||||
actionbar.pack_start(self.from_year_label)
|
||||
self.from_year_spin_button = Gtk.SpinButton.new_with_range(
|
||||
0, next_decade, 1)
|
||||
self.from_year_spin_button.connect(
|
||||
'value-changed', self.on_year_changed)
|
||||
self.from_year_spin_button = Gtk.SpinButton.new_with_range(0, next_decade, 1)
|
||||
self.from_year_spin_button.connect("value-changed", self.on_year_changed)
|
||||
actionbar.pack_start(self.from_year_spin_button)
|
||||
|
||||
self.to_year_label = Gtk.Label(label='to')
|
||||
self.to_year_label = Gtk.Label(label="to")
|
||||
actionbar.pack_start(self.to_year_label)
|
||||
self.to_year_spin_button = Gtk.SpinButton.new_with_range(
|
||||
0, next_decade, 1)
|
||||
self.to_year_spin_button.connect('value-changed', self.on_year_changed)
|
||||
self.to_year_spin_button = Gtk.SpinButton.new_with_range(0, next_decade, 1)
|
||||
self.to_year_spin_button.connect("value-changed", self.on_year_changed)
|
||||
actionbar.pack_start(self.to_year_spin_button)
|
||||
|
||||
refresh = IconButton('view-refresh-symbolic', 'Refresh list of albums')
|
||||
refresh.connect('clicked', self.on_refresh_clicked)
|
||||
refresh = IconButton("view-refresh-symbolic", "Refresh list of albums")
|
||||
refresh.connect("clicked", self.on_refresh_clicked)
|
||||
actionbar.pack_end(refresh)
|
||||
|
||||
self.add(actionbar)
|
||||
@@ -94,17 +89,16 @@ class AlbumsPanel(Gtk.Box):
|
||||
scrolled_window = Gtk.ScrolledWindow()
|
||||
self.grid = AlbumsGrid()
|
||||
self.grid.connect(
|
||||
'song-clicked',
|
||||
lambda _, *args: self.emit('song-clicked', *args),
|
||||
"song-clicked", lambda _, *args: self.emit("song-clicked", *args),
|
||||
)
|
||||
self.grid.connect('cover-clicked', self.on_grid_cover_clicked)
|
||||
self.grid.connect("cover-clicked", self.on_grid_cover_clicked)
|
||||
scrolled_window.add(self.grid)
|
||||
self.add(scrolled_window)
|
||||
|
||||
def make_combobox(
|
||||
self,
|
||||
items: Iterable[Tuple[str, str]],
|
||||
on_change: Callable[['AlbumsPanel', Gtk.ComboBox], None],
|
||||
on_change: Callable[["AlbumsPanel", Gtk.ComboBox], None],
|
||||
) -> Gtk.ComboBox:
|
||||
store = Gtk.ListStore(str, str)
|
||||
for item in items:
|
||||
@@ -112,53 +106,46 @@ class AlbumsPanel(Gtk.Box):
|
||||
|
||||
combo = Gtk.ComboBox.new_with_model(store)
|
||||
combo.set_id_column(0)
|
||||
combo.connect('changed', on_change)
|
||||
combo.connect("changed", on_change)
|
||||
|
||||
renderer_text = Gtk.CellRendererText()
|
||||
combo.pack_start(renderer_text, True)
|
||||
combo.add_attribute(renderer_text, 'text', 1)
|
||||
combo.add_attribute(renderer_text, "text", 1)
|
||||
|
||||
return combo
|
||||
|
||||
def populate_genre_combo(
|
||||
self,
|
||||
app_config: AppConfiguration,
|
||||
force: bool = False,
|
||||
self, app_config: AppConfiguration, force: bool = False,
|
||||
):
|
||||
if not CacheManager.ready():
|
||||
return
|
||||
|
||||
def get_genres_done(f: CacheManager.Result):
|
||||
try:
|
||||
new_store = [
|
||||
(genre.value, genre.value) for genre in (f.result() or [])
|
||||
]
|
||||
new_store = [(genre.value, genre.value) for genre in (f.result() or [])]
|
||||
|
||||
util.diff_song_store(self.genre_combo.get_model(), new_store)
|
||||
|
||||
current_genre_id = self.get_id(self.genre_combo)
|
||||
if current_genre_id != app_config.state.current_album_genre:
|
||||
self.genre_combo.set_active_id(
|
||||
app_config.state.current_album_genre)
|
||||
self.genre_combo.set_active_id(app_config.state.current_album_genre)
|
||||
finally:
|
||||
self.updating_query = False
|
||||
|
||||
# Never force. We invalidate the cache ourselves (force is used when
|
||||
# sort params change).
|
||||
genres_future = CacheManager.get_genres(force=False)
|
||||
genres_future.add_done_callback(
|
||||
lambda f: GLib.idle_add(get_genres_done, f))
|
||||
genres_future.add_done_callback(lambda f: GLib.idle_add(get_genres_done, f))
|
||||
|
||||
def update(self, app_config: AppConfiguration, force: bool = False):
|
||||
self.updating_query = True
|
||||
|
||||
self.sort_type_combo.set_active_id(app_config.state.current_album_sort)
|
||||
self.alphabetical_type_combo.set_active_id(
|
||||
app_config.state.current_album_alphabetical_sort)
|
||||
self.from_year_spin_button.set_value(
|
||||
app_config.state.current_album_from_year)
|
||||
self.to_year_spin_button.set_value(
|
||||
app_config.state.current_album_to_year)
|
||||
app_config.state.current_album_alphabetical_sort
|
||||
)
|
||||
self.from_year_spin_button.set_value(app_config.state.current_album_from_year)
|
||||
self.to_year_spin_button.set_value(app_config.state.current_album_to_year)
|
||||
self.populate_genre_combo(app_config, force=force)
|
||||
|
||||
# Show/hide the combo boxes.
|
||||
@@ -169,10 +156,10 @@ class AlbumsPanel(Gtk.Box):
|
||||
else:
|
||||
element.hide()
|
||||
|
||||
show_if('alphabetical', self.alphabetical_type_combo)
|
||||
show_if('byGenre', self.genre_combo)
|
||||
show_if('byYear', self.from_year_label, self.from_year_spin_button)
|
||||
show_if('byYear', self.to_year_label, self.to_year_spin_button)
|
||||
show_if("alphabetical", self.alphabetical_type_combo)
|
||||
show_if("byGenre", self.genre_combo)
|
||||
show_if("byYear", self.from_year_label, self.from_year_spin_button)
|
||||
show_if("byYear", self.to_year_label, self.to_year_spin_button)
|
||||
|
||||
self.grid.update(self.grid_order_token, app_config, force=force)
|
||||
|
||||
@@ -183,24 +170,23 @@ class AlbumsPanel(Gtk.Box):
|
||||
return None
|
||||
|
||||
def on_refresh_clicked(self, button: Any):
|
||||
self.emit('refresh-window', {}, True)
|
||||
self.emit("refresh-window", {}, True)
|
||||
|
||||
def on_type_combo_changed(self, combo: Gtk.ComboBox):
|
||||
new_active_sort = self.get_id(combo)
|
||||
self.grid_order_token = self.grid.update_params(type_=new_active_sort)
|
||||
self.emit_if_not_updating(
|
||||
'refresh-window',
|
||||
{'current_album_sort': new_active_sort},
|
||||
False,
|
||||
"refresh-window", {"current_album_sort": new_active_sort}, False,
|
||||
)
|
||||
|
||||
def on_alphabetical_type_change(self, combo: Gtk.ComboBox):
|
||||
new_active_alphabetical_sort = self.get_id(combo)
|
||||
self.grid_order_token = self.grid.update_params(
|
||||
alphabetical_type=new_active_alphabetical_sort)
|
||||
alphabetical_type=new_active_alphabetical_sort
|
||||
)
|
||||
self.emit_if_not_updating(
|
||||
'refresh-window',
|
||||
{'current_album_alphabetical_sort': new_active_alphabetical_sort},
|
||||
"refresh-window",
|
||||
{"current_album_alphabetical_sort": new_active_alphabetical_sort},
|
||||
False,
|
||||
)
|
||||
|
||||
@@ -208,9 +194,7 @@ class AlbumsPanel(Gtk.Box):
|
||||
new_active_genre = self.get_id(combo)
|
||||
self.grid_order_token = self.grid.update_params(genre=new_active_genre)
|
||||
self.emit_if_not_updating(
|
||||
'refresh-window',
|
||||
{'current_album_genre': new_active_genre},
|
||||
True,
|
||||
"refresh-window", {"current_album_genre": new_active_genre}, True,
|
||||
)
|
||||
|
||||
def on_year_changed(self, entry: Gtk.SpinButton) -> bool:
|
||||
@@ -219,25 +203,19 @@ class AlbumsPanel(Gtk.Box):
|
||||
if self.to_year_spin_button == entry:
|
||||
self.grid_order_token = self.grid.update_params(to_year=year)
|
||||
self.emit_if_not_updating(
|
||||
'refresh-window',
|
||||
{'current_album_to_year': year},
|
||||
True,
|
||||
"refresh-window", {"current_album_to_year": year}, True,
|
||||
)
|
||||
else:
|
||||
self.grid_order_token = self.grid.update_params(from_year=year)
|
||||
self.emit_if_not_updating(
|
||||
'refresh-window',
|
||||
{'current_album_from_year': year},
|
||||
True,
|
||||
"refresh-window", {"current_album_from_year": year}, True,
|
||||
)
|
||||
|
||||
return False
|
||||
|
||||
def on_grid_cover_clicked(self, grid: Any, id: str):
|
||||
self.emit(
|
||||
'refresh-window',
|
||||
{'selected_album_id': id},
|
||||
False,
|
||||
"refresh-window", {"selected_album_id": id}, False,
|
||||
)
|
||||
|
||||
def emit_if_not_updating(self, *args):
|
||||
@@ -248,23 +226,20 @@ class AlbumsPanel(Gtk.Box):
|
||||
|
||||
class AlbumsGrid(Gtk.Overlay):
|
||||
"""Defines the albums panel."""
|
||||
|
||||
__gsignals__ = {
|
||||
'song-clicked': (
|
||||
"song-clicked": (
|
||||
GObject.SignalFlags.RUN_FIRST,
|
||||
GObject.TYPE_NONE,
|
||||
(int, object, object),
|
||||
),
|
||||
'cover-clicked': (
|
||||
GObject.SignalFlags.RUN_FIRST,
|
||||
GObject.TYPE_NONE,
|
||||
(object, ),
|
||||
),
|
||||
"cover-clicked": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, (object,),),
|
||||
}
|
||||
type_: str = 'random'
|
||||
alphabetical_type: str = 'name'
|
||||
type_: str = "random"
|
||||
alphabetical_type: str = "name"
|
||||
from_year: int = 2010
|
||||
to_year: int = 2020
|
||||
genre: str = 'Rock'
|
||||
genre: str = "Rock"
|
||||
latest_applied_order_ratchet: int = 0
|
||||
order_ratchet: int = 0
|
||||
|
||||
@@ -283,20 +258,24 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
return self.album.id
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'<AlbumsGrid.AlbumModel {self.album}>'
|
||||
return f"<AlbumsGrid.AlbumModel {self.album}>"
|
||||
|
||||
def update_params(
|
||||
self,
|
||||
type_: str = None,
|
||||
alphabetical_type: str = None,
|
||||
from_year: int = None,
|
||||
to_year: int = None,
|
||||
genre: str = None,
|
||||
self,
|
||||
type_: str = None,
|
||||
alphabetical_type: str = None,
|
||||
from_year: int = None,
|
||||
to_year: int = None,
|
||||
genre: str = None,
|
||||
) -> int:
|
||||
# If there's a diff, increase the ratchet.
|
||||
if (self.type_ != type_ or self.alphabetical_type != alphabetical_type
|
||||
or self.from_year != from_year or self.to_year != to_year
|
||||
or self.genre != genre):
|
||||
if (
|
||||
self.type_ != type_
|
||||
or self.alphabetical_type != alphabetical_type
|
||||
or self.from_year != from_year
|
||||
or self.to_year != to_year
|
||||
or self.genre != genre
|
||||
):
|
||||
self.order_ratchet += 1
|
||||
self.type_ = type_ or self.type_
|
||||
self.alphabetical_type = alphabetical_type or self.alphabetical_type
|
||||
@@ -328,8 +307,8 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
halign=Gtk.Align.CENTER,
|
||||
selection_mode=Gtk.SelectionMode.SINGLE,
|
||||
)
|
||||
self.grid_top.connect('child-activated', self.on_child_activated)
|
||||
self.grid_top.connect('size-allocate', self.on_grid_resize)
|
||||
self.grid_top.connect("child-activated", self.on_child_activated)
|
||||
self.grid_top.connect("size-allocate", self.on_grid_resize)
|
||||
|
||||
self.list_store_top = Gio.ListStore()
|
||||
self.grid_top.bind_model(self.list_store_top, self.create_widget)
|
||||
@@ -357,7 +336,7 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
halign=Gtk.Align.CENTER,
|
||||
selection_mode=Gtk.SelectionMode.SINGLE,
|
||||
)
|
||||
self.grid_bottom.connect('child-activated', self.on_child_activated)
|
||||
self.grid_bottom.connect("child-activated", self.on_child_activated)
|
||||
|
||||
self.list_store_bottom = Gio.ListStore()
|
||||
self.grid_bottom.bind_model(self.list_store_bottom, self.create_widget)
|
||||
@@ -368,7 +347,7 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
self.add(scrolled_window)
|
||||
|
||||
self.spinner = Gtk.Spinner(
|
||||
name='grid-spinner',
|
||||
name="grid-spinner",
|
||||
active=True,
|
||||
halign=Gtk.Align.CENTER,
|
||||
valign=Gtk.Align.CENTER,
|
||||
@@ -376,10 +355,7 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
self.add_overlay(self.spinner)
|
||||
|
||||
def update(
|
||||
self,
|
||||
order_token: int,
|
||||
app_config: AppConfiguration,
|
||||
force: bool = False,
|
||||
self, order_token: int, app_config: AppConfiguration, force: bool = False,
|
||||
):
|
||||
if order_token < self.latest_applied_order_ratchet:
|
||||
return
|
||||
@@ -397,16 +373,13 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
|
||||
# Update the detail panel.
|
||||
children = self.detail_box_inner.get_children()
|
||||
if len(children) > 0 and hasattr(children[0], 'update'):
|
||||
if len(children) > 0 and hasattr(children[0], "update"):
|
||||
children[0].update(force=force)
|
||||
|
||||
error_dialog = None
|
||||
|
||||
def update_grid(
|
||||
self,
|
||||
order_token: int,
|
||||
force: bool = False,
|
||||
selected_id: str = None,
|
||||
self, order_token: int, force: bool = False, selected_id: str = None,
|
||||
):
|
||||
if not CacheManager.ready():
|
||||
self.spinner.hide()
|
||||
@@ -414,11 +387,8 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
|
||||
# Calculate the type.
|
||||
type_ = self.type_
|
||||
if self.type_ == 'alphabetical':
|
||||
type_ += {
|
||||
'name': 'ByName',
|
||||
'artist': 'ByArtist',
|
||||
}[self.alphabetical_type]
|
||||
if self.type_ == "alphabetical":
|
||||
type_ += {"name": "ByName", "artist": "ByArtist"}[self.alphabetical_type]
|
||||
|
||||
def do_update(f: CacheManager.Result):
|
||||
try:
|
||||
@@ -431,11 +401,12 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
transient_for=self.get_toplevel(),
|
||||
message_type=Gtk.MessageType.ERROR,
|
||||
buttons=Gtk.ButtonsType.OK,
|
||||
text='Failed to retrieve albums',
|
||||
text="Failed to retrieve albums",
|
||||
)
|
||||
self.error_dialog.format_secondary_markup(
|
||||
f'Getting albums by {type_} failed due to the following'
|
||||
f' error\n\n{e}')
|
||||
f"Getting albums by {type_} failed due to the following"
|
||||
f" error\n\n{e}"
|
||||
)
|
||||
self.error_dialog.run()
|
||||
self.error_dialog.destroy()
|
||||
self.error_dialog = None
|
||||
@@ -447,8 +418,8 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
return
|
||||
|
||||
should_reload = (
|
||||
force
|
||||
or self.latest_applied_order_ratchet < self.order_ratchet)
|
||||
force or self.latest_applied_order_ratchet < self.order_ratchet
|
||||
)
|
||||
self.latest_applied_order_ratchet = self.order_ratchet
|
||||
|
||||
self.list_store.remove_all()
|
||||
@@ -484,13 +455,14 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
# =========================================================================
|
||||
def on_child_activated(self, flowbox: Gtk.FlowBox, child: Gtk.Widget):
|
||||
click_top = flowbox == self.grid_top
|
||||
selected_index = (
|
||||
child.get_index() + (0 if click_top else len(self.list_store_top)))
|
||||
selected_index = child.get_index() + (
|
||||
0 if click_top else len(self.list_store_top)
|
||||
)
|
||||
|
||||
if click_top and selected_index == self.current_selection:
|
||||
self.emit('cover-clicked', None)
|
||||
self.emit("cover-clicked", None)
|
||||
else:
|
||||
self.emit('cover-clicked', self.list_store[selected_index].id)
|
||||
self.emit("cover-clicked", self.list_store[selected_index].id)
|
||||
|
||||
def on_grid_resize(self, flowbox: Gtk.FlowBox, rect: Gdk.Rectangle):
|
||||
# TODO (#124): this doesn't work with themes that add extra padding.
|
||||
@@ -500,22 +472,21 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
if new_items_per_row != self.items_per_row:
|
||||
self.items_per_row = min((rect.width // 230), 7)
|
||||
self.detail_box_inner.set_size_request(
|
||||
self.items_per_row * 230 - 10,
|
||||
-1,
|
||||
self.items_per_row * 230 - 10, -1,
|
||||
)
|
||||
|
||||
self.reflow_grids()
|
||||
|
||||
# Helper Methods
|
||||
# =========================================================================
|
||||
def create_widget(self, item: 'AlbumsGrid.AlbumModel') -> Gtk.Box:
|
||||
def create_widget(self, item: "AlbumsGrid.AlbumModel") -> Gtk.Box:
|
||||
widget_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
# Cover art image
|
||||
artwork = SpinnerImage(
|
||||
loading=False,
|
||||
image_name='grid-artwork',
|
||||
spinner_name='grid-artwork-spinner',
|
||||
image_name="grid-artwork",
|
||||
spinner_name="grid-artwork-spinner",
|
||||
image_size=200,
|
||||
)
|
||||
widget_box.pack_start(artwork, False, False, 0)
|
||||
@@ -532,16 +503,16 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
|
||||
# Header for the widget
|
||||
header_text = (
|
||||
item.album.title
|
||||
if isinstance(item.album, Child) else item.album.name)
|
||||
item.album.title if isinstance(item.album, Child) else item.album.name
|
||||
)
|
||||
|
||||
header_label = make_label(header_text, 'grid-header-label')
|
||||
header_label = make_label(header_text, "grid-header-label")
|
||||
widget_box.pack_start(header_label, False, False, 0)
|
||||
|
||||
# Extra info for the widget
|
||||
info_text = util.dot_join(item.album.artist, item.album.year)
|
||||
if info_text:
|
||||
info_label = make_label(info_text, 'grid-info-label')
|
||||
info_label = make_label(info_text, "grid-info-label")
|
||||
widget_box.pack_start(info_label, False, False, 0)
|
||||
|
||||
# Download the cover art.
|
||||
@@ -553,26 +524,24 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
artwork.set_loading(True)
|
||||
|
||||
cover_art_filename_future = CacheManager.get_cover_art_filename(
|
||||
item.album.coverArt,
|
||||
before_download=lambda: GLib.idle_add(start_loading),
|
||||
item.album.coverArt, before_download=lambda: GLib.idle_add(start_loading),
|
||||
)
|
||||
cover_art_filename_future.add_done_callback(
|
||||
lambda f: GLib.idle_add(on_artwork_downloaded, f))
|
||||
lambda f: GLib.idle_add(on_artwork_downloaded, f)
|
||||
)
|
||||
|
||||
widget_box.show_all()
|
||||
return widget_box
|
||||
|
||||
def reflow_grids(
|
||||
self,
|
||||
force_reload_from_master: bool = False,
|
||||
selection_changed: bool = False,
|
||||
self, force_reload_from_master: bool = False, selection_changed: bool = False,
|
||||
):
|
||||
# Determine where the cuttoff is between the top and bottom grids.
|
||||
entries_before_fold = len(self.list_store)
|
||||
if self.current_selection is not None and self.items_per_row:
|
||||
entries_before_fold = (
|
||||
((self.current_selection // self.items_per_row) + 1)
|
||||
* self.items_per_row)
|
||||
(self.current_selection // self.items_per_row) + 1
|
||||
) * self.items_per_row
|
||||
|
||||
if force_reload_from_master:
|
||||
# Just remove everything and re-add all of the items.
|
||||
@@ -606,8 +575,7 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
del self.list_store_top[-1]
|
||||
|
||||
if self.current_selection is not None:
|
||||
to_select = self.grid_top.get_child_at_index(
|
||||
self.current_selection)
|
||||
to_select = self.grid_top.get_child_at_index(self.current_selection)
|
||||
if not to_select:
|
||||
return
|
||||
self.grid_top.select_child(to_select)
|
||||
@@ -621,10 +589,9 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
model = self.list_store[self.current_selection]
|
||||
detail_element = AlbumWithSongs(model.album, cover_art_size=300)
|
||||
detail_element.connect(
|
||||
'song-clicked',
|
||||
lambda _, *args: self.emit('song-clicked', *args),
|
||||
"song-clicked", lambda _, *args: self.emit("song-clicked", *args),
|
||||
)
|
||||
detail_element.connect('song-selected', lambda *a: None)
|
||||
detail_element.connect("song-selected", lambda *a: None)
|
||||
|
||||
self.detail_box_inner.pack_start(detail_element, True, True, 0)
|
||||
self.detail_box.show_all()
|
||||
|
Reference in New Issue
Block a user