Skip to content
3 changes: 3 additions & 0 deletions src/Resources/Storage/Disk.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public class Monitor.Disk : GLib.Object {
public string model;
public uint64 size;
public uint64 size_mounted;
public uint64 free;
public string revision;
public string id;
Expand All @@ -22,11 +23,13 @@ public class Monitor.Disk : GLib.Object {
revision = drive.revision;
id = drive.id;
free = 0;
size_mounted = 0;
}

public void add_volume (Volume vol) {
volumes.add (vol);
free = free + vol.free;
size_mounted = size_mounted + vol.size_mounted;
}

public Gee.ArrayList<Volume?> get_volumes () {
Expand Down
1 change: 1 addition & 0 deletions src/Resources/Storage/Storage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
Posix.statvfs buf;
Posix.statvfs_exec (block_fs.mount_points[0], out buf);
current_volume.free = (uint64) buf.f_bfree * (uint64) buf.f_bsize;
current_volume.size_mounted = (uint64) buf.f_blocks * (uint64) buf.f_bsize;

// } else {
// current_volume.mount_point = "";
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/Storage/Volume.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Monitor.Volume : Object {
public string uuid;
public string mount_point;
public uint64 size;
public uint64 size_mounted;
public uint64 free;
public uint64 offset;

Expand All @@ -25,6 +26,7 @@ public class Monitor.Volume : Object {
type = block.id_type;
size = block.size;
uuid = block.id_uuid;
size_mounted = 0;
}

public void add_slave (string? new_slave) {
Expand Down
26 changes: 14 additions & 12 deletions src/Views/SystemView/SystemStorageView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,24 @@ public class Monitor.SystemStorageView : Gtk.Box {
size = H3
};

string size_string = format_size ((uint64) drive.size, IEC_UNITS);
string used_string = format_size ((uint64) (drive.size - drive.free), IEC_UNITS);
var size_string = format_size ((uint64) drive.size);
var used_string = format_size ((uint64) (drive.size_mounted - drive.free));
var available_string = format_size ((uint64) drive.size_mounted);

string drive_block_name_and_size_string = "%s 𐄁 %s / %s".printf (drive.device, used_string, size_string);
drive_name_label.secondary_text = "%s 𐄁 %s".printf (drive.device, size_string);

if (drive.free == 0) {
drive_block_name_and_size_string = "%s 𐄁 %s".printf (drive.device, size_string);
}

var drive_block_name_and_size_label = new Gtk.Label (drive_block_name_and_size_string) {
///TRANSLATORS: Only the words "Used" and "available" need to be translated,
///the positional strings placeholders are already translated by the GLib.format_string () function.
var drive_usage_string = _("Used %s of %s available").printf (used_string, available_string);
var drive_usage_label = new Gtk.Label (drive_usage_string) {
halign = START,
margin_top = 6,
margin_bottom = 6
};
drive_block_name_and_size_label.add_css_class (Granite.CssClass.DIM);
drive_usage_label.add_css_class (Granite.CssClass.DIM);

var drive_not_mounted_label = new Gtk.Label (_("Not mounted")) {
margin_top = 6,
halign = START
};
drive_not_mounted_label.add_css_class (Granite.CssClass.DIM);
Expand All @@ -122,7 +124,6 @@ public class Monitor.SystemStorageView : Gtk.Box {
margin_bottom = 6
};
usagebar.add_css_class (Granite.STYLE_CLASS_FLAT);
usagebar.set_value (100.0 * (drive.size - drive.free) / drive.size);

var drive_box = new Gtk.Box (VERTICAL, 0) {
margin_top = 6,
Expand All @@ -131,10 +132,11 @@ public class Monitor.SystemStorageView : Gtk.Box {
margin_start = 12
};
drive_box.append (drive_name_label);
drive_box.append (drive_block_name_and_size_label);
if (drive.free == 0) {
if (drive.size_mounted == 0) {
drive_box.append (drive_not_mounted_label);
} else {
drive_box.append (drive_usage_label);
usagebar.set_value (100.0 * (drive.size_mounted - drive.free) / drive.size_mounted);
drive_box.append (usagebar);
}

Expand Down
Loading