mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Adding new remotes now happens in a thread
This commit is contained in:
@@ -187,8 +187,8 @@ class OrphansWindow(Adw.Window):
|
||||
|
||||
# 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()
|
||||
|
||||
@@ -26,6 +26,16 @@ class PopularRemotesWindow(Adw.Window):
|
||||
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 @@ class PopularRemotesWindow(Adw.Window):
|
||||
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=""):
|
||||
|
||||
Reference in New Issue
Block a user