[gnome-boxes] vm-creator: Don't put 'Live' in domain's title



commit c43b51ee44d8430566e095bf12ef48deafd7825e
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Aug 15 16:58:47 2012 +0300

    vm-creator: Don't put 'Live' in domain's title
    
    Now that we have a special CellRenderer in icon view that can display an
    optional 2nd line of text under the boxes, we use that to display
    supplementary information about the box. For now, we only show 'Live' or
    'Installing..' when appropriate.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681924

 src/collection-view.vala |   14 +++++++++++++-
 src/installer-media.vala |    5 -----
 src/libvirt-machine.vala |   16 ++++++++++++++++
 src/machine.vala         |    1 +
 src/vm-creator.vala      |    2 --
 src/wizard-source.vala   |    7 ++++++-
 6 files changed, 36 insertions(+), 9 deletions(-)
---
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 18bfa22..0a5a7e4 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -18,6 +18,7 @@ private class Boxes.CollectionView: Boxes.UI {
     private enum ModelColumns {
         SCREENSHOT = Gd.MainColumns.ICON,
         TITLE = Gd.MainColumns.PRIMARY_TEXT,
+        INFO = Gd.MainColumns.SECONDARY_TEXT,
         SELECTED = Gd.MainColumns.SELECTED,
         ITEM = Gd.MainColumns.LAST,
 
@@ -156,6 +157,7 @@ private class Boxes.CollectionView: Boxes.UI {
 
     private Gtk.TreeIter append (Gdk.Pixbuf pixbuf,
                                  string title,
+                                 string? info,
                                  CollectionItem item)
     {
         Gtk.TreeIter iter;
@@ -163,6 +165,8 @@ private class Boxes.CollectionView: Boxes.UI {
         model.append (out iter);
         model.set (iter, ModelColumns.SCREENSHOT, pixbuf);
         model.set (iter, ModelColumns.TITLE, title);
+        if (info != null)
+            model.set (iter, ModelColumns.INFO, info);
         model.set (iter, ModelColumns.SELECTED, false);
         model.set (iter, ModelColumns.ITEM, item);
 
@@ -179,7 +183,7 @@ private class Boxes.CollectionView: Boxes.UI {
             return;
         }
 
-        var iter = append (machine.pixbuf, machine.name, item);
+        var iter = append (machine.pixbuf, machine.name, machine.info, item);
         var pixbuf_id = machine.notify["pixbuf"].connect (() => {
             // apparently iter is stable after insertion/removal/sort
             model.set (iter, ModelColumns.SCREENSHOT, machine.pixbuf);
@@ -192,6 +196,12 @@ private class Boxes.CollectionView: Boxes.UI {
         });
         item.set_data<ulong> ("name_id", name_id);
 
+        var info_id = machine.notify["info"].connect (() => {
+            // apparently iter is stable after insertion/removal/sort
+            model.set (iter, ModelColumns.INFO, machine.info);
+        });
+        item.set_data<ulong> ("info_id", info_id);
+
         item.ui_state = UIState.COLLECTION;
         actor_remove (item.actor);
 
@@ -231,6 +241,8 @@ private class Boxes.CollectionView: Boxes.UI {
         item.disconnect (pixbuf_id);
         var name_id = item.get_data<ulong> ("name_id");
         item.disconnect (name_id);
+        var info_id = item.get_data<ulong> ("info_id");
+        item.disconnect (info_id);
     }
 
     private Gtk.TreePath? get_path_for_item (CollectionItem item) {
diff --git a/src/installer-media.vala b/src/installer-media.vala
index c8f20f0..4c4e8f8 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -149,10 +149,5 @@ private class Boxes.InstallerMedia : GLib.Object {
 
             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);
     }
 }
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index ba902a1..92ce4fc 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -14,6 +14,20 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         set { source.set_boolean ("source", "save-on-quit", value); }
     }
 
+    public override string? info {
+        get {
+            if (domain_config == null)
+                return null;
+
+            if (VMConfigurator.is_live_config (domain_config))
+                return _("Live");
+            else if (VMConfigurator.is_install_config (domain_config))
+                return _("Installing...");
+            else
+                return null;
+        }
+    }
+
     private bool _connect_display;
     public override void disconnect_display () {
         stay_on_display = false;
@@ -66,6 +80,8 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
 
             var volume = get_storage_volume (connection, domain, null);
             storage_volume_path = (volume != null)? volume.get_path () : null;
+
+            notify_property ("info");
         } catch (GLib.Error error) {
             critical ("Failed to fetch configuration for domain '%s': %s", domain.get_name (), error.message);
         }
diff --git a/src/machine.vala b/src/machine.vala
index 9352da7..fc9c8a6 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -10,6 +10,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
     public Boxes.DisplayConfig config;
     public Gdk.Pixbuf? pixbuf { get; set; }
     public bool stay_on_display;
+    public virtual string? info { get { return null; } }
 
     private ulong show_id;
     private ulong hide_id;
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index 7a12e39..986a02c 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -154,8 +154,6 @@ private class Boxes.VMCreator {
         var base_title = install_media.label;
         title = base_title;
         var base_name = (install_media.os != null) ? install_media.os.short_id : base_title;
-        if (install_media.live)
-            base_name += "-live";
         name = base_name;
 
         var pool = yield get_storage_pool ();
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 860e399..88e0fd0 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -223,7 +223,12 @@ private class Boxes.WizardSource: GLib.Object {
         var vbox = new Gtk.VBox (true, 5);
         hbox.pack_start (vbox, true, true);
 
-        var label = new Gtk.Label (media.label);
+        var media_label = media.label;
+        if (media.os_media != null && media.os_media.live)
+            // Translators: We show 'Live' tag next or below the name of live OS media or box based on such media.
+            //              http://en.wikipedia.org/wiki/Live_CD
+            media_label += " (" +  _("Live") + ")";
+        var label = new Gtk.Label (media_label);
         label.set_ellipsize (Pango.EllipsizeMode.END);
         label.get_style_context ().add_class ("boxes-source-label");
         label.xalign = 0.0f;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]