Merge lp:~noxan/switchboard-plug-about/fix-1161643-hdd-and-ram-size into lp:~elementary-apps/switchboard-plug-about/trunk

Proposed by Richard Stromer
Status: Merged
Merged at revision: 88
Proposed branch: lp:~noxan/switchboard-plug-about/fix-1161643-hdd-and-ram-size
Merge into: lp:~elementary-apps/switchboard-plug-about/trunk
Diff against target: 37 lines (+10/-7)
1 file modified
src/about-plug.vala (+10/-7)
To merge this branch: bzr merge lp:~noxan/switchboard-plug-about/fix-1161643-hdd-and-ram-size
Reviewer Review Type Date Requested Status
Jaap Broekhuizen (community) Approve
Review via email: mp+164283@code.launchpad.net

This proposal supersedes a proposal from 2013-05-16.

Description of the change

Improved the fix again.

To post a comment you must log in.
Revision history for this message
Richard Stromer (noxan) wrote :

To give credits properly: Took the idea of using FormatSizeFlags.IEC_UNITS from teemperor's branch.

Revision history for this message
Jaap Broekhuizen (jaapz-b) wrote :

Would be nicer if we didn't have to execute command line tools with spawn_command_line_sync, but I guess this will do for now :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/about-plug.vala'
2--- src/about-plug.vala 2013-04-20 15:29:09 +0000
3+++ src/about-plug.vala 2013-05-16 23:51:26 +0000
4@@ -137,7 +137,7 @@
5 }
6
7 //Memory
8- memory = GLib.format_size (get_mem_info_for("MemTotal:") * 1000);
9+ memory = GLib.format_size (get_mem_info_for("MemTotal:") * 1024, FormatSizeFlags.IEC_UNITS);
10
11 // Graphics
12 Process.spawn_command_line_sync ("lspci", out graphics);
13@@ -156,15 +156,18 @@
14 }
15
16 // Hard Drive
17- Process.spawn_command_line_sync ("df -h", out hdd);
18+ Process.spawn_command_line_sync ("df", out hdd);
19+ Regex hdd_size_regex = /^\S+\s+(\d+)\s+\d+/;
20+ uint64 hdd_size = 0;
21 foreach (string partition in hdd.split ("\n")) {
22- if ("/\n" in partition + "\n") {
23- hdd = partition;
24+ if (partition.has_prefix ("/dev/")) {
25+ MatchInfo match_info;
26+ if (hdd_size_regex.match (partition, 0, out match_info)) {
27+ hdd_size += match_info.fetch (1).to_uint64 ();
28+ }
29 }
30 }
31- hdd = hdd.split ("G")[0];
32- hdd = hdd.reverse ().split (" ")[0].reverse ();
33- hdd = GLib.format_size (hdd.to_uint64 () * 1000000000);
34+ hdd = GLib.format_size (hdd_size * 1024, FormatSizeFlags.IEC_UNITS);
35 }
36
37 private string get_graphics_from_string(string graphics) {

Subscribers

People subscribed via source and target branches

to all changes: