Initial structure for installing from local file

This commit is contained in:
Heliguy
2024-10-07 15:58:07 -04:00
parent f694748c81
commit 969f028a90
2 changed files with 36 additions and 16 deletions

View File

@@ -8,40 +8,57 @@ from .sidebar_button import SidebarButton
class SelectPage(Adw.NavigationPage):
__gtype_name__ = "SelectPage"
gtc = Gtk.Template.Child
nav_view = gtc()
results_page = gtc()
remotes_group = gtc()
add_remote_row = gtc()
open_row = gtc()
def start_loading(self):
self.nav_view.pop()
for row in self.remote_rows:
self.remotes_group.remove(row)
self.remote_rows.clear()
def end_loading(self):
for installation, remotes in HostInfo.remotes.items():
for remote in remotes:
if remote.disabled:
continue
row = Adw.ActionRow(title=remote.title, subtitle=_("Installation: {}").format(installation), activatable=True)
row.add_suffix(Gtk.Image(icon_name="right-large-symbolic"))
row.connect("activated", self.results_page.show_remote, remote, installation, self.nav_view)
self.remotes_group.add(row)
self.remote_rows.append(row)
self.remotes_group.set_visible(len(self.remote_rows) != 0)
def file_choose_callback(self, object, result):
file = object.open_finish(result)
print(file.get_path())
def on_open(self, *args):
file_filter = Gtk.FileFilter(name=_("Flatpaks"))
file_filter.add_suffix("flatpak")
file_filter.add_suffix("flatpakref")
filters = Gio.ListStore.new(Gtk.FileFilter)
filters.append(file_filter)
file_chooser = Gtk.FileDialog()
file_chooser.set_filters(filters)
file_chooser.set_default_filter(file_filter)
file_chooser.open(HostInfo.main_window, None, self.file_choose_callback)
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Extra Object Creation
self.remote_rows = []
# Connections
self.add_remote_row.connect("activated", lambda *_: HostInfo.main_window.activate_row(HostInfo.main_window.remotes_row))
self.nav_view.connect("popped", self.results_page.on_back)
self.remote_rows = []
self.open_row.connect("activated", self.on_open)
# Apply

View File

@@ -5,7 +5,7 @@ class PackageInstallWorker:
""" Expect Package Installation Request Data to be Formatted as Such
[
{
"remote": "<remote name>",
"remote": "<remote name>" or "local_file",
"installation": "<installation name>",
"package_names": ["<pkg id 1>", "<pkg id 2>", ...],
},
@@ -50,11 +50,14 @@ class PackageInstallWorker:
else:
real_installation = f"--installation={installation}"
this.process = subprocess.Popen(
['flatpak-spawn', '--host', 'flatpak', 'install', '-y', group['remote'], real_installation] + group['package_names'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True,
)
print(group['remote'], group['package_names'], "\n\n\n\n\n\n\n\n")
cmd = ['flatpak-spawn', '--host', 'flatpak', 'install', '-y']
# Handle local file installs. They don't have a remote specified
if group['remote'] != "local_file":
cmd.append(group['remote'])
cmd += [real_installation] + group['package_names']
this.process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
percent_pattern = r'\d{1,3}%'
amount_pattern = r'(\d+)/(\d+)'
for line in this.process.stdout: