Further work on open file package install

This commit is contained in:
Heliguy
2024-10-07 23:01:54 -04:00
parent 969f028a90
commit 624748082e

View File

@@ -35,9 +35,42 @@ class SelectPage(Adw.NavigationPage):
self.remotes_group.set_visible(len(self.remote_rows) != 0)
def on_file_dialog_response(self, dialog, response, row):
installation = row.get_selected_item().get_string()
HostInfo.main_window.toast_overlay.add_toast(
ErrorToast(response, installation).toast
)
def file_choose_callback(self, object, result):
file = object.open_finish(result)
print(file.get_path())
files = object.open_multiple_finish(result)
if not files:
return
# file = object.open_finish(result)
pg = Adw.PreferencesGroup(
title=_("Choose an installation for this package"),
description=_("Apps installed to the {} installation are only available for you.").format("user"),
)
rows = []
for file in files:
row = Adw.ComboRow(
title=file.get_basename(),
model=Gtk.StringList(strings=HostInfo.installations)
)
rows.append(row)
pg.add(row)
dialog = Adw.AlertDialog(
heading=_("Install this Package?"),
body=file.get_basename(),
extra_child=pg,
)
pg.add(row)
dialog.present(HostInfo.main_window)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("continue", _("Install"))
dialog.set_response_appearance("continue", Adw.ResponseAppearance.SUGGESTED)
# dialog.connect("response", self.on_file_dialog_response, row)
dialog.present(HostInfo.main_window)
def on_open(self, *args):
file_filter = Gtk.FileFilter(name=_("Flatpaks"))
@@ -48,7 +81,7 @@ class SelectPage(Adw.NavigationPage):
file_chooser = Gtk.FileDialog()
file_chooser.set_filters(filters)
file_chooser.set_default_filter(file_filter)
file_chooser.open(HostInfo.main_window, None, self.file_choose_callback)
file_chooser.open_multiple(HostInfo.main_window, None, self.file_choose_callback)
def __init__(self, **kwargs):
super().__init__(**kwargs)