snapshots: Show indication of the 'current' snapshot (bz 1017385)

This commit is contained in:
Cole Robinson 2014-02-01 11:25:35 -05:00
parent fa6fedd959
commit 09390b8151
3 changed files with 71 additions and 18 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.0 on Sat Nov 9 17:57:11 2013 -->
<!-- Generated with glade 3.16.1 -->
<interface>
<!-- interface-requires gtk+ 3.6 -->
<requires lib="gtk+" version="3.6"/>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -376,7 +376,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -397,7 +397,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -411,7 +411,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -449,7 +449,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -463,7 +463,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -477,7 +477,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -506,7 +506,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -520,7 +520,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -535,7 +535,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -571,11 +571,51 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
<property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="snapshot-is-current">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-info</property>
<property name="icon_size">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label652">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;small&gt;&lt;i&gt;This was the most recently applied snapshot.&lt;/i&gt;&lt;/small&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
</child>
</object>
</child>
</object>

View File

@ -186,6 +186,8 @@ class vmmDomainSnapshot(vmmLibvirtObject):
status = libvirt.VIR_DOMAIN_NOSTATE
return vm_status_icons[status]
def is_current(self):
return self._backend.isCurrent()
def is_external(self):
if self.get_xmlobj().memory_type == "external":
return True

View File

@ -116,21 +116,29 @@ class vmmSnapshotPage(vmmGObjectUI):
buf = Gtk.TextBuffer()
self.widget("snapshot-new-description").set_buffer(buf)
# [name, row label, tooltip, icon name, sortname]
model = Gtk.ListStore(str, str, str, str, str)
# [name, row label, tooltip, icon name, sortname, current]
model = Gtk.ListStore(str, str, str, str, str, bool)
model.set_sort_column_id(4, Gtk.SortType.ASCENDING)
col = Gtk.TreeViewColumn("")
col.set_min_width(150)
col.set_expand(True)
col.set_spacing(6)
img = Gtk.CellRendererPixbuf()
img.set_property("stock-size", Gtk.IconSize.LARGE_TOOLBAR)
txt = Gtk.CellRendererText()
col.pack_start(img, False)
col.add_attribute(img, 'icon-name', 3)
txt = Gtk.CellRendererText()
col.pack_start(txt, False)
col.add_attribute(txt, 'markup', 1)
col.add_attribute(img, 'icon-name', 3)
img = Gtk.CellRendererPixbuf()
img.set_property("stock-size", Gtk.IconSize.MENU)
img.set_property("icon-name", Gtk.STOCK_APPLY)
col.pack_start(img, True)
col.add_attribute(img, "visible", 5)
def _sep_cb(_model, _iter, ignore):
return not bool(_model[_iter][0])
@ -229,10 +237,10 @@ class vmmSnapshotPage(vmmGObjectUI):
label = "%s\n<span size='small'>%s: %s%s</span>" % (
(name, _("VM State"), state, external))
model.append([name, label, desc, snap.run_status_icon_name(),
sortname])
sortname, snap.is_current()])
if has_internal and has_external:
model.append([None, None, None, None, "2"])
model.append([None, None, None, None, "2", False])
select_name = select_name or (cursnap and cursnap.get_name() or None)
uiutil.set_row_selection(self.widget("snapshot-list"), select_name)
@ -286,6 +294,7 @@ class vmmSnapshotPage(vmmGObjectUI):
state = snap and snap.run_status() or ""
icon = snap and snap.run_status_icon_name() or None
is_external = snap and snap.is_external() or False
is_current = snap and snap.is_current() or False
timestamp = ""
if snap:
@ -296,6 +305,8 @@ class vmmSnapshotPage(vmmGObjectUI):
if name:
title = "<b>Snapshot '%s':</b>" % util.xml_escape(name)
uiutil.set_grid_row_visible(
self.widget("snapshot-is-current"), is_current)
self.widget("snapshot-title").set_markup(title)
self.widget("snapshot-timestamp").set_text(timestamp)
self.widget("snapshot-description").get_buffer().set_text(desc)