virtManager: oslist: Push users towards linuxXXXX options

Have the UI push users more towards better defaults, by discouraging
the 'generic' entry and offering the 'linuxXXXX' entries when their
distro or OS version is not in the list.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2022-02-11 13:40:09 -05:00
parent 95ba78f3e8
commit 1f8afc8668
3 changed files with 22 additions and 7 deletions

View File

@ -52,9 +52,9 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Can't find the operating system you are looking for?
Try selecting the next most recent version displayed,
or use the "Generic OS" entry.</property>
<property name="label" translatable="yes">Can't find the operating system you are looking for? Try selecting a similar distro or version, or use one of the 'Generic' options.</property>
<property name="wrap">True</property>
<property name="max-width-chars">60</property>
</object>
<packing>
<property name="expand">True</property>

View File

@ -6,10 +6,15 @@
from gi.repository import Gdk, Gtk
import virtinst
from virtinst import xmlutil
from .baseclass import vmmGObjectUI
def _always_show(osobj):
return bool(osobj.is_generic() or osobj.is_linux_generic())
class vmmOSList(vmmGObjectUI):
__gsignals__ = {
"os-selected": (vmmGObjectUI.RUN_FIRST, None, [object])
@ -53,6 +58,8 @@ class vmmOSList(vmmGObjectUI):
os_list_model = Gtk.ListStore(object, str)
all_os = virtinst.OSDB.list_os(sortkey="label")
# Always put the generic entries at the end of the list
all_os = list(sorted(all_os, key=_always_show))
for os in all_os:
os_list_model.append([os, "%s (%s)" % (os.label, os.name)])
@ -70,6 +77,10 @@ class vmmOSList(vmmGObjectUI):
nameCol.add_attribute(text, 'text', 1)
os_list.append_column(nameCol)
markup = "<small>%s</small>" % xmlutil.xml_escape(
self.widget("eol-warn").get_text())
self.widget("eol-warn").set_markup(markup)
###################
# Private helpers #
@ -176,13 +187,13 @@ class vmmOSList(vmmGObjectUI):
def _filter_os_cb(self, model, titer, ignore1):
osobj = model.get(titer, 0)[0]
if osobj.is_generic():
return True
if self._filter_eol:
if osobj.eol:
return False
if _always_show(osobj):
return True
if self._filter_name is not None and self._filter_name != "":
label = osobj.label.lower()
name = osobj.name.lower()

View File

@ -67,7 +67,8 @@ class _OSDB(object):
# Add our custom generic variant
o = Libosinfo.Os()
o.set_param("short-id", "generic")
o.set_param("name", _("Generic OS"))
o.set_param("name",
_("Generic or unknown OS. Usage is not recommended."))
self.__os_generic = _OsVariant(o)
return self.__os_generic
@ -357,6 +358,9 @@ class _OsVariant(object):
def is_generic(self):
return self.name == "generic"
def is_linux_generic(self):
return re.match(r"linux\d\d\d\d", self.name)
def is_windows(self):
return self._family in ['win9x', 'winnt', 'win16']