clan-vm-manager: Fix regression part2
This commit is contained in:
@@ -81,7 +81,7 @@ class ClanURI:
|
|||||||
if machine_name:
|
if machine_name:
|
||||||
uri += f"#{machine_name}"
|
uri += f"#{machine_name}"
|
||||||
|
|
||||||
# users might copy whitespace along with the uri
|
# Users might copy whitespace along with the URI
|
||||||
uri = uri.strip()
|
uri = uri.strip()
|
||||||
|
|
||||||
# Check if the URI starts with clan://
|
# Check if the URI starts with clan://
|
||||||
@@ -90,6 +90,12 @@ class ClanURI:
|
|||||||
if uri.startswith(prefix):
|
if uri.startswith(prefix):
|
||||||
uri = uri[len(prefix) :]
|
uri = uri[len(prefix) :]
|
||||||
|
|
||||||
|
# Fix missing colon (caused by browsers like Firefox)
|
||||||
|
if "//" in uri and ":" not in uri.split("//", 1)[0]:
|
||||||
|
# If there's a `//` but no colon before it, add one before the `//`
|
||||||
|
parts = uri.split("//", 1)
|
||||||
|
uri = f"{parts[0]}://{parts[1]}"
|
||||||
|
|
||||||
# Parse the URI into components
|
# Parse the URI into components
|
||||||
# url://netloc/path;parameters?query#fragment
|
# url://netloc/path;parameters?query#fragment
|
||||||
components: urllib.parse.ParseResult = urllib.parse.urlparse(uri)
|
components: urllib.parse.ParseResult = urllib.parse.urlparse(uri)
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ def test_get_url() -> None:
|
|||||||
assert uri.get_url() == "/home/user/Downloads"
|
assert uri.get_url() == "/home/user/Downloads"
|
||||||
|
|
||||||
|
|
||||||
|
def test_firefox_strip_uri() -> None:
|
||||||
|
uri = ClanURI.from_str("clan://https//git.clan.lol/clan/democlan")
|
||||||
|
assert uri.get_url() == "https://git.clan.lol/clan/democlan"
|
||||||
|
uri = ClanURI.from_str("clan://git+https//git.clan.lol/clan/democlan.git")
|
||||||
|
assert uri.get_url() == "git+https://git.clan.lol/clan/democlan.git"
|
||||||
|
|
||||||
|
|
||||||
def test_local_uri() -> None:
|
def test_local_uri() -> None:
|
||||||
# Create a ClanURI object from a local URI
|
# Create a ClanURI object from a local URI
|
||||||
uri = ClanURI.from_str("clan://file:///home/user/Downloads")
|
uri = ClanURI.from_str("clan://file:///home/user/Downloads")
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from clan_vm_manager.views.logs import Logs
|
|||||||
|
|
||||||
gi.require_version("Adw", "1")
|
gi.require_version("Adw", "1")
|
||||||
|
|
||||||
from gi.repository import Adw, Gio, GLib
|
from gi.repository import Adw, Gio, GLib, Gtk
|
||||||
|
|
||||||
from clan_vm_manager.components.trayicon import TrayIcon
|
from clan_vm_manager.components.trayicon import TrayIcon
|
||||||
|
|
||||||
@@ -46,14 +46,15 @@ class MainWindow(Adw.ApplicationWindow):
|
|||||||
# Initialize all views
|
# Initialize all views
|
||||||
stack_view = ViewStack.use().view
|
stack_view = ViewStack.use().view
|
||||||
|
|
||||||
# clamp = Adw.Clamp()
|
# @hsjobeki: Do not remove clamp it is needed to limit the width
|
||||||
# clamp.set_child(stack_view)
|
clamp = Adw.Clamp()
|
||||||
# clamp.set_maximum_size(1000)
|
clamp.set_child(stack_view)
|
||||||
|
clamp.set_maximum_size(1000)
|
||||||
|
|
||||||
# scroll = Gtk.ScrolledWindow()
|
scroll = Gtk.ScrolledWindow()
|
||||||
# scroll.set_propagate_natural_height(True)
|
scroll.set_propagate_natural_height(True)
|
||||||
# scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||||
# scroll.set_child(clamp)
|
scroll.set_child(clamp)
|
||||||
|
|
||||||
stack_view.add_named(ClanList(config), "list")
|
stack_view.add_named(ClanList(config), "list")
|
||||||
stack_view.add_named(Details(), "details")
|
stack_view.add_named(Details(), "details")
|
||||||
@@ -61,7 +62,7 @@ class MainWindow(Adw.ApplicationWindow):
|
|||||||
|
|
||||||
stack_view.set_visible_child_name(config.initial_view)
|
stack_view.set_visible_child_name(config.initial_view)
|
||||||
|
|
||||||
view.set_content(stack_view)
|
view.set_content(scroll)
|
||||||
|
|
||||||
self.connect("destroy", self.on_destroy)
|
self.connect("destroy", self.on_destroy)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user