Attaching and inlining. What is the preferred way?<br>Network graphing did not work here, but seems unrelated to this patch.<br><br># HG changeset patch<br># User Jon Nordby <<a href="mailto:jononor@gmail.com">jononor@gmail.com</a>><br>
# Date 1257879542 -3600<br># Node ID 4cc78a5138a02eaa6f7b2ab7d1224eb9a9b2041c<br># Parent 2907191a7a21c9eb51aad693f642ea9561d50ebc<br>manager: Bring back multiple graph as an option.<br><br>Essentially a revert of the changes in 09189003ddf9<br>
<br>diff -r 2907191a7a21 -r 4cc78a5138a0 src/<a href="http://virt-manager.schemas.in">virt-manager.schemas.in</a><br>--- a/src/<a href="http://virt-manager.schemas.in">virt-manager.schemas.in</a> Wed Oct 28 20:35:13 2009 -0400<br>
+++ b/src/<a href="http://virt-manager.schemas.in">virt-manager.schemas.in</a> Tue Nov 10 19:59:02 2009 +0100<br>@@ -1,15 +1,41 @@<br> <gconfschemafile><br> <schemalist><br> <schema><br>- <key>/schemas/apps/::PACKAGE::/vmlist-fields/stats-type</key><br>
- <applyto>/apps/::PACKAGE::/vmlist-fields/stats-type</applyto><br>+ <key>/schemas/apps/::PACKAGE::/vmlist-fields/disk_usage</key><br>+ <applyto>/apps/::PACKAGE::/vmlist-fields/disk_usage</applyto><br>
<owner>::PACKAGE::</owner><br>- <type>int</type><br>+ <type>bool</type><br> <default>0</default><br> <br> <locale name="C"><br>- <short>Stats type in manager view</short><br>
- <long>Type of stats to graph (cpu, disk, net) in manager view</long><br>+ <short>Show disk I/O in summary</short><br>+ <long>Show the disk I/O field in the domain list summary view</long><br>
+ </locale><br>+ </schema><br>+<br>+ <schema><br>+ <key>/schemas/apps/::PACKAGE::/vmlist-fields/network_traffic</key><br>+ <applyto>/apps/::PACKAGE::/vmlist-fields/network_traffic</applyto><br>
+ <owner>::PACKAGE::</owner><br>+ <type>bool</type><br>+ <default>0</default><br>+<br>+ <locale name="C"><br>+ <short>Show network I/O in summary</short><br>
+ <long>Show the network I/O field in the domain list summary view</long><br>+ </locale><br>+ </schema><br>+<br>+ <schema><br>+ <key>/schemas/apps/::PACKAGE::/vmlist-fields/cpu_usage</key><br>
+ <applyto>/apps/::PACKAGE::/vmlist-fields/cpu_usage</applyto><br>+ <owner>::PACKAGE::</owner><br>+ <type>bool</type><br>+ <default>1</default><br>+<br>+ <locale name="C"><br>
+ <short>Show cpu usage in summary</short><br>+ <long>Show the cpu usage field in the domain list summary view</long><br> </locale><br> </schema><br> <br>diff -r 2907191a7a21 -r 4cc78a5138a0 src/virtManager/config.py<br>
--- a/src/virtManager/config.py Wed Oct 28 20:35:13 2009 -0400<br>+++ b/src/virtManager/config.py Tue Nov 10 19:59:02 2009 +0100<br>@@ -245,12 +245,23 @@<br> # Suggest gconf syncs, so that the unset dirs are fully removed<br>
self.conf.suggest_sync()<br> <br>- def get_vmlist_stats_type(self):<br>- return self.conf.get_int(self.conf_dir + "/vmlist-fields/stats_type")<br>+ def is_vmlist_cpu_usage_visible(self):<br>
+ return self.conf.get_bool(self.conf_dir + "/vmlist-fields/cpu_usage")<br> <br>- def set_vmlist_stats_type(self, val):<br>- self.conf.set_int(self.conf_dir + "/vmlist-fields/stats_type", val)<br>
+ def is_vmlist_disk_io_visible(self):<br>+ return self.conf.get_bool(self.conf_dir + "/vmlist-fields/disk_usage")<br> <br>+ def is_vmlist_network_traffic_visible(self):<br>+ return self.conf.get_bool(self.conf_dir + "/vmlist-fields/network_traffic")<br>
+<br>+ def set_vmlist_cpu_usage_visible(self, state):<br>+ self.conf.set_bool(self.conf_dir + "/vmlist-fields/cpu_usage", state)<br>+<br>+ def set_vmlist_disk_io_visible(self, state):<br>+ self.conf.set_bool(self.conf_dir + "/vmlist-fields/disk_usage", state)<br>
+<br>+ def set_vmlist_network_traffic_visible(self, state):<br>+ self.conf.set_bool(self.conf_dir + "/vmlist-fields/network_traffic", state)<br> <br> def get_default_directory(self, conn, _type):<br>
if not _type:<br>@@ -290,9 +301,14 @@<br> def set_view_system_tray(self, val):<br> self.conf.set_bool(self.conf_dir + "/system-tray", val)<br> <br>- def on_vmlist_stats_type_changed(self, callback):<br>
- self.conf.notify_add(self.conf_dir + "/vmlist-fields/stats_type",<br>- callback)<br>+ def on_vmlist_cpu_usage_visible_changed(self, callback):<br>+ self.conf.notify_add(self.conf_dir + "/vmlist-fields/cpu_usage", callback)<br>
+<br>+ def on_vmlist_disk_io_visible_changed(self, callback):<br>+ self.conf.notify_add(self.conf_dir + "/vmlist-fields/disk_usage", callback)<br>+<br>+ def on_vmlist_network_traffic_visible_changed(self, callback):<br>
+ self.conf.notify_add(self.conf_dir + "/vmlist-fields/network_traffic", callback)<br> <br> def get_stats_update_interval(self):<br> interval = self.conf.get_int(self.conf_dir + "/stats/update-interval")<br>
diff -r 2907191a7a21 -r 4cc78a5138a0 src/virtManager/manager.py<br>--- a/src/virtManager/manager.py Wed Oct 28 20:35:13 2009 -0400<br>+++ b/src/virtManager/manager.py Tue Nov 10 19:59:02 2009 +0100<br>@@ -34,8 +34,6 @@<br>
from virtManager.graphwidgets import CellRendererSparkline<br> from virtManager import util as util<br> <br>-VMLIST_SORT_NAME = 1<br>-VMLIST_SORT_STATS = 2<br> <br> # fields in the tree model data set<br> ROW_HANDLE = 0<br>
@@ -52,8 +50,9 @@<br> <br> # Columns in the tree view<br> COL_NAME = 0<br>-COL_STATUS = 1<br>-COL_STATS = 2<br>+COL_CPU = 1<br>+COL_DISK = 2<br>+COL_NETWORK = 3<br> <br> rcstring = """<br> style "toolbar-style" {<br>
@@ -159,12 +158,11 @@<br> self.startup_error = None<br> self.ignore_pause = False<br> <br>- self.stats_column = None<br>- self.stats_sparkline = None<br>-<br> self.prepare_vmlist()<br>
<br>- self.config.on_vmlist_stats_type_changed(self.stats_toggled_config)<br>+ self.config.on_vmlist_cpu_usage_visible_changed(self.toggle_cpu_usage_visible_widget)<br>+ self.config.on_vmlist_disk_io_visible_changed(self.toggle_disk_io_visible_widget)<br>
+ self.config.on_vmlist_network_traffic_visible_changed(self.toggle_network_traffic_visible_widget)<br> <br> # Register callbacks with the global stats enable/disable values<br> # that disable the associated vmlist widgets if reporting is disabled<br>
@@ -173,6 +171,11 @@<br> self.config.on_stats_enable_net_poll_changed(self.enable_polling,<br> cfg.STATS_NETWORK)<br> <br>+ self.window.get_widget("menu_view_stats_cpu").set_active(self.config.is_vmlist_cpu_usage_visible())<br>
+ self.window.get_widget("menu_view_stats_disk").set_active(self.config.is_vmlist_disk_io_visible())<br>+ self.window.get_widget("menu_view_stats_network").set_active(self.config.is_vmlist_network_traffic_visible())<br>
+<br>+<br> self.vmmenu_icons = {}<br> self.vmmenu_icons["run"] = gtk.Image()<br> self.vmmenu_icons["run"].set_from_stock(gtk.STOCK_MEDIA_PLAY,<br>@@ -325,12 +328,12 @@<br> self.connmenu.show()<br>
<br> self.window.signal_autoconnect({<br>- "on_menu_view_stats_disk_toggled" : (self.stats_toggled,<br>- cfg.STATS_DISK),<br>- "on_menu_view_stats_network_toggled" : (self.stats_toggled,<br>
- cfg.STATS_NETWORK),<br>- "on_menu_view_stats_cpu_toggled" : (self.stats_toggled,<br>- cfg.STATS_CPU),<br>
+ "on_menu_view_cpu_usage_activate": (self.toggle_stats_visible,<br>+ cfg.STATS_CPU),<br>+ "on_menu_view_disk_io_activate" : (self.toggle_stats_visible,<br>
+ cfg.STATS_DISK),<br>+ "on_menu_view_network_traffic_activate": (self.toggle_stats_visible,<br>+ cfg.STATS_NETWORK),<br>
<br> "on_vm_manager_delete_event": self.close,<br> "on_menu_file_add_connection_activate": self.new_connection,<br>@@ -845,11 +848,15 @@<br> nameCol.set_expand(True)<br>
nameCol.set_spacing(6)<br> cpuUsageCol = gtk.TreeViewColumn(_("CPU usage"))<br>- cpuUsageCol.set_min_width(150)<br>+# cpuUsageCol.set_min_width(150)<br>+ diskIOCol = gtk.TreeViewColumn(_("Disk I/O"))<br>
+ networkTrafficCol = gtk.TreeViewColumn(_("Network I/O"))<br> <br> statusCol = nameCol<br> vmlist.append_column(nameCol)<br> vmlist.append_column(cpuUsageCol)<br>+ vmlist.append_column(diskIOCol)<br>
+ vmlist.append_column(networkTrafficCol)<br> <br> # For the columns which follow, we deliberately bind columns<br> # to fields in the list store & on each update copy the info<br>@@ -868,7 +875,7 @@<br>
name_txt = gtk.CellRendererText()<br> nameCol.pack_start(name_txt, True)<br> nameCol.add_attribute(name_txt, 'markup', ROW_MARKUP)<br>- nameCol.set_sort_column_id(VMLIST_SORT_NAME)<br>
+ nameCol.set_sort_column_id(COL_NAME)<br> <br> cpuUsage_txt = gtk.CellRendererText()<br> cpuUsage_img = CellRendererSparkline()<br>@@ -879,14 +886,37 @@<br> cpuUsageCol.pack_start(cpuUsage_txt, False)<br>
cpuUsageCol.add_attribute(cpuUsage_img, 'visible', ROW_IS_VM)<br> cpuUsageCol.add_attribute(cpuUsage_txt, 'visible', ROW_IS_CONN)<br>- cpuUsageCol.set_sort_column_id(VMLIST_SORT_STATS)<br>
- self.stats_sparkline = cpuUsage_img<br>- self.stats_column = cpuUsageCol<br>- self.stats_toggled(None, self.get_stats_type())<br>+ cpuUsageCol.set_cell_data_func(cpuUsage_img, self.cpu_usage_img, None)<br>
+ cpuUsageCol.set_visible(self.config.is_vmlist_cpu_usage_visible())<br>+ cpuUsageCol.set_sort_column_id(COL_CPU)<br> <br>- model.set_sort_func(VMLIST_SORT_NAME, self.vmlist_name_sorter)<br>+ diskIO_img = CellRendererSparkline()<br>
+ diskIO_img.set_property("xpad", 6)<br>+ diskIO_img.set_property("ypad", 12)<br>+ diskIO_img.set_property("reversed", True)<br>+ diskIOCol.pack_start(diskIO_img, True)<br>
+ diskIOCol.add_attribute(diskIO_img, 'visible', ROW_IS_VM)<br>+ diskIOCol.set_cell_data_func(diskIO_img, self.disk_io_img, None)<br>+ diskIOCol.set_visible(self.config.is_vmlist_disk_io_visible())<br>
+ diskIOCol.set_sort_column_id(COL_DISK)<br> <br>- model.set_sort_column_id(VMLIST_SORT_NAME, gtk.SORT_ASCENDING)<br>+ networkTraffic_img = CellRendererSparkline()<br>+ networkTraffic_img.set_property("xpad", 6)<br>
+ networkTraffic_img.set_property("ypad", 12)<br>+ networkTraffic_img.set_property("reversed", True)<br>+ networkTrafficCol.pack_start(networkTraffic_img, True)<br>+ networkTrafficCol.add_attribute(networkTraffic_img, 'visible', ROW_IS_VM)<br>
+ networkTrafficCol.set_cell_data_func(networkTraffic_img,<br>+ self.network_traffic_img, None)<br>+ networkTrafficCol.set_visible(self.config.is_vmlist_network_traffic_visible())<br>
+ networkTrafficCol.set_sort_column_id(COL_NETWORK)<br>+<br>+ model.set_sort_func(COL_NAME, self.vmlist_name_sorter)<br>+ model.set_sort_func(COL_CPU, self.vmlist_cpu_usage_sorter)<br>+ model.set_sort_func(COL_DISK, self.vmlist_disk_io_sorter)<br>
+ model.set_sort_func(COL_NETWORK, self.vmlist_network_usage_sorter)<br>+<br>+ model.set_sort_column_id(COL_NAME, gtk.SORT_ASCENDING)<br> <br> def vmlist_name_sorter(self, model, iter1, iter2):<br> return cmp(model.get_value(iter1, ROW_NAME),<br>
@@ -918,53 +948,31 @@<br> widget.set_sensitive(False)<br> tool_text = _("Disabled in preferences dialog.")<br> <br>- if self.get_stats_type() == userdata:<br>- # Switch graphs over to guaranteed safe value<br>
- self.stats_toggled(None, cfg.STATS_CPU)<br>-<br> util.tooltip_wrapper(widget, tool_text)<br> <br>- def stats_toggled_config(self, ignore1, ignore2, conf_entry, ignore4):<br>- self.stats_toggled(None, conf_entry.get_value().get_int())<br>
+ def toggle_network_traffic_visible_widget(self, *ignore):<br>+ vmlist = self.window.get_widget("vm-list")<br>+ col = vmlist.get_column(COL_NETWORK)<br>+ col.set_visible(self.config.is_vmlist_network_traffic_visible())<br>
<br>- def get_stats_type(self):<br>- return self.config.get_vmlist_stats_type()<br>+ def toggle_disk_io_visible_widget(self, *ignore):<br>+ vmlist = self.window.get_widget("vm-list")<br>+ col = vmlist.get_column(COL_DISK)<br>
+ col.set_visible(self.config.is_vmlist_disk_io_visible())<br> <br>- def stats_toggled(self, src, stats_id):<br>- if src and not src.get_active():<br>- return<br>+ def toggle_cpu_usage_visible_widget(self, *ignore):<br>
+ vmlist = self.window.get_widget("vm-list")<br>+ col = vmlist.get_column(COL_CPU)<br>+ col.set_visible(self.config.is_vmlist_cpu_usage_visible())<br> <br>- if stats_id == cfg.STATS_NETWORK:<br>
- column_name = _("Network I/O")<br>- stats_func = self.network_traffic_img<br>- sort_func = self.vmlist_network_usage_sorter<br>- widg = "menu_view_stats_network"<br>
- elif stats_id == cfg.STATS_DISK:<br>- column_name = _("Disk I/O")<br>- stats_func = self.disk_io_img<br>- sort_func = self.vmlist_disk_io_sorter<br>- widg = "menu_view_stats_disk"<br>
- elif stats_id == cfg.STATS_CPU:<br>- column_name = _("CPU Usage")<br>- stats_func = self.cpu_usage_img<br>- sort_func = self.vmlist_cpu_usage_sorter<br>- widg = "menu_view_stats_cpu"<br>
- else:<br>- return<br>-<br>- if not src:<br>- self.window.get_widget(widg).set_active(True)<br>-<br>- if self.stats_column:<br>- vmlist = self.window.get_widget("vm-list")<br>
- model = vmlist.get_model()<br>- self.stats_column.set_title(column_name)<br>- self.stats_column.set_cell_data_func(self.stats_sparkline,<br>- stats_func, None)<br>
- model.set_sort_func(VMLIST_SORT_STATS, sort_func)<br>-<br>- if stats_id != self.get_stats_type():<br>- self.config.set_vmlist_stats_type(stats_id)<br>+ def toggle_stats_visible(self, src, stats_id):<br>
+ visible = src.get_active()<br>+ set_stats = {<br>+ cfg.STATS_CPU: self.config.set_vmlist_cpu_usage_visible,<br>+ cfg.STATS_DISK: self.config.set_vmlist_disk_io_visible,<br>+ cfg.STATS_NETWORK: self.config.set_vmlist_network_traffic_visible,<br>
+ }<br>+ set_stats[stats_id](visible)<br> <br> def cpu_usage_img(self, column, cell, model, _iter, data):<br> if model.get_value(_iter, ROW_HANDLE) is None:<br>diff -r 2907191a7a21 -r 4cc78a5138a0 src/vmm-manager.glade<br>
--- a/src/vmm-manager.glade Wed Oct 28 20:35:13 2009 -0400<br>+++ b/src/vmm-manager.glade Tue Nov 10 19:59:02 2009 +0100<br>@@ -158,33 +158,31 @@<br> <child><br> <widget class="GtkMenu" id="menu1"><br>
<property name="visible">True</property><br>- <child><br>- <widget class="GtkRadioMenuItem" id="menu_view_stats_cpu"><br>
+ <child><br>+ <widget class="GtkCheckMenuItem" id="menu_view_stats_cpu"><br> <property name="visible">True</property><br>
- <property name="label" translatable="yes">CPU</property><br>+ <property name="label" translatable="yes">CPU Usage</property><br>
<property name="use_underline">True</property><br>- <property name="draw_as_radio">True</property><br>- <signal name="toggled" handler="on_menu_view_stats_cpu_toggled"/><br>
+ <property name="active">True</property><br>+ <signal name="activate" handler="on_menu_view_cpu_usage_activate"/><br>
+ </widget><br>+ </child><br>+ <child><br>+ <widget class="GtkCheckMenuItem" id="menu_view_stats_disk"><br>
+ <property name="visible">True</property><br>+ <property name="label" translatable="yes">Disk I/O</property><br>
+ <property name="use_underline">True</property><br>+ <property name="active">True</property><br>+ <signal name="activate" handler="on_menu_view_disk_io_activate"/><br>
</widget><br> </child><br> <child><br>- <widget class="GtkRadioMenuItem" id="menu_view_stats_disk"><br>
+ <widget class="GtkCheckMenuItem" id="menu_view_stats_network"><br> <property name="visible">True</property><br>
- <property name="label" translatable="yes">Disk</property><br>+ <property name="label" translatable="yes">Network I/O</property><br>
<property name="use_underline">True</property><br>- <property name="draw_as_radio">True</property><br>- <property name="group">menu_view_stats_cpu</property><br>
- <signal name="toggled" handler="on_menu_view_stats_disk_toggled"/><br>- </widget><br>- </child><br>
- <child><br>- <widget class="GtkRadioMenuItem" id="menu_view_stats_network"><br>- <property name="visible">True</property><br>
- <property name="label" translatable="yes">Network</property><br>- <property name="use_underline">True</property><br>
- <property name="draw_as_radio">True</property><br>- <property name="group">menu_view_stats_cpu</property><br>- <signal name="toggled" handler="on_menu_view_stats_network_toggled"/><br>
+ <property name="active">True</property><br>+ <signal name="activate" handler="on_menu_view_network_traffic_activate"/><br>
</widget><br> </child><br> </widget><br><br clear="all"><br><br>-- <br>Regards Jon Nordby - <a href="http://www.jonnor.com">www.jonnor.com</a><br>