I spent the past week working mainly on backend code for the listview. I found that most of my effort this week went to figuring out how the necessary classes functioned.
To start with, last week I stole some code from GNOME Shell and tried to dissect it so I could see how it dealt with things like scope within closures, and callbacks. When I code in Java, I generally use an IDE. When I was first learning concepts (like loops, which were difficult to understand at first, and recursion) I generally put the code into the IDE, inserted a break point, and stepped through the code so I could see how the variables changed values. Replicating that process with the terminal, with GJS, has been interesting: I end up inserting logging into my code so I can easily match my debug output to my code, and then read them side by side to determine how execution is happening.This is not quite as user-friendly as an IDE GUI: a single run of the application with debug set to 6 yields ~33,000 lines of output. So, yeah. Usually I set debug to 3 :)
After reading some code over and over (mainly selections.js from Documents, but also random blog posts on the internet, Stack Overflow, and whatever else I could find), I could understand the Shell code enough to be able to re-write it. After that I moved on to writing the gstreamer code.
Last week Bastien pointed me to some Gst.Discoverer code in Totem. Again, what I accomplished was getting the basic structure set up and functioning so I can fill in details (such as which tags to discover) as I go along.
I also started to add a basic playback functionality and spent some time being driven insane by a bug. It turned out that I had a bug in the "Record" toggle button which was setting the pipeline state to paused when the button was inactive (that is, when I pressed "Stop"), so I never received eos messages on the Gst.Bus and consequently never set the pipeline state to null.
This coming week I am planning to work on an object that stores the uris and dates that I retrieve from the GFileEnumerator. Since I only want to load fifty files at a time into the listview, I also need to implement a sensible sorting algorithm to sort by most recent before I store the information (although I think GFileEnumerator does this already). I'm planning to read the code for Rhythmbox in tomorrow to see if it is helpful; so far most of the applications I've read through seem to use database queries for this, rather than implementing it by hand. Anyway, I think it will be an interesting problem, and hopefully I can write a decent solution :) After it is finished, I will add a "load file" object to play.js and a "load more" object to listview.js.
No comments:
Post a Comment