Saving works, progress bar still doesn't appear in a timely fashion though.

This commit is contained in:
Hugh O. Brock 2006-07-19 10:54:39 -04:00
parent 7db7488a15
commit 487e75e3d6
2 changed files with 82 additions and 22 deletions

View File

@ -3265,4 +3265,70 @@ Inactive virtual machines</property>
</child>
</widget>
<widget class="GtkWindow" id="vmm-save-progress">
<property name="visible">True</property>
<property name="title" translatable="yes">Saving VM Image</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">True</property>
<child>
<widget class="GtkVBox" id="vbox13">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label94">
<property name="visible">True</property>
<property name="label" translatable="yes">Please wait while the VM image saves...</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.600000023842</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">10</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkProgressBar" id="pbar">
<property name="visible">True</property>
<property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
<property name="fraction">0</property>
<property name="pulse_step">0.10000000149</property>
<property name="text" translatable="yes"></property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -20,7 +20,6 @@ import gobject
import gtk
import sys
import libvirt
from time import sleep
from virtManager.about import vmmAbout
from virtManager.connect import vmmConnect
@ -35,7 +34,6 @@ class vmmEngine:
self.windowConnect = None
self.windowPreferences = None
self.windowAbout = None
self.connections = {}
self.timer = None
@ -205,7 +203,10 @@ class vmmEngine:
con = self.get_connection(uri, False)
vm = con.get_vm(uuid)
status = vm.status()
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED, libvirt.VIR_DOMAIN_PAUSED ]:
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN,
libvirt.VIR_DOMAIN_SHUTOFF,
libvirt.VIR_DOMAIN_CRASHED,
libvirt.VIR_DOMAIN_PAUSED ]:
print "Save requested, but machine is shutdown / shutoff / paused"
else:
self.fcdialog = gtk.FileChooserDialog("Save Virtual Machine",
@ -215,31 +216,24 @@ class vmmEngine:
gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT),
None)
self.fcdialog.set_do_overwrite_confirmation(True)
# also set up the progress bar now
self.pbar_glade = gtk.glade.XML(config.get_glade_file(), "vmm-save-progress")
self.pbar_win = self.pbar_glade.get_widget("vmm-save-progress")
self.pbar_win.hide()
response = self.fcdialog.run()
self.fcdialog.hide()
if(response == gtk.RESPONSE_ACCEPT):
print "file save dialog should now be hidden"
uri_to_save = self.fcdialog.get_filename()
# show a lovely bouncing progress bar until the vm actually saves
self.pbar_dlg = gtk.Dialog("Saving VM Image",
src.window.get_widget("vmm-details"))
self.pbar_dlg.connect("destroy", self.destroy_pbar_dlg)
self.pbar = gtk.ProgressBar()
self.pbar_dlg.vbox.add(self.pbar)
self.pbar.show()
print "About to present the progress bar"
self.timer = gobject.timeout_add (100, self.pbar.pulse)
self.pbar_dlg.present()
self.timer = gobject.timeout_add (100,
self.pbar_glade.get_widget("pbar").pulse)
self.pbar_win.present()
# actually save the vm
vm.save( uri_to_save )
self.pbar_dlg.destroy()
gobject.source_remove(self.timer)
self.timer = 0
self.pbar_win.hide()
self.fcdialog.destroy()
def destroy_pbar_dlg(self, widget, data=None):
gobject.source_remove(self.timer)
self.timer = 0
widget.destroy();
self.pbar_win.destroy()