From 33a2d1a1c8eece3c55dd69aed1e7d4018b3d15aa Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 24 Apr 2014 16:58:11 +0200 Subject: [PATCH] virt-manager: use autocomplete for OS variant selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Giuseppe Scrivano --- 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 05e4e4ba..b575a7e6 100644 --- a/ui/create.ui +++ b/ui/create.ui @@ -1675,21 +1675,6 @@ is not yet supported.</small> - - - True - False - - - - 1 - 2 - 1 - 2 - GTK_FILL - - - True @@ -1733,6 +1718,27 @@ is not yet supported.</small> + + + True + False + True + + + + True + + + + + 1 + 2 + 1 + 2 + GTK_FILL + + + diff --git a/virtManager/create.py b/virtManager/create.py index 038649dc..5bad03e4 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