[gnome-boxes] size-property: Use bytes rather than KB



commit 9b51f544c3a580b1eabe4b7a23109c9ca4995de0
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Feb 6 00:09:11 2013 +0200

    size-property: Use bytes rather than KB
    
    Use of KB as the unit didn't turn out to be as good an idea as I
    originaly thought. It only forces a lot of conversion everwhere, which
    serves contrary to my intentions when I chose KB.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688333

 src/i-properties-provider.vala      |    8 ++++----
 src/libvirt-machine-properties.vala |   16 ++++++++--------
 2 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/src/i-properties-provider.vala b/src/i-properties-provider.vala
index 9883a2d..8efd122 100644
--- a/src/i-properties-provider.vala
+++ b/src/i-properties-provider.vala
@@ -54,14 +54,14 @@ private class Boxes.SizeProperty : Boxes.Property {
     public signal void changed (uint64 value);
 
     public SizeProperty (string name, uint64 size, uint64 min, uint64 max, uint64 step) {
-        var label = new Gtk.Label (format_size (((uint64) size) * Osinfo.KIBIBYTES, 
FormatSizeFlags.IEC_UNITS));
+        var label = new Gtk.Label (format_size ((uint64) size, FormatSizeFlags.IEC_UNITS));
         label.halign = Gtk.Align.CENTER;
 
         var scale = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, min, max, step);
 
-        scale.add_mark (min, Gtk.PositionType.BOTTOM, format_size (min * Osinfo.KIBIBYTES, 
FormatSizeFlags.IEC_UNITS));
+        scale.add_mark (min, Gtk.PositionType.BOTTOM, format_size (min, FormatSizeFlags.IEC_UNITS));
         scale.add_mark (max, Gtk.PositionType.BOTTOM,
-                        "%s (maximum)".printf (format_size (max * Osinfo.KIBIBYTES, 
FormatSizeFlags.IEC_UNITS)));
+                        "%s (maximum)".printf (format_size (max, FormatSizeFlags.IEC_UNITS)));
 
         scale.set_show_fill_level (true);
         scale.set_restrict_to_fill_level (false);
@@ -75,7 +75,7 @@ private class Boxes.SizeProperty : Boxes.Property {
 
         scale.value_changed.connect (() => {
             uint64 v = (uint64) scale.get_value ();
-            label.set_text (format_size (v * Osinfo.KIBIBYTES, FormatSizeFlags.IEC_UNITS));
+            label.set_text (format_size (v, FormatSizeFlags.IEC_UNITS));
             scale.set_fill_level (v);
 
             changed ((uint64) scale.get_value ());
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index b843e78..3d9ba4b 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -354,9 +354,9 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
             var property = add_size_property (ref list,
                                               _("Memory"),
                                               machine.domain_config.memory,
-                                              Osinfo.MEBIBYTES / Osinfo.KIBIBYTES,
-                                              max_ram,
-                                              Osinfo.MEBIBYTES / Osinfo.KIBIBYTES);
+                                              Osinfo.MEBIBYTES,
+                                              max_ram * Osinfo.KIBIBYTES,
+                                              Osinfo.MEBIBYTES);
             property.changed.connect (on_ram_changed);
 
             this.notify["state"].connect (() => {
@@ -456,14 +456,14 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
             var volume_info = machine.storage_volume.get_info ();
             var pool = get_storage_pool (machine.connection);
             var pool_info = pool.get_info ();
-            var max_storage = (volume_info.capacity + pool_info.available)  / Osinfo.KIBIBYTES;
+            var max_storage = volume_info.capacity + pool_info.available;
 
             var property = add_size_property (ref list,
                                               _("Maximum Disk Size"),
-                                              volume_info.capacity / Osinfo.KIBIBYTES,
-                                              volume_info.capacity / Osinfo.KIBIBYTES,
+                                              volume_info.capacity,
+                                              volume_info.capacity,
                                               max_storage,
-                                              Osinfo.GIBIBYTES / Osinfo.KIBIBYTES);
+                                              Osinfo.GIBIBYTES);
             property.changed.connect (on_storage_changed);
         } catch (GLib.Error error) {
             warning ("Failed to get information on volume '%s' or it's parent pool: %s",
@@ -485,7 +485,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
                         disk.resize (value, 0);
                 } else
                     // Currently this never happens as properties page cant be reached without starting the 
machine
-                    machine.storage_volume.resize (value * Osinfo.KIBIBYTES, StorageVolResizeFlags.NONE);
+                    machine.storage_volume.resize (value, StorageVolResizeFlags.NONE);
                 debug ("Storage changed to %llu", value);
             } catch (GLib.Error error) {
                 warning ("Failed to change storage capacity of volume '%s' to %llu: %s",



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