[gnome-boxes/downloads-fixups: 2/5] wizard-source: Move OS title compose func to util-app.vala
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/downloads-fixups: 2/5] wizard-source: Move OS title compose func to util-app.vala
- Date: Tue, 13 Nov 2018 13:54:56 +0000 (UTC)
commit a7e08e958870a31505cbfaabda3c175d27377643
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Nov 13 11:31:12 2018 +0100
wizard-source: Move OS title compose func to util-app.vala
src/util-app.vala | 39 +++++++++++++++++++++++++++++++++++++++
src/wizard-source.vala | 39 +--------------------------------------
2 files changed, 40 insertions(+), 38 deletions(-)
---
diff --git a/src/util-app.vala b/src/util-app.vala
index aba87cfd..81fe47c3 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -102,6 +102,45 @@ public void fetch_os_logo (Gtk.Image image, Osinfo.Os os, int size) {
}
}
+ public string serialize_os_title (Osinfo.Media media) {
+ var title = "unknown";
+
+ /* Libosinfo lacks some OS variant names, so we do some
+ parsing here to compose a unique human-readable media
+ identifier. */
+ var variant = "";
+ var variants = media.get_os_variants ();
+ if (variants.get_length () > 0)
+ variant = (variants.get_nth (0) as Osinfo.OsVariant).get_name ();
+ else if ((media.os as Osinfo.Product).name != null) {
+ variant = (media.os as Osinfo.Product).name;
+ if (media.url != null && media.url.contains ("server"))
+ variant += " Server";
+ } else {
+ var file = File.new_for_uri (media.url);
+
+ title = file.get_basename ().replace ("_", "");
+ }
+
+ var subvariant = "";
+
+ if (media.url != null) {
+ if (media.url.contains ("netinst"))
+ subvariant = "(netinst)";
+ else if (media.url.contains ("minimal"))
+ subvariant = "(minimal)";
+ else if (media.url.contains ("dvd"))
+ subvariant = "(DVD)";
+ }
+
+ var is_live = media.live ? " (" + _("Live") + ")" : "";
+
+ title = @"$variant $(media.architecture) $subvariant $is_live";
+
+ /* Strip consequent whitespaces */
+ return title.replace (" ", "");
+ }
+
public async GVir.StoragePool ensure_storage_pool (GVir.Connection connection) throws GLib.Error {
var pool = get_storage_pool (connection);
if (pool == null) {
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 889ce886..5b14bfa8 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -83,7 +83,7 @@ public override void get_preferred_height (out int minimum_height, out int natur
public WizardDownloadableEntry (Osinfo.Media media) {
this.from_os (media.os);
- setup_label (media);
+ title = serialize_os_title (media);
details = media.os.vendor;
url = media.url;
@@ -94,43 +94,6 @@ public WizardDownloadableEntry (Osinfo.Media media) {
this.os = os;
}
-
- private void setup_label (Osinfo.Media media) {
- /* Libosinfo lacks some OS variant names, so we do some
- parsing here to compose a unique human-readable media
- identifier. */
- var variant = "";
- var variants = media.get_os_variants ();
- if (variants.get_length () > 0)
- variant = (variants.get_nth (0) as Osinfo.OsVariant).get_name ();
- else if ((media.os as Osinfo.Product).name != null) {
- variant = (media.os as Osinfo.Product).name;
- if (url != null && media.url.contains ("server"))
- variant += " Server";
- } else {
- var file = File.new_for_uri (media.url);
-
- title = file.get_basename ().replace ("_", "");
- }
-
- var subvariant = "";
-
- if (media.url != null) {
- if (media.url.contains ("netinst"))
- subvariant = "(netinst)";
- else if (media.url.contains ("minimal"))
- subvariant = "(minimal)";
- else if (media.url.contains ("dvd"))
- subvariant = "(DVD)";
- }
-
- var is_live = media.live ? " (" + _("Live") + ")" : "";
-
- title = @"$variant $(media.architecture) $subvariant $is_live";
-
- /* Strip consequent whitespaces */
- title = title.replace (" ", "");
- }
}
[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-media-entry.ui")]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]