Re: [PATCH] virt-manager: show sound devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 28, 2008 at 11:51:28AM -0400, Cole Robinson wrote:
> The attached patch teaches virt-manager how to parse
> sound device xml for virtual machines. Each separate
> <sound model='blah'/> will show up as a separate
> device in the VM details listing. The patch also
> implements deleting these devices.

ACK this is good.

> 
> I put a screenshot up that should explain most of the
> changes:
> 
> http://crobinso.fedorapeople.org/virt-manager/vmm-sound.png

We sooooo badly need to find us a graphic designer who can build
a complete set of proper icons for  CPU, memory, disk, NIC, sound,
input, PCI and USB devices. The icons we use currently just look
rubbish - i'm inclined to say we should get rid of them unless
we can get good graphics because they're not really adding value
anymore.


> diff -r f4c491621a10 -r 8a86b6ed3a80 src/virtManager/details.py
> --- a/src/virtManager/details.py	Wed Jul 23 16:23:56 2008 -0400
> +++ b/src/virtManager/details.py	Wed Jul 23 17:24:12 2008 -0400
> @@ -55,6 +55,7 @@
>  HW_LIST_TYPE_NIC = 4
>  HW_LIST_TYPE_INPUT = 5
>  HW_LIST_TYPE_GRAPHICS = 6
> +HW_LIST_TYPE_SOUND = 7
>  
>  # Console pages
>  PAGE_UNAVAILABLE = 0
> @@ -252,6 +253,7 @@
>              "on_config_network_remove_clicked": self.remove_network,
>              "on_config_input_remove_clicked": self.remove_input,
>              "on_config_graphics_remove_clicked": self.remove_graphics,
> +            "on_config_sound_remove_clicked": self.remove_sound,
>              "on_add_hardware_button_clicked": self.add_hardware,
>  
>              "on_details_menu_view_fullscreen_activate": self.toggle_fullscreen,
> @@ -536,6 +538,8 @@
>                  self.refresh_input_page()
>              elif pagetype == HW_LIST_TYPE_GRAPHICS:
>                  self.refresh_graphics_page()
> +            elif pagetype == HW_LIST_TYPE_SOUND:
> +                self.refresh_sound_page()
>              elif pagetype == HW_LIST_TYPE_BOOT:
>                  self.refresh_boot_page()
>                  self.window.get_widget("config-boot-options-apply").set_sensitive(False)
> @@ -720,6 +724,8 @@
>                      self.refresh_input_page()
>                  elif pagetype == HW_LIST_TYPE_GRAPHICS:
>                      self.refresh_graphics_page()
> +                elif pagetype == HW_LIST_TYPE_SOUND:
> +                    self.refresh_sound_page()
>  
>      def refresh_summary(self):
>          self.window.get_widget("overview-cpu-usage-text").set_text("%d %%" % self.vm.cpu_time_percentage())
> @@ -889,6 +895,21 @@
>                  self.window.get_widget("config-input-remove").set_sensitive(False)
>              else:
>                  self.window.get_widget("config-input-remove").set_sensitive(True)
> +
> +    def refresh_sound_page(self):
> +        vmlist = self.window.get_widget("hw-list")
> +        selection = vmlist.get_selection()
> +        active = selection.get_selected()
> +        if active[1] is None:
> +            return
> +        sound = active[0].get_value(active[1], HW_LIST_COL_DEVICE)
> +        self.window.get_widget("sound-model").set_text(sound[3])
> +
> +        # Can't remove sound dev from live guest
> +        if self.vm.is_active():
> +            self.window.get_widget("config-sound-remove").set_sensitive(False)
> +        else:
> +            self.window.get_widget("config-sound-remove").set_sensitive(True)
>  
>      def refresh_boot_page(self):
>          # Refresh autostart
> @@ -1296,6 +1317,18 @@
>              self.remove_device(xml)
>              self.refresh_resources()
>  
> +    def remove_sound(self, src):
> +        vmlist = self.window.get_widget("hw-list")
> +        selection = vmlist.get_selection()
> +        active = selection.get_selected()
> +        if active[1] is None:
> +            return
> +        sound = active[0].get_value(active[1], HW_LIST_COL_DEVICE)
> +
> +        xml = "<sound model='%s'/>" % sound[3]
> +        self.remove_device(xml)
> +        self.refresh_resources()
> +
>      def prepare_hw_list(self):
>          hw_list_model = gtk.ListStore(str, str, int, gtk.gdk.Pixbuf, int, gobject.TYPE_PYOBJECT)
>          self.window.get_widget("hw-list").set_model(hw_list_model)
> @@ -1426,6 +1459,25 @@
>              if missing:
>                  hw_list_model.insert(insertAt, [_("Display"), gtk.STOCK_SELECT_COLOR, gtk.ICON_SIZE_LARGE_TOOLBAR, None, HW_LIST_TYPE_GRAPHICS, graphic])
>  
> +        # Populate list of sound devices
> +        currentSounds = {}
> +        for sound in self.vm.get_sound_devices():
> +            missing = True
> +            insertAt = 0
> +            currentSounds[sound[3]] = 1
> +            for row in hw_list_model:
> +                if row[HW_LIST_COL_TYPE] == HW_LIST_TYPE_SOUND and \
> +                   row[HW_LIST_COL_DEVICE][3] == sound[3]:
> +                    # Update metadata
> +                    row[HW_LIST_COL_DEVICE] = sound
> +                    missing = False
> +
> +                if row[HW_LIST_COL_TYPE] <= HW_LIST_TYPE_SOUND:
> +                    insertAt = insertAt + 1
> +            # Add in row
> +            if missing:
> +                hw_list_model.insert(insertAt, [_("Sound: %s" % sound[3]), gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_LARGE_TOOLBAR, None, HW_LIST_TYPE_SOUND, sound])
> +
>          # Now remove any no longer current devs
>          devs = range(len(hw_list_model))
>          devs.reverse()
> @@ -1441,6 +1493,9 @@
>              elif row[HW_LIST_COL_TYPE] == HW_LIST_TYPE_INPUT and not currentInputs.has_key(row[HW_LIST_COL_DEVICE][3]):
>                  removeIt = True
>              elif row[HW_LIST_COL_TYPE] == HW_LIST_TYPE_GRAPHICS and not currentGraphics.has_key(row[HW_LIST_COL_DEVICE][3]):
> +                removeIt = True
> +            elif row[HW_LIST_COL_TYPE] == HW_LIST_TYPE_SOUND and not \
> +                 currentSounds.has_key(row[HW_LIST_COL_DEVICE][3]):

If we're going to break long lines, break all of them in that
conditional :-)


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux