[gnome-boxes] Keep "name" as a generic free-form base item text



commit 149418d69848f1f28d4a1a6b9b43a0d14361090d
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Wed Jul 18 14:42:48 2012 +0200

    Keep "name" as a generic free-form base item text
    
    "title" should stay libvirt specific.
    
    Now renaming a remote machine connection in properties update
    properties topbar label correctly again.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=680168

 src/collection-view.vala |    4 ++--
 src/collection.vala      |   11 -----------
 src/display-page.vala    |    2 +-
 src/libvirt-machine.vala |    8 ++++----
 src/machine.vala         |    4 ++--
 src/properties.vala      |    2 +-
 6 files changed, 10 insertions(+), 21 deletions(-)
---
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 866ebf7..b465e84 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -172,7 +172,7 @@ private class Boxes.CollectionView: Boxes.UI {
             return;
         }
 
-        var iter = append (machine.pixbuf, item.title, item);
+        var iter = append (machine.pixbuf, machine.name, item);
         var pixbuf_id = machine.notify["pixbuf"].connect (() => {
             // apparently iter is stable after insertion/removal/sort
             model.set (iter, ModelColumns.SCREENSHOT, machine.pixbuf);
@@ -240,7 +240,7 @@ private class Boxes.CollectionView: Boxes.UI {
             if (item_a == null || item_b == null) // FIXME?!
                 return 0;
 
-            return item_a.title.collate (item_b.title);
+            return item_a.name.collate (item_b.name);
         });
         model.set_sort_column_id (Gtk.SortColumn.DEFAULT, Gtk.SortType.ASCENDING);
 
diff --git a/src/collection.vala b/src/collection.vala
index aa141db..9cea481 100644
--- a/src/collection.vala
+++ b/src/collection.vala
@@ -2,17 +2,6 @@
 
 private abstract class Boxes.CollectionItem: Boxes.UI {
     public string name { set; get; }
-    public string title {
-        set {
-            _title = value;
-        }
-
-        owned get {
-            return _title ?? name;
-        }
-    }
-
-    private string? _title;
 }
 
 private class Boxes.Collection: GLib.Object {
diff --git a/src/display-page.vala b/src/display-page.vala
index 67ef3da..6b62500 100644
--- a/src/display-page.vala
+++ b/src/display-page.vala
@@ -192,7 +192,7 @@ private class Boxes.DisplayPage: GLib.Object {
         var machine = App.app.current_item as Boxes.Machine;
         return_if_fail (machine != null);
 
-        var title = machine.title;
+        var title = machine.name;
         if (grabbed)
             title = _("%s <b>(press Ctrl+Alt keys to ungrab)</b>").printf (title);
 
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 3c2e460..e998c9d 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -7,7 +7,6 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
     public GVirConfig.Domain domain_config;
     public GVir.Connection connection;
     private string? storage_volume_path;
-
     public VMCreator? vm_creator; // Under installation if this is set to non-null
 
     public bool save_on_quit {
@@ -92,9 +91,11 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
     public LibvirtMachine (CollectionSource source,
                            GVir.Connection connection,
                            GVir.Domain     domain) throws GLib.Error {
-        base (source, domain.get_name ());
+        var config = domain.get_config (0);
+        var item_name = config.get_title () ?? domain.get_name ();
+        base (source, item_name);
 
-        debug ("new libvirt machine: " + name);
+        debug ("new libvirt machine: " + domain.get_name ());
         this.config = new DisplayConfig (source, domain.get_uuid ());
         this.connection = connection;
         this.domain = domain;
@@ -129,7 +130,6 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         domain.stopped.connect (() => { state = MachineState.STOPPED; });
 
         update_domain_config ();
-        title = domain_config.get_title () ?? name;
         domain.updated.connect (update_domain_config);
 
         load_screenshot ();
diff --git a/src/machine.vala b/src/machine.vala
index 54e285b..0e0b2ec 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -361,9 +361,9 @@ private class Boxes.MachineActor: Boxes.UI {
 
         gtk_vbox.get_widget ().get_style_context ().add_class ("boxes-bg");
 
-        label = new Gtk.Label (machine.title);
+        label = new Gtk.Label (machine.name);
         label.modify_fg (Gtk.StateType.NORMAL, get_color ("white"));
-        machine.bind_property ("title", label, "label", BindingFlags.DEFAULT);
+        machine.bind_property ("name", label, "label", BindingFlags.DEFAULT);
         vbox.add (label);
         vbox.set_valign (Gtk.Align.START);
         password_entry = new Gtk.Entry ();
diff --git a/src/properties.vala b/src/properties.vala
index 5ad1e01..e0b290b 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -231,7 +231,7 @@ private class Boxes.Properties: Boxes.UI {
 
         switch (ui_state) {
         case UIState.PROPERTIES:
-            toolbar_label_bind = App.app.current_item.bind_property ("title", toolbar_label, "label", BindingFlags.SYNC_CREATE);
+            toolbar_label_bind = App.app.current_item.bind_property ("name", toolbar_label, "label", BindingFlags.SYNC_CREATE);
             populate ();
             opacity = 255;
             break;



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