January 2018
Beginner to intermediate
454 pages
10h 8m
English
The other feature to add is to show a bigger cover when we click the play button. We'll start by adding a function to get the image from the selection in the playlist:
pub fn pixbuf(&self) -> Option<Pixbuf> { let selection = self.treeview.get_selection(); if let Some((_, iter)) = selection.get_selected() { let value = self.model.get_value(&iter, PIXBUF_COLUMN as i32); return value.get::<Pixbuf>(); } None }
This method to be added to the Playlist structure starts by getting the selection; if there's one, it simply gets the pixbuf from the model and returns it. Otherwise, it returns None.
We can now write a function that will fetch the cover from the playlist and show the image:
use gtk::Image; use ...