addhardware: Modernize 'graphics' UI

- Drop SDL, it doesn't mesh with modern libvirt
- Drop keymap, modern qemu/virt-manager handle this automagically
- Drop big text fields
- Misc other cleanups and simplifications
This commit is contained in:
Cole Robinson 2013-09-02 11:54:36 -04:00
parent 288a611ff7
commit efbc815a60
4 changed files with 274 additions and 454 deletions

View File

@ -1011,379 +1011,23 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<object class="GtkTable" id="table38"> <object class="GtkGrid" id="table38">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="n_rows">7</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
<child> <property name="column_spacing">6</property>
<object class="GtkLabel" id="label429">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Type:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-type</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child> <child>
<object class="GtkComboBox" id="graphics-type"> <object class="GtkComboBox" id="graphics-type">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property>
<signal name="changed" handler="on_graphics_type_changed" swapped="no"/> <signal name="changed" handler="on_graphics_type_changed" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="top_attach">0</property>
<property name="x_options">GTK_FILL</property> <property name="width">1</property>
<property name="y_options">GTK_FILL</property> <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label430">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Address:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-address</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label431">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Port:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-port</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label432">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Pa_ssword:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-password</property>
</object>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment160">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="bottom_padding">6</property>
<child>
<object class="GtkHBox" id="hbox67">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="image107">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="yalign">0</property>
<property name="stock">gtk-dialog-info</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label428">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="yalign">0</property>
<property name="xpad">7</property>
<property name="label" translatable="yes">&lt;small&gt;&lt;b&gt;Tip:&lt;/b&gt; VNC or Spice server is strongly recommended because it allows the virtual display to be embedded inside this application. It may also be used to allow access to the virtual display from a remote system.&lt;/small&gt;</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
<property name="width_chars">50</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</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>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment161">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="bottom_padding">6</property>
<property name="left_padding">20</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="graphics-address">
<property name="label" translatable="yes">Listen on all public network interfaces </property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
</object>
<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>
<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="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Keymap:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-keymap-chk</property>
</object>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_columns">4</property>
<child>
<object class="GtkCheckButton" id="graphics-keymap-chk">
<property name="label" translatable="yes">Same as host</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<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="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_graphics_keymap_toggled" swapped="no"/>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options"/>
<property name="y_options"/>
<property name="x_padding">17</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Other:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-keymap</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options"/>
<property name="y_options"/>
<property name="x_padding">10</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="graphics-keymap">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="y_options"/>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</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">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkTable" id="table8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_columns">4</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="label29">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_TLS port:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-port</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="graphics-port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<property name="adjustment">adjustment5</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
</object>
<packing>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="graphics-port-auto">
<property name="label" translatable="yes">A_utomatically allocated</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_graphics_port_auto_toggled" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="graphics-tls-port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<property name="adjustment">adjustment4</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -1423,9 +1067,195 @@
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="top_attach">4</property>
<property name="top_attach">5</property> <property name="width">1</property>
<property name="bottom_attach">6</property> <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label429">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Type:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-type</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="GtkLabel" id="label430">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Address:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-address</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>
<child>
<object class="GtkLabel" id="label432">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Pa_ssword:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-password</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label431">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Port:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-port</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="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="graphics-port-auto">
<property name="label" translatable="yes">A_utomatically allocated</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_graphics_port_auto_toggled" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="graphics-port-box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkSpinButton" id="graphics-port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<property name="invisible_char_set">True</property>
<property name="adjustment">adjustment5</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="graphics-tlsport-box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label29">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_TLS port:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-port</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="graphics-tls-port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<property name="invisible_char_set">True</property>
<property name="adjustment">adjustment4</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</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>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="graphics-address">
<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="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
</object> </object>

View File

@ -96,7 +96,6 @@ class vmmAddHardware(vmmGObjectUI):
"on_graphics_type_changed": self.change_graphics_type, "on_graphics_type_changed": self.change_graphics_type,
"on_graphics_port_auto_toggled": self.change_port_auto, "on_graphics_port_auto_toggled": self.change_port_auto,
"on_graphics_keymap_toggled": self.change_keymap,
"on_graphics_use_password": self.change_password_chk, "on_graphics_use_password": self.change_password_chk,
"on_char_device_type_changed": self.change_char_device_type, "on_char_device_type_changed": self.change_char_device_type,
@ -274,6 +273,13 @@ class vmmAddHardware(vmmGObjectUI):
graphics_list.pack_start(text, True) graphics_list.pack_start(text, True)
graphics_list.add_attribute(text, 'text', 0) graphics_list.add_attribute(text, 'text', 0)
# Graphics address
# [label, value]
self.widget("graphics-address").set_model(Gtk.ListStore(str, str))
text = Gtk.CellRendererText()
self.widget("graphics-address").pack_start(text, True)
self.widget("graphics-address").add_attribute(text, 'text', 0)
# Sound model list # Sound model list
sound_list = self.widget("sound-model") sound_list = self.widget("sound-model")
uihelpers.build_sound_combo(self.vm, sound_list) uihelpers.build_sound_combo(self.vm, sound_list)
@ -462,17 +468,22 @@ class vmmAddHardware(vmmGObjectUI):
input_box.set_active(0) input_box.set_active(0)
# Graphics init # Graphics init
self.change_port_auto()
graphics_box = self.widget("graphics-type") graphics_box = self.widget("graphics-type")
self.populate_graphics_model(graphics_box.get_model()) self.populate_graphics_model(graphics_box.get_model())
graphics_box.set_active(0) graphics_box.set_active(0)
self.widget("graphics-address").set_active(False)
model = self.widget("graphics-address").get_model()
model.clear()
model.append([_("Hypervisor default"), None])
model.append([_("Localhost only"), "127.0.0.1"])
model.append([_("All interfaces"), "0.0.0.0"])
self.widget("graphics-address").set_active(0)
self.change_port_auto()
self.widget("graphics-port-auto").set_active(True) self.widget("graphics-port-auto").set_active(True)
self.widget("graphics-password").set_text("") self.widget("graphics-password").set_text("")
self.widget("graphics-password").set_sensitive(False) self.widget("graphics-password").set_sensitive(False)
self.widget("graphics-password-chk").set_active(False) self.widget("graphics-password-chk").set_active(False)
self.widget("graphics-keymap").set_text("")
self.widget("graphics-keymap-chk").set_active(True)
# Sound init # Sound init
sound_box = self.widget("sound-model") sound_box = self.widget("sound-model")
@ -563,9 +574,8 @@ class vmmAddHardware(vmmGObjectUI):
def populate_graphics_model(self, model): def populate_graphics_model(self, model):
model.clear() model.clear()
model.append([_("VNC server"), "vnc"])
model.append([_("Spice server"), "spice"]) model.append([_("Spice server"), "spice"])
model.append([_("Local SDL window"), "sdl"]) model.append([_("VNC server"), "vnc"])
def populate_host_device_model(self, devtype, devcap, subtype, subcap): def populate_host_device_model(self, devtype, devcap, subtype, subcap):
devlist = self.widget("host-device") devlist = self.widget("host-device")
@ -663,38 +673,25 @@ class vmmAddHardware(vmmGObjectUI):
return None return None
return _type.get_model().get_value(_type.get_active_iter(), 1) return _type.get_model().get_value(_type.get_active_iter(), 1)
def get_config_graphics_port(self): def get_config_graphics_ports(self):
port = self.widget("graphics-port") if self.widget("graphics-port-auto").get_active():
portAuto = self.widget("graphics-port-auto") return -1, -1
if portAuto.get_active():
return -1
return int(port.get_value())
def get_config_graphics_tls_port(self): port = self.widget("graphics-port").get_value()
port = self.widget("graphics-tls-port") tlsport = self.widget("graphics-tls-port").get_value()
portAuto = self.widget("graphics-port-auto") if not self.widget("graphics-tls-port").get_visible():
if portAuto.get_active(): tlsport = -1
return -1 return int(port), int(tlsport)
return int(port.get_value())
def get_config_graphics_address(self): def get_config_graphics_address(self):
addr = self.widget("graphics-address") addr = self.widget("graphics-address")
if addr.get_active(): return addr.get_model()[addr.get_active()][1]
return "0.0.0.0"
return "127.0.0.1"
def get_config_graphics_password(self): def get_config_graphics_password(self):
if not self.widget("graphics-password-chk").get_active(): if not self.widget("graphics-password-chk").get_active():
return None return None
return self.widget("graphics-password").get_text() return self.widget("graphics-password").get_text()
def get_config_keymap(self):
g = self.widget("graphics-keymap")
if g.get_sensitive() and g.get_text() != "":
return g.get_text()
else:
return None
# Network getters # Network getters
def get_config_network(self): def get_config_network(self):
net_list = self.widget("net-list") net_list = self.widget("net-list")
@ -959,44 +956,17 @@ class vmmAddHardware(vmmGObjectUI):
# Graphics listeners # Graphics listeners
def change_graphics_type(self, ignore=None): def change_graphics_type(self, ignore=None):
graphics = self.get_config_graphics() self.change_port_auto()
if graphics in ["vnc", "spice"]:
self.widget("graphics-port-auto").set_sensitive(True)
self.widget("graphics-address").set_sensitive(True)
# Skip this code if the checkbox value is not changed. In this way
# the password field maintains its value.
if not self.widget("graphics-password-chk").get_sensitive():
self.widget("graphics-password").set_sensitive(False)
self.widget("graphics-password-chk").set_sensitive(True)
self.widget("graphics-password-chk").set_active(False)
self.widget("graphics-keymap-chk").set_sensitive(True)
self.change_port_auto()
else:
self.widget("graphics-port").set_sensitive(False)
self.widget("graphics-tls-port").set_sensitive(False)
self.widget("graphics-port-auto").set_sensitive(False)
self.widget("graphics-address").set_sensitive(False)
self.widget("graphics-password").set_sensitive(False)
self.widget("graphics-password-chk").set_sensitive(False)
self.widget("graphics-password-chk").set_active(False)
self.widget("graphics-keymap-chk").set_sensitive(False)
self.widget("graphics-keymap").set_sensitive(False)
def change_port_auto(self, ignore=None): def change_port_auto(self, ignore=None):
graphics = self.get_config_graphics() gtype = self.get_config_graphics()
tls_enable = graphics == "spice" is_auto = self.widget("graphics-port-auto").get_active()
if self.widget("graphics-port-auto").get_active(): is_spice = (gtype == "spice")
self.widget("graphics-port").set_sensitive(False)
self.widget("graphics-tls-port").set_sensitive(False)
else:
self.widget("graphics-port").set_sensitive(True)
self.widget("graphics-tls-port").set_sensitive(tls_enable)
def change_keymap(self, ignore=None): uihelpers.set_grid_row_visible(self.widget("graphics-port-box"),
if self.widget("graphics-keymap-chk").get_active(): not is_auto)
self.widget("graphics-keymap").set_sensitive(False) self.widget("graphics-port-box").set_visible(not is_auto)
else: self.widget("graphics-tlsport-box").set_visible(is_spice)
self.widget("graphics-keymap").set_sensitive(True)
def change_password_chk(self, ignore=None): def change_password_chk(self, ignore=None):
if self.widget("graphics-password-chk").get_active(): if self.widget("graphics-password-chk").get_active():
@ -1154,13 +1124,12 @@ class vmmAddHardware(vmmGObjectUI):
show_mode = bool( show_mode = bool(
fsdriver == virtinst.VirtualFilesystem.DRIVER_PATH or fsdriver == virtinst.VirtualFilesystem.DRIVER_PATH or
fsdriver == virtinst.VirtualFilesystem.DRIVER_DEFAULT) fsdriver == virtinst.VirtualFilesystem.DRIVER_DEFAULT)
self.widget("fs-mode-title").set_visible(show_mode) uihelpers.set_grid_row_visible(self.widget("fs-mode-box"), show_mode)
self.widget("fs-mode-box").set_visible(show_mode)
show_wrpol = bool( show_wrpol = bool(
fsdriver and fsdriver != virtinst.VirtualFilesystem.DRIVER_DEFAULT) fsdriver and fsdriver != virtinst.VirtualFilesystem.DRIVER_DEFAULT)
self.widget("fs-wrpolicy-title").set_visible(show_wrpol) uihelpers.set_grid_row_visible(self.widget("fs-wrpolicy-box"),
self.widget("fs-wrpolicy-box").set_visible(show_wrpol) show_wrpol)
@ -1437,15 +1406,14 @@ class vmmAddHardware(vmmGObjectUI):
gtype = self.get_config_graphics() gtype = self.get_config_graphics()
try: try:
port, tlsport = self.get_config_graphics_ports()
self._dev = virtinst.VirtualGraphics(self.conn.get_backend()) self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
self._dev.type = gtype self._dev.type = gtype
if gtype != "sdl": self._dev.port = port
self._dev.port = self.get_config_graphics_port() self._dev.passwd = self.get_config_graphics_password()
self._dev.passwd = self.get_config_graphics_password() self._dev.listen = self.get_config_graphics_address()
self._dev.listen = self.get_config_graphics_address()
self._dev.keymap = self.get_config_keymap()
if gtype == "spice": if gtype == "spice":
self._dev.tlsPort = self.get_config_graphics_tls_port() self._dev.tlsPort = tlsport
except ValueError, e: except ValueError, e:
self.err.val_err(_("Graphics device parameter error"), e) self.err.val_err(_("Graphics device parameter error"), e)

View File

@ -25,10 +25,11 @@
# pylint: disable=E0611 # pylint: disable=E0611
from gi.repository import Gdk from gi.repository import Gdk
from gi.repository import GLib from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gtk from gi.repository import Gtk
# pylint: enable=E0611 # pylint: enable=E0611
from virtManager import uihelpers
# pylint: disable=E1101 # pylint: disable=E1101
# pylint can't detect functions we inheirit from Gtk, ex: # pylint can't detect functions we inheirit from Gtk, ex:
# OverBox.set_over: Instance of 'OverBox' has no 'remove' member # OverBox.set_over: Instance of 'OverBox' has no 'remove' member
@ -91,9 +92,11 @@ class OverBox(Gtk.Box):
actual_min = self._get_actual_min() actual_min = self._get_actual_min()
if self.overWidget: if self.overWidget:
expand = self.child_get_property(self.overWidget, "expand") expand = uihelpers.child_get_property(self, self.overWidget,
fill = self.child_get_property(self.overWidget, "fill") "expand")
padding = self.child_get_property(self.overWidget, "padding") fill = uihelpers.child_get_property(self, self.overWidget, "fill")
padding = uihelpers.child_get_property(self, self.overWidget,
"padding")
# XXX: On Fedora 19 child_get_property isn't working :( # XXX: On Fedora 19 child_get_property isn't working :(
expand = True expand = True
@ -129,14 +132,6 @@ class OverBox(Gtk.Box):
# Custom functionality # # Custom functionality #
######################## ########################
def child_get_property(self, widget, propname):
# gtk3 bindings are crappy here, make it work like
# gobject.get_property()
value = GObject.Value()
value.init(GObject.TYPE_INT)
Gtk.Box.child_get_property(self, widget, propname, value)
return value.get_int()
def do_set_over(self, widget): def do_set_over(self, widget):
self.set_over(widget) self.set_over(widget)
@ -264,9 +259,9 @@ class OverBox(Gtk.Box):
self.overWidth = over.width self.overWidth = over.width
self.overHeight = over.height self.overHeight = over.height
expand = self.child_get_property(self.overWidget, "expand") expand = uihelpers.child_get_property(self, self.overWidget, "expand")
fill = self.child_get_property(self.overWidget, "fill") fill = uihelpers.child_get_property(self, self.overWidget, "fill")
padding = self.child_get_property(self.overWidget, "padding") padding = uihelpers.child_get_property(self, self.overWidget, "padding")
if expand or fill: if expand or fill:
wpad = 0 wpad = 0

View File

@ -23,6 +23,7 @@ import os
import statvfs import statvfs
# pylint: disable=E0611 # pylint: disable=E0611
from gi.repository import GObject
from gi.repository import Gtk from gi.repository import Gtk
# pylint: enable=E0611 # pylint: enable=E0611
@ -1358,6 +1359,32 @@ def set_list_selection(widget, rownum):
selection.select_path(path) selection.select_path(path)
def child_get_property(parent, child, propname):
# Wrapper for child_get_property, which pygobject doesn't properly
# introspect
value = GObject.Value()
value.init(GObject.TYPE_INT)
parent.child_get_property(child, propname, value)
return value.get_int()
def set_grid_row_visible(child, visible):
# For the passed widget, find its parent GtkGrid, and hide/show all
# elements that are in the same row as it. Simplifies having to name
# every element in a row when we want to dynamically hide things
# based on UI interraction
parent = child.get_parent()
if not type(parent) is Gtk.Grid:
raise RuntimeError("Programming error, parent must be grid, "
"not %s" % type(parent))
row = child_get_property(parent, child, "top-attach")
for child in parent.get_children():
if child_get_property(parent, child, "top-attach") == row:
child.set_visible(visible)
def default_uri(always_system=False): def default_uri(always_system=False):
if os.path.exists('/var/lib/xend'): if os.path.exists('/var/lib/xend'):
if (os.path.exists('/dev/xen/evtchn') or if (os.path.exists('/dev/xen/evtchn') or