# HG changeset patch
# User "Cole Robinson <crobinso@redhat.com>"
# Date 1221748433 14400
# Node ID 7bedb4d693bdc674392ca334e7ee94f1b818b8f8
# Parent  4148e2986cc51b01937b8bed2e103ac50e4d882a
Allow seeing connection details when conn disconnected, just desensitive all the add wizards.

diff -r 4148e2986cc5 -r 7bedb4d693bd src/virtManager/engine.py
--- a/src/virtManager/engine.py	Wed Sep 17 07:53:00 2008 -0400
+++ b/src/virtManager/engine.py	Thu Sep 18 10:33:53 2008 -0400
@@ -118,7 +118,8 @@
 
 
     def _do_connection_changed(self, connection):
-        if connection.get_state() == connection.STATE_ACTIVE:
+        if connection.get_state() == connection.STATE_ACTIVE or \
+           connection.get_state() == connection.STATE_CONNECTING:
             return
 
         hvuri = connection.get_uri()
diff -r 4148e2986cc5 -r 7bedb4d693bd src/virtManager/host.py
--- a/src/virtManager/host.py	Wed Sep 17 07:53:00 2008 -0400
+++ b/src/virtManager/host.py	Thu Sep 18 10:33:53 2008 -0400
@@ -29,6 +29,7 @@
 
 from virtinst import Storage
 
+from virtManager.connection import vmmConnection
 from virtManager.createnet import vmmCreateNetwork
 from virtManager.createpool import vmmCreatePool
 from virtManager.createvol import vmmCreateVolume
@@ -158,6 +159,8 @@
         self.conn.connect("pool-started", self.refresh_storage_pool)
         self.conn.connect("pool-stopped", self.refresh_storage_pool)
 
+        self.conn.connect("state-changed", self.conn_state_changed)
+
         self.window.signal_autoconnect({
             "on_menu_file_close_activate": self.close,
             "on_vmm_host_delete_event": self.close,
@@ -181,9 +184,7 @@
             })
 
         self.conn.connect("resources-sampled", self.refresh_resources)
-        self.refresh_resources()
-        self.reset_pool_state()
-        self.reset_net_state()
+        self.reset_state()
 
     def show(self):
         # Update autostart value
@@ -208,6 +209,12 @@
            self.window.get_widget("config-autoconnect").get_active():
             self.conn.toggle_autoconnect()
 
+    def reset_state(self):
+        self.refresh_resources()
+        self.reset_pool_state()
+        self.reset_net_state()
+        self.conn_state_changed()
+
     def refresh_resources(self, ignore=None):
         self.window.get_widget("performance-cpu").set_text("%d %%" % self.conn.cpu_time_percentage())
         vm_memory = self.conn.pretty_current_memory()
@@ -221,6 +228,11 @@
         memory_vector = self.conn.current_memory_vector()
         memory_vector.reverse()
         self.memory_usage_graph.set_property("data_array", memory_vector)
+
+    def conn_state_changed(self, ignore1=None):
+        state = (self.conn.get_state() == vmmConnection.STATE_ACTIVE)
+        self.window.get_widget("net-add").set_sensitive(state)
+        self.window.get_widget("pool-add").set_sensitive(state)
 
     # -------------------------
     # Virtual Network functions
diff -r 4148e2986cc5 -r 7bedb4d693bd src/virtManager/manager.py
--- a/src/virtManager/manager.py	Wed Sep 17 07:53:00 2008 -0400
+++ b/src/virtManager/manager.py	Thu Sep 18 10:33:53 2008 -0400
@@ -668,10 +668,8 @@
             self.window.get_widget("vm-open").set_sensitive(False)
             if conn.get_state() == vmmConnection.STATE_DISCONNECTED:
                 self.window.get_widget("vm-delete").set_sensitive(True)
-                self.window.get_widget("menu_host_details").set_sensitive(False)
             else:
                 self.window.get_widget("vm-delete").set_sensitive(False)
-                self.window.get_widget("menu_host_details").set_sensitive(True)
             if conn.get_state() == vmmConnection.STATE_ACTIVE:
                 self.window.get_widget("vm-new").set_sensitive(True)
                 self.window.get_widget("menu_file_restore_saved").set_sensitive(True)
@@ -680,6 +678,7 @@
                 self.window.get_widget("menu_file_restore_saved").set_sensitive(False)
             self.window.get_widget("menu_edit_details").set_sensitive(False)
             self.window.get_widget("menu_edit_delete").set_sensitive(False)
+            self.window.get_widget("menu_host_details").set_sensitive(True)
 
     def popup_vm_menu(self, widget, event):
         tuple = widget.get_path_at_pos(int(event.x), int(event.y))
