Convert search_install window to adw.dialog

This commit is contained in:
heliguy
2024-03-27 18:09:24 -04:00
parent 3260e07ea8
commit 0c1b8906a1
4 changed files with 16 additions and 20 deletions

View File

@@ -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:

View File

@@ -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):

View File

@@ -75,6 +75,8 @@ class WarehouseApplication(Adw.Application):
"open-search-install", self.open_search_install, ["<primary>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

View File

@@ -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()