[gnome-boxes/show-recomended-resources: 7/8] size-property: Use bytes rather than kibibytes



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

    size-property: Use bytes rather than kibibytes
    
    Use of kibibytes as the unit didn't turn out to be as good an idea as I
    originaly had thought. It only forces a lot of conversion everwhere,
    which serves contrary to my intentions when I chose kibibytes.

 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 7e2a0c1..0b9e378 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -391,9 +391,9 @@ private abstract class Boxes.LibvirtMachineProperties: Boxes.Machine {
             var property = add_size_property (ref list,
                                               _("Memory"),
                                               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 (() => {
@@ -492,14 +492,14 @@ private abstract class Boxes.LibvirtMachineProperties: Boxes.Machine {
             var volume_info = storage_volume.get_info ();
             var pool = get_storage_pool (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",
@@ -521,7 +521,7 @@ private abstract class Boxes.LibvirtMachineProperties: Boxes.Machine {
                         disk.resize (value, 0);
                 } else
                     // Currently this never happens as properties page cant be reached without starting the machine
-                    storage_volume.resize (value * Osinfo.KIBIBYTES, StorageVolResizeFlags.NONE);
+                    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]