Finalize file dialog UI

This commit is contained in:
heliguy4599
2024-10-08 23:39:53 -04:00
parent cb1ab7743a
commit 9092f75615
3 changed files with 35 additions and 68 deletions

View File

@@ -1,40 +1,21 @@
using Gtk 4.0;
using Adw 1;
template $FileInstallDialog : Adw.Dialog {
title: _("Install Local Files");
template $FileInstallDialog : Adw.AlertDialog {
follows-content-size: true;
Adw.ToolbarView {
[top]
Adw.HeaderBar {
show-start-title-buttons: false;
show-end-title-buttons: false;
[start]
Button cancel_button {
label: _("Cancel");
}
[end]
Button apply_button {
styles ["suggested-action"]
label: _("Add");
}
Box {
orientation: vertical;
spacing: 12;
Adw.PreferencesGroup packages_group {
}
Adw.ToastOverlay toast_overlay {
ScrolledWindow content_page {
propagate-natural-height: true;
propagate-natural-width: true;
Adw.Clamp {
ListBox list_box {
margin-start: 12;
margin-end: 12;
margin-top: 12;
margin-bottom: 12;
selection-mode: none;
valign: start;
styles ["boxed-list"]
}
}
Adw.PreferencesGroup installation_group {
Adw.ComboRow installation_row {
title: _("Installation");
}
}
}
responses [
cancel: _("Cancel"),
continue: _("Add") suggested,
]
}

View File

@@ -1,22 +1,24 @@
from gi.repository import Adw, Gtk, GLib, Gio
from .host_info import HostInfo
from .error_toast import error_toast
from .error_toast import ErrorToast
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/install_page/file_install_dialog.ui")
class FileInstallDialog(Adw.Dialog):
class FileInstallDialog(Adw.AlertDialog):
__gtype_name__ = "FileInstallDialog"
gtc = Gtk.Template.Child
cancel_button = gtc()
apply_button = gtc()
toast_overlay = gtc()
content_page = gtc()
list_box = gtc()
packages_group = gtc()
installation_row = gtc()
def generate_list(self):
for file in self.files:
row = Adw.ActionRow(title=file.get_basename())
self.list_box.append(row)
row.add_prefix(Gtk.Image(icon_name="flatpak-symbolic"))
self.packages_group.add(row)
def on_response(self, dialog, response):
if response != "continue":
return
def __init__(self, parent_page, files, **kwargs):
super().__init__(**kwargs)
@@ -27,5 +29,13 @@ class FileInstallDialog(Adw.Dialog):
# Apply
self.generate_list()
self.installation_row.set_model(Gtk.StringList(strings=HostInfo.installations))
if len(files) > 1:
self.set_heading(_("Add These Files?"))
self.set_body(_("Add these files to the queue to be installed"))
else:
self.set_heading(_("Add This File?"))
self.set_body(_("Add this file to the queue to be installed"))
# Connections
self.connect("response", self.on_response)

View File

@@ -3,6 +3,7 @@ from .host_info import HostInfo
from .error_toast import ErrorToast
from .results_page import ResultsPage
from .sidebar_button import SidebarButton
from .file_install_dialog import FileInstallDialog
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/install_page/select_page.ui")
class SelectPage(Adw.NavigationPage):
@@ -37,40 +38,15 @@ class SelectPage(Adw.NavigationPage):
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
)
HostInfo.main_window.toast_overlay.add_toast(ErrorToast(response, installation).toast)
def file_choose_callback(self, object, result):
files = object.open_multiple_finish(result)
if not files:
HostInfo.toast_overlay.add_toast(ErrorToast(_("Could not add files"), _("No files were found to install")))
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)
FileInstallDialog(self, files).present(HostInfo.main_window)
def on_open(self, *args):
file_filter = Gtk.FileFilter(name=_("Flatpaks"))