details: Rework graphics section to allow reusing table rows

This commit is contained in:
Cole Robinson 2010-12-20 12:34:32 -05:00
parent f2da834e1d
commit a3b50aa61f
2 changed files with 176 additions and 213 deletions

View File

@ -719,7 +719,7 @@ class vmmDetails(vmmGObjectUI):
uihelpers.build_netmodel_combo(self.vm, net_model)
# Graphics keymap
vnc_keymap = self.window.get_widget("vnc-keymap-combo")
vnc_keymap = self.window.get_widget("gfx-keymap-combo")
uihelpers.build_vnc_keymap_combo(self.vm, vnc_keymap,
no_default=no_default)
@ -1703,8 +1703,8 @@ class vmmDetails(vmmGObjectUI):
# Graphics options
def config_graphics_apply(self, dev_id_info):
passwd = self.window.get_widget("vnc-password").get_text() or None
keymap = self.get_combo_label_value("vnc-keymap")
passwd = self.window.get_widget("gfx-password").get_text() or None
keymap = self.get_combo_label_value("gfx-keymap")
return self._change_config_helper([self.vm.define_graphics_password,
self.vm.define_graphics_keymap],
@ -2229,16 +2229,29 @@ class vmmDetails(vmmGObjectUI):
if not gfx:
return
title = self.window.get_widget("graphics-title")
table = self.window.get_widget("graphics-table")
table.foreach(lambda w, ignore: w.hide(), ())
def set_title(text):
title.set_markup("<b>%s</b>" % text)
def show_row(widget_name, suffix=""):
base = "gfx-%s" % widget_name
self.window.get_widget(base + "-title").show()
self.window.get_widget(base + suffix).show()
def show_text(widget_name, text):
show_row(widget_name)
self.window.get_widget("gfx-" + widget_name).set_text(text)
gtype = gfx.type
is_vnc = (gtype == "vnc")
is_sdl = (gtype == "sdl")
is_other = (not any([is_vnc, is_sdl]))
self.window.get_widget("vnc-frame").set_property("visible", is_vnc)
self.window.get_widget("sdl-frame").set_property("visible", is_sdl)
self.window.get_widget("other-frame").set_property("visible", is_other)
if is_vnc:
set_title(_("VNC Display"))
port = (gfx.port == -1 and
_("Automatically allocated") or
str(gfx.port))
@ -2246,19 +2259,26 @@ class vmmDetails(vmmGObjectUI):
passwd = gfx.passwd or ""
keymap = (gfx.keymap or None)
self.window.get_widget("vnc-port").set_text(port)
self.window.get_widget("vnc-address").set_text(address)
self.window.get_widget("vnc-password").set_text(passwd)
self.set_combo_label("vnc-keymap", 0, keymap)
show_text("port", port)
show_text("address", address)
show_text("password", passwd)
show_row("keymap", "-box")
self.set_combo_label("gfx-keymap", 0, keymap)
elif is_sdl:
set_title(_("Local SDL Window"))
display = gfx.display or _("Unknown")
xauth = gfx.xauth or _("Unknown")
self.window.get_widget("sdl-display").set_text(display)
self.window.get_widget("sdl-xauth").set_text(xauth)
show_text("display", display)
show_text("xauth", xauth)
else:
self.window.get_widget("graphics-other-type").set_text(gtype)
gtype = str(gtype).upper()
set_title(_("%s Display") % gtype)
show_text("type", gtype)
def refresh_sound_page(self):
sound = self.get_hw_selection(HW_LIST_COL_DEVICE)

View File

@ -4002,15 +4002,14 @@ I/O:</property>
<property name="top_padding">3</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table34">
<widget class="GtkTable" id="graphics-table">
<property name="visible">True</property>
<property name="border_width">3</property>
<property name="n_rows">4</property>
<property name="n_rows">7</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">4</property>
<child>
<widget class="GtkLabel" id="vnc-port">
<widget class="GtkLabel" id="gfx-port">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label">label401</property>
@ -4019,14 +4018,14 @@ I/O:</property>
<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="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="vnc-address">
<widget class="GtkLabel" id="gfx-address">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label">label401</property>
@ -4035,57 +4034,33 @@ I/O:</property>
<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="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label418">
<widget class="GtkLabel" id="gfx-port-title">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="ypad">2</property>
<property name="label" translatable="yes">Port:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_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"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label412">
<widget class="GtkLabel" id="gfx-address-title">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="ypad">2</property>
<property name="label" translatable="yes">Address:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label419">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Password:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">vnc-password</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Keymap:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">vnc-keymap-combo</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
@ -4094,27 +4069,42 @@ I/O:</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="vnc-password">
<widget class="GtkLabel" id="gfx-password-title">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="invisible_char">●</property>
<signal name="changed" handler="on_vnc_password_changed"/>
<property name="xalign">1</property>
<property name="yalign">0</property>
<property name="ypad">7</property>
<property name="label" translatable="yes">_Password:</property>
<property name="use_underline">True</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>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox19">
<widget class="GtkLabel" id="gfx-keymap-title">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="ypad">8</property>
<property name="label" translatable="yes">_Keymap:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">gfx-keymap-combo</property>
</widget>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="gfx-keymap-box">
<property name="visible">True</property>
<child>
<widget class="GtkComboBox" id="vnc-keymap-combo">
<widget class="GtkComboBox" id="gfx-keymap-combo">
<property name="visible">True</property>
<signal name="changed" handler="on_vnc_keymap_combo_changed"/>
</widget>
@ -4123,7 +4113,7 @@ I/O:</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="vnc-keymap-label">
<widget class="GtkLabel" id="gfx-keymap-label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label">label</property>
@ -4136,12 +4126,108 @@ I/O:</property>
<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="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="gfx-display-title">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="ypad">2</property>
<property name="label">Display:</property>
</widget>
<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>
<widget class="GtkLabel" id="gfx-xauth-title">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="ypad">2</property>
<property name="label">XAuth:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="gfx-type">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label">label</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="gfx-xauth">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">label</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>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="gfx-display">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">label</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="GtkEntry" id="gfx-password">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="invisible_char">●</property>
<signal name="changed" handler="on_vnc_password_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="gfx-type-title">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Type:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
</widget>
@ -4149,7 +4235,7 @@ I/O:</property>
<child>
<widget class="GtkLabel" id="graphics-title">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;VNC Display&lt;/b&gt;</property>
<property name="label">&lt;b&gt;Display title&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
@ -4162,149 +4248,6 @@ I/O:</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="sdl-frame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment28">
<property name="visible">True</property>
<property name="top_padding">3</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table10">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">4</property>
<child>
<widget class="GtkLabel" id="label33">
<property name="visible">True</property>
<property name="label">Display:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label35">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label">XAuth:</property>
</widget>
<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>
<widget class="GtkLabel" id="sdl-display">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">label</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="sdl-xauth">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">label</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="y_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label34">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Local SDL Window&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="other-frame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment29">
<property name="visible">True</property>
<property name="top_padding">3</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table12">
<property name="visible">True</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">4</property>
<child>
<widget class="GtkLabel" id="label112">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Type:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="graphics-other-type">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label">label</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label36">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Virtual Graphics&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
<property name="position">8</property>