diff --git a/src/orphans_window.py b/src/orphans_window.py index 8635c240..10859523 100644 --- a/src/orphans_window.py +++ b/src/orphans_window.py @@ -187,8 +187,8 @@ def generateList(self): # Create row element dir_row = Adw.ActionRow(title=dir_name) - task = Gio.Task.new(None, None, None) path = self.user_data_path + dir_name + task = Gio.Task.new(None, None, None) task.run_in_thread(lambda _task, _obj, _data, _cancellable: self.sizeThread(dir_row, path)) select_button = Gtk.CheckButton() diff --git a/src/popular_remotes_window.py b/src/popular_remotes_window.py index 52e1d308..b1d4f8ae 100644 --- a/src/popular_remotes_window.py +++ b/src/popular_remotes_window.py @@ -26,6 +26,16 @@ def key_handler(self, _a, event, _c, _d): if event == Gdk.KEY_Escape: self.close() + def addRemoteCallback(self, _a, _b): + self.parent_window.generate_list() + + def addRemoteThread(self, command): + try: + subprocess.run(command, capture_output=True, check=True, env=self.new_env) + except Exception as e: + self.toast_overlay.add_toast(Adw.Toast.new(_("Could not add {}").format(self.name_to_add))) + print(e) + def on_add_response(self, _dialog, response_id, _function): if response_id == "cancel": return @@ -38,12 +48,8 @@ def on_add_response(self, _dialog, response_id, _function): self.url_to_add = self.url_to_add.strip() command = ['flatpak-spawn', '--host', 'flatpak', 'remote-add', '--if-not-exists', self.name_to_add, self.url_to_add, install_type] - try: - subprocess.run(command, capture_output=True, check=True, env=self.new_env) - except Exception as e: - self.toast_overlay.add_toast(Adw.Toast.new(_("Could not add {}").format(self.name_to_add))) - print(e) - self.parent_window.generate_list() + task = Gio.Task.new(None, None, self.addRemoteCallback) + task.run_in_thread(lambda _task, _obj, _data, _cancellable: self.addRemoteThread(command)) self.close() def add_handler(self, _widget, name="", link=""):