storagebrowse: Add pool refresh and vol delete options (bz 841715)

This commit is contained in:
Cole Robinson 2014-02-01 13:31:29 -05:00
parent 09390b8151
commit ba0c84ec76
2 changed files with 185 additions and 80 deletions

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<requires lib="gtk+" version="3.0"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -21,17 +22,19 @@
<property name="type_hint">dialog</property>
<signal name="delete-event" handler="on_vmm_storage_browse_delete_event" swapped="no"/>
<child>
<object class="GtkHBox" id="hbox2">
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">10</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkVBox" id="vbox3">
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">10</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="width_request">150</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
@ -41,22 +44,137 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
<object class="GtkTreeSelection" id="treeview-selection"/>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox3">
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Volumes&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="pool-refresh">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_pool_refresh_clicked" swapped="no"/>
<child>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-refresh</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="vol-delete">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_vol_delete_clicked" swapped="no"/>
<child>
<object class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-delete</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="vol-list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="row-activated" handler="on_vol_list_row_activated" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1">
<signal name="changed" handler="on_vol_list_changed" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkButtonBox" id="buttonbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">start</property>
<child>
<object class="GtkButton" id="browse-local">
<property name="visible">True</property>
@ -87,56 +205,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">10</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="vol-list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="row-activated" handler="on_vol_list_row_activated" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2">
<signal name="changed" handler="on_vol_list_changed" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
@ -145,10 +213,11 @@
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox4">
<object class="GtkButtonBox" id="buttonbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="layout_style">start</property>
<child>
<object class="GtkButton" id="new-volume">
<property name="label" translatable="yes">_New Volume</property>
@ -163,20 +232,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="non_homogeneous">True</property>
</packing>
</child>
<child>
@ -191,7 +247,8 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">1</property>
<property name="non_homogeneous">True</property>
</packing>
</child>
<child>
@ -207,7 +264,8 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">2</property>
<property name="non_homogeneous">True</property>
</packing>
</child>
</object>
@ -219,8 +277,8 @@
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>

View File

@ -26,6 +26,7 @@ from gi.repository import Gtk
# pylint: enable=E0611
from virtManager import host
from virtManager.asyncjob import vmmAsyncJob
from virtManager.createvol import vmmCreateVolume
from virtManager.baseclass import vmmGObjectUI
from virtManager import uiutil
@ -57,6 +58,7 @@ class vmmStorageBrowser(vmmGObjectUI):
self.local_args = {}
self.stable_defaults = False
self._in_refresh = False
self.builder.connect_signals({
"on_vmm_storage_browse_delete_event" : self.close,
@ -64,6 +66,8 @@ class vmmStorageBrowser(vmmGObjectUI):
"on_browse_local_clicked" : self.browse_local,
"on_new_volume_clicked" : self.new_volume,
"on_choose_volume_clicked" : self.finish,
"on_pool_refresh_clicked": self.pool_refresh,
"on_vol_delete_clicked": self.delete_vol,
"on_vol_list_row_activated" : self.finish,
"on_vol_list_changed": self.vol_selected,
})
@ -251,9 +255,50 @@ class vmmStorageBrowser(vmmGObjectUI):
pool_list = self.widget("pool-list")
host.populate_storage_pools(pool_list, self.conn, self.current_pool())
def delete_vol(self, src_ignore):
vol = self.current_vol()
if vol is None:
return
result = self.err.yes_no(_("Are you sure you want to permanently "
"delete the volume %s?") % vol.get_name())
if not result:
return
def cb():
vol.delete()
def idlecb():
self.refresh_current_pool()
self.populate_storage_volumes()
self.idle_add(idlecb)
logging.debug("Deleting volume '%s'", vol.get_name())
vmmAsyncJob.simple_async_noshow(cb, [], self,
_("Error refreshing volume '%s'") % vol.get_name())
def pool_refresh(self, src_ignore):
if self._in_refresh:
logging.debug("Already refreshing the pool, skipping")
return
pool = self.current_pool()
if pool is None:
return
self._in_refresh = True
def cb():
try:
pool.refresh()
self.idle_add(self.refresh_current_pool)
finally:
self._in_refresh = False
logging.debug("Refresh pool '%s'", pool.get_name())
vmmAsyncJob.simple_async_noshow(cb, [], self,
_("Error refreshing pool '%s'") % pool.get_name())
# Listeners
def pool_selected(self, src_ignore=None):
pool = self.current_pool()
@ -271,21 +316,23 @@ class vmmStorageBrowser(vmmGObjectUI):
vol = self.current_vol_row()
canchoose = bool(vol and vol[5])
self.widget("choose-volume").set_sensitive(canchoose)
self.widget("vol-delete").set_sensitive(canchoose)
def refresh_current_pool(self, createvol):
def refresh_current_pool(self, createvol=None):
cp = self.current_pool()
if cp is None:
return
cp.refresh()
self.refresh_storage_pool(None, cp.get_uuid())
name = createvol and createvol.vol.name or None
vol_list = self.widget("vol-list")
def select_volume(model, path, it, volume_name):
if model.get(it, 0)[0] == volume_name:
uiutil.set_list_selection(vol_list, path)
vol_list.get_model().foreach(select_volume, createvol.vol.name)
vol_list.get_model().foreach(select_volume, name)
def new_volume(self, src_ignore):
pool = self.current_pool()