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



commit c609d294d56ab501ab07d5fb54d025b505c827c2
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 615cfef8..a6cc1c2d 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);
-            }
-        });
-
         os_db.get_all_media_urls_as_store.begin ((db, result) => {
             try {
                 media_urls_store = os_db.get_all_media_urls_as_store.end (result);
@@ -485,6 +470,7 @@ public void setup_ui (AppWindow window) {
         return entry;
     }
 
+    [GtkCallback]
     private void on_downloadable_entry_clicked (Gtk.ListBoxRow row) {
         var entry = (row as WizardDownloadableEntry);
 
@@ -615,6 +601,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]