If user has all popular remotes, skip to new remot

This commit is contained in:
heliguy4599
2023-10-01 23:01:06 -04:00
parent 15f6cab028
commit 3179bdb09e
3 changed files with 38 additions and 5 deletions

View File

@@ -2,8 +2,8 @@ using Gtk 4.0;
using Adw 1;
template PopularRemotesWindow : Adw.Window {
default-width: 500;
default-height: 450;
default-width: 450;
default-height: 550;
title: _("Add a Remote");
Adw.ToolbarView main_toolbar_view {
@@ -26,6 +26,13 @@ template PopularRemotesWindow : Adw.Window {
Adw.Clamp{
Box {
orientation: vertical;
Label {
label: _("Choose from a list of popular remotes");
halign: start;
margin-start: 12;
margin-bottom: 3;
styles["title-4"]
}
ListBox list_of_remotes {
margin-top: 6;
margin-bottom: 6;

View File

@@ -39,7 +39,7 @@ class PopularRemotesWindow(Adw.Window):
except Exception as e:
self.toast_overlay.add_toast(Adw.Toast.new(_("Could not add {}").format(self.name_to_add)))
print(e)
self.generate_list()
self.parent_window.generate_list()
self.close()
def add_handler(self, _widget, name="", link=""):
@@ -49,6 +49,7 @@ class PopularRemotesWindow(Adw.Window):
dialog.add_response("continue", _("Add"))
dialog.set_response_enabled("continue", False)
dialog.set_response_appearance("continue", Adw.ResponseAppearance.SUGGESTED)
dialog.set_transient_for(self.parent_window)
def name_update(widget):
is_enabled = True
@@ -172,8 +173,8 @@ class PopularRemotesWindow(Adw.Window):
def __init__(self, parent_window, **kwargs):
super().__init__(**kwargs)
self.my_utils = myUtils(self)
self.parent_window = parent_window
self.connect("close-request", lambda *_: parent_window.generate_list())
self.set_modal(True)
self.set_transient_for(parent_window)
self.generate_list()

View File

@@ -87,7 +87,32 @@ class RemotesWindow(Adw.Window):
remote_row.add_suffix(remove_button)
def showPopularRemotes(self, widget):
PopularRemotesWindow(self).present()
remotes = [
["elementary", "https://flatpak.elementary.io/repo.flatpakrepo", _("ElementoryOS's Apps")],
["flathub", "https://dl.flathub.org/repo/flathub.flatpakrepo", _("The biggest repository of Flatpaks")],
["flathub-beta", "https://flathub.org/beta-repo/flathub-beta.flatpakrepo", _("The beta branch of the biggest repository of Flatpaks")],
["fedora", "oci+https://registry.fedoraproject.org", _("Flatpaks packaged by Fedora Linux")],
["gnome-nightly", "https://nightly.gnome.org/gnome-nightly.flatpakrepo", _("Beta GNOME Apps and Runtimes")],
["kdeapps", "https://distribute.kde.org/kdeapps.flatpakrepo", _("Beta KDE Apps and Runtimes")],
]
non_added_remotes = []
host_remotes = self.my_utils.getHostRemotes()
host_remotes_names = []
for i in range(len(self.host_remotes)):
host_remotes_names.append(self.host_remotes[i][0])
for i in range(len(remotes)):
if remotes[i][0] not in host_remotes_names:
non_added_remotes.append(remotes[i])
if len(non_added_remotes) > 0:
PopularRemotesWindow(self).present()
else:
PopularRemotesWindow(self).add_handler(widget)
def __init__(self, main_window, **kwargs):
super().__init__(**kwargs)