[gnome-boxes] app-window: Add foreach_view()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] app-window: Add foreach_view()
- Date: Sat, 22 Aug 2015 12:11:48 +0000 (UTC)
commit 83857a11a1669c504a13bf44069315f4fc6bb572
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri Jul 10 09:36:23 2015 +0200
app-window: Add foreach_view()
Add foreach_view(), allowing to easily iterate over all the views of the
window.
For now this isn't very useful since we only have a single view but a
list view will be added in a following patch.
https://bugzilla.gnome.org/show_bug.cgi?id=733252
src/app-window.vala | 13 +++++++++++--
src/app.vala | 6 +++---
src/collection-filter-switcher.vala | 10 +++++-----
3 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 3560f43..38c479b 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -95,6 +95,8 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
get { return collection_view; }
}
+ private ICollectionView[] views;
+
public GLib.Settings settings;
[GtkChild]
@@ -137,6 +139,8 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
move (x, y);
}
+
+ views = { collection_view };
}
public void setup_ui () {
@@ -187,7 +191,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
else
below_bin.visible_child = empty_boxes;
fullscreened = false;
- view.visible = true;
+ foreach_view ((view) => { view.visible = true; });
if (status_bind != null) {
status_bind.unbind (); // FIXME: We shouldn't neeed to explicitly unbind (Vala bug?)
@@ -224,6 +228,11 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
current_item.set_state (ui_state);
}
+ public void foreach_view (Func<ICollectionView> func) {
+ foreach (var view in views)
+ func (view);
+ }
+
public void show_properties () {
if (current_item != null) {
if (ui_state == UIState.COLLECTION && selection_mode)
@@ -287,7 +296,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
}
public void filter (string text) {
- view.filter.text = text;
+ foreach_view ((view) => { view.filter.text = text; });
}
[GtkCallback]
diff --git a/src/app.vala b/src/app.vala
index b73e1d7..2fe914a 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -127,10 +127,10 @@ private class Boxes.App: Gtk.Application {
collection = new Collection ();
collection.item_added.connect ((item) => {
- main_window.view.add_item (item);
+ main_window.foreach_view ((view) => { view.add_item (item); });
});
collection.item_removed.connect ((item) => {
- main_window.view.remove_item (item);
+ main_window.foreach_view ((view) => { view.remove_item (item); });
});
brokers.insert ("libvirt", LibvirtBroker.get_default ());
@@ -584,7 +584,7 @@ private class Boxes.App: Gtk.Application {
// If the main window have been removed,
// populate the new main window's collection view.
if (window_was_main)
- collection.populate (main_window.view);
+ main_window.foreach_view ((view) => { collection.populate (view); });
notify_property ("main-window");
diff --git a/src/collection-filter-switcher.vala b/src/collection-filter-switcher.vala
index 46bf99c..5f36bdd 100644
--- a/src/collection-filter-switcher.vala
+++ b/src/collection-filter-switcher.vala
@@ -10,16 +10,16 @@ private class Boxes.CollectionFilterSwitcher: Gtk.ButtonBox {
private Gtk.ToggleButton remote_button;
private Gtk.ToggleButton active_button;
- private CollectionFilter filter;
+ private weak AppWindow window;
public void setup_ui (AppWindow window) {
- filter = window.view.filter;
- assert (filter != null);
+ this.window = window;
+ assert (window != null);
all_button.active = true;
activate_button (all_button);
- filter.filter_func = null;
+ window.foreach_view ((view) => { view.filter.filter_func = null; });
}
private unowned CollectionFilterFunc? get_filter_func () {
@@ -55,6 +55,6 @@ private class Boxes.CollectionFilterSwitcher: Gtk.ButtonBox {
toggle_button.active = toggle_button == active_button;
}
- filter.filter_func = get_filter_func ();
+ window.foreach_view ((view) => { view.filter.filter_func = get_filter_func (); });
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]