aboutsummaryrefslogtreecommitdiff
path: root/src/book_form.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/book_form.py')
-rw-r--r--src/book_form.py17
1 files changed, 13 insertions, 4 deletions
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()]