addhw: Add browsing for FS source

Use recently added directory volume handling
This commit is contained in:
Cole Robinson 2011-06-08 18:38:03 -04:00
parent e726b371f2
commit a66ceae551
2 changed files with 79 additions and 48 deletions

View File

@ -90,6 +90,7 @@ class vmmAddHardware(vmmGObjectUI):
"on_char_device_type_changed": self.change_char_device_type,
"on_fs_type_combo_changed": self.change_fs_type,
"on_fs_source_browse_clicked": self.browse_fs_source,
# Char dev info signals
"char_device_type_focus": (self.update_doc, "char_type"),
@ -807,6 +808,13 @@ class vmmAddHardware(vmmGObjectUI):
if not failure:
self.close()
def show_pair_combo(self, basename, show_combo):
combo = self.window.get_widget(basename + "-combo")
label = self.window.get_widget(basename + "-label")
combo.set_property("visible", show_combo)
label.set_property("visible", not show_combo)
# Storage listeners
def browse_storage(self, ignore1):
self._browse_file(self.window.get_widget("config-storage-entry"))
@ -938,12 +946,9 @@ class vmmAddHardware(vmmGObjectUI):
if has_mode and self.window.get_widget("char-mode").get_active() == -1:
self.window.get_widget("char-mode").set_active(0)
def show_pair_combo(self, basename, show_combo):
combo = self.window.get_widget(basename + "-combo")
label = self.window.get_widget(basename + "-label")
combo.set_property("visible", show_combo)
label.set_property("visible", not show_combo)
# FS listeners
def browse_fs_source(self, ignore1):
self._browse_file(self.window.get_widget("fs-source"), isdir=True)
def change_fs_type(self, src):
idx = src.get_active()
@ -1328,17 +1333,20 @@ class vmmAddHardware(vmmGObjectUI):
# Unsorted helpers #
####################
def _browse_file(self, textent):
def _browse_file(self, textent, isdir=False):
def set_storage_cb(src, path):
if path:
textent.set_text(path)
conn = self.conn
reason = (isdir and
self.config.CONFIG_DIR_FS or
self.config.CONFIG_DIR_IMAGE)
if self.storage_browser == None:
self.storage_browser = vmmStorageBrowser(conn)
self.storage_browser.set_finish_cb(set_storage_cb)
self.storage_browser.set_browse_reason(self.config.CONFIG_DIR_IMAGE)
self.storage_browser.set_browse_reason(reason)
self.storage_browser.show(self.topwin, conn)

View File

@ -6,7 +6,7 @@
<property name="visible">True</property>
<property name="title" translatable="yes">Add new virtual hardware</property>
<property name="type_hint">dialog</property>
<signal name="delete_event" handler="on_vmm_create_delete_event" swapped="no"/>
<signal name="delete_event" handler="on_vmm_create_delete_event"/>
<child>
<widget class="GtkVBox" id="vbox23">
<property name="visible">True</property>
@ -74,7 +74,7 @@
<property name="tab_border">0</property>
<property name="tab_hborder">0</property>
<property name="tab_vborder">0</property>
<signal name="switch_page" handler="on_create_pages_switch_page" swapped="no"/>
<signal name="switch_page" handler="on_create_pages_switch_page"/>
<child>
<widget class="GtkVBox" id="page0-box">
<property name="visible">True</property>
@ -270,7 +270,7 @@
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">config-storage-create</property>
<signal name="toggled" handler="on_config_storage_select_toggled" swapped="no"/>
<signal name="toggled" handler="on_config_storage_select_toggled"/>
<child>
<widget class="GtkLabel" id="label124">
<property name="visible">True</property>
@ -303,7 +303,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_config_storage_browse_clicked" swapped="no"/>
<signal name="clicked" handler="on_config_storage_browse_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
@ -345,7 +345,7 @@
<accessibility>
<atkproperty name="AtkObject::accessible-name" translatable="yes">Device Type Field</atkproperty>
</accessibility>
<signal name="changed" handler="on_target_device_changed" swapped="no"/>
<signal name="changed" handler="on_target_device_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -518,7 +518,7 @@
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="clicked" handler="on_mac_address_clicked" swapped="no"/>
<signal name="clicked" handler="on_mac_address_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
@ -863,7 +863,7 @@
<child>
<widget class="GtkComboBox" id="graphics-type">
<property name="visible">True</property>
<signal name="changed" handler="on_graphics_type_changed" swapped="no"/>
<signal name="changed" handler="on_graphics_type_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -1040,7 +1040,7 @@
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="relief">half</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_graphics_keymap_toggled" swapped="no"/>
<signal name="toggled" handler="on_graphics_keymap_toggled"/>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
@ -1162,7 +1162,7 @@
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_graphics_port_auto_toggled" swapped="no"/>
<signal name="toggled" handler="on_graphics_port_auto_toggled"/>
</widget>
<packing>
<property name="left_attach">3</property>
@ -1450,8 +1450,8 @@ to connect to the virtual machine.</property>
<child>
<widget class="GtkComboBox" id="char-device-type">
<property name="visible">True</property>
<signal name="changed" handler="on_char_device_type_changed" swapped="no"/>
<signal name="focus" handler="on_char_device_type_focus" swapped="no"/>
<signal name="changed" handler="on_char_device_type_changed"/>
<signal name="focus" handler="on_char_device_type_focus"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -1511,7 +1511,7 @@ to connect to the virtual machine.</property>
<widget class="GtkEntry" id="char-path">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="focus_in_event" handler="char_path_focus_in" swapped="no"/>
<signal name="focus_in_event" handler="char_path_focus_in"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -1522,7 +1522,7 @@ to connect to the virtual machine.</property>
<widget class="GtkEntry" id="char-target-name">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="focus_in_event" handler="char_name_focus_in" swapped="no"/>
<signal name="focus_in_event" handler="char_name_focus_in"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -1553,7 +1553,7 @@ to connect to the virtual machine.</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<signal name="focus_in_event" handler="char_telnet_focus_in" swapped="no"/>
<signal name="focus_in_event" handler="char_telnet_focus_in"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -1582,8 +1582,8 @@ to connect to the virtual machine.</property>
<child>
<widget class="GtkComboBox" id="char-mode">
<property name="visible">True</property>
<signal name="changed" handler="on_char_mode_changed" swapped="no"/>
<signal name="focus" handler="on_char_mode_focus" swapped="no"/>
<signal name="changed" handler="on_char_mode_changed"/>
<signal name="focus" handler="on_char_mode_focus"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -1644,7 +1644,7 @@ to connect to the virtual machine.</property>
<widget class="GtkEntry" id="char-host">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="focus_in_event" handler="char_host_focus_in" swapped="no"/>
<signal name="focus_in_event" handler="char_host_focus_in"/>
</widget>
<packing>
<property name="position">0</property>
@ -1668,7 +1668,7 @@ to connect to the virtual machine.</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 67000 1 10 0</property>
<signal name="focus_in_event" handler="char_host_focus_in" swapped="no"/>
<signal name="focus_in_event" handler="char_host_focus_in"/>
</widget>
<packing>
<property name="expand">False</property>
@ -1691,7 +1691,7 @@ to connect to the virtual machine.</property>
<widget class="GtkEntry" id="char-bind-host">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="focus_in_event" handler="char_bind_host_focus_in" swapped="no"/>
<signal name="focus_in_event" handler="char_bind_host_focus_in"/>
</widget>
<packing>
<property name="position">0</property>
@ -1715,7 +1715,7 @@ to connect to the virtual machine.</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 67000 1 10 0</property>
<signal name="focus_in_event" handler="char_bind_host_focus_in" swapped="no"/>
<signal name="focus_in_event" handler="char_bind_host_focus_in"/>
</widget>
<packing>
<property name="expand">False</property>
@ -2012,8 +2012,8 @@ and default action should be used.</property>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Please indicate what watchdog device type
and default action should be used.</property>
<property name="label" translatable="yes">Please indicate which host directory to
access in the guest.</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
</widget>
@ -2052,7 +2052,7 @@ and default action should be used.</property>
<child>
<widget class="GtkComboBox" id="fs-type-combo">
<property name="visible">True</property>
<signal name="changed" handler="on_fs_type_combo_changed" swapped="no"/>
<signal name="changed" handler="on_fs_type_combo_changed"/>
</widget>
<packing>
<property name="expand">False</property>
@ -2123,7 +2123,7 @@ and default action should be used.</property>
<widget class="GtkLabel" id="fs-source-title">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label">_Source label:</property>
<property name="label">src labelll:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">fs-source</property>
</widget>
@ -2147,19 +2147,6 @@ and default action should be used.</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="fs-source">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="fs-target">
<property name="visible">True</property>
@ -2173,6 +2160,42 @@ and default action should be used.</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox13">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<widget class="GtkEntry" id="fs-source">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="fs-source-browse">
<property name="label" translatable="yes">_Browse...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_fs_source_browse_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</widget>
</child>
</widget>
@ -2226,7 +2249,7 @@ and default action should be used.</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_create_help_clicked" swapped="no"/>
<signal name="clicked" handler="on_create_help_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
@ -2242,7 +2265,7 @@ and default action should be used.</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_create_cancel_clicked" swapped="no"/>
<signal name="clicked" handler="on_create_cancel_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
@ -2257,7 +2280,7 @@ and default action should be used.</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_create_finish_clicked" swapped="no"/>
<signal name="clicked" handler="on_create_finish_clicked"/>
</widget>
<packing>
<property name="expand">False</property>