[gnome-boxes] Make use of GLib.format_size_full()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Make use of GLib.format_size_full()
- Date: Wed, 30 Nov 2011 00:03:17 +0000 (UTC)
commit ab121eb825b3dbf29083770e58aec6c4eaa753d2
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Nov 30 01:39:22 2011 +0200
Make use of GLib.format_size_full()
Make use of glib API to format size string to display to user. One
advantage is to leave out localization to glib.
https://bugzilla.gnome.org/show_bug.cgi?id=665068
src/wizard.vala | 16 ++++------------
vapi/upstream/glib-2.0.vapi | 15 ++++++++++++++-
2 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/src/wizard.vala b/src/wizard.vala
index c0c5cc1..c848dd9 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -116,16 +116,6 @@ private class Boxes.Wizard: Boxes.UI {
});
}
- private static string memory_to_string (int64 memory) {
- if (memory >= Osinfo.GIBIBYTES)
- // Translators: GB here means giga bytes. More information: http://en.wikipedia.org/wiki/Gigabyte
- return _("%lld GB".printf (memory / Osinfo.GIBIBYTES));
- else
- // Does anyone have < 1M memory?
- // Translators: MB here means mega bytes. More information: http://en.wikipedia.org/wiki/Megabyte
- return _("%lld MB".printf (memory / Osinfo.MEBIBYTES));
- }
-
public Wizard (App app) {
this.app = app;
@@ -292,8 +282,10 @@ private class Boxes.Wizard: Boxes.UI {
summary.add_property (_("Password"), media.hidden_password);
}
- summary.add_property (_("Memory"), memory_to_string (resources.ram));
- summary.add_property (_("Disk"), _("%s maximum".printf (memory_to_string (resources.storage))));
+ var memory = format_size_full (resources.ram, FormatSizeFlags.IEC_UNITS);
+ summary.add_property (_("Memory"), memory);
+ memory = format_size_full (resources.storage, FormatSizeFlags.IEC_UNITS);
+ summary.add_property (_("Disk"), _("%s maximum".printf (memory)));
}
}
}
diff --git a/vapi/upstream/glib-2.0.vapi b/vapi/upstream/glib-2.0.vapi
index b378d78..9b29013 100644
--- a/vapi/upstream/glib-2.0.vapi
+++ b/vapi/upstream/glib-2.0.vapi
@@ -2184,6 +2184,7 @@ namespace GLib {
public static GLib.LogFunc default_handler;
public static LogLevelFlags set_fatal_mask (string log_domain, LogLevelFlags log_levels);
public static LogLevelFlags set_always_fatal (LogLevelFlags log_levels);
+ public static void remove_handler (string? log_domain, uint handler_id);
public const string FILE;
public const int LINE;
@@ -2675,8 +2676,20 @@ namespace GLib {
[CCode (has_target = false)]
public delegate void VoidFunc ();
+ [Deprecated (replacement = "format_size")]
public string format_size_for_display (int64 size);
+ public string format_size (uint64 size);
+
+ public string format_size_full (uint64 size, FormatSizeFlags flags);
+
+ [CCode (cprefix = "G_FORMAT_SIZE_", has_type_id = false)]
+ public enum FormatSizeFlags {
+ DEFAULT,
+ LONG_FORMAT,
+ IEC_UNITS
+ }
+
/* Lexical Scanner */
[CCode (has_target = false)]
public delegate void ScannerMsgFunc (Scanner scanner, string message, bool error);
@@ -3878,7 +3891,7 @@ namespace GLib {
[CCode (cname = "g_sequence_get")]
public unowned G get ();
[CCode (cname = "g_sequence_set")]
- public unowned void set (owned G data);
+ public void set (owned G data);
}
public delegate int SequenceIterCompareFunc<G> (SequenceIter<G> a, SequenceIter<G> b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]