[gnome-boxes/port-assistant-widgets-to-hdy: 3/8] assistant: Make DownloadableMediaEntry derived of AssistantMediaEntry




commit 3e47a4956cbe7101e273038a290190b3145083dd
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Dec 9 11:26:17 2021 +0100

    assistant: Make DownloadableMediaEntry derived of AssistantMediaEntry
    
    So it gets all the benefits of Hdy.ActionRow.
    
    Yay to deleting code!

 data/gnome-boxes.gresource.xml          |  1 -
 data/ui/assistant/downloadable-entry.ui | 80 ---------------------------------
 src/assistant/downloadable-entry.vala   | 33 +++-----------
 src/assistant/downloads-page.vala       |  2 +-
 src/assistant/index-page.vala           |  4 +-
 src/assistant/media-entry.vala          |  4 +-
 6 files changed, 10 insertions(+), 114 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index d24a6ed9..f6c10a48 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -31,7 +31,6 @@
     <file preprocess="xml-stripblanks">ui/troubleshoot-view.ui</file>
     <file preprocess="xml-stripblanks">ui/unattended-setup-box.ui</file>
     <!-- VM Creation Assistant -->
-    <file preprocess="xml-stripblanks">ui/assistant/downloadable-entry.ui</file>
     <file preprocess="xml-stripblanks">ui/assistant/media-entry.ui</file>
     <file preprocess="xml-stripblanks">ui/assistant/vm-assistant.ui</file>
     <file preprocess="xml-stripblanks">ui/assistant/rhel-download-dialog.ui</file>
diff --git a/src/assistant/downloadable-entry.vala b/src/assistant/downloadable-entry.vala
index 3228b475..14271269 100644
--- a/src/assistant/downloadable-entry.vala
+++ b/src/assistant/downloadable-entry.vala
@@ -1,38 +1,15 @@
-[GtkTemplate (ui = "/org/gnome/Boxes/ui/assistant/downloadable-entry.ui")]
-public class Boxes.AssistantDownloadableEntry : Gtk.ListBoxRow {
+private class Boxes.AssistantDownloadableEntry : Boxes.AssistantMediaEntry {
     public Osinfo.Os? os;
-
-    [GtkChild]
-    private unowned Gtk.Image media_image;
-    [GtkChild]
-    private unowned Gtk.Label title_label;
-    [GtkChild]
-    private unowned Gtk.Label details_label;
-
-    public string title {
-        get { return title_label.get_text (); }
-        set { title_label.label = value; }
-    }
-
-    public string details {
-        get { return details_label.get_text (); }
-        set { details_label.label = value; }
-    }
     public string url;
 
-    public AssistantDownloadableEntry (Osinfo.Media media) {
-        this.from_os (media.os);
+    public AssistantDownloadableEntry.from_osinfo (Osinfo.Media media) {
+        this.os = media.os;
 
+        url = media.url;
         title = serialize_os_title (media);
-        details = media.os.vendor;
+        subtitle = media.os.vendor;
         set_tooltip_text (media.url ?? title);
 
-        url = media.url;
-    }
-
-    public AssistantDownloadableEntry.from_os (Osinfo.Os os) {
         Downloader.fetch_os_logo.begin (media_image, os, 64);
-
-        this.os = os;
     }
 }
diff --git a/src/assistant/downloads-page.vala b/src/assistant/downloads-page.vala
index 520b68ac..7317f811 100644
--- a/src/assistant/downloads-page.vala
+++ b/src/assistant/downloads-page.vala
@@ -84,7 +84,7 @@ private async void populate_recommended_list () {
     }
 
     private Gtk.Widget create_downloads_entry (Object item) {
-        return new AssistantDownloadableEntry (item as Osinfo.Media);
+        return new AssistantDownloadableEntry.from_osinfo (item as Osinfo.Media);
     }
 
     [GtkCallback]
diff --git a/src/assistant/index-page.vala b/src/assistant/index-page.vala
index a96b1efd..4ccf8775 100644
--- a/src/assistant/index-page.vala
+++ b/src/assistant/index-page.vala
@@ -87,11 +87,11 @@ private void populate_detected_sources_list (int? number_of_items = null) {
     }
 
     private Gtk.Widget add_media_entry (GLib.Object object) {
-        return new AssistantMediaEntry (object as InstallerMedia);
+        return new AssistantMediaEntry.from_installer_media (object as InstallerMedia);
     }
 
     private Gtk.Widget add_featured_media_entry (GLib.Object object) {
-        return new AssistantDownloadableEntry (object as Osinfo.Media);
+        return new AssistantDownloadableEntry.from_osinfo (object as Osinfo.Media);
     }
 
     [GtkCallback]
diff --git a/src/assistant/media-entry.vala b/src/assistant/media-entry.vala
index 0ca36c18..663f6ccb 100644
--- a/src/assistant/media-entry.vala
+++ b/src/assistant/media-entry.vala
@@ -3,9 +3,9 @@
     public InstallerMedia media;
 
     [GtkChild]
-    private unowned Gtk.Image media_image;
+    protected unowned Gtk.Image media_image;
 
-    public AssistantMediaEntry (InstallerMedia media) {
+    public AssistantMediaEntry.from_installer_media (InstallerMedia media) {
         this.media = media;
 
         if (media.os != null)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]