[gnome-boxes/boxes-newbox-assistant-306: 2/2] Downloads Hub WIP



commit 2ab225e176523869f01ee2ef205e7e61fc8138fa
Author: Felipe Borges <felipeborges gnome org>
Date:   Mon Nov 18 16:50:51 2019 +0100

    Downloads Hub WIP

 data/gnome-boxes.gresource.xml   |  1 +
 data/ui/collection-toolbar.ui    | 27 ++++++++++++++++++++++++
 data/ui/downloads-hub-popover.ui | 21 +++++++++++++++++++
 src/app-window.vala              |  2 +-
 src/assistant/index-page.vala    |  2 +-
 src/collection-toolbar.vala      |  4 +++-
 src/downloads-hub.vala           | 44 ++++++++++++++++++++++++++++++++++++++++
 src/meson.build                  |  1 +
 8 files changed, 99 insertions(+), 3 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 67dfbd8f..3280186a 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -13,6 +13,7 @@
     <file preprocess="xml-stripblanks">ui/collection-toolbar.ui</file>
     <file preprocess="xml-stripblanks">ui/display-page.ui</file>
     <file preprocess="xml-stripblanks">ui/display-toolbar.ui</file>
+    <file preprocess="xml-stripblanks">ui/downloads-hub-popover.ui</file>
     <file preprocess="xml-stripblanks">ui/editable-entry.ui</file>
     <file preprocess="xml-stripblanks">ui/empty-boxes.ui</file>
     <file preprocess="xml-stripblanks">ui/icon-view.ui</file>
diff --git a/data/ui/collection-toolbar.ui b/data/ui/collection-toolbar.ui
index ad117123..b6e43601 100644
--- a/data/ui/collection-toolbar.ui
+++ b/data/ui/collection-toolbar.ui
@@ -61,6 +61,33 @@
       </object>
     </child>
 
+    <child>
+      <object class="BoxesDownloadsHub" id="downloads_hub_btn">
+        <property name="visible">True</property>
+        <property name="valign">center</property>
+        <property name="use-underline">True</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child internal-child="accessible">
+          <object class="AtkObject">
+            <property name="accessible-name" translatable="yes">Downloads</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon-name">media-record-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
+
     <child>
       <object class="GtkMenuButton" id="hamburger_btn">
         <property name="visible">True</property>
diff --git a/data/ui/downloads-hub-popover.ui b/data/ui/downloads-hub-popover.ui
new file mode 100644
index 00000000..e7d79e5a
--- /dev/null
+++ b/data/ui/downloads-hub-popover.ui
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.19"/>
+  <template class="BoxesDownloadsHubPopover" parent="GtkPopover">
+    <property name="can_focus">False</property>
+    <property name="modal">True</property>
+    <property name="position">bottom</property>
+
+    <child>
+      <object class="GtkScrolledWindow">
+        <property name="visible">True</property>
+
+        <child>
+          <object class="GtkListBox" id="listbox">
+            <property name="visible">True</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/app-window.vala b/src/app-window.vala
index 51556afc..6ce4e2c8 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -232,7 +232,7 @@ private void ui_state_changed () {
                                             icon_view,
                                             list_view,
                                             props_window,
-                                            wizard_window,
+                                            //wizard_window,
                                             empty_boxes }) {
             ui.set_state (ui_state);
         }
diff --git a/src/assistant/index-page.vala b/src/assistant/index-page.vala
index 7a39d3df..bf0d339f 100644
--- a/src/assistant/index-page.vala
+++ b/src/assistant/index-page.vala
@@ -108,7 +108,7 @@ private void on_featured_media_selected (Gtk.ListBoxRow row) {
 
             rhel_dialog.run ();
         } else
-            on_download_selected (entry.url);
+            DownloadsHub.get_instance ().add_item (entry);
 
         dialog.close ();
     }
diff --git a/src/collection-toolbar.vala b/src/collection-toolbar.vala
index 2e337148..9a52ff61 100644
--- a/src/collection-toolbar.vala
+++ b/src/collection-toolbar.vala
@@ -16,6 +16,8 @@
     [GtkChild]
     private Button new_btn;
     [GtkChild]
+    private DownloadsHub downloads_hub_btn;
+    [GtkChild]
     private MenuButton hamburger_btn;
     [GtkChild]
     private CollectionFilterSwitcher filter_switcher;
@@ -62,7 +64,7 @@ public void click_search_button () {
 
     [GtkCallback]
     private void on_new_vm_btn_clicked () {
-        window.set_state (UIState.WIZARD);
+        //window.set_state (UIState.WIZARD);
     }
 
     [GtkCallback]
diff --git a/src/downloads-hub.vala b/src/downloads-hub.vala
new file mode 100644
index 00000000..aabdf655
--- /dev/null
+++ b/src/downloads-hub.vala
@@ -0,0 +1,44 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
+
+public class Boxes.DownloadsHub : Gtk.MenuButton {
+    private static DownloadsHub downloads_hub;
+
+    private GLib.ListStore model = new GLib.ListStore (typeof (Osinfo.Media));
+
+    private DownloadsHubPopover hub;
+
+    public static DownloadsHub get_instance () {
+        if (downloads_hub == null)
+            downloads_hub = new DownloadsHub ();
+
+        return downloads_hub;
+    }
+
+    construct {
+        hub = new Boxes.DownloadsHubPopover ();
+        hub.relative_to = this;
+
+        this.popover = hub;
+    }
+
+    public void add_item (WizardDownloadableEntry entry) {
+        var label = new Gtk.Label (entry.title);
+        label.visible = true;
+
+        hub.add_item (label);
+    }
+}
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/downloads-hub-popover.ui")]
+private class Boxes.DownloadsHubPopover : Gtk.Popover {
+    [GtkChild]
+    private ListBox listbox;
+
+    public DownloadsHubPopover () {
+    }
+
+    public void add_item (Gtk.Widget entry) {
+        listbox.insert (entry, -1);
+    }
+}
diff --git a/src/meson.build b/src/meson.build
index 4b741984..c78b8fbd 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -54,6 +54,7 @@ vala_sources = [
   'display-page.vala',
   'display-toolbar.vala',
   'display.vala',
+  'downloads-hub.vala',
   'editable-entry.vala',
   'i-properties-provider.vala',
   'i-collection-view.vala',


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