[gnome-boxes] properties-window: Add revert_state()



commit 29f9d1527e89c165073da7b9974abce4cd55e378
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Dec 4 15:35:49 2014 +0000

    properties-window: Add revert_state()
    
    Add a public method to revert the state to whatever it was before we
    arrived at 'properties' state or 'collection' state if last state
    doesn't make sense, and make use of this method in both PropertiesWindow
    itself and PropertiesToolbar.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741047

 src/properties-toolbar.vala |    6 +-----
 src/properties-window.vala  |   12 ++++++++++--
 2 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/properties-toolbar.vala b/src/properties-toolbar.vala
index 6c8ea9b..bd30378 100644
--- a/src/properties-toolbar.vala
+++ b/src/properties-toolbar.vala
@@ -28,11 +28,7 @@ private class Boxes.PropertiesToolbar: HeaderBar {
 
     [GtkCallback]
     private void on_back_clicked () {
-        if ((window.current_item as Machine).state != Machine.MachineState.RUNNING &&
-             window.previous_ui_state == UIState.DISPLAY)
-            window.set_state (UIState.COLLECTION);
-        else
-            window.set_state (window.previous_ui_state);
+        props_window.revert_state ();
     }
 
     [GtkCallback]
diff --git a/src/properties-window.vala b/src/properties-window.vala
index bcd151d..1d9eea9 100644
--- a/src/properties-window.vala
+++ b/src/properties-window.vala
@@ -26,6 +26,14 @@ private class Boxes.PropertiesWindow: Gtk.Window, Boxes.UI {
         notify["ui-state"].connect (ui_state_changed);
     }
 
+    public void revert_state () {
+        if ((app_window.current_item as Machine).state != Machine.MachineState.RUNNING &&
+             app_window.previous_ui_state == UIState.DISPLAY)
+            app_window.set_state (UIState.COLLECTION);
+        else
+            app_window.set_state (app_window.previous_ui_state);
+    }
+
     private void ui_state_changed () {
         properties.set_state (ui_state);
 
@@ -37,14 +45,14 @@ private class Boxes.PropertiesWindow: Gtk.Window, Boxes.UI {
     [GtkCallback]
     private bool on_key_pressed (Widget widget, Gdk.EventKey event) {
         if (event.keyval == Gdk.Key.Escape) // ESC -> back
-            topbar.back_button.clicked ();
+            revert_state ();
 
         return false;
     }
 
     [GtkCallback]
     private bool on_delete_event () {
-        topbar.back_button.clicked ();
+        revert_state ();
 
         return true;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]