virt-manager
changeset 1602:78c31a870744
details: Show disk size if available
| author | Cole Robinson <crobinso@redhat.com> |
|---|---|
| date | Wed Mar 03 18:43:48 2010 -0500 (2010-03-03) |
| parents | a42fc22785af |
| children | 0ff0cd98827c |
| files | src/virtManager/details.py src/vmm-details.glade |
line diff
1.1 --- a/src/virtManager/details.py Wed Mar 03 18:16:08 2010 -0500 1.2 +++ b/src/virtManager/details.py Wed Mar 03 18:43:48 2010 -0500 1.3 @@ -105,6 +105,12 @@ 1.4 1.5 return "%s %s" % (ret, idx) 1.6 1.7 +def prettyify_bytes(bytes): 1.8 + if bytes > (1024*1024*1024): 1.9 + return "%2.2f GB" % (bytes/(1024.0*1024.0*1024.0)) 1.10 + else: 1.11 + return "%2.2f MB" % (bytes/(1024.0*1024.0)) 1.12 + 1.13 class vmmDetails(gobject.GObject): 1.14 __gsignals__ = { 1.15 "action-show-console": (gobject.SIGNAL_RUN_FIRST, 1.16 @@ -1643,6 +1649,18 @@ 1.17 bus = diskinfo[8] 1.18 idx = diskinfo[9] 1.19 1.20 + size = _("Unknown") 1.21 + if not path: 1.22 + size = "-" 1.23 + else: 1.24 + vol = self.conn.get_vol_by_path(path) 1.25 + if vol: 1.26 + size = vol.get_pretty_capacity() 1.27 + elif not self.conn.is_remote(): 1.28 + ignore, bytes = virtinst.VirtualDisk.stat_local_path(path) 1.29 + if bytes != 0: 1.30 + size = prettyify_bytes(bytes) 1.31 + 1.32 is_cdrom = (devtype == virtinst.VirtualDisk.DEVICE_CDROM) 1.33 is_floppy = (devtype == virtinst.VirtualDisk.DEVICE_FLOPPY) 1.34 1.35 @@ -1654,6 +1672,7 @@ 1.36 self.window.get_widget("disk-readonly").set_active(ro) 1.37 self.window.get_widget("disk-readonly").set_sensitive(not is_cdrom) 1.38 self.window.get_widget("disk-shareable").set_active(share) 1.39 + self.window.get_widget("disk-size").set_text(size) 1.40 1.41 button = self.window.get_widget("config-cdrom-connect") 1.42 if is_cdrom or is_floppy:
2.1 --- a/src/vmm-details.glade Wed Mar 03 18:16:08 2010 -0500 2.2 +++ b/src/vmm-details.glade Wed Mar 03 18:43:48 2010 -0500 2.3 @@ -2558,7 +2558,7 @@ 2.4 <widget class="GtkTable" id="table32"> 2.5 <property name="visible">True</property> 2.6 <property name="border_width">3</property> 2.7 - <property name="n_rows">4</property> 2.8 + <property name="n_rows">5</property> 2.9 <property name="n_columns">3</property> 2.10 <property name="column_spacing">8</property> 2.11 <property name="row_spacing">4</property> 2.12 @@ -2707,6 +2707,34 @@ 2.13 <child> 2.14 <placeholder/> 2.15 </child> 2.16 + <child> 2.17 + <placeholder/> 2.18 + </child> 2.19 + <child> 2.20 + <widget class="GtkLabel" id="label4"> 2.21 + <property name="visible">True</property> 2.22 + <property name="xalign">1</property> 2.23 + <property name="label" translatable="yes">Storage size:</property> 2.24 + </widget> 2.25 + <packing> 2.26 + <property name="top_attach">4</property> 2.27 + <property name="bottom_attach">5</property> 2.28 + <property name="x_options">GTK_FILL</property> 2.29 + </packing> 2.30 + </child> 2.31 + <child> 2.32 + <widget class="GtkLabel" id="disk-size"> 2.33 + <property name="visible">True</property> 2.34 + <property name="xalign">0</property> 2.35 + <property name="label">size</property> 2.36 + </widget> 2.37 + <packing> 2.38 + <property name="left_attach">1</property> 2.39 + <property name="right_attach">2</property> 2.40 + <property name="top_attach">4</property> 2.41 + <property name="bottom_attach">5</property> 2.42 + </packing> 2.43 + </child> 2.44 </widget> 2.45 </child> 2.46 </widget>
