mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Add local file installation ability
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user