blob: 2444067abc1d2744fcb8b42d55d38d5ec976cf97 (
plain)
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
37
38
39
40
41
42
43
44
45
|
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk
import os
import logging
import pathlib
import src.utils as utils
import src.book_files as book_files
logger = logging.getLogger(__name__)
class RemovePathsDialog(Gtk.Window):
def __init__(self, parent_window, title, paths):
Gtk.Window.__init__(self)
self._paths = paths
utils.configure_dialog(self, parent_window, title, width=None, height=None)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20)
self.set_child(box)
utils.set_margin(box, 20)
for path in paths:
box.append(utils.label(path.as_posix()))
buttons_box = Gtk.Box(spacing=20)
buttons_box.set_halign(Gtk.Align.END)
box.append(buttons_box)
keep_button = Gtk.Button(label='Conserver')
keep_button.connect('clicked', lambda _: self.close())
buttons_box.append(keep_button)
delete_button = Gtk.Button(label='Supprimer')
delete_button.connect('clicked', lambda _: self._on_delete())
buttons_box.append(delete_button)
def _on_delete(self):
for path in self._paths:
logger.info('Removing source: %s', path)
pathlib.Path.unlink(path)
self.close()
|