Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 59 additions & 16 deletions src/Views/HardwareView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class About.HardwareView : Gtk.Box {
private string manufacturer_support_url;
private string memory;
private string processor;
private uint physical_cpus;
private uint physical_cores_per_cpu;
private uint logical_threads_per_cpu;
private string product_name;
private string product_version;
private SystemInterface system_interface;
Expand Down Expand Up @@ -57,6 +60,32 @@ public class About.HardwareView : Gtk.Box {
xalign = 0
};

var processor_details = new Gtk.Box (VERTICAL, 0) {
focusable = false
};

processor_details.append (label (_("CPUs: %u").printf (physical_cpus)));
processor_details.append (label (_("Cores per CPU: %u").printf (physical_cores_per_cpu)));
processor_details.append (label (_("Threads per CPU: %u").printf (logical_threads_per_cpu)));

var processor_popover = new Gtk.Popover () {
child = processor_details,
position = BOTTOM
};

var processor_button = new Gtk.MenuButton () {
halign = START,
valign = END,
focusable = false,
icon_name = "dialog-information",
popover = processor_popover
};
processor_button.add_css_class (Granite.CssClass.CIRCULAR);

var processor_box = new Gtk.Box (HORIZONTAL, 0);
processor_box.append (processor_info);
processor_box.append (processor_button);

var memory_info = new Gtk.Label (_("%s memory").printf (memory)) {
ellipsize = MIDDLE,
selectable = true,
Expand Down Expand Up @@ -115,7 +144,7 @@ public class About.HardwareView : Gtk.Box {

update_manufacturer_logo ();

details_box.append (processor_info);
details_box.append (processor_box);
details_box.append (graphics_box);

details_box.append (memory_info);
Expand Down Expand Up @@ -170,6 +199,21 @@ public class About.HardwareView : Gtk.Box {
});
}

private Gtk.Label label (string text) {
var label = new Gtk.Label (text) {
halign = Gtk.Align.START,
valign = Gtk.Align.END,
wrap = true,
selectable = false,
margin_top = 6,
margin_bottom = 0,
margin_start = 6,
margin_end = 6,
};

return label;
}

private void on_hostname_entry_activate () {
hostname_entry.secondary_icon_name = "process-working-symbolic";
hostname_entry.add_css_class ("spin");
Expand Down Expand Up @@ -229,7 +273,7 @@ public class About.HardwareView : Gtk.Box {
return ARMPartDecoder.decode_arm_model (cpu_implementer, cpu_part);
}

private string? get_cpu_info () {
private string? get_cpu_info (out uint cpus, out uint cores, out uint threads) {
unowned GLibTop.sysinfo? info = GLibTop.get_sysinfo ();

if (info == null) {
Expand Down Expand Up @@ -276,26 +320,21 @@ public class About.HardwareView : Gtk.Box {

string result = "";
foreach (var cpu in counts.entries) {
if (result.length > 0) {
result += "\n";
}

string cpu_name = _("Unknown Processor");
if (cpu.key.length > 0) {
cpu_name = clean_name (cpu.key);
}

if (cpu.@value == 2) {
result += _("Dual-Core %s").printf (cpu_name);
} else if (cpu.@value == 4) {
result += _("Quad-Core %s").printf (cpu_name);
} else if (cpu.@value == 6) {
result += _("Hexa-Core %s").printf (cpu_name);
} else {
result += "%u \u00D7 %s ".printf (cpu.@value, cpu_name);
}
cores = cpu.@value;

result = "%s".printf (cpu_name);

break;
}

cpus = counts.size;
threads = (uint) info.ncpu / cpus;

return result;
}

Expand Down Expand Up @@ -399,7 +438,11 @@ public class About.HardwareView : Gtk.Box {
}

private void fetch_hardware_info () {
string? cpu = get_cpu_info ();
string? cpu = get_cpu_info (
out physical_cpus,
out physical_cores_per_cpu,
out logical_threads_per_cpu
);

if (cpu == null) {
processor = _("Unknown Processor");
Expand Down
Loading