addhw: List known channel names in a comboboxentry

This commit is contained in:
Cole Robinson 2013-10-05 13:27:11 -04:00
parent 24137cdfe9
commit 9d21d2bb02
3 changed files with 83 additions and 46 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.0 on Sat Oct 5 11:25:05 2013 -->
<!-- Generated with glade 3.16.0 on Sat Oct 5 13:26:39 2013 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAdjustment" id="adjustment1">
@ -1416,7 +1416,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1430,36 +1430,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="char-target-name-label">
<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">char-target-name</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="char-target-name">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1475,7 +1446,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -1488,7 +1459,43 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="char-target-name-label">
<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>
</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>
<object class="GtkComboBox" id="char-target-name">
<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_char_target_name_changed" swapped="no"/>
<child internal-child="entry">
<object class="GtkEntry" id="combobox-entry">
<property name="can_focus">True</property>
<property name="width_chars">20</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>

View File

@ -85,6 +85,7 @@ class vmmAddHardware(vmmGObjectUI):
"on_graphics_use_password": self.change_password_chk,
"on_char_device_type_changed": self.change_char_device_type,
"on_char_target_name_changed": self.change_char_target_name,
"on_tpm_device_type_changed": self.change_tpm_device_type,
@ -263,6 +264,20 @@ class vmmAddHardware(vmmGObjectUI):
else:
model.append([None, "default"])
# Char target name
lst = self.widget("char-target-name")
model = Gtk.ListStore(str)
lst.set_model(model)
uihelpers.set_combo_text_column(lst, 0)
for n in VirtualChannelDevice.CHANNEL_NAMES:
model.append([n])
# Char device type
lst = self.widget("char-device-type")
model = Gtk.ListStore(str, str)
lst.set_model(model)
uihelpers.set_combo_text_column(lst, 1)
# Watchdog widgets
combo = self.widget("watchdog-model")
uihelpers.build_watchdogmodel_combo(self.vm, combo)
@ -448,13 +463,13 @@ class vmmAddHardware(vmmGObjectUI):
# Char parameters
self.widget("char-device-type").set_active(0)
self.widget("char-target-type").set_active(0)
self.widget("char-target-name").set_active(0)
self.widget("char-path").set_text("")
self.widget("char-host").set_text("127.0.0.1")
self.widget("char-port").set_value(4555)
self.widget("char-bind-host").set_text("127.0.0.1")
self.widget("char-bind-port").set_value(4556)
self.widget("char-use-telnet").set_active(False)
self.widget("char-target-name").set_text("com.redhat.spice.0")
# FS params
self.widget("fs-type-combo").set_active(0)
@ -916,16 +931,11 @@ class vmmAddHardware(vmmGObjectUI):
# Char device type
char_devtype = self.widget("char-device-type")
char_devtype_model = char_devtype.get_model()
char_devtype_model.clear()
char_class = self.get_char_type()
# Type name, desc
char_devtype_model = Gtk.ListStore(str, str)
char_devtype.clear()
char_devtype.set_model(char_devtype_model)
text = Gtk.CellRendererText()
char_devtype.pack_start(text, True)
char_devtype.add_attribute(text, 'text', 1)
for t in char_class.TYPES:
if (t in rhel6_blacklist and
not self.vm.rhel6_defaults()):
@ -956,8 +966,8 @@ class vmmAddHardware(vmmGObjectUI):
if page == PAGE_CHAR:
self.update_char_device_type_model()
devtype = self.widget("char-device-type")
self.change_char_device_type(devtype)
self.widget("char-device-type").emit("changed")
self.widget("char-target-name").emit("changed")
if page == PAGE_HOSTDEV:
(ignore, devtype, devcap,
@ -1097,6 +1107,19 @@ class vmmAddHardware(vmmGObjectUI):
uihelpers.set_grid_row_visible(self.widget(widget_name + "-label"),
make_visible)
def change_char_target_name(self, src):
if not src.get_visible():
return
text = src.get_child().get_text()
settype = None
if text == VirtualChannelDevice.CHANNEL_NAME_SPICE:
settype = "spicevmc"
elif (text == VirtualChannelDevice.CHANNEL_NAME_QEMUGA or
text == VirtualChannelDevice.CHANNEL_NAME_LIBGUESTFS):
settype = "unix"
uihelpers.set_row_selection(self.widget("char-device-type"), settype)
def change_char_device_type(self, src):
idx = src.get_active()
if idx < 0:
@ -1532,7 +1555,7 @@ class vmmAddHardware(vmmGObjectUI):
bind_host = self.widget("char-bind-host").get_text()
source_port = self.widget("char-port").get_value()
bind_port = self.widget("char-bind-port").get_value()
target_name = self.widget("char-target-name").get_text()
target_name = self.widget("char-target-name").get_child().get_text()
target_type = typebox.get_model()[typebox.get_active()][0]
if self.widget("char-use-telnet").get_active():

View File

@ -64,6 +64,13 @@ class _VirtualCharDevice(VirtualDevice):
CONSOLE_TARGETS = [CONSOLE_TARGET_SERIAL, CONSOLE_TARGET_UML,
CONSOLE_TARGET_XEN, CONSOLE_TARGET_VIRTIO]
CHANNEL_NAME_SPICE = "com.redhat.spice.0"
CHANNEL_NAME_QEMUGA = "org.qemu.guest_agent.0"
CHANNEL_NAME_LIBGUESTFS = "org.libguestfs.channel.0"
CHANNEL_NAMES = [CHANNEL_NAME_SPICE,
CHANNEL_NAME_QEMUGA,
CHANNEL_NAME_LIBGUESTFS]
@staticmethod
def pretty_type(ctype):
"""
@ -250,7 +257,7 @@ class _VirtualCharDevice(VirtualDevice):
def _default_target_name(self):
if self.type == self.TYPE_SPICEVMC:
return "com.redhat.spice.0"
return self.CHANNEL_NAME_SPICE
return None
target_name = XMLProperty("./target/@name",
doc=_("Sysfs name of virtio port in the guest"),