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"
|
||||
name.text = newname
|
||||
combo = win.find("Format:", "combo box")
|
||||
combo.click()
|
||||
combo.click_combo_entry()
|
||||
combo.find("raw", "menu item").click()
|
||||
win.find("Allocation:", "spin button").text = "0.5"
|
||||
finish.click()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.14"/>
|
||||
<object class="GtkAdjustment" id="adjustment1">
|
||||
|
@ -30,6 +30,9 @@
|
|||
<property name="resizable">False</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<signal name="delete-event" handler="on_vmm_create_vol_delete_event" swapped="no"/>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
|
@ -174,18 +177,6 @@
|
|||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</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>
|
||||
<object class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
|
@ -214,6 +205,25 @@
|
|||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</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>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
|
|
|
@ -116,6 +116,8 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
format_model = Gtk.ListStore(str, str)
|
||||
format_list.set_model(format_model)
|
||||
uiutil.init_combo_text_column(format_list, 1)
|
||||
for fmt in ["raw", "qcow2"]:
|
||||
format_model.append([fmt, fmt])
|
||||
|
||||
|
||||
def _make_stub_vol(self):
|
||||
|
@ -159,17 +161,10 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
self.widget("vol-name").grab_focus()
|
||||
self.vol_name_changed(self.widget("vol-name"))
|
||||
|
||||
self.populate_vol_format()
|
||||
hasformat = bool(len(self.vol.list_formats()))
|
||||
hasformat = self.vol.supports_property("format")
|
||||
uiutil.set_grid_row_visible(self.widget("vol-format"), hasformat)
|
||||
if hasformat:
|
||||
# Select the 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
|
||||
uiutil.set_list_selection(self.widget("vol-format"),
|
||||
self.conn.get_default_storage_format())
|
||||
|
||||
default_alloc = 0
|
||||
default_cap = 20
|
||||
|
@ -193,30 +188,11 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
self.widget("vol-parent-space").set_text(
|
||||
self.parent_pool.get_pretty_available())
|
||||
|
||||
|
||||
def get_config_format(self):
|
||||
if not self.widget("vol-format").is_visible():
|
||||
return None
|
||||
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):
|
||||
text = src.get_text()
|
||||
|
||||
|
|
Loading…
Reference in New Issue