Week 7

It has been two months since the program began. I’ve had various ups and downs when it came to fixing issues. The most trouble I seem to have so far, is with the understanding of the GTK widgets, signals, and their corresponsing handlers. While the documentation is comprehensive and the source code is accessible, it is the lack of examples, that sometimes leave me at a loss.

Talking about leaving me at a loss, I began to work on Browse-activity. It is a powerful activity, with a number of features. I decided that my best approach would be to understand more about WebKit2 API, in particular with the WebKit2.WebView module. I spent a lot of time understanding how the GET requests are made, how the resources from a web page are loaded and so on.

I began to look at the issue of a PDF being downloaded twice. What is means is that, when a download for a PDF is initiated, the GET request which is made first is abandoned or incomplete and a new GET request is made, which essentially downloads the PDF twice. This is bad because it uses more internet bandwidth and causes double-counting in server logs. I began to tackle this issue by repeatedly downloading content on Sugar desktop via Browse-activity to see if indeed the PDF is being downloaded twice. After confirming so, I began to look at the code to investigate further.

As I had mentioned before, python examples of WebKit2.WebView are very few. I had to completely rely on the documentation. WebView API says that anytime a new resource is being downloaded, a policy decision is created. Based on the policy several actions can be taken. These actions, roughly speaking, include Navigation, Ignore, Start and Download. I realised that for downloading a PDF, the action that is being taken is Ignore. I was surprised and on investigating futher I realised that a new GET request is being made elsewhere after taking the Ignore action and this is what is causing for the PDF to be downloaded twice.

After identifying this, it was just a simple process of changing the default action and I fixed the issue. To test it further, my mentor suggested me to run a SimpleHTTPServer and open http://localhost:8000 via Browse-activity. As expected only one GET request was being made.

The second issue I worked upon was the issue of Browse-activity homepage enhancement. The HTML code in the homepage was written 10 years ago and did not conform to the latest standards. Plus it was unintended. I come from a C, Java and Python background. I had little or no experience with HTML and JavaScript, so this was new to me. I researched quite a bit on HTML tags, Div and Span classes, and other customisations.

I also replaced exact pixel values to percentages so that the homepage scales on changing the display resolution of Browse-activity size.

Links to PR: Browse-activity: PR #102 Browse-activity: PR #101

Written on August 13, 2019