Show pool-specific explanations for the different parameters in the Create Pool wizard.

We pull the doc from virtinst's storage API.
This commit is contained in:
Cole Robinson 2009-01-25 15:41:44 -05:00
parent 524c73325c
commit 9be6f6ef67
2 changed files with 116 additions and 52 deletions

View File

@ -55,6 +55,7 @@ class vmmCreatePool(gobject.GObject):
self.topwin.hide()
self._pool = None
self._pool_class = Storage.StoragePool
self.error_msg = None
self.error_details = None
@ -67,10 +68,34 @@ class vmmCreatePool(gobject.GObject):
"on_pool_pages_change_page" : self.page_changed,
"on_pool_source_button_clicked" : self.browse_source_path,
"on_pool_target_button_clicked" : self.browse_target_path,
"on_pool_name_focus_in_event": (self.update_doc, "name",
"pool-info1"),
# I cannot for the life of me get a combobox to abide
# focus-in, button-pressed, motion-over, etc.
"on_pool_type_focus": (self.update_doc, "type", "pool-info1"),
"on_pool_type_changed": (self.update_doc_changed, "type",
"pool-info1"),
"on_pool_format_focus": (self.update_doc, "format", "pool-info2"),
"on_pool_format_changed": (self.update_doc_changed, "format",
"pool-info2"),
"on_pool_target_path_focus_in_event": (self.update_doc,
"target_path",
"pool-info2"),
"on_pool_source_path_focus_in_event": (self.update_doc,
"source_path",
"pool-info2"),
"on_pool_hostname_focus_in_event": (self.update_doc, "host",
"pool-info2"),
"on_pool_build_focus_in_event": (self.update_build_doc)
})
self.set_initial_state()
def test(self, ignore1, ignore2=None):
print "test"
def show(self):
self.topwin.show()
self.reset_state()
@ -99,8 +124,8 @@ class vmmCreatePool(gobject.GObject):
self.populate_pool_type()
self.window.get_widget("pool-info1").modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("grey"))
self.window.get_widget("pool-info2").modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("grey"))
self.window.get_widget("pool-info-box1").modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("grey"))
self.window.get_widget("pool-info-box2").modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("grey"))
def reset_state(self):
self.window.get_widget("pool-pages").set_current_page(0)
@ -317,8 +342,8 @@ class vmmCreatePool(gobject.GObject):
conn = self.conn.vmm
try:
pool_class = Storage.StoragePool.get_pool_class(typ)
self._pool = pool_class(name=name, conn=conn)
self._pool_class = Storage.StoragePool.get_pool_class(typ)
self._pool = self._pool_class(name=name, conn=conn)
except ValueError, e:
return self.err.val_err(_("Pool Parameter Error"), str(e))
@ -349,6 +374,34 @@ class vmmCreatePool(gobject.GObject):
"sure you want to 'build' this pool?"))
return True
def update_doc(self, ignore1, ignore2, param, infobox):
doc = self._build_doc_str(param)
self.window.get_widget(infobox).set_markup(doc)
def update_build_doc(self, ignore1, ignore2):
doc = ""
if self._pool.type == Storage.StoragePool.TYPE_DISK:
docstr = _("Format the source device.")
doc = self._build_doc_str("build", docstr)
self.window.get_widget("pool-info2").set_markup(doc)
def update_doc_changed(self, ignore1, param, infobox):
# Wrapper for update_doc and 'changed' signal
self.update_doc(None, None, param, infobox)
def _build_doc_str(self, param, docstr=None):
doc = ""
doctmpl = "<i><u>%s</u>: %s</i>"
prettyname = param.replace("_", " ").capitalize()
if docstr:
doc = doctmpl % (prettyname, docstr)
elif hasattr(self._pool_class, param):
doc = doctmpl % (prettyname,
getattr(self._pool_class, param).__doc__)
return doc
def _browse_file(self, dialog_name, startfolder=None, foldermode=False):
mode = gtk.FILE_CHOOSER_ACTION_OPEN

View File

@ -98,7 +98,7 @@
<child>
<widget class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<property name="spacing">20</property>
<property name="spacing">12</property>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
@ -106,19 +106,6 @@
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">5</property>
<child>
<widget class="GtkComboBox" id="pool-type">
<property name="visible">True</property>
</widget>
<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>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
@ -147,6 +134,7 @@
<widget class="GtkEntry" id="pool-name">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="focus_in_event" handler="on_pool_name_focus_in_event"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -154,27 +142,43 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="pool-type">
<property name="visible">True</property>
<signal name="button_press_event" handler="on_pool_type_button_press_event"/>
<signal name="changed" handler="on_pool_type_changed"/>
<signal name="motion_notify_event" handler="on_pool_type_motion_notify_event"/>
<signal name="focus_in_event" handler="on_pool_type_focus_in_event"/>
<signal name="focus" handler="on_pool_type_focus"/>
</widget>
<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="y_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<widget class="GtkEventBox" id="pool-info-box1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_NEVER</property>
<child>
<widget class="GtkTextView" id="pool-info1">
<widget class="GtkLabel" id="pool-info1">
<property name="width_request">150</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="text" translatable="yes">
</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xpad">3</property>
<property name="ypad">6</property>
<property name="label" translatable="yes">label</property>
<property name="wrap">True</property>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@ -277,7 +281,7 @@
<child>
<widget class="GtkHBox" id="hbox12">
<property name="visible">True</property>
<property name="spacing">20</property>
<property name="spacing">12</property>
<child>
<widget class="GtkTable" id="table2">
<property name="visible">True</property>
@ -285,6 +289,23 @@
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">4</property>
<child>
<widget class="GtkComboBox" id="pool-format">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_BUTTON_PRESS_MASK | GDK_STRUCTURE_MASK</property>
<signal name="changed" handler="on_pool_format_changed"/>
<signal name="focus" handler="on_pool_format_focus"/>
</widget>
<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>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="pool-build">
<property name="visible">True</property>
@ -292,6 +313,7 @@
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="focus_in_event" handler="on_pool_build_focus_in_event"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -322,6 +344,7 @@
<widget class="GtkEntry" id="pool-source-path">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="focus_in_event" handler="on_pool_source_path_focus_in_event"/>
</widget>
</child>
<child>
@ -356,6 +379,7 @@
<widget class="GtkEntry" id="pool-target-path">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="focus_in_event" handler="on_pool_target_path_focus_in_event"/>
</widget>
</child>
<child>
@ -405,19 +429,6 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="pool-format">
<property name="visible">True</property>
</widget>
<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>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
@ -435,6 +446,7 @@
<widget class="GtkEntry" id="pool-hostname">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="focus_in_event" handler="on_pool_hostname_focus_in_event"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -460,24 +472,23 @@
</widget>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<widget class="GtkEventBox" id="pool-info-box2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_NEVER</property>
<child>
<widget class="GtkTextView" id="pool-info2">
<widget class="GtkLabel" id="pool-info2">
<property name="width_request">150</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="text" translatable="yes">
</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xpad">3</property>
<property name="ypad">6</property>
<property name="label" translatable="yes">label</property>
<property name="wrap">True</property>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>