Add local file installation ability

This commit is contained in:
heliguy4599
2024-10-09 22:33:17 -04:00
parent e635b5cfd3
commit 25fd040cd7
5 changed files with 22 additions and 10 deletions

View File

@@ -18,7 +18,6 @@ class InstallationChooser(Adw.PreferencesGroup):
def get_installation(self):
for button, func in self.check_buttons.items():
if button.get_active():
HostInfo.main_window.toast_overlay.add_toast(Adw.Toast(title=func()))
return func()
return "" # Case for when no button is active (which shouldn't happen)
@@ -59,4 +58,4 @@ class InstallationChooser(Adw.PreferencesGroup):
self.choice_row.set_model(Gtk.StringList(strings=custom_installations))
# Connections
self.choice_row.connect("notify::css-classes", lambda *_: self.choice_check.activate())
self.choice_row.connect("notify::css-classes", lambda *_: self.choice_check.activate())

View File

@@ -25,7 +25,7 @@ template $FileInstallDialog : Adw.Dialog {
margin-start: 12;
margin-end: 12;
margin-bottom: 12;
margin-top: 6;
margin-top: 3;
Box {
orientation: vertical;
spacing: 12;

View File

@@ -35,13 +35,13 @@ class FileInstallDialog(Adw.Dialog):
self.generate_list()
if len(files) > 1:
self.set_title(_("Install Packages"))
self.packages_group.set_title(_("Review Packages"))
self.packages_group.set_description(_("The following packages will be installed"))
# self.packages_group.set_title(_("Review Packages"))
self.packages_group.set_title(_("The following packages will be installed"))
self.installation_chooser.set_content_strings(_("Packages"), True)
else:
self.set_title(_("Install Package"))
self.packages_group.set_title(_("Review Package"))
self.packages_group.set_description(_("The following package will be installed"))
self.set_title(_("Install a Package"))
# self.packages_group.set_title(_("Review Package"))
self.packages_group.set_title(_("The following package will be installed"))
self.installation_chooser.set_content_strings(_("package"), False)
# Connections

View File

@@ -36,6 +36,19 @@ class SelectPage(Adw.NavigationPage):
self.remotes_group.set_visible(len(self.remote_rows) != 0)
def local_install_apply_callback(self, installation, file_names):
install_page = HostInfo.main_window.pages[HostInfo.main_window.install_row]
requests = []
for file in file_names:
# sadly flatpak doesn't support multiple local installs in one command :(
requests.append({
"remote": "local_file",
"installation": installation,
"package_names": [file.get_path()],
})
install_page.install_packages(requests)
def file_choose_callback(self, object, result):
try:
files = object.open_multiple_finish(result)
@@ -43,7 +56,7 @@ class SelectPage(Adw.NavigationPage):
HostInfo.main_window.toast_overlay.add_toast(ErrorToast(_("Could not add files"), _("No files were found to install")))
return
FileInstallDialog(self, files, self.results_page.add_local_package_rows).present(HostInfo.main_window)
FileInstallDialog(self, files, self.local_install_apply_callback).present(HostInfo.main_window)
except GLib.GError as gle:
if not (gle.domain == "gtk-dialog-error-quark" and gle.code == 2):

View File

@@ -72,7 +72,7 @@ class PackageInstallWorker:
total = int(amount[1])
this.update_status(index, ratio, complete, total)
else:
this.update_status(index, ratio)
this.update_status(index, ratio, 0, 1)
this.process.wait(timeout=10)
if error := this.process.communicate()[1].strip():