[virt-tools-list] [PATCH] Add graphic type in preference dialog for new VM
Cole Robinson
crobinso at redhat.com
Mon Mar 21 16:16:38 UTC 2011
On 03/18/2011 08:59 AM, Marc-André Lureau wrote:
> ---
> src/virt-manager.schemas.in | 13 +++++++++++
> src/virtManager/config.py | 10 +++++++++
> src/virtManager/create.py | 6 ++++-
> src/virtManager/preferences.py | 16 ++++++++++++++
> src/vmm-preferences.glade | 44 ++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 88 insertions(+), 1 deletions(-)
>
I squashed in some small changes to make 'make check-pylint' happy, and applied:
http://git.fedorahosted.org/git?p=virt-manager.git;a=commit;h=771387052e956816c537e84333ef23178a149862
Thanks,
Cole
> diff --git a/src/virt-manager.schemas.in b/src/virt-manager.schemas.in
> index 2aeeb47..48cb7bb 100644
> --- a/src/virt-manager.schemas.in
> +++ b/src/virt-manager.schemas.in
> @@ -196,6 +196,19 @@
> </schema>
>
> <schema>
> + <key>/schemas/apps/::PACKAGE::/new-vm/graphics-type</key>
> + <applyto>/apps/::PACKAGE::/new-vm/graphics-type</applyto>
> + <owner>::PACKAGE::</owner>
> + <type>string</type>
> + <default>vnc</default>
> +
> + <locale name="C">
> + <short>Install selected graphics type for new VM</short>
> + <long>Install selected graphics type for new VM. vnc or spice</long>
> + </locale>
> + </schema>
> +
> + <schema>
> <key>/schemas/apps/::PACKAGE::/system-tray</key>
> <applyto>/apps/::PACKAGE::/system-tray</applyto>
> <owner>::PACKAGE::</owner>
> diff --git a/src/virtManager/config.py b/src/virtManager/config.py
> index b9bb275..92a3d6a 100644
> --- a/src/virtManager/config.py
> +++ b/src/virtManager/config.py
> @@ -508,6 +508,16 @@ class vmmConfig(object):
> def on_sound_remote_changed(self, cb, data=None):
> self.conf.notify_add(self.conf_dir + "/new-vm/remote-sound", cb, data)
>
> + def get_graphics_type(self):
> + ret = self.conf.get_string(self.conf_dir + "/new-vm/graphics_type")
> + if ret == None:
> + ret = "vnc"
> + return ret
> + def set_graphics_type(self, type):
> + self.conf.set_string(self.conf_dir + "/new-vm/graphics_type", type.lower())
> + def on_graphics_type_changed(self, cb, data=None):
> + self.conf.notify_add(self.conf_dir + "/new-vm/graphics_type", cb, data)
> +
>
> # URL/Media path history
> def _url_add_helper(self, gconf_path, url):
> diff --git a/src/virtManager/create.py b/src/virtManager/create.py
> index f742ac5..bd5b173 100644
> --- a/src/virtManager/create.py
> +++ b/src/virtManager/create.py
> @@ -901,6 +901,9 @@ class vmmCreate(vmmGObjectUI):
> return self.config.get_remote_sound()
> return self.config.get_local_sound()
>
> + def get_config_graphics_type(self):
> + return self.config.get_graphics_type()
> +
> def get_config_customize(self):
> return self.window.get_widget("summary-customize").get_active()
>
> @@ -1193,8 +1196,9 @@ class vmmCreate(vmmGObjectUI):
>
> # Set up graphics device
> try:
> + gtype = self.get_config_graphics_type()
> guest.add_device(virtinst.VirtualGraphics(
> - type=virtinst.VirtualGraphics.TYPE_VNC,
> + type=gtype,
> conn=guest.conn))
> guest.add_device(virtinst.VirtualVideoDevice(conn=guest.conn))
> except Exception, e:
> diff --git a/src/virtManager/preferences.py b/src/virtManager/preferences.py
> index a3f0b40..42fdc14 100644
> --- a/src/virtManager/preferences.py
> +++ b/src/virtManager/preferences.py
> @@ -43,6 +43,7 @@ class vmmPreferences(vmmGObjectUI):
> self.config.on_stats_history_length_changed(self.refresh_history_length)
> self.config.on_sound_local_changed(self.refresh_sound_local)
> self.config.on_sound_remote_changed(self.refresh_sound_remote)
> + self.config.on_graphics_type_changed(self.refresh_graphics_type)
> self.config.on_stats_enable_disk_poll_changed(self.refresh_disk_poll)
> self.config.on_stats_enable_net_poll_changed(self.refresh_net_poll)
>
> @@ -60,6 +61,7 @@ class vmmPreferences(vmmGObjectUI):
> self.refresh_console_scaling()
> self.refresh_sound_local()
> self.refresh_sound_remote()
> + self.refresh_graphics_type()
> self.refresh_disk_poll()
> self.refresh_net_poll()
> self.refresh_grabkeys_combination()
> @@ -89,6 +91,7 @@ class vmmPreferences(vmmGObjectUI):
> "on_prefs_confirm_removedev_toggled": self.change_confirm_removedev,
> "on_prefs_confirm_interface_toggled": self.change_confirm_interface,
> "on_prefs_btn_keys_define_clicked": self.change_grab_keys,
> + "on_prefs_graphics_type_changed": self.change_graphics_type,
> })
> util.bind_escape_key_close(self)
>
> @@ -143,6 +146,12 @@ class vmmPreferences(vmmGObjectUI):
> ignore4=None):
> self.window.get_widget("prefs-sound-remote").set_active(
> self.config.get_remote_sound())
> + def refresh_graphics_type(self, ignore1=None, ignore2=None, ignore=None,
> + ignore4=None):
> + active = { "vnc": 0,
> + "spice": 1 }[self.config.get_graphics_type()]
> + self.window.get_widget("prefs-graphics-type").set_active(
> + active)
>
> def refresh_disk_poll(self, ignore1=None, ignore2=None, ignore3=None,
> ignore4=None):
> @@ -271,6 +280,13 @@ class vmmPreferences(vmmGObjectUI):
> def change_confirm_interface(self, src):
> self.config.set_confirm_interface(src.get_active())
>
> + def change_graphics_type(self, src):
> + gtype = 'vnc'
> + idx = src.get_active()
> + if idx >= 0:
> + gtype = src.get_model()[idx][0]
> + self.config.set_graphics_type(gtype)
> +
> def show_help(self, src_ignore):
> # From the Preferences window, show the help document from
> # the Preferences page
> diff --git a/src/vmm-preferences.glade b/src/vmm-preferences.glade
> index 06ff38a..2f1f096 100644
> --- a/src/vmm-preferences.glade
> +++ b/src/vmm-preferences.glade
> @@ -536,6 +536,50 @@ For all domains</property>
> <property name="label" translatable="yes">Install Audio Device:</property>
> </widget>
> </child>
> +
> + <child>
> + <widget class="GtkLabel" id="label162">
> + <property name="visible">True</property>
> + <property name="label" translatable="yes">Install Graphics:</property>
> + <property name="use_underline">False</property>
> + <property name="use_markup">False</property>
> + <property name="justify">GTK_JUSTIFY_LEFT</property>
> + <property name="wrap">False</property>
> + <property name="selectable">False</property>
> + <property name="xalign">0</property>
> + <property name="yalign">0.5</property>
> + <property name="xpad">0</property>
> + <property name="ypad">0</property>
> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
> + <property name="width_chars">-1</property>
> + <property name="single_line_mode">False</property>
> + <property name="angle">0</property>
> + </widget>
> + <packing>
> + <property name="left_attach">0</property>
> + <property name="right_attach">1</property>
> + <property name="top_attach">2</property>
> + <property name="bottom_attach">3</property>
> + <property name="x_options">fill</property>
> + <property name="y_options"></property>
> + </packing>
> + </child>
> + <child>
> + <widget class="GtkComboBox" id="prefs-graphics-type">
> + <property name="visible">True</property>
> + <property name="items" translatable="no">VNC
> +Spice</property>
> + <signal name="changed" handler="on_prefs_graphics_type_changed"/>
> + </widget>
> + <packing>
> + <property name="left_attach">0</property>
> + <property name="right_attach">1</property>
> + <property name="top_attach">3</property>
> + <property name="bottom_attach">4</property>
> + <property name="x_padding">5</property>
> + <property name="x_options">fill</property>
> + </packing>
> + </child>
> </widget>
> </child>
> </widget>
More information about the virt-tools-list
mailing list