virt-manager/virtman-manager.diff

38 lines
1.8 KiB
Diff
Raw Normal View History

Index: virt-manager-0.8.1/src/virtManager/manager.py
===================================================================
--- virt-manager-0.8.1.orig/src/virtManager/manager.py
+++ virt-manager-0.8.1/src/virtManager/manager.py
@@ -529,7 +529,15 @@ class vmmManager(gobject.GObject):
vmlist = self.window.get_widget("vm-list")
selection = vmlist.get_selection()
active = selection.get_selected()
-
+ if active[1] == None and active[0] != None:
+ # in some cases on vhost, the connection is not being selected at startup.
+ # when creating new vms, if current_connection() returns None, several
+ # functions will fail, so if the user hasn't selected a connection, default
+ # to the first connection in the list.
+ first = active[0].get_iter_first()
+ if first != None:
+ selection.select_iter( first )
+ active = selection.get_selected()
treestore, treeiter = active
if treeiter != None:
return treestore[treeiter]
@@ -583,7 +591,14 @@ class vmmManager(gobject.GObject):
self.emit("action-show-connect")
def new_vm(self, ignore=None):
- self.emit("action-show-create", self.current_connection_uri())
+ conn = self.current_connection()
+ if conn.get_state() == vmmConnection.STATE_ACTIVE:
+ self.emit("action-show-create", self.current_connection_uri())
+ else:
+ message_box = gtk.MessageDialog( None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
+ _("Must select an active connection before creating a Virtual Machine") )
+ message_box.run()
+ message_box.destroy()
def show_about(self, src):
self.emit("action-show-about")