From 672c489471577b3bc98cfd51396cc3f20f8d0a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 3 Sep 2024 15:14:37 -0700 Subject: [PATCH] MainWindow: fix invalid bundle cast (#172) --- src/MainWindow.vala | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 37379469..cb88cf3c 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -29,7 +29,9 @@ public class Sideload.MainWindow : Gtk.ApplicationWindow { }; public File file { get; construct; } - public FlatpakFile flatpak_file { get; construct; } + + public FlatpakFile flatpak_file { get; private set; } + private Cancellable? current_cancellable = null; private Gtk.Stack stack; @@ -152,12 +154,14 @@ public class Sideload.MainWindow : Gtk.ApplicationWindow { return; } - if (content_type == REF_CONTENT_TYPE) { - flatpak_file = new FlatpakRefFile (file); - } else if (content_type == BUNDLE_CONTENT_TYPE) { - flatpak_file = new FlatpakBundleFile (file); - } else if (content_type == FLATPAK_HTTPS_CONTENT_TYPE) { - flatpak_file = new FlatpakRefFile (file); + switch (content_type) { + case REF_CONTENT_TYPE: + case FLATPAK_HTTPS_CONTENT_TYPE: + flatpak_file = new FlatpakRefFile (file); + break; + case BUNDLE_CONTENT_TYPE: + flatpak_file = new FlatpakBundleFile (file); + break; } if (flatpak_file.size == "0") { @@ -165,7 +169,9 @@ public class Sideload.MainWindow : Gtk.ApplicationWindow { stack.add_child (error_view); stack.visible_child = error_view; return; - } else if (flatpak_file is FlatpakRefFile) { + } + + if (flatpak_file is FlatpakRefFile) { progress_view = new ProgressView (ProgressView.ProgressType.REF_INSTALL); } else { progress_view = new ProgressView (ProgressView.ProgressType.BUNDLE_INSTALL); @@ -175,6 +181,7 @@ public class Sideload.MainWindow : Gtk.ApplicationWindow { stack.add_child (progress_view); main_view.install_request.connect (on_install_button_clicked); + flatpak_file.progress_changed.connect (on_progress_changed); flatpak_file.installation_failed.connect (on_install_failed); flatpak_file.installation_succeeded.connect (on_install_succeeded); @@ -187,8 +194,8 @@ public class Sideload.MainWindow : Gtk.ApplicationWindow { } else { if (flatpak_file is FlatpakRefFile) { main_view.display_ref_details (flatpak_file.size, flatpak_file.extra_remotes_needed, flatpak_file.permissions_flags); - } else { - main_view.display_bundle_details (flatpak_file.size, ((FlatpakBundleFile) file).has_remote, flatpak_file.extra_remotes_needed); + } else if (flatpak_file is FlatpakBundleFile) { + main_view.display_bundle_details (flatpak_file.size, ((FlatpakBundleFile) flatpak_file).has_remote, flatpak_file.extra_remotes_needed); } } });