choosecd: Customize dialog based on media type (cdrom, floppy)

This commit is contained in:
Cole Robinson 2009-12-14 14:52:52 -05:00
parent ed911036f1
commit 3ed0625000
3 changed files with 24 additions and 17 deletions

View File

@ -24,7 +24,7 @@ import virtinst
import virtManager.uihelpers as uihelpers
import virtManager.util as util
from virtManager.mediadev import MEDIA_CDROM
from virtManager.mediadev import MEDIA_FLOPPY
from virtManager.storagebrowse import vmmStorageBrowser
from virtManager.error import vmmErrorDialog
@ -38,7 +38,7 @@ class vmmChooseCD(gobject.GObject):
IS_FLOPPY = 1
IS_CDROM = 2
def __init__(self, config, dev_id_info, connection):
def __init__(self, config, dev_id_info, connection, media_type):
self.__gobject_init__()
self.window = gtk.glade.XML(config.get_glade_dir() + "/vmm-choose-cd.glade", "vmm-choose-cd", domain="virt-manager")
self.topwin = self.window.get_widget("vmm-choose-cd")
@ -53,6 +53,7 @@ class vmmChooseCD(gobject.GObject):
self.dev_id_info = dev_id_info
self.conn = connection
self.storage_browser = None
self.media_type = media_type
self.window.signal_autoconnect({
"on_media_toggled": self.media_toggled,
@ -142,7 +143,7 @@ class vmmChooseCD(gobject.GObject):
error = self.conn.mediadev_error
uihelpers.init_mediadev_combo(widget)
uihelpers.populate_mediadev_combo(self.conn, widget, MEDIA_CDROM)
uihelpers.populate_mediadev_combo(self.conn, widget, self.media_type)
if error:
warn.show()
@ -152,6 +153,11 @@ class vmmChooseCD(gobject.GObject):
self.window.get_widget("physical-media").set_sensitive(not bool(error))
if self.media_type == MEDIA_FLOPPY:
self.window.get_widget("physical-media").set_label(
_("Floppy D_rive"))
self.window.get_widget("iso-image").set_label(_("Floppy _Image"))
def set_storage_path(self, src, path):
self.window.get_widget("iso-path").set_text(path)

View File

@ -149,7 +149,7 @@ class vmmDetails(gobject.GObject):
self.serial_tabs = []
self.last_console_page = PAGE_CONSOLE
self.addhw = None
self.choose_cd = None
self.media_choosers = {"cdrom": None, "floppy": None}
self.ignorePause = False
self.ignoreDetails = False
@ -959,9 +959,6 @@ class vmmDetails(gobject.GObject):
curpath = diskinfo[3]
devtype = diskinfo[4]
is_cdrom = (devtype == virtinst.VirtualDisk.DEVICE_CDROM)
is_floppy = (devtype == virtinst.VirtualDisk.DEVICE_FLOPPY)
if curpath:
# Disconnect cdrom
self.change_storage_media(dev_id_info, None, _type=None)
@ -972,14 +969,18 @@ class vmmDetails(gobject.GObject):
return self.change_storage_media(dev_id_info, newpath, _type)
# Launch 'Choose CD' dialog
if self.choose_cd is None:
self.choose_cd = vmmChooseCD(self.config,
dev_id_info,
self.vm.get_connection())
self.choose_cd.connect("cdrom-chosen", change_cdrom_wrapper)
else:
self.choose_cd.dev_id_info = dev_id_info
self.choose_cd.show()
if self.media_choosers[devtype] is None:
ret = vmmChooseCD(self.config,
dev_id_info,
self.vm.get_connection(),
devtype)
ret.connect("cdrom-chosen", change_cdrom_wrapper)
self.media_choosers[devtype] = ret
dialog = self.media_choosers[devtype]
dialog.dev_id_info = dev_id_info
dialog.show()
##################################################
# Details/Hardware config changes (apply button) #

View File

@ -7,7 +7,7 @@
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Choose CD Media</property>
<property name="title" translatable="yes">Choose Media</property>
<property name="resizable">False</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
@ -196,7 +196,7 @@
<child>
<widget class="GtkLabel" id="title-label">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;CD Source Device Or File&lt;/b&gt;</property>
<property name="label" translatable="yes">&lt;b&gt;Choose Source Device or File&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>