From 1c458b456e331f378b9b61706051560e360e590c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= <mordae@anilinux.org>
Date: Sat, 8 Mar 2025 20:02:44 +0100
Subject: [PATCH] Style the file picker

---
 lazy_player/__init__.py | 22 +++++++++++++++++++---
 lazy_player/style.css   |  5 +++++
 2 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 lazy_player/style.css

diff --git a/lazy_player/__init__.py b/lazy_player/__init__.py
index c1ce128..715f236 100644
--- a/lazy_player/__init__.py
+++ b/lazy_player/__init__.py
@@ -1,12 +1,13 @@
 from __future__ import annotations
 
 import os
+from pathlib import Path
 from typing import Any, cast
 
 import gi
 
 gi.require_version("Gtk", "4.0")
-from gi.repository import Gtk  # NOQA: E402
+from gi.repository import Gdk, Gtk  # NOQA: E402
 
 
 class MainWindow(Gtk.ApplicationWindow):
@@ -81,8 +82,8 @@ class MainWindow(Gtk.ApplicationWindow):
                     else:
                         files.append(entry.name)
 
-        directories.sort()
-        files.sort()
+        directories.sort(key=lambda x: x.lower())
+        files.sort(key=lambda x: x.lower())
 
         for name in directories:
             list_store.append(f"{name}/")
@@ -95,6 +96,21 @@ class App(Gtk.Application):
     def __init__(self):
         super().__init__()
 
+        # Load CSS
+        css_provider = Gtk.CssProvider()
+        css_file = Path(__file__).parent / "style.css"
+        css_provider.load_from_path(str(css_file))
+
+        display = Gdk.Display.get_default()
+        if display is None:
+            raise RuntimeError("No display available")
+
+        Gtk.StyleContext.add_provider_for_display(
+            display,
+            css_provider,
+            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
+        )
+
     def do_activate(self):
         win = MainWindow(application=self)
         win.present()
diff --git a/lazy_player/style.css b/lazy_player/style.css
new file mode 100644
index 0000000..c95daf6
--- /dev/null
+++ b/lazy_player/style.css
@@ -0,0 +1,5 @@
+listview > row {
+  padding: 8px;
+  font-size: 48px;
+  font-family: monospace;
+}