[gnome-boxes] libvirt-machine-props: Add resource stats graphs



commit 37013275781d992ccee03ee59b6cdcc7526e73a1
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sat Nov 22 18:21:17 2014 +0000

    libvirt-machine-props: Add resource stats graphs
    
    Add resource stats graphs to properties under 'System' page.
    
    This is part of move of sidebar contents to main view before sidebar can
    be dropped.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733367

 src/libvirt-machine-properties.vala |   45 +++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 475de91..3bec4dd 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -139,6 +139,8 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
             break;
 
         case PropertiesPage.SYSTEM:
+            add_resource_usage_graphs (ref list);
+
             var ram_property = add_ram_property (ref list);
             var storage_property = add_storage_property (ref list);
             mark_recommended_resources.begin (ram_property, storage_property);
@@ -435,6 +437,48 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
         }
     }
 
+    private void add_resource_usage_graphs (ref List<Boxes.Property> list) {
+        var grid = new Gtk.Grid ();
+        grid.row_spacing = 5;
+        grid.column_spacing = 10;
+        grid.column_homogeneous = true;
+
+        // CPU
+        var cpu_graph = new MiniGraph ();
+        cpu_graph.ymax = 100;
+        cpu_graph.npoints = 20;
+        grid.attach (cpu_graph, 0, 0, 1, 1);
+        var label = new Gtk.Label (_("CPU"));
+        grid.attach (label, 0, 1, 1, 1);
+
+        // I/O
+        var io_graph = new MiniGraph ();
+        io_graph.ymax = 20;
+        grid.attach (io_graph, 1, 0, 1, 1);
+        label = new Gtk.Label (_("I/O"));
+        grid.attach (label, 1, 1, 1, 1);
+
+        // Network
+        var net_graph = new MiniGraph ();
+        net_graph.ymax = 20;
+        grid.attach (net_graph, 2, 0, 1, 1);
+        label = new Gtk.Label (_("Network"));
+        grid.attach (label, 2, 1, 1, 1);
+
+        var stats_id = machine.stats_updated.connect (() => {
+            cpu_graph.points = machine.cpu_stats;
+            io_graph.points = machine.io_stats;
+            net_graph.points = machine.net_stats;
+        });
+
+        var prop = add_property (ref list, null, grid);
+        ulong flushed_id = 0;
+        flushed_id = prop.flushed.connect (() => {
+            machine.disconnect (stats_id);
+            prop.disconnect (flushed_id);
+        });
+    }
+
     private SizeProperty? add_ram_property (ref List<Boxes.Property> list) {
         try {
             var max_ram = machine.connection.get_node_info ().memory;
@@ -446,6 +490,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
                                               max_ram * Osinfo.KIBIBYTES,
                                               64 * Osinfo.MEBIBYTES,
                                               FormatSizeFlags.IEC_UNITS);
+            property.widget.margin_top = 5;
             if ((VMConfigurator.is_install_config (machine.domain_config) ||
                  VMConfigurator.is_live_config (machine.domain_config)) &&
                 machine.window.previous_ui_state != Boxes.UIState.WIZARD)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]