Add package installation drag and drop

This commit is contained in:
heliguy4599
2024-10-12 15:17:33 -04:00
parent 49eebc00f6
commit 5cade3677f
2 changed files with 12 additions and 5 deletions

View File

@@ -172,6 +172,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
# Adding a remote
self.activate_row(self.remotes_row)
remotes_page = self.pages[self.remotes_row]
remotes_page.local_file_handler(remotes[0])
elif len(paks) > 0:
# Add packages
self.activate_row(self.install_row)
@@ -179,7 +180,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
install_page.select_page.file_dialog_handler(paks)
except Exception as e:
self.toast_overlay.add_toast(ErrorToast(_("Could not open files"), str(e)))
self.toast_overlay.add_toast(ErrorToast(_("Could not open files"), str(e)).toast)
def on_drop_enter(self, *args):
self.file_drop_stack.set_visible_child(self.file_drop_view)

View File

@@ -209,11 +209,9 @@ class RemotesPage(Adw.NavigationPage):
return
self.stack.set_visible_child(self.content_page if total > 0 else self.no_results)
def file_callback(self, chooser, result):
def local_file_handler(self, path):
try:
file = chooser.open_finish(result)
path = file.get_path()
name = path.split("/")[-1].split(".")[0]
info = {
"title": name.title(),
@@ -222,6 +220,14 @@ class RemotesPage(Adw.NavigationPage):
"link": path,
}
AddRemoteDialog(self.main_window, self, info).present(self.main_window)
except Exception as e:
self.toast_overlay.add_toast(ErrorToast(_("Could not open file"), str(e)).toast)
def file_callback(self, chooser, result):
try:
file = chooser.open_finish(result)
path = file.get_path()
self.local_file_handler(path)
except GLib.GError as ge:
if "Dismissed by user" in str(ge):
return