Commit 95f9178e authored by David Boddie's avatar David Boddie 💬
Browse files

Detect existing information and allow the process to be skipped

parent 43ad3985
......@@ -26,7 +26,8 @@ class Application(Gtk.Application):
self.timeout_id = None
self.lines = []
self.ready = False
self.output_dir = os.path.join(os.getenv('HOME'), '.local', 'share',
'librem5-get-package-info')
def do_activate(self):
window = Gtk.ApplicationWindow(application=self)
......@@ -36,20 +37,52 @@ class Application(Gtk.Application):
show_close_button=True)
window.set_titlebar(header)
self.output_dir = os.path.join(os.getenv('HOME'), '.local', 'share', 'librem5-get-package-info')
self.layout = Gtk.Box(orientation='vertical', margin=8, spacing=12)
if os.path.exists(self.output_dir):
question_label = Gtk.Label()
question_label.set_markup(_('<b>Existing information is available.</b>'))
view_button = Gtk.Button(
label=_('View existing information'), halign=Gtk.Align.CENTER)
view_button.connect('clicked', self.open_docs)
list_button = Gtk.Button(
label=_('Generate new information'), halign=Gtk.Align.CENTER)
list_button.connect('clicked', self.generate_new_info)
self.question_layout = Gtk.Box(orientation='vertical', margin=8,
spacing=12)
self.question_layout.add(question_label)
self.question_layout.add(view_button)
self.question_layout.add(list_button)
self.layout.add(self.question_layout)
else:
self.start_listing()
window.add(self.layout)
window.set_default_size(360, 720)
window.show_all()
def generate_new_info(self, *args):
self.question_layout.hide()
self.start_listing()
def start_listing(self):
layout = Gtk.Box(orientation='vertical', margin=8, spacing=12)
self.layout.add(layout)
vbox = Gtk.Box(orientation='vertical', margin=8, spacing=12)
self.label = Gtk.Label(hexpand=True, hexpand_set=True, ellipsize=True)
self.label.set_xalign(0.0)
try:
if os.path.exists(self.output_dir):
self.ready = True
else:
if not os.path.exists(self.output_dir):
os.mkdir(self.output_dir)
self.progress = Gtk.ProgressBar(show_text=True)
vbox.add(self.progress)
layout.add(self.progress)
self.label.set_text(_('Finding package information'))
self.label.set_justify(Gtk.Justification.LEFT)
......@@ -61,15 +94,8 @@ class Application(Gtk.Application):
'https://docs.puri.sm/Librem_5.html for information about '
'packages.'))
self.button = Gtk.Button(label=_('Open Package List'))
self.button.set_sensitive(self.ready)
self.button.connect('clicked', self.open_docs)
vbox.add(self.label)
vbox.add(self.button)
window.add(vbox)
window.set_default_size(360, 720)
window.show_all()
layout.add(self.label)
layout.show_all()
def get_installed_packages(self):
......@@ -121,8 +147,15 @@ class Application(Gtk.Application):
self.update_label()
except StopIteration:
self.lines.pop()
self.update_label()
self.button.set_sensitive(self.ready)
self.button = Gtk.Button(label=_('Open Package List'),
halign=Gtk.Align.CENTER)
self.button.connect('clicked', self.open_docs)
self.layout.add(self.button)
self.button.show()
return False
return True
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment