[gnome-boxes/wip/resize-snapshots2: 2/6] libvirt-machine-props: Refactor a private method



commit 5cdfe0c96daf55ad1d8dae8e39d3dc89b530c458
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Apr 6 14:05:34 2016 +0100

    libvirt-machine-props: Refactor a private method
    
    Move out code handling maxed-out storage from add_storage_property() to
    a new method, add_maxed_out_storage_property().

 src/libvirt-machine-properties.vala |   52 +++++++++++++++++++----------------
 1 files changed, 28 insertions(+), 24 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 91d69c8..198bad0 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -533,30 +533,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
             var max_storage = volume_info.allocation + pool_info.available;
 
             if (min_storage >= max_storage) {
-                var label = new Gtk.Label ("");
-                var capacity = format_size (volume_info.capacity, FormatSizeFlags.DEFAULT);
-                var allocation = format_size (volume_info.allocation, FormatSizeFlags.DEFAULT);
-                var markup = _("<span color=\"grey\">Maximum Disk Size</span>\t\t %s <span 
color=\"grey\">(%s used)</span>").printf (capacity, allocation);
-                label.set_markup (markup);
-                label.halign = Gtk.Align.START;
-
-                add_property (ref list, null, label);
-
-                var infobar = new Gtk.InfoBar ();
-                infobar.message_type = Gtk.MessageType.WARNING;
-
-                var content = infobar.get_content_area ();
-
-                var image = new Gtk.Image ();
-                image.icon_name = "dialog-warning";
-                image.icon_size = 3;
-                content.add (image);
-
-                var msg = _("There is not enough space on your machine to increase the maximum disk size.");
-                label = new Gtk.Label (msg);
-                content.add (label);
-
-                add_property (ref list, null, infobar);
+                add_maxed_out_storage_property (ref list, volume_info);
 
                 return null;
             }
@@ -590,6 +567,33 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
         }
     }
 
+    private void add_maxed_out_storage_property (ref List<Boxes.Property> list, StorageVolInfo volume_info) {
+        var label = new Gtk.Label ("");
+        var capacity = format_size (volume_info.capacity, FormatSizeFlags.DEFAULT);
+        var allocation = format_size (volume_info.allocation, FormatSizeFlags.DEFAULT);
+        var markup = _("<span color=\"grey\">Maximum Disk Size</span>\t\t %s <span color=\"grey\">(%s 
used)</span>").printf (capacity, allocation);
+        label.set_markup (markup);
+        label.halign = Gtk.Align.START;
+
+        add_property (ref list, null, label);
+
+        var infobar = new Gtk.InfoBar ();
+        infobar.message_type = Gtk.MessageType.WARNING;
+
+        var content = infobar.get_content_area ();
+
+        var image = new Gtk.Image ();
+        image.icon_name = "dialog-warning";
+        image.icon_size = 3;
+        content.add (image);
+
+        var msg = _("There is not enough space on your machine to increase the maximum disk size.");
+        label = new Gtk.Label (msg);
+        content.add (label);
+
+        add_property (ref list, null, infobar);
+    }
+
     private void on_storage_changed (Boxes.Property property, uint64 value) {
         // Ensure that we don't end-up changing storage like a 1000 times a second while user moves the 
slider..
         property.deferred_change = () => {


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