createvol: Use blue header like other wizards

This commit is contained in:
Cole Robinson 2013-09-27 13:05:52 -04:00
parent 33f15f58f0
commit 2da4ed7cf1
2 changed files with 200 additions and 229 deletions

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.15.4 on Fri Sep 27 13:04:46 2013 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAdjustment" id="adjustment1">
@ -20,82 +21,32 @@
</object>
<object class="GtkWindow" id="vmm-create-vol">
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="title" translatable="yes">Add a Storage Volume</property>
<property name="default_width">500</property>
<property name="default_height">320</property>
<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>
<object class="GtkVBox" id="vbox1">
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">15</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkAlignment" id="alignment2">
<object class="GtkViewport" id="header">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">1</property>
<property name="resize_mode">queue</property>
<child>
<object class="GtkVBox" id="vbox2">
<object class="GtkHBox" id="hbox77">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<property name="border_width">6</property>
<property name="spacing">10</property>
<child>
<object class="GtkVBox" id="vbox3">
<object class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkHBox" id="hbox4">
<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-new</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;span size='x-large'&gt;New Storage Volume&lt;/span&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Create a storage unit that can be used directly by a virtual machine.</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<property name="stock">gtk-new</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="expand">False</property>
@ -104,23 +55,80 @@
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox5">
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">20</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;span size='large' color='white'&gt;Create storage volume&lt;/span&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</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="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="spacing">15</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">1</property>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Create a storage unit to be used directly by a virtual machine.</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">24</property>
<child>
<object class="GtkTable" id="table1">
<object class="GtkGrid" id="table1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">3</property>
<property name="row_spacing">5</property>
<property name="hexpand">True</property>
<property name="row_spacing">4</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkHBox" id="hbox10">
<property name="visible">True</property>
@ -131,6 +139,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<property name="width_chars">30</property>
<signal name="changed" handler="on_vol_name_changed" swapped="no"/>
</object>
<packing>
@ -154,22 +163,38 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options">GTK_FILL</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">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>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">vol-name</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -182,24 +207,10 @@
<property name="mnemonic_widget">vol-format</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">vol-name</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
@ -223,7 +234,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;span size='large'&gt;Storage Volume Quota&lt;/span&gt;</property>
<property name="label" translatable="yes">&lt;b&gt;Storage Volume Quota&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
@ -289,14 +300,12 @@
</packing>
</child>
<child>
<object class="GtkTable" id="table2">
<object class="GtkGrid" id="table2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">8</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="column_spacing">3</property>
<property name="row_spacing">5</property>
<property name="row_spacing">4</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkSpinButton" id="vol-capacity">
<property name="visible">True</property>
@ -304,13 +313,14 @@
<property name="invisible_char">●</property>
<property name="adjustment">adjustment2</property>
<property name="climb_rate">10</property>
<property name="digits">1</property>
<signal name="value-changed" handler="on_vol_capacity_value_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -320,15 +330,14 @@
<property name="invisible_char">●</property>
<property name="adjustment">adjustment1</property>
<property name="climb_rate">10</property>
<property name="digits">1</property>
<signal name="value-changed" handler="on_vol_allocation_value_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -336,14 +345,13 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">MB</property>
<property name="label" translatable="yes">GB</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"/>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -351,28 +359,13 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">MB</property>
<property name="label" translatable="yes">GB</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Allocation:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">vol-allocation</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -385,8 +378,26 @@
<property name="mnemonic_widget">vol-capacity</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Allocation:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">vol-allocation</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
@ -407,106 +418,60 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">never</property>
<child>
<object class="GtkViewport" id="vol-info-view">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="resize_mode">queue</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkLabel" id="vol-info">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xpad">2</property>
<property name="ypad">2</property>
<property name="label" translatable="yes">&lt;span size='small'&gt;&lt;i&gt;&lt;u&gt;Name&lt;/u&gt;: Name of the
volume to create. File
extension may be
appended
&lt;u&gt;Format&lt;/u&gt;: File/Partition
format of the volume
&lt;u&gt;Capacity&lt;/u&gt;: Maximum
size of the volume.
&lt;u&gt;Allocation&lt;/u&gt;: Actual size
allocated to volume
at this time.&lt;/i&gt;&lt;/span&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</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>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="vol-cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_vol_cancel_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="vol-create">
<property name="label" translatable="yes">_Finish</property>
<object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image1</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_vol_create_clicked" swapped="no"/>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="vol-cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_vol_cancel_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="vol-create">
<property name="label" translatable="yes">_Finish</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image1</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_vol_create_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>

View File

@ -26,14 +26,12 @@ from gi.repository import Gtk
from gi.repository import Gdk
# pylint: enable=E0611
from virtManager import uihelpers
from virtManager.baseclass import vmmGObjectUI
from virtManager.asyncjob import vmmAsyncJob
from virtinst import StorageVolume
DEFAULT_ALLOC = 0
DEFAULT_CAP = 8192
class vmmCreateVolume(vmmGObjectUI):
__gsignals__ = {
@ -112,6 +110,9 @@ class vmmCreateVolume(vmmGObjectUI):
return suffix
def _init_state(self):
blue = Gdk.color_parse("#0072A8")
self.widget("header").modify_bg(Gtk.StateType.NORMAL, blue)
format_list = self.widget("vol-format")
format_model = Gtk.ListStore(str, str)
format_list.set_model(format_model)
@ -119,9 +120,6 @@ class vmmCreateVolume(vmmGObjectUI):
format_list.pack_start(text2, False)
format_list.add_attribute(text2, 'text', 1)
self.widget("vol-info-view").modify_bg(Gtk.StateType.NORMAL,
Gdk.Color.parse("grey")[1])
def _make_stub_vol(self):
self.vol = StorageVolume(self.conn.get_backend())
@ -146,17 +144,23 @@ class vmmCreateVolume(vmmGObjectUI):
else:
self.widget("vol-format").set_sensitive(False)
alloc = DEFAULT_ALLOC
if self.parent_pool.get_type() == "logical":
default_alloc = 0
default_cap = 8
islogical = (self.parent_pool.get_type() == "logical")
alloc = default_alloc
if islogical:
# Sparse LVM volumes don't auto grow, so alloc=0 is useless
alloc = DEFAULT_CAP
alloc = default_alloc
uihelpers.set_grid_row_visible(self.widget("vol-allocation"),
not islogical)
self.widget("vol-allocation").set_range(0,
int(self.parent_pool.get_available() / 1024 / 1024))
int(self.parent_pool.get_available() / 1024 / 1024 / 1024))
self.widget("vol-allocation").set_value(alloc)
self.widget("vol-capacity").set_range(1,
int(self.parent_pool.get_available() / 1024 / 1024))
self.widget("vol-capacity").set_value(DEFAULT_CAP)
int(self.parent_pool.get_available() / 1024 / 1024 / 1024))
self.widget("vol-capacity").set_value(default_cap)
self.widget("vol-parent-name").set_markup(
"<b>" + self.parent_pool.get_name() + "'s</b>")
@ -273,13 +277,15 @@ class vmmCreateVolume(vmmGObjectUI):
fmt = self.get_config_format()
alloc = self.widget("vol-allocation").get_value()
cap = self.widget("vol-capacity").get_value()
if not self.widget("vol-allocation").get_visible():
alloc = cap
try:
self._make_stub_vol()
self.vol.capacity = cap
self.vol.name = volname
self.vol.allocation = (alloc * 1024 * 1024)
self.vol.capacity = (cap * 1024 * 1024)
self.vol.allocation = (alloc * 1024 * 1024 * 1024)
self.vol.capacity = (cap * 1024 * 1024 * 1024)
if fmt:
self.vol.format = fmt
self.vol.validate()