[gnome-boxes] wizard-source: Port 'Downloaded' list to GtkListBox



commit 1ec59fc47056a3900d42cc6b704fd54d089ddb2d
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Oct 25 12:58:21 2017 +0200

    wizard-source: Port 'Downloaded' list to GtkListBox
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790381

 data/ui/wizard-media-entry.ui |    2 +-
 data/ui/wizard-scrolled.ui    |    4 +---
 src/wizard-source.vala        |   21 ++++++++++-----------
 3 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/data/ui/wizard-media-entry.ui b/data/ui/wizard-media-entry.ui
index d8c5c0f..401470c 100644
--- a/data/ui/wizard-media-entry.ui
+++ b/data/ui/wizard-media-entry.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.9 -->
-  <template class="BoxesWizardMediaEntry" parent="GtkButton">
+  <template class="BoxesWizardMediaEntry" parent="GtkListBoxRow">
     <property name="visible">True</property>
     <style>
       <class name="boxes-menu-row"/>
diff --git a/data/ui/wizard-scrolled.ui b/data/ui/wizard-scrolled.ui
index a9e48f4..097faa0 100644
--- a/data/ui/wizard-scrolled.ui
+++ b/data/ui/wizard-scrolled.ui
@@ -10,10 +10,8 @@
       <class name="boxes-menu-scrolled"/>
     </style>
     <child>
-      <object class="GtkBox" id="vbox">
+      <object class="GtkListBox" id="vbox">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">0</property>
       </object>
     </child>
   </template>
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 9c363cd..e207924 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -15,7 +15,7 @@ public delegate bool ClickedFunc ();
 [GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-scrolled.ui")]
 private class Boxes.WizardScrolled : Gtk.ScrolledWindow {
     [GtkChild]
-    public Gtk.Box vbox;
+    public Gtk.ListBox vbox;
 
     private int num_visible { get; set; }
 
@@ -39,12 +39,10 @@ private class Boxes.WizardScrolled : Gtk.ScrolledWindow {
 
     public override void get_preferred_height (out int minimum_height, out int natural_height) {
         base.get_preferred_height (out minimum_height, out natural_height);
-        var viewport = get_child () as Gtk.Viewport;
-        var box = viewport.get_child () as Gtk.Box;
 
         int height = 0;
         int i = 0;
-        foreach (var w in box.get_children ()) {
+        foreach (var w in vbox.get_children ()) {
             if (!w.get_visible ())
                 continue;
             int child_height;
@@ -60,7 +58,7 @@ private class Boxes.WizardScrolled : Gtk.ScrolledWindow {
 }
 
 [GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-media-entry.ui")]
-private class Boxes.WizardMediaEntry : Gtk.Button {
+private class Boxes.WizardMediaEntry : Gtk.ListBoxRow {
     public InstallerMedia media;
 
     [GtkChild]
@@ -239,7 +237,7 @@ private class Boxes.WizardSource: Gtk.Stack {
 
     private AppWindow window;
 
-    private Gtk.Box media_vbox;
+    private Gtk.ListBox media_vbox;
 
     private Gtk.ListStore? media_urls_store;
 
@@ -312,6 +310,12 @@ private class Boxes.WizardSource: Gtk.Stack {
         var num_visible = (Gdk.Screen.height () > 800)? 3 : 2;
         media_scrolled.setup (num_visible);
         media_vbox = media_scrolled.vbox;
+        media_vbox.row_activated.connect((row) => {
+            var entry = (row as WizardMediaEntry);
+            on_media_selected (entry.media);
+
+            selected = entry;
+        });
         draw_as_css_box (url_entry_vbox);
 
         update_libvirt_sytem_entry_visibility.begin ();
@@ -458,11 +462,6 @@ private class Boxes.WizardSource: Gtk.Stack {
     private void add_media_entry (InstallerMedia media) {
         var entry = new WizardMediaEntry (media);
         media_vbox.add (entry);
-        entry.clicked.connect (() => {
-            on_media_selected (media);
-
-            selected = entry;
-        });
 
         media_scrolled.show ();
     }


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