The attached patch adds options to virt-manager's preferences section for adding an audio device to new VMs. The new option defaults to adding audio for all new local VMs, but skipping audio for remote VMs. I opted for the preferences screen approach since it seems like the type of thing users will either always or never want, and the new VM wizard is kind of cluttered as it is. Couple of screenshots: http://fedorapeople.org/~crobinso/virt-manager/virt-manager-sound-prefs.png http://fedorapeople.org/~crobinso/virt-manager/virt-manager-sound-summary.png Thanks, Cole
diff -r cae15335fd61 src/virt-manager.schemas.in --- a/src/virt-manager.schemas.in Sun Aug 10 20:58:36 2008 -0400 +++ b/src/virt-manager.schemas.in Thu Aug 14 20:47:46 2008 -0400 @@ -169,5 +169,30 @@ </locale> </schema> + <schema> + <key>/schemas/apps/::PACKAGE::/new-vm/local-sound</key> + <applyto>/apps/::PACKAGE::/new-vm/local-sound</applyto> + <owner>::PACKAGE::</owner> + <type>bool</type> + <default>1</default> + + <locale name="C"> + <short>Install sound device for local VM</short> + <long>Whether to install a sound device for local VMs or not</long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/::PACKAGE::/new-vm/remote-sound</key> + <applyto>/apps/::PACKAGE::/new-vm/remote-sound</applyto> + <owner>::PACKAGE::</owner> + <type>bool</type> + <default>0</default> + + <locale name="C"> + <short>Install sound device for remote VM</short> + <long>Whether to install a sound device for remote VMs or not</long> + </locale> + </schema> </schemalist> </gconfschemafile> diff -r cae15335fd61 src/virtManager/config.py --- a/src/virtManager/config.py Sun Aug 10 20:58:36 2008 -0400 +++ b/src/virtManager/config.py Thu Aug 14 20:47:46 2008 -0400 @@ -219,6 +219,17 @@ def set_console_grab_notify(self, state): self.conf.set_bool(self.conf_dir + "/console/grab-notify", state) + def get_local_sound(self): + return self.conf.get_bool(self.conf_dir + "/new-vm/local-sound") + + def get_remote_sound(self): + return self.conf.get_bool(self.conf_dir + "/new-vm/remote-sound") + + def set_local_sound(self, state): + self.conf.set_bool(self.conf_dir + "/new-vm/local-sound", state) + + def set_remote_sound(self, state): + self.conf.set_bool(self.conf_dir + "/new-vm/remote-sound", state) def get_secret_name(self, vm): return "vm-console-" + vm.get_uuid() diff -r cae15335fd61 src/virtManager/create.py --- a/src/virtManager/create.py Sun Aug 10 20:58:36 2008 -0400 +++ b/src/virtManager/create.py Thu Aug 14 20:47:46 2008 -0400 @@ -472,6 +472,11 @@ return type.get_model().get_value(type.get_active_iter(), 1) return "N/A" + def get_config_sound(self): + if self.connection.is_remote(): + return self.config.get_remote_sound() + return self.config.get_local_sound() + def page_changed(self, notebook, page, page_number): # would you like some spaghetti with your salad, sir? @@ -549,6 +554,7 @@ self.window.get_widget("summary-mac-address").set_text(macaddr) else: self.window.get_widget("summary-mac-address").set_text("-") + self.window.get_widget("summary-audio").set_text(str(self.get_config_sound())) self.window.get_widget("create-forward").hide() self.window.get_widget("create-finish").show() @@ -598,6 +604,14 @@ "".join(traceback.format_exc())) return False + try: + if self.get_config_sound(): + guest.sound_devs.append(virtinst.VirtualAudio(model="es1370")) + except Exception, e: + self.err.show_err(_("Error setting up sound device:") + str(e), + "".join(traceback.format_exc())) + return False + logging.debug("Creating a VM " + guest.name + \ "\n Type: " + guest.type + \ "\n UUID: " + guest.uuid + \ @@ -609,7 +623,8 @@ "\n # VCPUs: " + str(guest.vcpus) + \ "\n Filesize: " + str(self._disk.size) + \ "\n Disk image: " + str(self.get_config_disk_image()) +\ - "\n Non-sparse file: " + str(self.non_sparse)) + "\n Non-sparse file: " + str(self.non_sparse) + \ + "\n Audio?: " + self.config_get_sound()) #let's go self.install_error = None diff -r cae15335fd61 src/virtManager/preferences.py --- a/src/virtManager/preferences.py Sun Aug 10 20:58:36 2008 -0400 +++ b/src/virtManager/preferences.py Thu Aug 14 20:47:46 2008 -0400 @@ -41,6 +41,7 @@ self.refresh_history_length() self.refresh_console_popup() self.refresh_console_keygrab() + self.refresh_sound_options() self.window.signal_autoconnect({ "on_stats_update_interval_changed": self.change_update_interval, @@ -50,6 +51,8 @@ "on_close_clicked": self.close, "on_vmm_preferences_delete_event": self.close, "on_preferences_help_clicked": self.show_help, + "on_local_sound_toggled": self.change_local_sound, + "on_remote_sound_toggled": self.change_remote_sound, }) def close(self,ignore1=None,ignore2=None): @@ -73,6 +76,11 @@ def refresh_console_keygrab(self,ignore1=None,ignore2=None,ignore3=None,ignore4=None): self.window.get_widget("console-keygrab").set_active(self.config.get_console_keygrab()) + def refresh_sound_options(self, ignore1=None, ignore2=None, ignore=None, + ignore4=None): + self.window.get_widget("local-sound").set_active(self.config.get_local_sound()) + self.window.get_widget("remote-sound").set_active(self.config.get_remote_sound()) + def change_update_interval(self, src): self.config.set_stats_update_interval(src.get_value_as_int()) @@ -85,6 +93,12 @@ def change_console_keygrab(self, box): self.config.set_console_keygrab(box.get_active()) + def change_local_sound(self, src): + self.config.set_local_sound(not self.config.get_local_sound()) + + def change_remote_sound(self, src): + self.config.set_remote_sound(not self.config.get_remote_sound()) + def show_help(self, src): # From the Preferences window, show the help document from the Preferences page self.emit("action-show-help", "virt-manager-preferences-window") diff -r cae15335fd61 src/vmm-create.glade --- a/src/vmm-create.glade Sun Aug 10 20:58:36 2008 -0400 +++ b/src/vmm-create.glade Thu Aug 14 20:47:46 2008 -0400 @@ -4760,7 +4760,7 @@ <widget class="GtkTable" id="table29"> <property name="border_width">6</property> <property name="visible">True</property> - <property name="n_rows">18</property> + <property name="n_rows">20</property> <property name="n_columns">3</property> <property name="homogeneous">False</property> <property name="row_spacing">3</property> @@ -5681,6 +5681,90 @@ <property name="right_attach">3</property> <property name="top_attach">10</property> <property name="bottom_attach">11</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label401"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Sound</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</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">3</property> + <property name="top_attach">18</property> + <property name="bottom_attach">19</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label402"> + <property name="visible">True</property> + <property name="label" translatable="yes">Enable Audio:</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">1</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">1</property> + <property name="right_attach">2</property> + <property name="top_attach">19</property> + <property name="bottom_attach">20</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="summary-audio"> + <property name="visible">True</property> + <property name="label" translatable="yes"></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">2</property> + <property name="right_attach">3</property> + <property name="top_attach">19</property> + <property name="bottom_attach">20</property> <property name="x_options">fill</property> <property name="y_options"></property> </packing> diff -r cae15335fd61 src/vmm-preferences.glade --- a/src/vmm-preferences.glade Sun Aug 10 20:58:36 2008 -0400 +++ b/src/vmm-preferences.glade Thu Aug 14 20:47:46 2008 -0400 @@ -107,6 +107,32 @@ <property name="column_spacing">3</property> <child> + <widget class="GtkSpinButton" id="stats-update-interval"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_IF_VALID</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">False</property> + <property name="adjustment">5 1 60 1 5 5</property> + <accessibility> + <atkproperty name="AtkObject::accessible_name" translatable="yes">Status Interval</atkproperty> + </accessibility> + <signal name="value_changed" handler="on_stats_update_interval_changed" last_modification_time="Mon, 03 Apr 2006 15:27:12 GMT"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> <widget class="GtkLabel" id="label36"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -131,7 +157,6 @@ <property name="right_attach">1</property> <property name="top_attach">0</property> <property name="bottom_attach">1</property> - <property name="x_options">fill</property> <property name="y_options"></property> </packing> </child> @@ -159,33 +184,33 @@ <property name="right_attach">1</property> <property name="top_attach">1</property> <property name="bottom_attach">2</property> - <property name="x_options">fill</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkSpinButton" id="stats-update-interval"> + <widget class="GtkLabel" id="label39"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">True</property> - <property name="update_policy">GTK_UPDATE_IF_VALID</property> - <property name="snap_to_ticks">False</property> + <property name="label" translatable="yes">samples</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="adjustment">5 1 60 1 5 5</property> - <accessibility> - <atkproperty name="AtkObject::accessible_name" translatable="yes">Status Interval</atkproperty> - </accessibility> - <signal name="value_changed" handler="on_stats_update_interval_changed" last_modification_time="Mon, 03 Apr 2006 15:27:12 GMT"/> + <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">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> <property name="y_options"></property> </packing> </child> @@ -213,34 +238,6 @@ <property name="right_attach">3</property> <property name="top_attach">0</property> <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label39"> - <property name="visible">True</property> - <property name="label" translatable="yes">samples</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">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> <property name="y_options"></property> </packing> </child> @@ -329,7 +326,7 @@ <widget class="GtkTable" id="table31"> <property name="visible">True</property> <property name="n_rows">4</property> - <property name="n_columns">2</property> + <property name="n_columns">1</property> <property name="homogeneous">False</property> <property name="row_spacing">0</property> <property name="column_spacing">0</property> @@ -470,6 +467,132 @@ <property name="fill">True</property> </packing> </child> + + <child> + <widget class="GtkFrame" id="frame10"> + <property name="border_width">3</property> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> + + <child> + <widget class="GtkAlignment" id="alignment128"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="border_width">3</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">3</property> + + <child> + <widget class="GtkLabel" id="label348"> + <property name="visible">True</property> + <property name="label" translatable="yes">Install Audio Device:</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.5</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="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="local-sound"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Local VM</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_local_sound_toggled" last_modification_time="Thu, 14 Aug 2008 02:22:14 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="remote-sound"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Remote VM</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_remote_sound_toggled" last_modification_time="Thu, 14 Aug 2008 02:22:08 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label347"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>New VM Preferences</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</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="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> </widget> <packing> <property name="padding">0</property>
_______________________________________________ et-mgmt-tools mailing list et-mgmt-tools@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/et-mgmt-tools