[gnome-boxes/download-oses-page: 10/12] wizard-source: Make the RHEL entry a GtkListBoxRow



commit 3fbe85a6b2095df9e0bd01f571a5aa730430e9b5
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Jan 24 12:06:53 2018 +0100

    wizard-source: Make the RHEL entry a GtkListBoxRow

 data/ui/wizard-source.ui | 151 +++++++++++++++++++++++++----------------------
 src/wizard-source.vala   |  42 ++++++++-----
 2 files changed, 106 insertions(+), 87 deletions(-)
---
diff --git a/data/ui/wizard-source.ui b/data/ui/wizard-source.ui
index 7345e8c8..47dab2c9 100644
--- a/data/ui/wizard-source.ui
+++ b/data/ui/wizard-source.ui
@@ -274,81 +274,11 @@
                 <property name="border-width">20</property>
                 <property name="margin-start">20</property>
                 <property name="margin-end">20</property>
-                <child>
-                  <object class="GtkButton" id="install_rhel_button">
-                    <property name="visible">True</property>
-                    <signal name="clicked" handler="on_install_rhel_button_clicked"/>
-                    <style>
-                      <class name="boxes-menu-row"/>
-                    </style>
-                    <child>
-                      <object class="GtkBox" id="install_rhel_hbox">
-                        <property name="visible">True</property>
-                        <property name="margin-start">15</property>
-                        <property name="margin-end">15</property>
-                        <property name="spacing">20</property>
-                        <property name="orientation">horizontal</property>
-                        <child>
-                          <object class="GtkImage" id="install_rhel_image">
-                            <property name="icon-size">0</property>
-                            <property name="no-show-all">True</property>
-                            <property name="pixel-size">64</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkBox" id="install_rhel_vbox">
-                            <property name="visible">True</property>
-                            <property name="homogeneous">True</property>
-                            <property name="orientation">vertical</property>
-                            <child>
-                              <object class="GtkLabel" id="install_rhel_label">
-                                <property name="visible">True</property>
-                                <property name="ellipsize">end</property>
-                                <property name="halign">start</property>
-                                <property name="valign">end</property>
-                                <property name="use-underline">True</property>
-                                <property name="label" translatable="yes">Red Hat Enterprise Linux</property>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="install_rhel_details_label">
-                                <property name="visible">True</property>
-                                <property name="ellipsize">end</property>
-                                <property name="halign">start</property>
-                                <property name="valign">start</property>
-                                <property name="label" translatable="yes">Available with a free Red Hat 
developer account</property>
-                                <style>
-                                  <class name="boxes-step-label"/>
-                                  <class name="dim-label"/>
-                                </style>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                              </packing>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                </child>
 
                 <child>
                   <object class="GtkListBox" id="downloads_list">
                     <property name="visible">True</property>
+                    <signal name="row-activated" handler="on_downloadable_entry_clicked"/>
                   </object>
                 </child>
               </object>
@@ -496,4 +426,83 @@
       </packing>
     </child>
   </template>
+
+  <object class="GtkListBoxRow" id="install_rhel_button">
+    <property name="visible">True</property>
+    <property name="activatable">False</property>
+    <style>
+      <class name="boxes-menu-row"/>
+    </style>
+    <child>
+      <object class="GtkButton">
+      <property name="visible">True</property>
+      <signal name="clicked" handler="on_install_rhel_button_clicked"/>
+      <style>
+        <class name="flat"/>
+      </style>
+      <child>
+        <object class="GtkBox" id="install_rhel_hbox">
+          <property name="visible">True</property>
+          <property name="margin-start">15</property>
+          <property name="margin-end">15</property>
+          <property name="spacing">20</property>
+          <property name="orientation">horizontal</property>
+          <child>
+            <object class="GtkImage" id="install_rhel_image">
+              <property name="icon-size">0</property>
+              <property name="no-show-all">True</property>
+              <property name="pixel-size">64</property>
+            </object>
+            <packing>
+              <property name="expand">False</property>
+              <property name="fill">False</property>
+            </packing>
+          </child>
+          <child>
+            <object class="GtkBox" id="install_rhel_vbox">
+              <property name="visible">True</property>
+              <property name="homogeneous">True</property>
+              <property name="orientation">vertical</property>
+              <child>
+                <object class="GtkLabel" id="install_rhel_label">
+                  <property name="visible">True</property>
+                  <property name="ellipsize">end</property>
+                  <property name="halign">start</property>
+                  <property name="valign">end</property>
+                  <property name="use-underline">True</property>
+                  <property name="label" translatable="yes">Red Hat Enterprise Linux</property>
+                </object>
+                <packing>
+                  <property name="expand">True</property>
+                  <property name="fill">True</property>
+                </packing>
+              </child>
+              <child>
+                  <object class="GtkLabel" id="install_rhel_details_label">
+                    <property name="visible">True</property>
+                    <property name="ellipsize">end</property>
+                    <property name="halign">start</property>
+                    <property name="valign">start</property>
+                    <property name="label" translatable="yes">Available with a free Red Hat developer 
account</property>
+                    <style>
+                      <class name="boxes-step-label"/>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
 </interface>
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index bbcc3bf8..09190bd8 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -289,7 +289,7 @@ private void on_notify_estimated_load_progress () {
     [GtkChild]
     private Gtk.Label libvirt_sys_import_label;
     [GtkChild]
-    private Gtk.Button install_rhel_button;
+    private Gtk.ListBoxRow install_rhel_button;
     [GtkChild]
     private Gtk.Image install_rhel_image;
     [GtkChild]
@@ -412,21 +412,6 @@ public void setup_ui (AppWindow window) {
         downloads_vbox.bind_model (available_downloads_model, create_downloadable_entry);
         downloads_vbox.row_activated.connect (on_downloadable_entry_clicked);
 
-        downloads_list.bind_model (available_downloads_model, create_downloadable_entry);
-        downloads_list.row_activated.connect (on_downloadable_entry_clicked);
-
-        os_db.list_downloadable_oses.begin ((db, result) => {
-            try {
-                var media_list = os_db.list_downloadable_oses.end (result);
-
-                foreach (var media in media_list) {
-                    available_downloads_model.append (media);
-                }
-            } catch (OSDatabaseError error) {
-                debug ("Failed to populate the list of downloadable OSes: %s", error.message);
-            }
-        });
-
         // We need a Shadowman logo and libosinfo mandates that we specify an
         // OsinfoOs to get a logo. However, we don't have an OsinfoOs to begin
         // with, and by the time we get one from the Red Hat developer portal
@@ -464,6 +449,7 @@ public void setup_ui (AppWindow window) {
         return entry;
     }
 
+    [GtkCallback]
     private void on_downloadable_entry_clicked (Gtk.ListBoxRow row) {
         var entry = (row as WizardDownloadableEntry);
 
@@ -594,6 +580,30 @@ private void on_media_selected (InstallerMedia media) {
     [GtkCallback]
     private void on_download_an_os_button_clicked () {
         page = SourcePage.DOWNLOADS;
+
+        if (downloads_list.get_children ().length () != 0)
+            return;
+
+        var os_db = media_manager.os_db;
+        os_db.list_downloadable_oses.begin ((db, result) => {
+            try {
+                var media_list = os_db.list_downloadable_oses.end (result);
+
+                foreach (var media in media_list) {
+                    var entry = new WizardDownloadableEntry (media);
+
+                    downloads_list.insert (entry, -1);
+                }
+            } catch (OSDatabaseError error) {
+                debug ("Failed to populate the list of downloadable OSes: %s", error.message);
+            }
+        });
+
+        /* We manually add the custom download entries.
+         * custom download entries are items which require
+         * special handling such as an authentication page
+         * before we obtain a direct image URL. */
+        downloads_list.insert (install_rhel_button, 0);
     }
 
     [GtkCallback]


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