[gnome-boxes] os-database: Make use of compare_cpu_architectures()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] os-database: Make use of compare_cpu_architectures()
- Date: Fri, 15 Feb 2013 14:29:23 +0000 (UTC)
commit a1d78572b0b318cd92cca29d5cfe47bbf0d3971d
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Feb 5 23:02:44 2013 +0200
os-database: Make use of compare_cpu_architectures()
Make use of compare_cpu_architectures() function when finding
minimum/recommended resources for an OS.
https://bugzilla.gnome.org/show_bug.cgi?id=688333
src/os-database.vala | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/os-database.vala b/src/os-database.vala
index 88df742..2853647 100644
--- a/src/os-database.vala
+++ b/src/os-database.vala
@@ -139,9 +139,7 @@ private class Boxes.OSDatabase : GLib.Object {
if (prefs.length <= 0)
return null;
- var filter = new Filter ();
- filter.add_constraint (RESOURCES_PROP_ARCHITECTURE, prefs[0]);
- var filtered = (list as Osinfo.List).new_filtered (filter) as ResourcesList;
+ var filtered = filter_resources_list_by_arch (list, prefs[0]);
if (filtered.get_length () <= 0)
return get_prefered_resources (list, prefs[1:prefs.length]);
else
@@ -150,6 +148,18 @@ private class Boxes.OSDatabase : GLib.Object {
return filtered.get_nth (0) as Resources;
}
+ private ResourcesList filter_resources_list_by_arch (ResourcesList list, string arch) {
+ var new_list = new ResourcesList ();
+ foreach (var entity in list.get_elements ()) {
+ var resources = entity as Resources;
+ var compatibility = compare_cpu_architectures (arch, resources.architecture);
+ if (compatibility == CPUArchCompatibity.IDENTICAL || compatibility ==
CPUArchCompatibity.COMPATIBLE)
+ new_list.add (resources);
+ }
+
+ return new_list;
+ }
+
private async bool ensure_db_loaded () {
if (db != null)
return true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]