[gnome-boxes] check default connection is there before crashing badly,
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] check default connection is there before crashing badly,
- Date: Mon, 16 Jan 2012 17:22:58 +0000 (UTC)
commit 143aac685626d9c8145c9140b0f10094705a37cd
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Fri Jan 13 12:27:05 2012 +0100
check default connection is there before crashing badly,
And wait until the default connection is ready before proceeding
with installer etc..
https://bugzilla.gnome.org/show_bug.cgi?id=667859
src/app.vala | 30 +++++++++++++++++++++++-------
src/main.vala | 2 +-
2 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index a7a1a78..57837d3 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -41,7 +41,7 @@ private class Boxes.App: Boxes.UI {
public GLib.SimpleAction action_properties;
public GLib.SimpleAction action_fullscreen;
- public signal void activate ();
+ public signal void ready ();
private Gtk.Application application;
private Clutter.TableLayout box_table;
private CollectionView view;
@@ -120,11 +120,12 @@ private class Boxes.App: Boxes.UI {
collection.item_removed.connect ((item) => {
view.remove_item (item);
});
- setup_sources.begin ();
+ setup_sources.begin ((obj, rest) => {
+ ready ();
+ });
});
application.activate.connect_after ((app) => {
- activate ();
window.present ();
});
}
@@ -146,6 +147,9 @@ private class Boxes.App: Boxes.UI {
}
private async void setup_libvirt (CollectionSource source) {
+ if (connections.lookup (source.name) != null)
+ return;
+
var connection = new GVir.Connection (source.uri);
try {
@@ -176,13 +180,13 @@ private class Boxes.App: Boxes.UI {
add_domain (source, connection, domain);
});
- connections.replace (source.name, connection);
+ connections.insert (source.name, connection);
}
- public void add_collection_source (CollectionSource source) {
+ public async void add_collection_source (CollectionSource source) {
switch (source.source_type) {
case "libvirt":
- setup_libvirt (source);
+ yield setup_libvirt (source);
break;
case "vnc":
@@ -208,8 +212,20 @@ private class Boxes.App: Boxes.UI {
}
}
+ try {
+ var source = new CollectionSource.with_file ("QEMU Session");
+ yield add_collection_source (source);
+ } catch (GLib.Error error) {
+ warning (error.message);
+ }
+ if (default_connection == null) {
+ printerr ("error: missing or failing default libvirt connection");
+ application.release (); // will end application
+ return;
+ }
+
var dir = File.new_for_path (get_pkgconfig_source ());
- get_sources_from_dir (dir);
+ get_sources_from_dir.begin (dir);
}
private async void get_sources_from_dir (File dir) {
diff --git a/src/main.vala b/src/main.vala
index b43ca74..0c3cc67 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -67,7 +67,7 @@ public int main (string[] args) {
var app = new Boxes.App ();
- app.activate.connect (() => {
+ app.ready.connect (() => {
if (uris != null) {
// FIXME: We only handle a single URI from commandline
var file = File.new_for_commandline_arg (uris[0]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]