summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>2012-07-10 01:28:52 +0300
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>2012-07-10 23:54:00 +0300
commitdb96a87e69d1f5323e1008c5dae5036cf724009e (patch)
tree08a02f4732d4cbfd5a8d39c2a33c12a8abcaa4bf
parenta1c7ae28a3d3b6fb045761e682cbc24a4c1136ec (diff)
installer-media: Refactor label setup code
https://bugzilla.gnome.org/show_bug.cgi?id=679657
-rw-r--r--src/installer-media.vala32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/installer-media.vala b/src/installer-media.vala
index a726161..a0823c9 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -20,14 +20,12 @@ private class Boxes.InstallerMedia : Object {
Media? media,
Osinfo.Resources? resources) {
this.device_file = path;
- this.label = label;
this.os = os;
this.os_media = media;
this.resources = resources;
from_image = true;
- if (media != null && media.live)
- this.label = _("%s (Live)").printf (label);
+ setup_label (label);
}
public static async InstallerMedia create_for_path (string path,
@@ -52,15 +50,7 @@ private class Boxes.InstallerMedia : Object {
os = yield media_manager.os_db.guess_os_from_install_media (device_file, out os_media, cancellable);
}
- if (os != null)
- label = os.get_name ();
- if (os_media != null && os_media.live)
- // Translators: We are appending " (Live)" suffix to name of OS media to indication that it's live.
- // http://en.wikipedia.org/wiki/Live_CD
- label = _("%s (Live)").printf (label);
-
- if (label == null)
- label = Path.get_basename (device_file);
+ setup_label ();
// FIXME: these values could be made editable somehow
var architecture = (os_media != null) ? os_media.architecture : "i686";
@@ -111,4 +101,22 @@ private class Boxes.InstallerMedia : Object {
os_media = os_db.get_media_by_id (os, media_id);
}
}
+
+ private void setup_label (string? label = null) {
+ if (label != null)
+ this.label = label;
+ else if (os != null)
+ this.label = os.get_name ();
+ else {
+ // No appropriate label? :( Lets just use filename then
+ this.label = Path.get_basename (device_file);
+
+ return;
+ }
+
+ if (os_media != null && os_media.live)
+ // Translators: We are appending " (Live)" suffix to name of OS media to indication that it's live.
+ // http://en.wikipedia.org/wiki/Live_CD
+ this.label = _("%s (Live)").printf (this.label);
+ }
}