[virt-manager RFC PATCH] virt-manager: use autocomplete for OS variant selection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After the migration to libosinfo, choosing an OS variant from "New VM"
wizard became a mess for the very long list of options.
Using an autocomplete entry text will facilitate this task, as an user
can start typing the variant as soon as the OS type is selected.
The combo-box is left untouched, so undecided users can still use it.

UI-suggested-by: Máirín Duffy <duffy@xxxxxxxxxx>
Signed-off-by: Giuseppe Scrivano <gscrivan@xxxxxxxxxx>
---
 ui/create.ui          | 36 +++++++++++++++++++++---------------
 virtManager/create.py | 32 +++++++++++++++++++++++++++-----
 2 files changed, 48 insertions(+), 20 deletions(-)

diff --git a/ui/create.ui b/ui/create.ui
index 05e4e4b..b575a7e 100644
--- a/ui/create.ui
+++ b/ui/create.ui
@@ -1676,21 +1676,6 @@ is not yet supported.&lt;/small&gt;</property>
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkComboBox" id="install-os-version">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <signal name="changed" handler="on_install_os_version_changed" swapped="no"/>
-                                      </object>
-                                      <packing>
-                                        <property name="left_attach">1</property>
-                                        <property name="right_attach">2</property>
-                                        <property name="top_attach">1</property>
-                                        <property name="bottom_attach">2</property>
-                                        <property name="x_options">GTK_FILL</property>
-                                        <property name="y_options"/>
-                                      </packing>
-                                    </child>
-                                    <child>
                                       <object class="GtkComboBox" id="install-os-type">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -1733,6 +1718,27 @@ is not yet supported.&lt;/small&gt;</property>
                                         <property name="y_options"/>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <object class="GtkComboBox" id="install-os-version">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="has_entry">True</property>
+                                        <signal name="changed" handler="on_install_os_version_changed" swapped="no"/>
+                                        <child internal-child="entry">
+                                          <object class="GtkEntry" id="install-os-version-entry">
+                                            <property name="can_focus">True</property>
+                                          </object>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">1</property>
+                                        <property name="right_attach">2</property>
+                                        <property name="top_attach">1</property>
+                                        <property name="bottom_attach">2</property>
+                                        <property name="x_options">GTK_FILL</property>
+                                        <property name="y_options"/>
+                                      </packing>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
diff --git a/virtManager/create.py b/virtManager/create.py
index 038649d..5bad03e 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -295,6 +295,12 @@ class vmmCreate(vmmGObjectUI):
         uiutil.set_combo_text_column(os_variant_list, 1)
         os_variant_list.set_row_separator_func(sep_func, os_variant_list)
 
+        entry = self.widget("install-os-version-entry")
+        completion = Gtk.EntryCompletion()
+        entry.set_completion(completion)
+        completion.set_text_column(1)
+        completion.set_inline_completion(True)
+
         # Archtecture
         # [value, label]
         archList = self.widget("config-arch")
@@ -855,6 +861,9 @@ class vmmCreate(vmmGObjectUI):
         # Add action option
         self._add_os_row(model, label=_("Show all OS options"), action=True)
 
+        completion = self.widget("install-os-version-entry").get_completion()
+        completion.set_model(model)
+
     def populate_media_model(self, model, urls):
         model.clear()
         if urls is not None:
@@ -886,7 +895,7 @@ class vmmCreate(vmmGObjectUI):
         self.set_caps_state()
 
     def populate_summary(self):
-        distro, version, dlabel, vlabel = self.get_config_os_info()
+        distro, version, ignore1, dlabel, vlabel = self.get_config_os_info()
         mem = self.pretty_memory(int(self.guest.memory))
         cpu = str(int(self.guest.vcpus))
 
@@ -978,7 +987,15 @@ class vmmCreate(vmmGObjectUI):
         distro = None
         dlabel = None
         variant = None
-        vlabel = None
+        vlabel = self.widget("install-os-version-entry").get_text()
+
+        for i in self.widget("install-os-version").get_model():
+            if not i[2] and not i[3] and i[1] == vlabel:
+                variant = i[0]
+                break
+
+        if vlabel and not variant:
+            return (None, None, False, None, None)
 
         if drow:
             distro = drow[0]
@@ -989,6 +1006,7 @@ class vmmCreate(vmmGObjectUI):
 
         return (distro and str(distro),
                 variant and str(variant),
+                True,
                 str(dlabel), str(vlabel))
 
     def get_config_local_media(self, store_media=False):
@@ -1157,6 +1175,7 @@ class vmmCreate(vmmGObjectUI):
         self.widget("install-os-version").set_visible(not dodetect)
 
         if dodetect:
+            self.widget("install-os-version-entry").set_text("")
             self.mediaDetected = False
             self.detect_media_os()
 
@@ -1175,8 +1194,8 @@ class vmmCreate(vmmGObjectUI):
                 self.populate_os_type_model()
                 return
 
-        variant = self.widget("install-os-version")
-        variant.set_active(0)
+        self.widget("install-os-version-entry").set_text("")
+        self.widget("install-os-version-entry").grab_focus()
 
     def change_os_version(self, box):
         show_all = uiutil.get_list_selection(box, 3)
@@ -1466,7 +1485,10 @@ class vmmCreate(vmmGObjectUI):
         is_import = False
         init = None
         fs = None
-        distro, variant, ignore1, ignore2 = self.get_config_os_info()
+        distro, variant, valid, ignore1, ignore2 = self.get_config_os_info()
+
+        if not valid:
+            return self.err.val_err(_("Please specify a valid OS variant."))
 
         if instmethod == INSTALL_PAGE_ISO:
             instclass = virtinst.DistroInstaller
-- 
1.9.0

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list





[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux