[virt-tools-list] [virt-manager PATCH v2 3/3] addhardware: add a tool tip when USB controller already existed

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Tue Jun 10 08:03:24 UTC 2014


Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
v2: add a switch for function show_tooltip.

 ui/addhardware.ui          | 22 +++++++++++++++++++---
 virtManager/addhardware.py | 12 ++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/ui/addhardware.ui b/ui/addhardware.ui
index 97d03c0..7a5b30d 100644
--- a/ui/addhardware.ui
+++ b/ui/addhardware.ui
@@ -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>
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 0678f03..02cff57 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -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)
-- 
1.9.0




More information about the virt-tools-list mailing list