diff --git a/data/ui/search_install.blp b/data/ui/search_install.blp index d04de40..fb08468 100644 --- a/data/ui/search_install.blp +++ b/data/ui/search_install.blp @@ -1,11 +1,10 @@ using Gtk 4.0; using Adw 1; -template $SearchInstallWindow: Adw.Window { - default-width: 500; - default-height: 450; +template $SearchInstallWindow: Adw.Dialog { + content-width: 500; + content-height: 450; title: ""; - modal: true; Adw.ToolbarView main_toolbar_view { content: diff --git a/src/common.py b/src/common.py index ba73398..a62e260 100644 --- a/src/common.py +++ b/src/common.py @@ -14,6 +14,7 @@ class myUtils: self.uninstall_success = True self.new_env = dict(os.environ) self.new_env["LC_ALL"] = "C" + self.is_dialog_open = False def trash_folder(self, path): if not os.path.exists(path): diff --git a/src/main.py b/src/main.py index 1c3dbd4..5da8598 100644 --- a/src/main.py +++ b/src/main.py @@ -75,6 +75,8 @@ class WarehouseApplication(Adw.Application): "open-search-install", self.open_search_install, ["i"] ) + self.is_dialog_open = False + gtk_version = ( str(Gtk.MAJOR_VERSION) + "." @@ -102,16 +104,16 @@ class WarehouseApplication(Adw.Application): lang=lang, ) - my_utils = myUtils(self) + self.my_utils = myUtils(self) total = 0 - for rem in my_utils.get_host_remotes(): - if my_utils.get_install_type(rem[7]) != "disabled": + for rem in self.my_utils.get_host_remotes(): + if self.my_utils.get_install_type(rem[7]) != "disabled": total += 1 if total < 1: self.lookup_action(f"open-search-install").set_enabled(False) def open_search_install(self, widget, _): - SearchInstallWindow(self.props.active_window).present() + SearchInstallWindow(self.props.active_window).present(self.props.active_window) def batch_mode_shortcut(self, widget, _): button = self.props.active_window.batch_mode_button diff --git a/src/search_install_window.py b/src/search_install_window.py index e1959f5..93617c7 100644 --- a/src/search_install_window.py +++ b/src/search_install_window.py @@ -51,9 +51,7 @@ class ResultRow(Adw.ActionRow): @Gtk.Template( resource_path="/io/github/flattool/Warehouse/../data/ui/search_install.ui" ) -class SearchInstallWindow( - Adw.Window -): # TODO: stop execution of thread when search is changed +class SearchInstallWindow(Adw.Dialog): __gtype_name__ = "SearchInstallWindow" back_button = Gtk.Template.Child() @@ -220,7 +218,8 @@ class SearchInstallWindow( def done(*args): self.parent_window.refresh_list_of_flatpaks(None, False) - self.disconnect(self.no_close_id) # Make window able to close + # Make window able to close + self.set_can_close(True) if self.my_utils.install_success: self.close() self.parent_window.toast_overlay.add_toast( @@ -234,9 +233,8 @@ class SearchInstallWindow( Adw.Toast.new(_("Some apps didn't install")) ) - self.no_close_id = self.connect( - "close-request", lambda event: True - ) # Make window unable to close + # Make window unable to close + self.set_can_close(False) task = Gio.Task.new(None, None, done) task.run_in_thread(thread) @@ -265,8 +263,4 @@ class SearchInstallWindow( # Apply Widgets self.add_controller(event_controller) - self.set_transient_for(parent_window) - self.generate_remotes_list() - self.set_size_request(260, 230) - self.set_modal(True) - self.set_resizable(True) + self.generate_remotes_list() \ No newline at end of file