From 4bf46d74418118a1dfb406b7078e78461082db54 Mon Sep 17 00:00:00 2001 From: Heliguy Date: Wed, 9 Oct 2024 12:09:33 -0400 Subject: [PATCH] Implement installation chooser --- src/remotes_page/add_remote_dialog.blp | 38 ++++++++++++++------------ src/remotes_page/add_remote_dialog.py | 7 +++-- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/remotes_page/add_remote_dialog.blp b/src/remotes_page/add_remote_dialog.blp index 70630ed..587cd6c 100644 --- a/src/remotes_page/add_remote_dialog.blp +++ b/src/remotes_page/add_remote_dialog.blp @@ -27,25 +27,27 @@ template $AddRemoteDialog : Adw.Dialog { propagate-natural-height: true; propagate-natural-width: true; Adw.Clamp { - ListBox { - margin-start: 12; - margin-end: 12; - margin-top: 12; - margin-bottom: 12; - selection-mode: none; - valign: start; - styles ["boxed-list"] - Adw.EntryRow title_row { - title: _("Enter Title"); + margin-start: 12; + margin-end: 12; + margin-top: 12; + margin-bottom: 12; + Box { + orientation: vertical; + spacing: 12; + Adw.PreferencesGroup { + title: _("Remote Details"); + styles ["boxed-list"] + Adw.EntryRow title_row { + title: _("Enter Title"); + } + Adw.EntryRow name_row { + title: _("Enter Name"); + } + Adw.EntryRow url_row { + title: _("Enter Repo URL"); + } } - Adw.EntryRow name_row { - title: _("Enter Name"); - } - Adw.EntryRow url_row { - title: _("Enter Repo URL"); - } - Adw.ComboRow installation_row { - title: _("Installation"); + $InstallationChooser installation_chooser { } } } diff --git a/src/remotes_page/add_remote_dialog.py b/src/remotes_page/add_remote_dialog.py index df2929a..18054ed 100644 --- a/src/remotes_page/add_remote_dialog.py +++ b/src/remotes_page/add_remote_dialog.py @@ -2,6 +2,7 @@ from gi.repository import Adw, Gtk, GLib, Gio from .host_info import HostInfo from .error_toast import ErrorToast from .loading_status import LoadingStatus +from .installation_chooser import InstallationChooser import subprocess, re @Gtk.Template(resource_path="/io/github/flattool/Warehouse/remotes_page/add_remote_dialog.ui") @@ -16,7 +17,7 @@ class AddRemoteDialog(Adw.Dialog): title_row = gtc() name_row = gtc() url_row = gtc() - installation_row = gtc() + installation_chooser = gtc() def on_apply(self, *args): self.parent_page.status_stack.set_visible_child(self.parent_page.adding_view) @@ -30,7 +31,7 @@ class AddRemoteDialog(Adw.Dialog): self.name_row.get_text(), self.url_row.get_text() ] - installation = self.installation_row.get_selected_item().get_string() + installation = self.installation_chooser.get_installation() if installation == "user" or installation == "system": cmd.append(f"--{installation}") else: @@ -90,7 +91,7 @@ class AddRemoteDialog(Adw.Dialog): self.url_passes = False # Apply - self.installation_row.set_model(self.string_list) + self.installation_chooser.set_content_strings(_("remote"), False) if remote_info: self.title_row.set_text(remote_info["title"]) self.name_row.set_text(remote_info["name"])