vmwindow: vm state-changed update flow changes
* Don't process events when the window isn't showing * Only update console/details if that tab is actually selected. Otherwise in some corner cases we can connect to the VM console while on the details page Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
c0c704e1fa
commit
e58cc956b5
|
@ -589,6 +589,7 @@ class vmmConsolePages(vmmGObjectUI):
|
||||||
self.widget("console-gfx-viewport"))
|
self.widget("console-gfx-viewport"))
|
||||||
self._viewer.cleanup()
|
self._viewer.cleanup()
|
||||||
self._viewer = None
|
self._viewer = None
|
||||||
|
log.debug("Viewer disconnected")
|
||||||
|
|
||||||
def _refresh_vm_state(self):
|
def _refresh_vm_state(self):
|
||||||
self._activate_default_console_page()
|
self._activate_default_console_page()
|
||||||
|
@ -963,7 +964,7 @@ class vmmConsolePages(vmmGObjectUI):
|
||||||
def vmwindow_viewer_get_pixbuf(self):
|
def vmwindow_viewer_get_pixbuf(self):
|
||||||
return self._viewer.console_get_pixbuf()
|
return self._viewer.console_get_pixbuf()
|
||||||
|
|
||||||
def vmwindow_close_viewer(self):
|
def vmwindow_close(self):
|
||||||
return self._activate_vm_unavailable_page(
|
return self._activate_vm_unavailable_page(
|
||||||
_("Viewer disconnected."))
|
_("Viewer disconnected."))
|
||||||
def vmwindow_get_title_message(self):
|
def vmwindow_get_title_message(self):
|
||||||
|
|
|
@ -975,12 +975,31 @@ class vmmDetails(vmmGObjectUI):
|
||||||
# vmwindow Public API #
|
# vmwindow Public API #
|
||||||
#######################
|
#######################
|
||||||
|
|
||||||
|
def _refresh_vm_state(self):
|
||||||
|
active = self.vm.is_active()
|
||||||
|
self.widget("overview-name").set_editable(not active)
|
||||||
|
|
||||||
|
reason = self.vm.run_status_reason()
|
||||||
|
if reason:
|
||||||
|
status = "%s (%s)" % (self.vm.run_status(), reason)
|
||||||
|
else:
|
||||||
|
status = self.vm.run_status()
|
||||||
|
self.widget("overview-status-text").set_text(status)
|
||||||
|
self.widget("overview-status-icon").set_from_icon_name(
|
||||||
|
self.vm.run_status_icon_name(),
|
||||||
|
Gtk.IconSize.BUTTON)
|
||||||
|
|
||||||
def vmwindow_resources_refreshed(self):
|
def vmwindow_resources_refreshed(self):
|
||||||
row = self._get_hw_row()
|
row = self._get_hw_row()
|
||||||
if row and row[HW_LIST_COL_TYPE] == HW_LIST_TYPE_STATS:
|
if row and row[HW_LIST_COL_TYPE] == HW_LIST_TYPE_STATS:
|
||||||
self._refresh_stats_page()
|
self._refresh_stats_page()
|
||||||
|
|
||||||
def vmwindow_page_refresh(self):
|
def vmwindow_refresh_vm_state(self, is_current_page):
|
||||||
|
if not is_current_page:
|
||||||
|
self._disable_apply()
|
||||||
|
return
|
||||||
|
|
||||||
|
self._refresh_vm_state()
|
||||||
self._repopulate_hw_list()
|
self._repopulate_hw_list()
|
||||||
|
|
||||||
if self.widget("config-apply").get_sensitive():
|
if self.widget("config-apply").get_sensitive():
|
||||||
|
@ -1002,23 +1021,8 @@ class vmmDetails(vmmGObjectUI):
|
||||||
def vmwindow_has_unapplied_changes(self):
|
def vmwindow_has_unapplied_changes(self):
|
||||||
return self._has_unapplied_changes(self._get_hw_row())
|
return self._has_unapplied_changes(self._get_hw_row())
|
||||||
|
|
||||||
def vmwindow_refresh_vm_state(self):
|
def vmwindow_close(self):
|
||||||
active = self.vm.is_active()
|
self._disable_apply()
|
||||||
self.widget("overview-name").set_editable(not active)
|
|
||||||
|
|
||||||
reason = self.vm.run_status_reason()
|
|
||||||
if reason:
|
|
||||||
status = "%s (%s)" % (self.vm.run_status(), reason)
|
|
||||||
else:
|
|
||||||
status = self.vm.run_status()
|
|
||||||
self.widget("overview-status-text").set_text(status)
|
|
||||||
self.widget("overview-status-icon").set_from_icon_name(
|
|
||||||
self.vm.run_status_icon_name(),
|
|
||||||
Gtk.IconSize.BUTTON)
|
|
||||||
|
|
||||||
def vmwindow_show_details(self):
|
|
||||||
# When vmwindow switches to use, refresh the current page
|
|
||||||
self._refresh_page()
|
|
||||||
|
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
|
|
|
@ -420,7 +420,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
||||||
self.vm.refresh_snapshots()
|
self.vm.refresh_snapshots()
|
||||||
self._populate_snapshot_list(select_name)
|
self._populate_snapshot_list(select_name)
|
||||||
|
|
||||||
def show_page(self):
|
def vmwindow_refresh_vm_state(self):
|
||||||
if not self._initial_populate:
|
if not self._initial_populate:
|
||||||
self._populate_snapshot_list()
|
self._populate_snapshot_list()
|
||||||
|
|
||||||
|
|
|
@ -251,10 +251,8 @@ class vmmVMWindow(vmmGObjectUI):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.topwin.hide()
|
self.topwin.hide()
|
||||||
try:
|
self._console.vmwindow_close()
|
||||||
self._console.vmwindow_close_viewer()
|
self._details.vmwindow_close()
|
||||||
except Exception: # pragma: no cover
|
|
||||||
log.error("Failure when disconnecting from desktop server")
|
|
||||||
|
|
||||||
self.emit("closed")
|
self.emit("closed")
|
||||||
vmmEngine.get_instance().decrement_window_counter()
|
vmmEngine.get_instance().decrement_window_counter()
|
||||||
|
@ -336,10 +334,8 @@ class vmmVMWindow(vmmGObjectUI):
|
||||||
return
|
return
|
||||||
|
|
||||||
if is_details:
|
if is_details:
|
||||||
self._details.vmwindow_show_details()
|
|
||||||
pages.set_current_page(DETAILS_PAGE_DETAILS)
|
pages.set_current_page(DETAILS_PAGE_DETAILS)
|
||||||
elif is_snapshot:
|
elif is_snapshot:
|
||||||
self._snapshots.show_page()
|
|
||||||
pages.set_current_page(DETAILS_PAGE_SNAPSHOTS)
|
pages.set_current_page(DETAILS_PAGE_SNAPSHOTS)
|
||||||
else:
|
else:
|
||||||
pages.set_current_page(DETAILS_PAGE_CONSOLE)
|
pages.set_current_page(DETAILS_PAGE_CONSOLE)
|
||||||
|
@ -438,8 +434,6 @@ class vmmVMWindow(vmmGObjectUI):
|
||||||
self.widget("control-snapshots").set_tooltip_text(tooltip)
|
self.widget("control-snapshots").set_tooltip_text(tooltip)
|
||||||
|
|
||||||
self._refresh_current_page()
|
self._refresh_current_page()
|
||||||
self._details.vmwindow_refresh_vm_state()
|
|
||||||
self._console.vmwindow_refresh_vm_state()
|
|
||||||
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
|
@ -584,10 +578,15 @@ class vmmVMWindow(vmmGObjectUI):
|
||||||
self._details.vmwindow_resources_refreshed()
|
self._details.vmwindow_resources_refreshed()
|
||||||
|
|
||||||
def _refresh_current_page(self, newpage=None):
|
def _refresh_current_page(self, newpage=None):
|
||||||
if not newpage:
|
newpage = newpage or self.widget("details-pages").get_current_page()
|
||||||
newpage = self.widget("details-pages").get_current_page()
|
|
||||||
if newpage == DETAILS_PAGE_DETAILS:
|
is_details = newpage == DETAILS_PAGE_DETAILS
|
||||||
self._details.vmwindow_page_refresh()
|
self._details.vmwindow_refresh_vm_state(is_details)
|
||||||
|
|
||||||
|
if newpage == DETAILS_PAGE_CONSOLE:
|
||||||
|
self._console.vmwindow_refresh_vm_state()
|
||||||
|
elif newpage == DETAILS_PAGE_SNAPSHOTS:
|
||||||
|
self._snapshots.vmwindow_refresh_vm_state()
|
||||||
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
@ -698,10 +697,12 @@ class vmmVMWindow(vmmGObjectUI):
|
||||||
self._refresh_title()
|
self._refresh_title()
|
||||||
|
|
||||||
def _vm_state_changed_cb(self, src):
|
def _vm_state_changed_cb(self, src):
|
||||||
self._refresh_vm_state()
|
if self.is_visible():
|
||||||
|
self._refresh_vm_state()
|
||||||
|
|
||||||
def _resources_sampled_cb(self, src):
|
def _resources_sampled_cb(self, src):
|
||||||
self._refresh_resources()
|
if self.is_visible():
|
||||||
|
self._refresh_resources()
|
||||||
|
|
||||||
def _console_page_changed_cb(self, src):
|
def _console_page_changed_cb(self, src):
|
||||||
self._sync_console_page_menu_state()
|
self._sync_console_page_menu_state()
|
||||||
|
|
Loading…
Reference in New Issue