[gnome-boxes/wip/exalm/libhandy1: 5/6] Use GtkStack and GtkStackSwitcher for collection views
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/exalm/libhandy1: 5/6] Use GtkStack and GtkStackSwitcher for collection views
- Date: Tue, 26 May 2020 15:54:01 +0000 (UTC)
commit 5f06e807bdb7011998bafd4ea2b530af87be01c1
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue May 26 20:10:47 2020 +0500
Use GtkStack and GtkStackSwitcher for collection views
data/gnome-boxes.gresource.xml | 1 -
data/ui/app-window.ui | 32 +++++++++++++++++--
data/ui/collection-filter-switcher.ui | 39 -----------------------
data/ui/collection-toolbar.ui | 2 +-
src/app-window.vala | 36 ++++++++++++++--------
src/collection-filter-switcher.vala | 58 -----------------------------------
src/collection-toolbar.vala | 6 ++--
src/empty-boxes.vala | 2 +-
src/meson.build | 1 -
9 files changed, 57 insertions(+), 120 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index e8951023..e0d68b5e 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -11,7 +11,6 @@
<file>icons/eye-open-negative-filled-symbolic.svg</file>
<file preprocess="xml-stripblanks">ui/app-window.ui</file>
<file preprocess="xml-stripblanks">ui/auth-notification.ui</file>
- <file preprocess="xml-stripblanks">ui/collection-filter-switcher.ui</file>
<file preprocess="xml-stripblanks">ui/collection-filter-view.ui</file>
<file preprocess="xml-stripblanks">ui/collection-toolbar.ui</file>
<file preprocess="xml-stripblanks">ui/display-page.ui</file>
diff --git a/data/ui/app-window.ui b/data/ui/app-window.ui
index f20f5069..4f4002a7 100644
--- a/data/ui/app-window.ui
+++ b/data/ui/app-window.ui
@@ -16,7 +16,11 @@
| | |
| | |-> below_bin = new Gtk.Stack ();
| | |
- | | |-> collection_view = new Boxes.CollectionView ();
+ | | |-> collection_stack = new Gtk.Stack ();
+ | | | |
+ | | | |-> all_view = new Boxes.CollectionView ();
+ | | | |
+ | | | |-> favorites_view = new Boxes.CollectionView ();
| | |
| | |-> empty_boxes = new Boxes.EmptyBoxes ();
| | |
@@ -91,12 +95,34 @@
</child>
<child>
- <object class="BoxesCollectionFilterView" id="collection_view">
+ <object class="GtkStack" id="collection_stack">
<property name="visible">True</property>
+ <property name="transition-type">crossfade</property>
+ <child>
+ <object class="BoxesCollectionFilterView" id="all_view">
+ <property name="visible">True</property>
+ <property name="filter-type">all</property>
+ </object>
+ <packing>
+ <property name="title" translatable="yes" comments="Translators: this is a switch to
show all boxes in main view.">All</property>
+ <property name="name">all-view</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="BoxesCollectionFilterView" id="favorites_view">
+ <property name="visible">True</property>
+ <property name="filter-type">favorites</property>
+ </object>
+ <packing>
+ <property name="title" translatable="yes" comments="Translators: this is a switch to
show only favorite boxes in main view.">Favorites</property>
+ <property name="name">favorites-view</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="name">collection-view</property>
+ <property name="name">collection-stack</property>
</packing>
</child>
diff --git a/data/ui/collection-toolbar.ui b/data/ui/collection-toolbar.ui
index e9e641fd..c77b7537 100644
--- a/data/ui/collection-toolbar.ui
+++ b/data/ui/collection-toolbar.ui
@@ -9,7 +9,7 @@
</style>
<child type="title">
- <object class="BoxesCollectionFilterSwitcher" id="filter_switcher">
+ <object class="GtkStackSwitcher" id="stack_switcher">
<property name="visible">True</property>
</object>
</child>
diff --git a/src/app-window.vala b/src/app-window.vala
index 4167fa5b..327c2624 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -94,13 +94,21 @@
[GtkChild]
public Gtk.Stack below_bin;
[GtkChild]
- private CollectionFilterView collection_view;
+ public Gtk.Stack collection_stack;
+ [GtkChild]
+ private CollectionFilterView all_view;
+ [GtkChild]
+ private CollectionFilterView favorites_view;
public ViewType view_type { get; set; default = ViewType.ICON; }
public ICollectionView view {
get {
- return collection_view.view;
+ var current_view = collection_stack.visible_child;
+
+ assert (current_view is CollectionFilterView);
+
+ return ((CollectionFilterView) current_view).view;
}
}
@@ -165,7 +173,8 @@ public AppWindow (Gtk.Application app) {
public void setup_ui () {
topbar.setup_ui (this);
display_page.setup_ui (this);
- collection_view.setup_ui (this);
+ all_view.setup_ui (this);
+ favorites_view.setup_ui (this);
selectionbar.setup_ui (this);
searchbar.setup_ui (this);
empty_boxes.setup_ui (this);
@@ -197,7 +206,8 @@ private void ui_state_changed () {
// The order is important for some widgets here (e.g properties must change its state before wizard
so it can
// 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,
- collection_view,
+ all_view,
+ favorites_view,
props_window,
//wizard_window,
empty_boxes }) {
@@ -212,11 +222,12 @@ private void ui_state_changed () {
switch (ui_state) {
case UIState.COLLECTION:
if (App.app.collection.length != 0)
- below_bin.visible_child = collection_view;
+ below_bin.visible_child = collection_stack;
else
below_bin.visible_child = empty_boxes;
- collection_view.view_type = view_type;
+ all_view.view_type = view_type;
+ favorites_view.view_type = view_type;
fullscreened = false;
@@ -371,7 +382,8 @@ public void select_item (CollectionItem item) {
}
public void filter (string text) {
- collection_view.foreach_view ((view) => { view.filter.text = text; });
+ all_view.foreach_view ((view) => { view.filter.text = text; });
+ favorites_view.foreach_view ((view) => { view.filter.text = text; });
}
[GtkCallback]
@@ -417,12 +429,14 @@ public bool on_key_pressed (Widget widget, Gdk.EventKey event) {
} else if (event.keyval == Gdk.Key.a &&
(event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK) {
selection_mode = true;
- collection_view.foreach_view ((view) => { view.select_all (); });
+ all_view.foreach_view ((view) => { view.select_all (); });
+ favorites_view.foreach_view ((view) => { view.select_all (); });
return true;
} else if (event.keyval == Gdk.Key.A &&
(event.state & default_modifiers) == (Gdk.ModifierType.CONTROL_MASK |
Gdk.ModifierType.SHIFT_MASK)) {
- collection_view.foreach_view ((view) => { view.unselect_all (); });
+ all_view.foreach_view ((view) => { view.unselect_all (); });
+ favorites_view.foreach_view ((view) => { view.unselect_all (); });
return true;
} else if (((direction == Gtk.TextDirection.LTR && // LTR
@@ -499,8 +513,4 @@ private void on_machine_deleted_notify () {
if (this != App.app.main_window && current_machine.deleted)
on_delete_event ();
}
-
- public void set_filter_type (CollectionFilterView.FilterType filter_type) {
- collection_view.filter_type = filter_type;
- }
}
diff --git a/src/collection-toolbar.vala b/src/collection-toolbar.vala
index c62d12aa..1502921f 100644
--- a/src/collection-toolbar.vala
+++ b/src/collection-toolbar.vala
@@ -20,7 +20,7 @@
[GtkChild]
public MenuButton hamburger_btn;
[GtkChild]
- private CollectionFilterSwitcher filter_switcher;
+ private StackSwitcher stack_switcher;
private AppWindow window;
@@ -43,7 +43,7 @@ public void setup_ui (AppWindow window) {
window.notify["ui-state"].connect (ui_state_changed);
App.app.notify["main-window"].connect (ui_state_changed);
- filter_switcher.setup_ui (window);
+ stack_switcher.stack = window.collection_stack;
var builder = new Builder.from_resource ("/org/gnome/Boxes/ui/menus.ui");
MenuModel menu = (MenuModel) builder.get_object ("app-menu");
@@ -114,7 +114,7 @@ private void ui_state_changed () {
new_btn.show ();
grid_btn.visible = window.view_type != AppWindow.ViewType.ICON;
list_btn.visible = window.view_type != AppWindow.ViewType.LIST;
- custom_title = filter_switcher;
+ custom_title = stack_switcher;
break;
case UIState.CREDS:
diff --git a/src/empty-boxes.vala b/src/empty-boxes.vala
index 119585d9..a0624273 100644
--- a/src/empty-boxes.vala
+++ b/src/empty-boxes.vala
@@ -36,6 +36,6 @@ private void update_visibility () {
if (visible)
window.below_bin.set_visible_child_name ("empty-boxes");
else
- window.below_bin.set_visible_child_name ("collection-view");
+ window.below_bin.set_visible_child_name ("collection-stack");
}
}
diff --git a/src/meson.build b/src/meson.build
index c5804d02..8d2b2c08 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -52,7 +52,6 @@ vala_sources = [
'archive-writer.vala',
'auth-notification.vala',
'collection.vala',
- 'collection-filter-switcher.vala',
'collection-filter-view.vala',
'collection-toolbar.vala',
'display-page.vala',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]