77from gi .repository import Gtk , Gdk , Gio , Pango , GdkPixbuf , Adw , GLib
88
99from backend import grab_all_songs , ms_to_mmss
10+ from backend .constants import DEFAULT_SONG_INFO_IMAGE_SIZE
1011from .songs_table import create_song_store , create_song_selection_model , create_songs_table , Song
1112from .song_info import display_song_info
1213
13- def create_album_button (db_type : str , db_path : str , album_art_dir : str , album_info : dict , nav_view : Adw .NavigationView , image_size : int = 120 ) -> Gtk .Button :
14+ def create_album_button (db_type : str , db_path : str , album_art_dir : str , album_info : dict , nav_view : Adw .NavigationView , image_size : int = 120 , get_song_image_size = None ) -> Gtk .Button :
1415 """Creates a button with Album Art, Name, and Artist.
1516
1617 Args:
@@ -20,6 +21,7 @@ def create_album_button(db_type: str, db_path: str, album_art_dir: str, album_in
2021 album_info (dict): Album metadata containing art, name, artist, genres, songs
2122 nav_view (Adw.NavigationView): Navigation view to push detail page onto
2223 image_size (int): Size of the album art image
24+ get_song_image_size (callable): Returns current scaled image size for song info display
2325
2426 Returns:
2527 Gtk.Button: The button with album art and info
@@ -61,10 +63,10 @@ def create_album_button(db_type: str, db_path: str, album_art_dir: str, album_in
6163 box .append (artist_label )
6264
6365 button .set_child (box )
64- button .connect ("clicked" , lambda btn : _show_album_info (album_info , db_type , db_path , album_art_dir , nav_view ))
66+ button .connect ("clicked" , lambda btn : _show_album_info (album_info , db_type , db_path , album_art_dir , nav_view , get_song_image_size ))
6567 return button
6668
67- def _show_album_info (album_info : dict , db_type : str , db_path : str , album_art_dir : str , nav_view : Adw .NavigationView ) -> None :
69+ def _show_album_info (album_info : dict , db_type : str , db_path : str , album_art_dir : str , nav_view : Adw .NavigationView , get_song_image_size = None ) -> None :
6870 """Shows the given album info when an album cover is clicked
6971 Absolutely insanity how chunky this function got. TODO: come back and make better
7072 """
@@ -142,7 +144,8 @@ def on_selection_changed(sel, position, n_items):
142144 child = song_info_box .get_first_child ()
143145
144146 # rebuild
145- song_info_widget = display_song_info (song_data )
147+ img_size = get_song_image_size () if get_song_image_size else DEFAULT_SONG_INFO_IMAGE_SIZE
148+ song_info_widget = display_song_info (song_data , image_size = img_size )
146149 song_info_box .append (song_info_widget )
147150 song_info_box .set_visible (True )
148151
@@ -153,7 +156,8 @@ def on_selection_changed(sel, position, n_items):
153156 def select_first ():
154157 selection .set_selected (0 )
155158 # manually trigger display
156- song_info_widget = display_song_info (songs_data [0 ])
159+ img_size = get_song_image_size () if get_song_image_size else DEFAULT_SONG_INFO_IMAGE_SIZE
160+ song_info_widget = display_song_info (songs_data [0 ], image_size = img_size )
157161 song_info_box .append (song_info_widget )
158162 song_info_box .set_visible (True )
159163 return False
0 commit comments