From a3b50aa61f8c41bbccb8c3db4dcea65dbcd6f63a Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mon, 20 Dec 2010 12:34:32 -0500 Subject: [PATCH] details: Rework graphics section to allow reusing table rows --- src/virtManager/details.py | 50 ++++-- src/vmm-details.glade | 339 +++++++++++++++---------------------- 2 files changed, 176 insertions(+), 213 deletions(-) diff --git a/src/virtManager/details.py b/src/virtManager/details.py index 43ba0a32c..ba3f919ea 100644 --- a/src/virtManager/details.py +++ b/src/virtManager/details.py @@ -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("%s" % 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) diff --git a/src/vmm-details.glade b/src/vmm-details.glade index 9299adf5f..2e159313d 100644 --- a/src/vmm-details.glade +++ b/src/vmm-details.glade @@ -4002,15 +4002,14 @@ I/O: 3 12 - + True 3 - 4 + 7 2 8 - 4 - + True 0 label401 @@ -4019,14 +4018,14 @@ I/O: 1 2 - 1 - 2 + 4 + 5 GTK_FILL - + True 0 label401 @@ -4035,57 +4034,33 @@ I/O: 1 2 + 3 + 4 GTK_FILL - + True 1 + 2 Port: - 1 - 2 + 4 + 5 GTK_FILL - + True 1 + 2 Address: - - GTK_FILL - - - - - - True - 1 - _Password: - True - vnc-password - - - 2 - 3 - GTK_FILL - - - - - - True - 1 - _Keymap: - True - vnc-keymap-combo - 3 4 @@ -4094,27 +4069,42 @@ I/O: - + True - True - False - - + 1 + 0 + 7 + _Password: + True - 1 - 2 - 2 - 3 + 5 + 6 GTK_FILL - GTK_FILL + - + + True + 1 + 8 + _Keymap: + True + gfx-keymap-combo + + + 6 + 7 + GTK_FILL + + + + + True - + True @@ -4123,7 +4113,7 @@ I/O: - + True 0 label @@ -4136,12 +4126,108 @@ I/O: 1 2 - 3 - 4 + 6 + 7 + GTK_FILL + + + + + + True + 1 + 2 + Display: + + + 1 + 2 GTK_FILL GTK_FILL + + + True + 1 + 2 + XAuth: + + + 2 + 3 + GTK_FILL + GTK_FILL + + + + + True + 0 + label + + + 1 + 2 + GTK_FILL + + + + + True + 0 + label + + + 1 + 2 + 2 + 3 + GTK_FILL + GTK_FILL + + + + + True + 0 + label + + + 1 + 2 + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + True + False + + + + + 1 + 2 + 5 + 6 + GTK_FILL + + + + + True + 1 + Type: + + + GTK_FILL + + @@ -4149,7 +4235,7 @@ I/O: True - <b>VNC Display</b> + <b>Display title</b> True @@ -4162,149 +4248,6 @@ I/O: 0 - - - True - 0 - none - - - True - 3 - 12 - - - True - 2 - 2 - 8 - 4 - - - True - Display: - - - GTK_FILL - GTK_FILL - - - - - True - 1 - XAuth: - - - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - 0 - label - - - 1 - 2 - GTK_FILL - - - - - True - 0 - label - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - - - - - True - <b>Local SDL Window</b> - True - - - label_item - - - - - False - 1 - - - - - True - 0 - none - - - True - 3 - 12 - - - True - 2 - 8 - 4 - - - True - 1 - Type: - - - GTK_FILL - - - - - True - 0 - label - - - 1 - 2 - - - - - - - - - True - <b>Virtual Graphics</b> - True - - - label_item - - - - - False - 2 - - 8