1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk
import os
import src.utils as utils
import src.book_files as book_files
class BookDelete(Gtk.Window):
def __init__(self, parent_window, library, book_id, data, on_parent_confirm):
Gtk.Window.__init__(self)
self._on_parent_confirm = on_parent_confirm
utils.configure_dialog(self, parent_window, data['title'], width=None, height=None)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20)
self.set_child(box)
utils.set_margin(box, 20)
picture = Gtk.Picture.new_for_filename(f'{library}/{book_id}/cover.png')
picture.set_can_shrink(False)
box.append(picture)
for path in book_files.get(library, book_id):
box.append(utils.label(os.path.basename(path)))
confirm_button = Gtk.Button(label='Supprimer')
confirm_button.add_css_class('g-DangerButton')
confirm_button.connect('clicked', lambda _: self._on_confirm())
box.append(confirm_button)
def _on_confirm(self):
self._on_parent_confirm()
self.close()
|