[gnome-boxes/additional-cleanups: 1/4] app-window: Simplify "empty state" page
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/additional-cleanups: 1/4] app-window: Simplify "empty state" page
- Date: Thu, 9 Dec 2021 15:04:05 +0000 (UTC)
commit 4d1d4b70d16956200c3dbf1e14654aed1b85f447
Author: Felipe Borges <felipeborges gnome org>
Date: Thu Dec 9 15:31:59 2021 +0100
app-window: Simplify "empty state" page
Using HdyStatusPage directly.
data/gnome-boxes.gresource.xml | 1 -
data/ui/app-window.ui | 64 +++++++++++++++++++++++-------------------
data/ui/empty-boxes.ui | 57 -------------------------------------
src/app-window.vala | 27 +++++++++++++-----
src/empty-boxes.vala | 41 ---------------------------
src/meson.build | 1 -
6 files changed, 55 insertions(+), 136 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index f6c10a48..598d8bed 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -13,7 +13,6 @@
<file preprocess="xml-stripblanks">ui/display-toolbar.ui</file>
<file preprocess="xml-stripblanks">ui/downloads-hub.ui</file>
<file preprocess="xml-stripblanks">ui/downloads-hub-row.ui</file>
- <file preprocess="xml-stripblanks">ui/empty-boxes.ui</file>
<file preprocess="xml-stripblanks">ui/icon-view.ui</file>
<file preprocess="xml-stripblanks">ui/icon-view-child.ui</file>
<file preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">ui/kbd-shortcuts-window.ui</file>
diff --git a/data/ui/app-window.ui b/data/ui/app-window.ui
index 99dc0157..4767e1a3 100644
--- a/data/ui/app-window.ui
+++ b/data/ui/app-window.ui
@@ -78,10 +78,44 @@
<property name="transition-duration">400</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="visible-child-name">connecting-page</property>
<child>
- <object class="BoxesEmptyBoxes" id="empty_boxes">
+ <object class="GtkBox">
<property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="halign">fill</property>
+ <property name="valign">fill</property>
+
+ <child>
+ <object class="GtkSpinner">
+ <property name="visible">True</property>
+ <property name="active">True</property>
+ <property name="width-request">32</property>
+ <property name="height-request">32</property>
+ </object>
+
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+
+ <packing>
+ <property name="name">connecting-page</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="HdyStatusPage" id="empty_boxes">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="icon-name">empty-boxes</property>
+ <property name="title" translatable="yes">Welcome to Boxes</property>
+ <property name="description" translatable="yes">Use the <b>+</b> button to
create your first virtual machine.</property>
</object>
<packing>
<property name="name">empty-boxes</property>
@@ -124,34 +158,6 @@
<property name="name">display-page</property>
</packing>
</child>
-
- <child>
- <object class="GtkBox" id="spinner-box">
- <property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="halign">fill</property>
- <property name="valign">fill</property>
-
- <child>
- <object class="GtkSpinner" id="spinner">
- <property name="visible">True</property>
- <property name="active">True</property>
- <property name="width-request">32</property>
- <property name="height-request">32</property>
- </object>
-
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </object>
-
- <packing>
- <property name="name">connecting-page</property>
- </packing>
- </child>
</object>
</child>
</object>
diff --git a/src/app-window.vala b/src/app-window.vala
index dfc9f5af..baed07f3 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -81,7 +81,7 @@
[GtkChild]
public unowned DisplayPage display_page;
[GtkChild]
- public unowned EmptyBoxes empty_boxes;
+ public unowned Hdy.StatusPage empty_boxes;
[GtkChild]
public unowned TroubleshootView troubleshoot_view;
[GtkChild]
@@ -130,8 +130,6 @@ public AppWindow (Gtk.Application app) {
settings = new GLib.Settings ("org.gnome.boxes");
- notify["ui-state"].connect (ui_state_changed);
-
Gtk.Window.set_default_icon_name (Config.APPLICATION_ID);
Hdy.StyleManager.get_default ().color_scheme = PREFER_DARK;
@@ -174,14 +172,31 @@ public void setup_ui () {
list_view.setup_ui (this);
selectionbar.setup_ui (this);
searchbar.setup_ui (this);
- empty_boxes.setup_ui (this);
troubleshoot_view.setup_ui (this);
notificationbar.searchbar = searchbar;
group = new Gtk.WindowGroup ();
group.add_window (this);
+ App.app.call_when_ready (on_app_ready);
+ }
+
+ private void on_app_ready () {
+ notify["ui-state"].connect (ui_state_changed);
notify["view-type"].connect (ui_state_changed);
+
+ on_collection_changed ();
+ App.app.collection.item_added.connect (on_collection_changed);
+ App.app.collection.item_removed.connect (on_collection_changed);
+ }
+
+ private void on_collection_changed () {
+ bool collection_is_empty = (App.app.collection.length == 0);
+
+ if (collection_is_empty)
+ below_bin.visible_child = empty_boxes;
+ else
+ below_bin.visible_child = view;
}
private void save_window_geometry () {
@@ -202,9 +217,7 @@ private void ui_state_changed () {
// flush any deferred changes for wizard to pick-up when going back from properties to wizard
(review).
foreach (var ui in new Boxes.UI[] { topbar,
icon_view,
- list_view,
- //wizard_window,
- empty_boxes }) {
+ list_view }) {
ui.set_state (ui_state);
}
diff --git a/src/meson.build b/src/meson.build
index 5d7e1127..c858ce90 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -96,7 +96,6 @@ vala_sources = [
'welcome-tutorial.vala',
'welcome-tutorial-page.vala',
'downloader.vala',
- 'empty-boxes.vala',
'tracker-iso-query.vala',
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]