[gnome-boxes] App: Add call_when_ready
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] App: Add call_when_ready
- Date: Mon, 28 Jan 2013 14:39:14 +0000 (UTC)
commit 7ce3c4e5fcb844473eafaf65d851737a2a4a02e1
Author: Alexander Larsson <alexl redhat com>
Date: Fri Jan 25 15:34:42 2013 +0100
App: Add call_when_ready
This makes it easy to queue calls until the app is in the ready
state.
https://bugzilla.gnome.org/show_bug.cgi?id=692306
src/app.vala | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 437b1ca..fa869cb 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -65,6 +65,7 @@ private class Boxes.App: Boxes.UI {
public Collection collection;
public CollectionFilter filter;
+ private bool is_ready;
public signal void ready (bool first_time);
public signal void item_selected (CollectionItem item);
private Boxes.Application application;
@@ -159,6 +160,7 @@ private class Boxes.App: Boxes.UI {
});
setup_sources.begin ((obj, result) => {
setup_sources.end (result);
+ is_ready = true;
var no_items = collection.items.length == 0;
ready (no_items);
});
@@ -167,6 +169,15 @@ private class Boxes.App: Boxes.UI {
check_module_kvm_loaded.begin ();
}
+ public delegate void CallReadyFunc (bool first_time);
+ public void call_when_ready (CallReadyFunc func) {
+ if (is_ready)
+ func (false);
+ ready.connect ((first_time) => {
+ func (first_time);
+ });
+ }
+
public void activate () {
window.present ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]