createvol: Only show raw+qcow2 as file formats
And turn the combo into a text entry, so users can enter their own if they want. raw and qcow2 covers the vast majority of usecases
This commit is contained in:
parent
68907f1e6e
commit
f13d10590d
|
@ -48,7 +48,7 @@ class CreateVol(uiutils.UITestCase):
|
||||||
newname = "a-newvol.raw"
|
newname = "a-newvol.raw"
|
||||||
name.text = newname
|
name.text = newname
|
||||||
combo = win.find("Format:", "combo box")
|
combo = win.find("Format:", "combo box")
|
||||||
combo.click()
|
combo.click_combo_entry()
|
||||||
combo.find("raw", "menu item").click()
|
combo.find("raw", "menu item").click()
|
||||||
win.find("Allocation:", "spin button").text = "0.5"
|
win.find("Allocation:", "spin button").text = "0.5"
|
||||||
finish.click()
|
finish.click()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Generated with glade 3.20.0 -->
|
<!-- Generated with glade 3.22.1 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.14"/>
|
<requires lib="gtk+" version="3.14"/>
|
||||||
<object class="GtkAdjustment" id="adjustment1">
|
<object class="GtkAdjustment" id="adjustment1">
|
||||||
|
@ -30,6 +30,9 @@
|
||||||
<property name="resizable">False</property>
|
<property name="resizable">False</property>
|
||||||
<property name="type_hint">dialog</property>
|
<property name="type_hint">dialog</property>
|
||||||
<signal name="delete-event" handler="on_vmm_create_vol_delete_event" swapped="no"/>
|
<signal name="delete-event" handler="on_vmm_create_vol_delete_event" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box1">
|
<object class="GtkBox" id="box1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -174,18 +177,6 @@
|
||||||
<property name="top_attach">0</property>
|
<property name="top_attach">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkComboBox" id="vol-format">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="halign">start</property>
|
|
||||||
<signal name="changed" handler="on_vol_format_changed" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label4">
|
<object class="GtkLabel" id="label4">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -214,6 +205,25 @@
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBox" id="vol-format">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="has_entry">True</property>
|
||||||
|
<signal name="changed" handler="on_vol_format_changed" swapped="no"/>
|
||||||
|
<child internal-child="entry">
|
||||||
|
<object class="GtkEntry" id="vol-format-entry">
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="width_chars">10</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<property name="left_attach">0</property>
|
||||||
|
|
|
@ -116,6 +116,8 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||||
format_model = Gtk.ListStore(str, str)
|
format_model = Gtk.ListStore(str, str)
|
||||||
format_list.set_model(format_model)
|
format_list.set_model(format_model)
|
||||||
uiutil.init_combo_text_column(format_list, 1)
|
uiutil.init_combo_text_column(format_list, 1)
|
||||||
|
for fmt in ["raw", "qcow2"]:
|
||||||
|
format_model.append([fmt, fmt])
|
||||||
|
|
||||||
|
|
||||||
def _make_stub_vol(self):
|
def _make_stub_vol(self):
|
||||||
|
@ -159,17 +161,10 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||||
self.widget("vol-name").grab_focus()
|
self.widget("vol-name").grab_focus()
|
||||||
self.vol_name_changed(self.widget("vol-name"))
|
self.vol_name_changed(self.widget("vol-name"))
|
||||||
|
|
||||||
self.populate_vol_format()
|
hasformat = self.vol.supports_property("format")
|
||||||
hasformat = bool(len(self.vol.list_formats()))
|
|
||||||
uiutil.set_grid_row_visible(self.widget("vol-format"), hasformat)
|
uiutil.set_grid_row_visible(self.widget("vol-format"), hasformat)
|
||||||
if hasformat:
|
uiutil.set_list_selection(self.widget("vol-format"),
|
||||||
# Select the default storage format
|
self.conn.get_default_storage_format())
|
||||||
self.widget("vol-format").set_active(0)
|
|
||||||
default = self.conn.get_default_storage_format()
|
|
||||||
for row in self.widget("vol-format").get_model():
|
|
||||||
if row[0] == default:
|
|
||||||
self.widget("vol-format").set_active_iter(row.iter)
|
|
||||||
break
|
|
||||||
|
|
||||||
default_alloc = 0
|
default_alloc = 0
|
||||||
default_cap = 20
|
default_cap = 20
|
||||||
|
@ -193,30 +188,11 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||||
self.widget("vol-parent-space").set_text(
|
self.widget("vol-parent-space").set_text(
|
||||||
self.parent_pool.get_pretty_available())
|
self.parent_pool.get_pretty_available())
|
||||||
|
|
||||||
|
|
||||||
def get_config_format(self):
|
def get_config_format(self):
|
||||||
|
if not self.widget("vol-format").is_visible():
|
||||||
|
return None
|
||||||
return uiutil.get_list_selection(self.widget("vol-format"))
|
return uiutil.get_list_selection(self.widget("vol-format"))
|
||||||
|
|
||||||
def populate_vol_format(self):
|
|
||||||
stable_whitelist = ["raw", "qcow2", "qed"]
|
|
||||||
model = self.widget("vol-format").get_model()
|
|
||||||
model.clear()
|
|
||||||
|
|
||||||
formats = self.vol.list_formats()
|
|
||||||
if self.vol.list_create_formats() is not None:
|
|
||||||
formats = self.vol.list_create_formats()
|
|
||||||
|
|
||||||
if (self.vol.file_type == self.vol.TYPE_FILE and
|
|
||||||
self.conn.stable_defaults()):
|
|
||||||
newfmts = []
|
|
||||||
for f in stable_whitelist:
|
|
||||||
if f in formats:
|
|
||||||
newfmts.append(f)
|
|
||||||
formats = newfmts
|
|
||||||
|
|
||||||
for f in formats:
|
|
||||||
model.append([f, f])
|
|
||||||
|
|
||||||
def vol_name_changed(self, src):
|
def vol_name_changed(self, src):
|
||||||
text = src.get_text()
|
text = src.get_text()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue