addhardware: add a tool tip when USB controller already existed

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This commit is contained in:
Chen Hanxiao 2014-06-16 11:50:04 +08:00
parent e124f3e401
commit ba96af8df8
2 changed files with 31 additions and 3 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<!-- Generated with glade 3.16.0 on Wed Apr 23 16:58:20 2014 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">67000</property>
<property name="step_increment">1</property>
@ -169,12 +169,12 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<signal name="changed" handler="on_config_storage_devtype_changed" swapped="no"/>
<child internal-child="accessible">
<object class="AtkObject" id="config-storage-devtype-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Device Type Field</property>
</object>
</child>
<signal name="changed" handler="on_config_storage_devtype_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@ -387,6 +387,22 @@
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkImage" id="controller-tooltip">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-info</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">2</property>

View File

@ -869,9 +869,20 @@ class vmmAddHardware(vmmGObjectUI):
def populate_controller_model(self, src):
ignore = src
def show_tooltip(model_tooltip, show):
vmname = self.vm.get_name()
tooltip = (_("%s already has a USB controller attached.\n"
"Adding more than one USB controller is not supported.\n"
"You can change the USB controller type in the VM details screen.")
% vmname)
model_tooltip.set_visible(show)
model_tooltip.set_tooltip_text(tooltip)
controller_type = self.get_config_controller_type()
modellist = self.widget("controller-model")
modellist.set_sensitive(True)
model_tooltip = self.widget("controller-tooltip")
show_tooltip(model_tooltip, False)
controllers = self.vm.get_controller_devices()
if controller_type == VirtualController.TYPE_USB:
@ -883,6 +894,7 @@ class vmmAddHardware(vmmGObjectUI):
self._remove_usb_controller = usb_controllers[0]
self.widget("create-finish").set_sensitive(True)
else:
show_tooltip(model_tooltip, True)
self.widget("create-finish").set_sensitive(False)
else:
self.widget("create-finish").set_sensitive(True)