mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-05 09:17:57 +03:00
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:
parent
95ba78f3e8
commit
1f8afc8668
@ -52,9 +52,9 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="label" translatable="yes">Can't find the operating system you are looking for?
|
<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>
|
||||||
Try selecting the next most recent version displayed,
|
<property name="wrap">True</property>
|
||||||
or use the "Generic OS" entry.</property>
|
<property name="max-width-chars">60</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
|
@ -6,10 +6,15 @@
|
|||||||
from gi.repository import Gdk, Gtk
|
from gi.repository import Gdk, Gtk
|
||||||
|
|
||||||
import virtinst
|
import virtinst
|
||||||
|
from virtinst import xmlutil
|
||||||
|
|
||||||
from .baseclass import vmmGObjectUI
|
from .baseclass import vmmGObjectUI
|
||||||
|
|
||||||
|
|
||||||
|
def _always_show(osobj):
|
||||||
|
return bool(osobj.is_generic() or osobj.is_linux_generic())
|
||||||
|
|
||||||
|
|
||||||
class vmmOSList(vmmGObjectUI):
|
class vmmOSList(vmmGObjectUI):
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
"os-selected": (vmmGObjectUI.RUN_FIRST, None, [object])
|
"os-selected": (vmmGObjectUI.RUN_FIRST, None, [object])
|
||||||
@ -53,6 +58,8 @@ class vmmOSList(vmmGObjectUI):
|
|||||||
os_list_model = Gtk.ListStore(object, str)
|
os_list_model = Gtk.ListStore(object, str)
|
||||||
|
|
||||||
all_os = virtinst.OSDB.list_os(sortkey="label")
|
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:
|
for os in all_os:
|
||||||
os_list_model.append([os, "%s (%s)" % (os.label, os.name)])
|
os_list_model.append([os, "%s (%s)" % (os.label, os.name)])
|
||||||
@ -70,6 +77,10 @@ class vmmOSList(vmmGObjectUI):
|
|||||||
nameCol.add_attribute(text, 'text', 1)
|
nameCol.add_attribute(text, 'text', 1)
|
||||||
os_list.append_column(nameCol)
|
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 #
|
# Private helpers #
|
||||||
@ -176,13 +187,13 @@ class vmmOSList(vmmGObjectUI):
|
|||||||
|
|
||||||
def _filter_os_cb(self, model, titer, ignore1):
|
def _filter_os_cb(self, model, titer, ignore1):
|
||||||
osobj = model.get(titer, 0)[0]
|
osobj = model.get(titer, 0)[0]
|
||||||
if osobj.is_generic():
|
|
||||||
return True
|
|
||||||
|
|
||||||
if self._filter_eol:
|
if self._filter_eol:
|
||||||
if osobj.eol:
|
if osobj.eol:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if _always_show(osobj):
|
||||||
|
return True
|
||||||
|
|
||||||
if self._filter_name is not None and self._filter_name != "":
|
if self._filter_name is not None and self._filter_name != "":
|
||||||
label = osobj.label.lower()
|
label = osobj.label.lower()
|
||||||
name = osobj.name.lower()
|
name = osobj.name.lower()
|
||||||
|
@ -67,7 +67,8 @@ class _OSDB(object):
|
|||||||
# Add our custom generic variant
|
# Add our custom generic variant
|
||||||
o = Libosinfo.Os()
|
o = Libosinfo.Os()
|
||||||
o.set_param("short-id", "generic")
|
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)
|
self.__os_generic = _OsVariant(o)
|
||||||
return self.__os_generic
|
return self.__os_generic
|
||||||
|
|
||||||
@ -357,6 +358,9 @@ class _OsVariant(object):
|
|||||||
def is_generic(self):
|
def is_generic(self):
|
||||||
return self.name == "generic"
|
return self.name == "generic"
|
||||||
|
|
||||||
|
def is_linux_generic(self):
|
||||||
|
return re.match(r"linux\d\d\d\d", self.name)
|
||||||
|
|
||||||
def is_windows(self):
|
def is_windows(self):
|
||||||
return self._family in ['win9x', 'winnt', 'win16']
|
return self._family in ['win9x', 'winnt', 'win16']
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user