[gnome-boxes] app: No more implements UIState
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] app: No more implements UIState
- Date: Fri, 8 Aug 2014 16:22:29 +0000 (UTC)
commit adef58f4a7a82022bcf1ce8a53ce6cf8b9090718
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed Jul 16 12:46:29 2014 +0200
app: No more implements UIState
UI state is now managed by AppWindow as each window can have a different
UI state from the others.
This is needed to drop the use of AppWindow singleton and therefore to
make multiple windows possible.
https://bugzilla.gnome.org/show_bug.cgi?id=732098
src/app-window.vala | 10 +++++-----
src/app.vala | 19 +++++--------------
src/collection-toolbar.vala | 8 ++++----
src/collection-view.vala | 2 +-
src/display-toolbar.vala | 4 ++--
src/libvirt-machine-properties.vala | 4 ++--
src/machine.vala | 18 +++++++++---------
src/properties-toolbar.vala | 2 +-
src/searchbar.vala | 2 +-
src/spice-display.vala | 4 ++--
src/topbar.vala | 4 ++--
src/vm-creator.vala | 6 +++---
src/wizard.vala | 6 +++---
13 files changed, 40 insertions(+), 49 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index b562829..4c4c482 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -192,7 +192,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
// Show for the first selected item
foreach (var item in selected_items) {
current_item = item;
- App.app.set_state (UIState.PROPERTIES);
+ set_state (UIState.PROPERTIES);
break;
}
}
@@ -207,12 +207,12 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
notificationbar.display_error (message);
});
- if (App.app.ui_state != UIState.CREDS)
- App.app.set_state (UIState.CREDS); // Start the CREDS state
+ if (ui_state != UIState.CREDS)
+ set_state (UIState.CREDS); // Start the CREDS state
}
public void select_item (CollectionItem item) {
- if (App.app.ui_state == UIState.COLLECTION && !selection_mode) {
+ if (ui_state == UIState.COLLECTION && !selection_mode) {
current_item = item;
if (current_item is Machine) {
@@ -226,7 +226,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
} else if (ui_state == UIState.WIZARD) {
current_item = item;
- App.app.set_state (UIState.PROPERTIES);
+ set_state (UIState.PROPERTIES);
}
}
diff --git a/src/app.vala b/src/app.vala
index 58f8056..9e910ec 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -15,13 +15,10 @@ private abstract class Boxes.Broker : GLib.Object {
}
}
-private class Boxes.App: Gtk.Application, Boxes.UI {
+private class Boxes.App: Gtk.Application {
public static App app;
public static Boxes.AppWindow window;
- public UIState previous_ui_state { get; protected set; }
- public UIState ui_state { get; protected set; }
-
public string? uri { get; set; }
public Collection collection;
public CollectionFilter filter;
@@ -99,8 +96,6 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
"wrap-license", true);
});
add_action (action);
-
- notify["ui-state"].connect (ui_state_changed);
}
public override void startup () {
@@ -161,7 +156,7 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
window = new Boxes.AppWindow (this);
window.setup_ui ();
- set_state (UIState.COLLECTION);
+ window.set_state (UIState.COLLECTION);
window.present ();
}
@@ -247,7 +242,7 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
if (opt_search != null) {
call_when_ready (() => {
window.searchbar.text = string.joinv (" ", opt_search);
- if (ui_state == UIState.COLLECTION)
+ if (window.ui_state == UIState.COLLECTION)
window.searchbar.search_mode_enabled = true;
});
}
@@ -279,7 +274,7 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
}
public void open_name (string name) {
- set_state (UIState.COLLECTION);
+ window.set_state (UIState.COLLECTION);
// after "ready" all items should be listed
foreach (var item in collection.items.data) {
@@ -292,7 +287,7 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
}
public bool open_uuid (string uuid) {
- set_state (UIState.COLLECTION);
+ window.set_state (UIState.COLLECTION);
// after "ready" all items should be listed
foreach (var item in collection.items.data) {
@@ -392,10 +387,6 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
}
}
- private void ui_state_changed () {
- window.set_state (ui_state);
- }
-
private void suspend_machines () {
// if we are not the main Boxes instance, 'collection' won't
// be set as it's created in GtkApplication::startup()
diff --git a/src/collection-toolbar.vala b/src/collection-toolbar.vala
index 3f43137..6463000 100644
--- a/src/collection-toolbar.vala
+++ b/src/collection-toolbar.vala
@@ -34,17 +34,17 @@ private class Boxes.CollectionToolbar: HeaderBar {
search_btn.bind_property ("active", App.window.searchbar, "search-mode-enabled",
BindingFlags.BIDIRECTIONAL);
- App.app.notify["ui-state"].connect (ui_state_changed);
+ App.window.notify["ui-state"].connect (ui_state_changed);
}
[GtkCallback]
private void on_new_btn_clicked () {
- App.app.set_state (UIState.WIZARD);
+ App.window.set_state (UIState.WIZARD);
}
[GtkCallback]
private void on_back_btn_clicked () {
- App.app.set_state (UIState.COLLECTION);
+ App.window.set_state (UIState.COLLECTION);
}
[GtkCallback]
@@ -65,7 +65,7 @@ private class Boxes.CollectionToolbar: HeaderBar {
}
private void ui_state_changed () {
- switch (App.app.ui_state) {
+ switch (App.window.ui_state) {
case UIState.COLLECTION:
back_btn.hide ();
select_btn.show ();
diff --git a/src/collection-view.vala b/src/collection-view.vala
index d9fc3be..6af1adb 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -147,7 +147,7 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
});
item.set_data<ulong> ("under_construct_id", under_construct_id);
- item.set_state (App.app.ui_state);
+ item.set_state (App.window.ui_state);
}
public List<CollectionItem> get_selected_items () {
diff --git a/src/display-toolbar.vala b/src/display-toolbar.vala
index cad2823..ac82be3 100644
--- a/src/display-toolbar.vala
+++ b/src/display-toolbar.vala
@@ -114,7 +114,7 @@ private class Boxes.DisplayToolbar: Gtk.HeaderBar {
[GtkCallback]
private void on_back_clicked () {
- App.app.set_state (UIState.COLLECTION);
+ App.window.set_state (UIState.COLLECTION);
}
[GtkCallback]
@@ -124,6 +124,6 @@ private class Boxes.DisplayToolbar: Gtk.HeaderBar {
[GtkCallback]
private void on_props_clicked () {
- App.app.set_state (UIState.PROPERTIES);
+ App.window.set_state (UIState.PROPERTIES);
}
}
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 16c7cf0..7b57a60 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -421,7 +421,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
FormatSizeFlags.IEC_UNITS);
if ((VMConfigurator.is_install_config (machine.domain_config) ||
VMConfigurator.is_live_config (machine.domain_config)) &&
- App.app.previous_ui_state != Boxes.UIState.WIZARD)
+ App.window.previous_ui_state != Boxes.UIState.WIZARD)
property.sensitive = false;
else
property.changed.connect (on_ram_changed);
@@ -485,7 +485,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
property.defer_interval = 0;
if ((VMConfigurator.is_install_config (machine.domain_config) ||
VMConfigurator.is_live_config (machine.domain_config)) &&
- App.app.previous_ui_state != Boxes.UIState.WIZARD)
+ App.window.previous_ui_state != Boxes.UIState.WIZARD)
property.sensitive = false;
else
property.changed.connect (on_storage_changed);
diff --git a/src/machine.vala b/src/machine.vala
index d9b3c98..d14afc0 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -73,16 +73,16 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
App.window.current_item == this &&
value != MachineState.RUNNING &&
value != MachineState.UNKNOWN) {
- App.app.set_state (Boxes.UIState.COLLECTION);
+ App.window.set_state (Boxes.UIState.COLLECTION);
}
}
}
protected void show_display () {
- switch (App.app.ui_state) {
+ switch (App.window.ui_state) {
case Boxes.UIState.CREDS:
- App.app.set_state (Boxes.UIState.DISPLAY);
+ App.window.set_state (Boxes.UIState.DISPLAY);
show_display ();
break;
@@ -136,7 +136,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
disconnected_id = _display.disconnected.connect ((failed) => {
message (@"display $name disconnected");
if (!stay_on_display && App.window.current_item == this)
- App.app.set_state (Boxes.UIState.COLLECTION);
+ App.window.set_state (Boxes.UIState.COLLECTION);
if (failed)
App.window.notificationbar.display_error (_("Connection to '%s' failed").printf (name));
});
@@ -171,8 +171,8 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
pixbuf = draw_fallback_vm ();
notify["ui-state"].connect (ui_state_changed);
- ui_state_id = App.app.notify["ui-state"].connect (() => {
- if (App.app.ui_state == UIState.DISPLAY)
+ ui_state_id = App.window.notify["ui-state"].connect (() => {
+ if (App.window.ui_state == UIState.DISPLAY)
set_screenshot_enable (false);
else
set_screenshot_enable (true);
@@ -545,11 +545,11 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
try_connect_display.begin (flags | Machine.ConnectFlags.IGNORE_SAVED_STATE);
});
notification.dismissed.connect (() => {
- App.app.set_state (UIState.COLLECTION);
+ App.window.set_state (UIState.COLLECTION);
});
} catch (GLib.Error e) {
debug ("connect display failed: %s", e.message);
- App.app.set_state (UIState.COLLECTION);
+ App.window.set_state (UIState.COLLECTION);
App.window.notificationbar.display_error (_("Connection to '%s' failed").printf (name));
}
}
@@ -575,7 +575,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
};
Notification.CancelFunc cancel_func = () => {
auth_notification = null;
- App.app.set_state (UIState.COLLECTION);
+ App.window.set_state (UIState.COLLECTION);
};
// Translators: %s => name of launched box
diff --git a/src/properties-toolbar.vala b/src/properties-toolbar.vala
index ce7a4fb..5a6c86c 100644
--- a/src/properties-toolbar.vala
+++ b/src/properties-toolbar.vala
@@ -13,6 +13,6 @@ private class Boxes.PropertiesToolbar: HeaderBar {
[GtkCallback]
private void on_back_clicked () {
- App.app.set_state (App.app.previous_ui_state);
+ App.window.set_state (App.window.previous_ui_state);
}
}
diff --git a/src/searchbar.vala b/src/searchbar.vala
index c669d1f..12ffb3d 100644
--- a/src/searchbar.vala
+++ b/src/searchbar.vala
@@ -48,7 +48,7 @@ private class Boxes.Searchbar: Gtk.SearchBar {
}
private bool on_app_key_pressed (Gtk.Widget widget, Gdk.EventKey event) {
- if (App.app.ui_state != UIState.COLLECTION)
+ if (App.window.ui_state != UIState.COLLECTION)
return false;
return handle_event ((Gdk.Event) event);
diff --git a/src/spice-display.vala b/src/spice-display.vala
index b9a3bb3..bda3eeb 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -19,7 +19,7 @@ private class Boxes.SpiceDisplay: Boxes.Display {
public bool resize_guest { get; set; }
private void ui_state_changed () {
// TODO: multi display
- if (App.app.ui_state == UIState.DISPLAY) {
+ if (App.window.ui_state == UIState.DISPLAY) {
// disable resize guest when minimizing guest widget
var display = get_display (0) as Spice.Display;
display.resize_guest = resize_guest;
@@ -68,7 +68,7 @@ private class Boxes.SpiceDisplay: Boxes.Display {
config.sync_properties (gtk_session, gtk_session_sync_properties);
});
- App.app.notify["ui-state"].connect (ui_state_changed);
+ App.window.notify["ui-state"].connect (ui_state_changed);
}
Spice.MainChannel? main_channel;
diff --git a/src/topbar.vala b/src/topbar.vala
index 09467f1..c4774b5 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -32,7 +32,7 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
// Clicks the appropriate back button depending on the ui state.
public void click_back_button () {
- switch (App.app.ui_state) {
+ switch (App.window.ui_state) {
case UIState.PROPERTIES:
break;
case UIState.CREDS:
@@ -51,7 +51,7 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
// Clicks the appropriate cancel button dependent on the ui state.
public void click_cancel_button () {
- switch (App.app.ui_state) {
+ switch (App.window.ui_state) {
case UIState.COLLECTION:
if (App.window.selection_mode)
App.window.selection_mode = false;
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index 8ae872f..ebd0ed3 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -68,12 +68,12 @@ private class Boxes.VMCreator {
!(install_media as UnattendedInstaller).setup_box.express_install) {
ulong signal_id = 0;
- signal_id = App.app.notify["ui-state"].connect (() => {
- if (App.app.ui_state != UIState.COLLECTION)
+ signal_id = App.window.notify["ui-state"].connect (() => {
+ if (App.window.ui_state != UIState.COLLECTION)
return;
App.window.select_item (machine); // This also starts the domain for us
- App.app.disconnect (signal_id);
+ App.window.disconnect (signal_id);
return;
});
diff --git a/src/wizard.vala b/src/wizard.vala
index 651a9de..516f60f 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -112,7 +112,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
case WizardPage.LAST:
create.begin ((obj, result) => {
if (create.end (result))
- App.app.set_state (UIState.COLLECTION);
+ App.window.set_state (UIState.COLLECTION);
else
App.window.notificationbar.display_error (_("Box creation failed"));
});
@@ -618,7 +618,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
cancel_button.clicked.connect (() => {
cleanup ();
wizard_source.page = SourcePage.MAIN;
- App.app.set_state (UIState.COLLECTION);
+ App.window.set_state (UIState.COLLECTION);
});
back_button = App.window.topbar.wizard_toolbar.back_btn;
back_button.clicked.connect (() => {
@@ -638,7 +638,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
}
public void open_with_uri (string uri, bool skip_review_for_live = true) {
- App.app.set_state (UIState.WIZARD);
+ App.window.set_state (UIState.WIZARD);
this.skip_review_for_live = skip_review_for_live;
page = WizardPage.SOURCE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]