From 25fd040cd710a7bdb7d0c174316324f614643896 Mon Sep 17 00:00:00 2001 From: heliguy4599 Date: Wed, 9 Oct 2024 22:33:17 -0400 Subject: [PATCH] Add local file installation ability --- src/gtk/installation_chooser.py | 3 +-- src/install_page/file_install_dialog.blp | 2 +- src/install_page/file_install_dialog.py | 10 +++++----- src/install_page/select_page.py | 15 ++++++++++++++- src/package_install_worker.py | 2 +- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/gtk/installation_chooser.py b/src/gtk/installation_chooser.py index bcbcbe8..532b9ca 100644 --- a/src/gtk/installation_chooser.py +++ b/src/gtk/installation_chooser.py @@ -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()) \ No newline at end of file + self.choice_row.connect("notify::css-classes", lambda *_: self.choice_check.activate()) diff --git a/src/install_page/file_install_dialog.blp b/src/install_page/file_install_dialog.blp index d2b68f6..71cf506 100644 --- a/src/install_page/file_install_dialog.blp +++ b/src/install_page/file_install_dialog.blp @@ -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; diff --git a/src/install_page/file_install_dialog.py b/src/install_page/file_install_dialog.py index 69a1a51..11f5003 100644 --- a/src/install_page/file_install_dialog.py +++ b/src/install_page/file_install_dialog.py @@ -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 diff --git a/src/install_page/select_page.py b/src/install_page/select_page.py index 8c23450..8af3927 100644 --- a/src/install_page/select_page.py +++ b/src/install_page/select_page.py @@ -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): diff --git a/src/package_install_worker.py b/src/package_install_worker.py index 4cb89b3..fc18717 100644 --- a/src/package_install_worker.py +++ b/src/package_install_worker.py @@ -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():