diff options
| author | Joris Guyonvarch | 2025-12-26 18:41:26 +0100 |
|---|---|---|
| committer | Joris Guyonvarch | 2025-12-27 20:41:44 +0100 |
| commit | a110c200e86d2325af07167531fac0f61d9681a0 (patch) | |
| tree | 90e843f915a2e153ba735849afd83710d90560bf /src/picture_cache.py | |
| parent | a26d92ad5055fa057647158eb79511e7b1841162 (diff) | |
Switch to GUI to manage the library
Allow to regroup the CLI and the view into one unique tool.
Diffstat (limited to 'src/picture_cache.py')
| -rw-r--r-- | src/picture_cache.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/picture_cache.py b/src/picture_cache.py new file mode 100644 index 0000000..8da136b --- /dev/null +++ b/src/picture_cache.py @@ -0,0 +1,25 @@ +import gi +gi.require_version("Gtk", "4.0") +from gi.repository import Gtk +import logging + +logger = logging.getLogger(__name__) + +class PictureCache: + + def __init__(self): + self._cache = {} + + def get(self, path): + if path in self._cache: + logger.debug('Loading from cache: %s', path) + return self._cache[path] + else: + picture = Gtk.Picture.new_for_filename(path) + logger.debug('Adding in cache: %s', path) + self._cache[path] = picture + return picture + + def invalidate(self, path): + logger.debug('Invalidating: %s', path) + del self._cache[path] |
