From f641c5b987b35f63ad066c0fa634c0a9f11bc7ab Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Sat, 17 Jan 2026 13:21:52 +0100 Subject: Show dialog to keep or remove book sources --- src/book_form.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/book_form.py') diff --git a/src/book_form.py b/src/book_form.py index 5968592..2e5bc52 100644 --- a/src/book_form.py +++ b/src/book_form.py @@ -1,21 +1,27 @@ import gi gi.require_version('Gtk', '4.0') from gi.repository import Gtk +import logging +import os.path import src.utils as utils import src.models as models from src.ui.entry_list import EntryList from src.ui.book_entries import BookEntries from src.ui.cover_entry import CoverEntry +from src.remove_paths_dialog import RemovePathsDialog import src.book_store as book_store import src.book_files as book_files import src.str_format as str_format +logger = logging.getLogger(__name__) + class BookForm(Gtk.Window): def __init__(self, parent_window, resources, library, conn, msg, book = None): Gtk.Window.__init__(self) + self._parent_window = parent_window self._book = book self._library = library self._conn = conn @@ -74,9 +80,6 @@ class BookForm(Gtk.Window): # Books self._book_entries = BookEntries(self) box.append(self._book_entries) - self._remove_book_sources = Gtk.CheckButton.new_with_label(' Supprimer les sources') - self._remove_book_sources.set_active(True) - box.append(self._remove_book_sources) # Init values if book: @@ -124,11 +127,17 @@ class BookForm(Gtk.Window): cover = self._cover_entry.get_image() books = self._book_entries.get_books() - book_id = book_store.store(self._library, self._conn, data, cover, books, self._book, self._remove_book_sources.get_active()) + book_id = book_store.store(self._library, self._conn, data, cover, books, self._book) if book_id: self.close() self._msg(['book-saved', book_id, data]) + # Ask whether to remove book sources + directory = f'{self._library}/{book_id}' + external_paths = [p for p in books.keys() if os.path.dirname(p) != directory] + if external_paths: + RemovePathsDialog(self._parent_window, 'Supprimer les sources', external_paths).present() + def non_empty(xs): return [x.strip() for x in xs if x.strip()] -- cgit v1.2.3