Tame thumbnail a bit

This commit is contained in:
Jan Hamal Dvořák 2025-03-09 22:23:22 +01:00
parent fa98ed28b2
commit 82cb252eb5
2 changed files with 8 additions and 14 deletions

View file

@ -19,7 +19,6 @@ from gi.repository import Gdk, GLib, Gst, Gtk, Pango # NOQA: E402
class MainWindow(Gtk.ApplicationWindow): class MainWindow(Gtk.ApplicationWindow):
file_info_label: Gtk.Label
stack: Gtk.Stack stack: Gtk.Stack
list_view: Gtk.ListView list_view: Gtk.ListView
list_model: FileListModel list_model: FileListModel
@ -99,21 +98,18 @@ class MainWindow(Gtk.ApplicationWindow):
# Left third (1/3 width) # Left third (1/3 width)
left_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) left_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
left_box.set_valign(Gtk.Align.CENTER) left_box.set_valign(Gtk.Align.START)
left_box.set_halign(Gtk.Align.FILL) left_box.set_halign(Gtk.Align.FILL)
# Create image widget for thumbnail with fixed 16:9 aspect # Create image widget for thumbnail
self.thumbnail_image = Gtk.Picture() self.thumbnail_image = Gtk.Picture()
self.thumbnail_image.set_name("thumbnail-image")
self.thumbnail_image.set_size_request(384, 216) # 16:9 aspect ratio self.thumbnail_image.set_size_request(384, 216) # 16:9 aspect ratio
self.thumbnail_image.set_can_shrink(True) self.thumbnail_image.set_can_shrink(True)
self.thumbnail_image.set_keep_aspect_ratio(True) self.thumbnail_image.set_keep_aspect_ratio(True)
self.thumbnail_image.set_resource(None) self.thumbnail_image.set_resource(None)
left_box.append(self.thumbnail_image) left_box.append(self.thumbnail_image)
self.file_info_label = Gtk.Label(label="")
self.file_info_label.set_wrap(True)
left_box.append(self.file_info_label)
# Right two-thirds (2/3 width) # Right two-thirds (2/3 width)
right_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) right_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
right_box.set_hexpand(True) right_box.set_hexpand(True)
@ -274,11 +270,8 @@ class MainWindow(Gtk.ApplicationWindow):
position: int, position: int,
n_items: int, n_items: int,
): ):
if selection_model.get_selected() == Gtk.INVALID_LIST_POSITION: if selection_model.get_selected() != Gtk.INVALID_LIST_POSITION:
self.file_info_label.set_text("")
else:
file_item = self.selection file_item = self.selection
self.file_info_label.set_text(file_item.name)
# Update thumbnail if available # Update thumbnail if available
if file_item.thumbnail: if file_item.thumbnail:
@ -474,9 +467,6 @@ class MainWindow(Gtk.ApplicationWindow):
self.list_model.set_items(items) self.list_model.set_items(items)
if items:
self.file_info_label.set_text(items[0].name)
class App(Gtk.Application): class App(Gtk.Application):
def __init__(self, thumbnailer: Thumbnailer): def __init__(self, thumbnailer: Thumbnailer):

View file

@ -33,3 +33,7 @@ listview > row {
border-radius: 8px; border-radius: 8px;
margin: 32px; margin: 32px;
} }
#thumbnail-image {
margin: 8px;
}