Implementing the PlaybackPopover on Music

Hey everyone!

In the last post, I told that I was working on static version of PlaylistPopover (which now I’ll call PlaybackPopover or PlaybackBuffer since it doesn’t show just playlists that you create).

Now, I finally started to work on Music base code, although I’m still using the static version for testing and such.

First of all, I needed to study and figure out how to catch the current playback to print that in the console. I got this information in Player.playlist, and after worked the data I was able to do that.

Then, I needed attach my static script on gnome-music.

To do that, I was able to use the UI file that I had done for static version, just making a small changes (like changing ID names).

In the python part, I needed to rewrite almost all the code to adapt to gnome-music (although the logic be the same). So, I could print the current playback in the new Music popover and no longer on the console.

This is a first screenshot of PlaybackBuffer on Music:

I created a new github repository which is separated from the static script (which link I posted on the last post) to work with gnome-music freely.

As I also mentioned in the last post, I have some difficulties to implement a Gtk.ListBox with a model. The documentation is not clear enough and I didn’t find any examples of implementation.

My mentor was working in a personal project which uses Gtk.ListBox with model. He sent me an example and discussed with me. That helped me to understand better how to implement it, succeeding this time.

Since I had these difficulties, I have decided to do a little tutorial to help someone who also has difficulties with it.

I’ll post that and I also will post an example on GNOME Developer Platform Demos.

It has been very gratifying to work with gnome-music and to see my work taking shape.

Now, I’m implementing a Gtk.Stack which will select between these tree popover layouts according the view selected by the user.

But this is subject to the next post! 😉

I see you there!

Improving my Gtk and Music knowledge


Happy new year for everyone!

It is time for a new report about my progress on Outreachy :)

During the past few weeks I have studied about how to work with Gtk. It was necessary since I didn’t have so many experience with it. Also, I have taken a time to understand how Gnome Music works.

One of the results of this is a static current playlist widget implementation that I mentioned in the last post. You can take a look at it here.

Screenshot from 2016-01-09 01-52-31

Obviously it still need to be aesthetically polished but I will let to do this later. As I said, right now I’m focused on to learn and in how things work.

To accomplish it, I used the following approach:

  1. I coded everything without any worries about code style or good practices (aka spiking code). The reasons for this are to focus on learning the basis and to do not distract myself with anything
  2. After have understood what is needed to be done, I rewrote everything trying to achieve a better code quality.

Being more specific, in the first step I coded everything using just Python, without any shortcuts or tools that would facilitate my job.

In the second step, I’ve decided to use Glade to generate the widget structure to than import it using Gtk.Builder. This final approach follows the way that Music works (and probably almost every Gnome App) which permits to separate logic from UI in a better way.

After have completed this steps I’m feeling that I have learned many concepts of GTK and that I’m more prepared to accomplish my Outreachy project.

Finally, I would like to mention one main difficult that I faced. My mentor suggested me to use a ListBox with a ListModel to display the playlist itself. But, until now, I didn’t find a way on how to do this in Python. The documentation is not clear enough and I didn’t find any example of implementation. Well, for now, the solution discussed with my mentor is to forget the ListModel and just use ListBox.

Oh, and I almost forgot, I also take a look on Gnome Music code to find a way to retrieve the data that I will use to feed my widget. It looks like the Player.playlist has the information that I need. I was able to iterate over it and print on terminal the current playlist.

With the static widget and the needed data, I’m going to implement the widget on Music in the next week (the thing is starting to get serious :D). I’m very excited to this and I hope to make a great job.

See you in the next post!