1 from gi.repository
import Gtk
as gtk
10 self.
window = gtk.Window(gtk.WindowType.TOPLEVEL)
11 self.window.set_title(
'Naptime Filter')
12 self.window.connect(
'destroy',
lambda x: self.window.destroy())
13 self.window.set_border_width(10)
14 self.window.set_default_size(210, 150)
18 self.window.show_all()
23 last_update_label = gtk.Label()
25 if DBConstants.SETTINGS.LAST_NAPTIME_UPDATE:
26 markup = UIUtils.utc_to_local_str(DBConstants.SETTINGS.LAST_NAPTIME_UPDATE)
27 last_update_label.set_markup(
'Last Update: <b>%s</b>' % (markup))
28 vbox.pack_start(last_update_label,
True,
True, 0)
30 last_path_label = gtk.Label()
31 last_path_label.set_markup(
'Last Path: <b>%s</b>' % (str(DBConstants.SETTINGS.LAST_NAPTIME_FOLDER)))
32 vbox.pack_start(last_path_label,
True,
True, 0)
35 folder_label = gtk.Label(
'Naptime Folder:')
36 folder_entry = gtk.Entry()
37 folder_entry.set_width_chars(50)
38 browse_button = gtk.Button(
'Browse')
39 browse_button.connect(
'clicked',
lambda w: UIUtils.browse_folder(
'Select naptime folder', folder_entry))
40 hbox.pack_start(folder_label,
True,
False, 0)
41 hbox.pack_start(folder_entry,
True,
False, 0)
42 hbox.pack_start(browse_button,
True,
False, 0)
43 vbox.pack_start(hbox,
True,
False, 0)
45 button_box = gtk.HButtonBox()
46 button_box.set_layout(gtk.ButtonBoxStyle.EDGE)
47 cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL, label=
'Cancel')
48 cancel_button.connect(
'clicked',
lambda w: self.window.destroy())
49 button_box.add(cancel_button)
51 update_button = gtk.Button(stock=gtk.STOCK_OK, label=
'Update')
52 update_button.connect(
'clicked',
53 lambda w: self.
update_db(folder_entry.get_text())
55 button_box.add(update_button)
57 vbox.pack_end(button_box,
True,
True, 0)
62 prog_diag =
ProgressDialog(title=
'Processing...', phases=[
'Please Wait'])
66 error_filenames = Naptime.update_naptime_data(db, path, prog_diag=prog_diag)
68 prog_diag.ensure_finish()
71 UIUtils.show_message_dialog(
72 'Unable to process the following files - see the log file for details:\n' +
73 '\n'.join(map(os.path.basename, error_filenames)),
74 dialog_type=gtk.MessageType.ERROR
78 UIUtils.show_message_dialog(
'Naptime database table updated successfully.')