From 892f9a63a2249cf6fc2978ed85681697cd52d3fb Mon Sep 17 00:00:00 2001 From: heliguy4599 Date: Sat, 12 Oct 2024 23:27:06 -0400 Subject: [PATCH] Fix closed by user error in open files shortcut --- src/main.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main.py b/src/main.py index ea5d720..b602217 100644 --- a/src/main.py +++ b/src/main.py @@ -29,6 +29,7 @@ from gi.repository import Gtk, Gio, Adw, GLib from .host_info import HostInfo from .window import WarehouseWindow from .const import Config +from .error_toast import ErrorToast class WarehouseApplication(Adw.Application): """The main application singleton class.""" @@ -96,9 +97,17 @@ class WarehouseApplication(Adw.Application): window = self.props.active_window def file_choose_callback(object, result): - files = object.open_multiple_finish(result) - window.on_file_drop(None, files, None, None) - + try: + files = object.open_multiple_finish(result) + if not files: + window.toast_overlay.add_toast(ErrorToast(_("Could not add files"), _("No files were found")).toast) + return + + window.on_file_drop(None, files, None, None) + except GLib.GError as gle: + if not (gle.domain == "gtk-dialog-error-quark" and gle.code == 2): + window.toast_overlay.add_toast(ErrorToast(_("Could not add files"), str(gle)).toast) + file_filter = Gtk.FileFilter(name=_("Flatpaks & Remotes")) file_filter.add_suffix("flatpak") file_filter.add_suffix("flatpakref")