[gnome-boxes] app: Add main_window prop
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] app: Add main_window prop
- Date: Fri, 8 Aug 2014 16:23:50 +0000 (UTC)
commit a079d4fa1cf9a7029097aad4ce0d831b8ead716b
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri Jul 18 14:18:48 2014 +0200
app: Add main_window prop
We name the new property 'main_window' as later we'll add
support for multiple windows and this property will point to the main
window.
This patch also updates OvirtBroker, VMCreator and VMImporter
accordingly.
https://bugzilla.gnome.org/show_bug.cgi?id=732098
src/app.vala | 63 +++++++++++++++++++++++++-----------------------
src/ovirt-broker.vala | 4 +-
src/vm-creator.vala | 12 +++++----
src/vm-importer.vala | 2 +-
4 files changed, 43 insertions(+), 38 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 9e910ec..3943bdc 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -19,6 +19,8 @@ private class Boxes.App: Gtk.Application {
public static App app;
public static Boxes.AppWindow window;
+ public AppWindow main_window { get; private set; }
+
public string? uri { get; set; }
public Collection collection;
public CollectionFilter filter;
@@ -47,21 +49,21 @@ private class Boxes.App: Gtk.Application {
add_action (action);
action = new GLib.SimpleAction ("select-all", null);
- action.activate.connect (() => { window.view.select (SelectionCriteria.ALL); });
+ action.activate.connect (() => { main_window.view.select (SelectionCriteria.ALL); });
add_action (action);
action = new GLib.SimpleAction ("select-running", null);
- action.activate.connect (() => { window.view.select (SelectionCriteria.RUNNING); });
+ action.activate.connect (() => { main_window.view.select (SelectionCriteria.RUNNING); });
add_action (action);
action = new GLib.SimpleAction ("select-none", null);
- action.activate.connect (() => { window.view.select (SelectionCriteria.NONE); });
+ action.activate.connect (() => { main_window.view.select (SelectionCriteria.NONE); });
add_action (action);
action = new GLib.SimpleAction ("help", null);
action.activate.connect (() => {
try {
- Gtk.show_uri (window.get_screen (),
+ Gtk.show_uri (main_window.get_screen (),
"help:gnome-boxes",
Gtk.get_current_event_time ());
} catch (GLib.Error e) {
@@ -83,7 +85,7 @@ private class Boxes.App: Gtk.Application {
"Jakub Steiner <jsteiner redhat com>"
};
- Gtk.show_about_dialog (window,
+ Gtk.show_about_dialog (main_window,
"artists", artists,
"authors", authors,
"translator-credits", _("translator-credits"),
@@ -115,10 +117,10 @@ private class Boxes.App: Gtk.Application {
collection = new Collection ();
collection.item_added.connect ((item) => {
- window.view.add_item (item);
+ main_window.view.add_item (item);
});
collection.item_removed.connect ((item) => {
- window.view.remove_item (item);
+ main_window.view.remove_item (item);
});
brokers.insert ("libvirt", LibvirtBroker.get_default ());
@@ -151,14 +153,15 @@ private class Boxes.App: Gtk.Application {
public override void activate () {
base.activate ();
- if (window != null)
+ if (main_window != null)
return;
- window = new Boxes.AppWindow (this);
- window.setup_ui ();
- window.set_state (UIState.COLLECTION);
+ main_window = new Boxes.AppWindow (this);
+ window = main_window;
+ main_window.setup_ui ();
+ main_window.set_state (UIState.COLLECTION);
- window.present ();
+ main_window.present ();
}
static bool opt_fullscreen;
@@ -229,11 +232,11 @@ private class Boxes.App: Gtk.Application {
if (file.query_exists ()) {
if (is_uri)
- window.wizard.open_with_uri (arg);
+ main_window.wizard.open_with_uri (arg);
else
- window.wizard.open_with_uri (file.get_uri ());
+ main_window.wizard.open_with_uri (file.get_uri ());
} else if (is_uri)
- window.wizard.open_with_uri (arg);
+ main_window.wizard.open_with_uri (arg);
else
open_name (arg);
});
@@ -241,20 +244,20 @@ private class Boxes.App: Gtk.Application {
if (opt_search != null) {
call_when_ready (() => {
- window.searchbar.text = string.joinv (" ", opt_search);
- if (window.ui_state == UIState.COLLECTION)
- window.searchbar.search_mode_enabled = true;
+ main_window.searchbar.text = string.joinv (" ", opt_search);
+ if (main_window.ui_state == UIState.COLLECTION)
+ main_window.searchbar.search_mode_enabled = true;
});
}
if (opt_fullscreen)
- window.fullscreened = true;
+ main_window.fullscreened = true;
return 0;
}
public bool quit_app () {
- window.hide ();
+ main_window.hide ();
Idle.add (() => {
quit ();
@@ -268,18 +271,18 @@ private class Boxes.App: Gtk.Application {
public override void shutdown () {
base.shutdown ();
- window.notificationbar.cancel ();
- window.wizard.cleanup ();
+ main_window.notificationbar.cancel ();
+ main_window.wizard.cleanup ();
suspend_machines ();
}
public void open_name (string name) {
- window.set_state (UIState.COLLECTION);
+ main_window.set_state (UIState.COLLECTION);
// after "ready" all items should be listed
foreach (var item in collection.items.data) {
if (item.name == name) {
- window.select_item (item);
+ main_window.select_item (item);
break;
}
@@ -287,7 +290,7 @@ private class Boxes.App: Gtk.Application {
}
public bool open_uuid (string uuid) {
- window.set_state (UIState.COLLECTION);
+ main_window.set_state (UIState.COLLECTION);
// after "ready" all items should be listed
foreach (var item in collection.items.data) {
@@ -298,7 +301,7 @@ private class Boxes.App: Gtk.Application {
if (machine.config.uuid != uuid)
continue;
- window.select_item (item);
+ main_window.select_item (item);
return true;
}
@@ -425,7 +428,7 @@ private class Boxes.App: Gtk.Application {
}
public List<CollectionItem> selected_items {
- owned get { return window.view.get_selected_items (); }
+ owned get { return main_window.view.get_selected_items (); }
}
/**
@@ -463,16 +466,16 @@ private class Boxes.App: Gtk.Application {
}
};
- window.notificationbar.display_for_action (message, _("_Undo"), (owned) undo, (owned) really_remove);
+ main_window.notificationbar.display_for_action (message, _("_Undo"), (owned) undo, (owned)
really_remove);
}
public void remove_selected_items () {
- var selected_items = window.view.get_selected_items ();
+ var selected_items = main_window.view.get_selected_items ();
var num_selected = selected_items.length ();
if (num_selected == 0)
return;
- window.selection_mode = false;
+ main_window.selection_mode = false;
var message = (num_selected == 1) ? _("Box '%s' has been deleted").printf (selected_items.data.name)
:
ngettext ("%u box has been deleted",
diff --git a/src/ovirt-broker.vala b/src/ovirt-broker.vala
index d0114ab..10f5944 100644
--- a/src/ovirt-broker.vala
+++ b/src/ovirt-broker.vala
@@ -55,7 +55,7 @@ private class Boxes.OvirtBroker : Boxes.Broker {
// finish, otherwise yield add_source() will never return
auth.unpause ();
};
- App.window.notificationbar.display_for_optional_auth ("oVirt broker", (owned) auth_cb, (owned)
cancel_cb);
+ App.app.main_window.notificationbar.display_for_optional_auth ("oVirt broker", (owned) auth_cb,
(owned) cancel_cb);
auth.pause ();
return false;
@@ -66,7 +66,7 @@ private class Boxes.OvirtBroker : Boxes.Broker {
yield proxy.fetch_vms_async (null);
} catch (GLib.Error error) {
debug ("Failed to connect to broker: %s", error.message);
- App.window.notificationbar.display_error (_("Connection to oVirt broker failed"));
+ App.app.main_window.notificationbar.display_error (_("Connection to oVirt broker failed"));
}
proxies.insert (source.name, proxy);
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index ebd0ed3..8b757f9 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -46,7 +46,7 @@ private class Boxes.VMCreator {
yield install_media.prepare_for_installation (name, cancellable);
} catch (GLib.Error error) {
var msg = _("An error occurred during installation preparation. Express Install disabled.");
- App.window.notificationbar.display_error (msg);
+ App.app.main_window.notificationbar.display_error (msg);
debug("Disabling unattended installation: %s", error.message);
}
@@ -68,12 +68,14 @@ private class Boxes.VMCreator {
!(install_media as UnattendedInstaller).setup_box.express_install) {
ulong signal_id = 0;
- signal_id = App.window.notify["ui-state"].connect (() => {
- if (App.window.ui_state != UIState.COLLECTION)
+ var window = App.app.main_window;
+
+ signal_id = window.notify["ui-state"].connect (() => {
+ if (window.ui_state != UIState.COLLECTION)
return;
- App.window.select_item (machine); // This also starts the domain for us
- App.window.disconnect (signal_id);
+ window.select_item (machine); // This also starts the domain for us
+ window.disconnect (signal_id);
return;
});
diff --git a/src/vm-importer.vala b/src/vm-importer.vala
index f01c918..abeaf99 100644
--- a/src/vm-importer.vala
+++ b/src/vm-importer.vala
@@ -51,7 +51,7 @@ private class Boxes.VMImporter : Boxes.VMCreator {
source_media.device_file,
error.message);
var ui_message = _("Box import from file '%s' failed.").printf (source_media.device_file);
- App.window.notificationbar.display_error (ui_message);
+ App.app.main_window.notificationbar.display_error (ui_message);
machine.delete ();
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]