Skip to content

Commit

Permalink
MainWindow: fix invalid bundle cast (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Sep 3, 2024
1 parent c6721e2 commit 672c489
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -152,20 +154,24 @@ 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") {
var error_view = new ErrorView (flatpak_file.error_code, flatpak_file.error_message);
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);
Expand All @@ -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);
Expand All @@ -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);
}
}
});
Expand Down

0 comments on commit 672c489

Please sign in to comment.