[gnome-boxes] Simplify status tracking
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Simplify status tracking
- Date: Mon, 19 Nov 2012 10:01:09 +0000 (UTC)
commit 1d003efc8c67fa724cd3694fbf3f43c5369cb4d7
Author: Alexander Larsson <alexl redhat com>
Date: Fri Nov 16 15:22:28 2012 +0100
Simplify status tracking
Instead of signal connections we just bind properties. This also
centralizes the status handling to App.vala.
https://bugzilla.gnome.org/show_bug.cgi?id=688473
src/app.vala | 13 ++++---------
src/topbar.vala | 11 ++++++-----
2 files changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 50f7757..9320890 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -60,7 +60,7 @@ private class Boxes.App: Boxes.UI {
public CollectionSource default_source { get { return sources.get ("QEMU Session"); } }
private uint configure_id;
- private ulong status_id;
+ private GLib.Binding status_bind;
private ulong got_error_id;
public static const uint configure_id_timeout = 100; // 100ms
@@ -559,12 +559,10 @@ private class Boxes.App: Boxes.UI {
switch (ui_state) {
case UIState.COLLECTION:
set_main_ui_state ();
+ topbar.status = null;
+ status_bind = null;
if (current_item is Machine) {
var machine = current_item as Machine;
- if (status_id != 0) {
- machine.disconnect (status_id);
- status_id = 0;
- }
if (got_error_id != 0) {
machine.disconnect (got_error_id);
got_error_id = 0;
@@ -738,10 +736,7 @@ private class Boxes.App: Boxes.UI {
actor.set_easing_duration (App.app.duration);
// Track machine status in toobar
- topbar.set_status (machine.status);
- status_id = machine.notify["status"].connect ( () => {
- topbar.set_status (machine.status);
- });
+ status_bind = machine.bind_property ("status", topbar, "status", BindingFlags.SYNC_CREATE);
got_error_id = machine.got_error.connect ( (message) => {
App.app.notificationbar.display_error (message);
diff --git a/src/topbar.vala b/src/topbar.vala
index a7ef926..9710344 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -25,6 +25,12 @@ private class Boxes.Topbar: Boxes.UI {
private Gd.MainToolbar selection_toolbar;
private Gd.MainToolbar collection_toolbar;
+ public string? _status;
+ public string? status {
+ get { return _status; }
+ set { _status = value; collection_toolbar.set_labels (_status, null); }
+ }
+
public Topbar () {
setup_topbar ();
@@ -128,10 +134,6 @@ private class Boxes.Topbar: Boxes.UI {
select_btn.sensitive = App.app.collection.items.length != 0;
}
- public void set_status (string? text) {
- collection_toolbar.set_labels (text, null);
- }
-
private void update_selection_label () {
var items = App.app.selected_items.length ();
if (items > 0)
@@ -145,7 +147,6 @@ private class Boxes.Topbar: Boxes.UI {
public override void ui_state_changed () {
switch (ui_state) {
case UIState.COLLECTION:
- set_status (null);
notebook.page = TopbarPage.COLLECTION;
back_btn.hide ();
spinner.hide ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]