Commit 142c25bf authored by Felipe Borges's avatar Felipe Borges
Browse files

assistant, downloads-hub: Restore support to download from URI

Fixes #520
parent 39c3d76a
Pipeline #267472 failed with stages
in 65 minutes and 58 seconds
......@@ -20,6 +20,7 @@
private GLib.ListStore recommended_model;
public signal void media_selected (Gtk.ListBoxRow row);
public signal void url_entered ();
private AssistantDownloadsPageView _page;
public AssistantDownloadsPageView page {
......@@ -105,6 +106,14 @@ private void on_search_changed () {
if (text == null)
return;
var uri = Xml.URI.parse (text);
if (uri.scheme.has_prefix ("http")) {
DownloadsHub.get_instance ().add_url (text);
url_entered ();
return;
}
search.text = text;
}
......
......@@ -37,6 +37,7 @@
source_medias.set_header_func (use_list_box_separator);
featured_medias.set_header_func (use_list_box_separator);
recommended_downloads_page.url_entered.connect (() => { dialog.hide (); });
}
public void setup (VMAssistant dialog) {
......
......@@ -34,10 +34,12 @@ public static DownloadsHub get_default () {
}
public void add_item (WizardDownloadableEntry entry) {
n_items+=1;
var row = new DownloadsHubRow.from_entry (entry);
add_row (row);
}
private void add_row (DownloadsHubRow row) {
n_items+=1;
if (!button.visible)
button.visible = true;
......@@ -64,6 +66,11 @@ public void add_item (WizardDownloadableEntry entry) {
popup ();
}
public void add_url (string url) {
var row = new DownloadsHubRow.from_url (url);
add_row (row);
}
private void on_row_deleted () {
n_items-= 1;
if (!ongoing_downloads) {
......@@ -165,17 +172,27 @@ private bool draw_button_pie (Widget drawing_area, Cairo.Context context) {
Downloader.fetch_os_logo.begin (image, entry.os, 64);
setup (entry.url);
}
public DownloadsHubRow.from_url (string url) {
label.label = url;
setup (url);
}
private void setup (string url) {
progress_notify_id = progress.notify["progress"].connect (() => {
progress_bar.fraction = progress.progress;
});
progress_bar.fraction = progress.progress = 0;
var soup_download_uri = new Soup.URI (entry.url);
var soup_download_uri = new Soup.URI (url);
var download_path = soup_download_uri.get_path ();
var filename = GLib.Path.get_basename (download_path);
download.begin (entry.url, filename);
download.begin (url, filename);
}
private async void download (string url, string filename) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment