[gnome-boxes/simplify-assistant-landing-page: 63/64] assistant: Fallback to downloads when detected sources aren't found
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/simplify-assistant-landing-page: 63/64] assistant: Fallback to downloads when detected sources aren't found
- Date: Fri, 11 Feb 2022 10:12:54 +0000 (UTC)
commit 9bfdcccc1b7fa957f86227b2bca781f2b9a61fab
Author: Felipe Borges <felipeborges gnome org>
Date: Fri Feb 11 11:04:10 2022 +0100
assistant: Fallback to downloads when detected sources aren't found
If no valid installer media is indexed by tracker we would have an
empty page. Let's fill it with "Featured Downloads" when there's
no "Detected Sources" to show.
data/ui/assistant/pages/index-page.ui | 38 +++++++++++++++++++++++++++--------
src/assistant/index-page.vala | 29 +++++++++++++++++++++++---
2 files changed, 56 insertions(+), 11 deletions(-)
---
diff --git a/data/ui/assistant/pages/index-page.ui b/data/ui/assistant/pages/index-page.ui
index 93bbf4a9..9747e275 100644
--- a/data/ui/assistant/pages/index-page.ui
+++ b/data/ui/assistant/pages/index-page.ui
@@ -46,18 +46,40 @@
</child>
<child>
- <object class="HdyPreferencesGroup" id="detected_sources_section">
+ <object class="GtkStack" id="medias_stack">
<property name="visible">True</property>
- <property name="title" translatable="yes">Detected Sources</property>
+ <child>
+ <object class="HdyPreferencesGroup" id="detected_sources_section">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Detected Sources</property>
+ <child>
+ <object class="GtkListBox" id="source_medias">
+ <property name="visible">True</property>
+ <property name="selection-mode">none</property>
+ <signal name="row-activated" handler="on_source_media_selected"/>
+ <style>
+ <class name="content"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
- <object class="GtkListBox" id="source_medias">
+ <object class="HdyPreferencesGroup" id="downloadable_sources_section">
<property name="visible">True</property>
- <property name="selection-mode">none</property>
- <signal name="row-activated" handler="on_source_media_selected"/>
- <style>
- <class name="content"/>
- </style>
+ <property name="title" translatable="yes">Featured Downloads</property>
+
+ <child>
+ <object class="GtkListBox" id="downloadable_medias">
+ <property name="visible">True</property>
+ <property name="selection-mode">none</property>
+ <signal name="row-activated" handler="on_featured_media_selected"/>
+ <style>
+ <class name="content"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/src/assistant/index-page.vala b/src/assistant/index-page.vala
index 38013723..881ad0be 100644
--- a/src/assistant/index-page.vala
+++ b/src/assistant/index-page.vala
@@ -3,6 +3,7 @@
[GtkTemplate (ui = "/org/gnome/Boxes/ui/assistant/pages/index-page.ui")]
private class Boxes.AssistantIndexPage : AssistantPage {
GLib.ListStore source_model = new GLib.ListStore (typeof (InstallerMedia));
+ GLib.ListStore downloads_model = new GLib.ListStore (typeof (Osinfo.Media));
private VMAssistant dialog;
@@ -17,10 +18,14 @@
[GtkChild]
private unowned ScrolledWindow home_page;
[GtkChild]
- private unowned Hdy.PreferencesGroup detected_sources_section;
+ private unowned Stack medias_stack;
+ [GtkChild]
+ private unowned Hdy.PreferencesGroup downloadable_sources_section;
[GtkChild]
private unowned ListBox source_medias;
[GtkChild]
+ private unowned ListBox downloadable_medias;
+ [GtkChild]
private unowned Revealer panel_revealer;
private Gtk.Button view_more_medias_button;
@@ -31,6 +36,7 @@
populate_media_lists.begin ();
source_medias.bind_model (source_model, add_media_entry);
+ downloadable_medias.bind_model (downloads_model, add_downloadable_entry);
view_more_medias_button = new Gtk.Button () {
visible = true,
@@ -74,11 +80,13 @@ private async void populate_media_lists () {
private void populate_detected_sources_list (int? number_of_items = null) {
var number_of_available_medias = installer_medias.length ();
- detected_sources_section.visible = (number_of_available_medias > 0);
source_model.remove_all ();
- if (number_of_available_medias == 0)
+ if (number_of_available_medias == 0) {
+ populate_recommended_downloads_list ();
+
return;
+ }
foreach (var media in installer_medias) {
source_model.append (media);
@@ -88,10 +96,25 @@ private void populate_detected_sources_list (int? number_of_items = null) {
}
}
+ private async void populate_recommended_downloads_list () {
+ downloads_model.remove_all ();
+ medias_stack.set_visible_child (downloadable_sources_section);
+
+ foreach (var media in yield get_recommended_downloads ()) {
+ if (media != null) {
+ downloads_model.append (media);
+ }
+ }
+ }
+
private Gtk.Widget add_media_entry (GLib.Object object) {
return new AssistantMediaEntry.from_installer_media (object as InstallerMedia);
}
+ private Gtk.Widget add_downloadable_entry (GLib.Object object) {
+ return new AssistantDownloadableEntry.from_osinfo (object as Osinfo.Media);
+ }
+
[GtkCallback]
private void update_topbar () {
dialog.previous_button.label = _("Cancel");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]