mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 21:18:04 +03:00
snapshots: Add a right click menu for start/stop
This commit is contained in:
parent
111f4353a3
commit
fdb79b9832
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.16.0 on Sat Oct 5 14:43:35 2013 -->
|
||||
<!-- Generated with glade 3.16.0 on Sat Oct 5 14:56:52 2013 -->
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.6 -->
|
||||
<object class="GtkImage" id="image3">
|
||||
@ -302,6 +302,8 @@
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkWindow" id="snapshot-top-window">
|
||||
<property name="width_request">600</property>
|
||||
<property name="height_request">400</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="snapshot-top-box">
|
||||
@ -328,6 +330,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<signal name="button-press-event" handler="on_snapshot_list_button_press_event" swapped="no"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection">
|
||||
<signal name="changed" handler="on_snapshot_list_changed" swapped="no"/>
|
||||
@ -665,9 +668,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="has_tooltip">True</property>
|
||||
<property name="tooltip_markup" translatable="yes">Revert guest to selected snapshot</property>
|
||||
<property name="tooltip_text" translatable="yes">Revert guest to selected snapshot</property>
|
||||
<property name="tooltip_markup" translatable="yes">Run selected snapshot</property>
|
||||
<signal name="clicked" handler="on_snapshot_start_clicked" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkImage" id="someicon">
|
||||
|
@ -64,6 +64,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
||||
|
||||
self._initial_populate = False
|
||||
|
||||
self._snapmenu = None
|
||||
self._init_ui()
|
||||
|
||||
self._snapshot_new = self.widget("snapshot-new")
|
||||
@ -77,6 +78,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
||||
"on_snapshot_start_clicked": self._on_start_clicked,
|
||||
"on_snapshot_apply_clicked": self._on_apply_clicked,
|
||||
"on_snapshot_list_changed": self._snapshot_selected,
|
||||
"on_snapshot_list_button_press_event": self._popup_snapshot_menu,
|
||||
|
||||
# 'Create' dialog
|
||||
"on_snapshot_new_delete_event": self._snapshot_new_close,
|
||||
@ -139,6 +141,29 @@ class vmmSnapshotPage(vmmGObjectUI):
|
||||
slist.append_column(col)
|
||||
slist.set_row_separator_func(_sep_cb, None)
|
||||
|
||||
# Snapshot popup menu
|
||||
menu = Gtk.Menu()
|
||||
|
||||
item = Gtk.ImageMenuItem(_("_Start snapshot"))
|
||||
item.set_use_underline(True)
|
||||
img = Gtk.Image()
|
||||
img.set_from_stock(Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.MENU)
|
||||
item.set_image(img)
|
||||
item.show()
|
||||
item.connect("activate", self._on_start_clicked)
|
||||
menu.add(item)
|
||||
|
||||
item = Gtk.ImageMenuItem(_("_Delete snapshot"))
|
||||
item.set_use_underline(True)
|
||||
img = Gtk.Image()
|
||||
img.set_from_stock(Gtk.STOCK_DELETE, Gtk.IconSize.MENU)
|
||||
item.set_image(img)
|
||||
item.show()
|
||||
item.connect("activate", self._on_delete_clicked)
|
||||
menu.add(item)
|
||||
|
||||
self._snapmenu = menu
|
||||
|
||||
|
||||
###################
|
||||
# Functional bits #
|
||||
@ -470,6 +495,12 @@ class vmmSnapshotPage(vmmGObjectUI):
|
||||
# Listeners #
|
||||
#############
|
||||
|
||||
def _popup_snapshot_menu(self, src, event):
|
||||
ignore = src
|
||||
if event.button != 3:
|
||||
return
|
||||
self._snapmenu.popup(None, None, None, None, 0, event.time)
|
||||
|
||||
def _snapshot_new_close(self, *args, **kwargs):
|
||||
ignore = args
|
||||
ignore = kwargs
|
||||
@ -511,19 +542,19 @@ class vmmSnapshotPage(vmmGObjectUI):
|
||||
|
||||
def _on_start_clicked(self, ignore):
|
||||
snap = self._get_selected_snapshot()
|
||||
result = self.err.yes_no(_("Are you sure you want to revert to "
|
||||
result = self.err.yes_no(_("Are you sure you want to run "
|
||||
"snapshot '%s'? All disk changes since "
|
||||
"the last snapshot was created will be "
|
||||
"discarded.") % snap.get_name())
|
||||
if not result:
|
||||
return
|
||||
|
||||
logging.debug("Reverting to snapshot '%s'", snap.get_name())
|
||||
logging.debug("Running snapshot '%s'", snap.get_name())
|
||||
vmmAsyncJob.simple_async(self.vm.revert_to_snapshot,
|
||||
[snap], self,
|
||||
_("Restoring snapshot"),
|
||||
_("Restoring snapshot '%s'") % snap.get_name(),
|
||||
_("Error restoring snapshot '%s'") %
|
||||
_("Running snapshot"),
|
||||
_("Running snapshot '%s'") % snap.get_name(),
|
||||
_("Error running snapshot '%s'") %
|
||||
snap.get_name(),
|
||||
finish_cb=self._refresh_snapshots)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user