2016-04-09

In The Beginning...

Years ago, when I first heard that Ubuntu Touch would have apps written in QML, I decided to write a Qt based front end for MuttonChop!. My logic was, if Ubuntu is using QML then there will be support for Qt. With my favorite text editor at the ready, I began to hack together some Python code to make a Qt application using Pyside.

Since all of my MuttonChop! related projects are named after sideburn sporting figures from California history, this project was named after Commodore John F Stockton. The project name has stayed, but from the very beginning the project strayed from being a MuttonChop! controller to something completely different.

Once the basics of the main UI window for Stockton had been coded, I thought "hey, why not just add a WebKit WebView to access the Mobile UI for MuttonChop?". Being lazy and not wanting to code another MuttonChop UI, I did just that. From there, a URL input was added to give the end user a way of changing the URL displayed in the WebView.

After that, I opened a URL in Stockton, resized the window, and moves the window to a specific location on my desktop. Suddenly there was a need to always have a Stockton window open in a fixed location on my desktop when Stockon is launched with a certain url. Bang zoom, clacking the keyboard, and the main features of Stockon were done.

Fast-Forward a Bit...

There were actions that I wanted to perform using my mobile device and it was necessary to write a few "apps" to get the job done. Aside from doing what the apps were supposed to do, I wanted them to "run" on all mobile devices as well as on the desktop, and the easiest way for me to accomplish that feat was to write the apps using HTML, Javascript, and CSS, and then access the apps via a web browser on any given machine. For the most part, all of the apps ran fine in Stockton on my desktop. However...

Problems Were Encountered

  • CORS... fucking CORS!

    CORS is what makes writing an app that runs in a webbrowser such an amazing pain in the ass. When I write a python app that makes web requests, I simply write some code to make a request, and then process the result of the request. This is the same with Ruby, and Vala, and just about every other programming language... with the exception of JavaScript running in a browser. CORS is what limits apps in a browser from only making AJAX request to files on the same server hosting the app.

    Fortunately, the WebKit1 library fully allows developers to configure a WebView to load local files and let those local files make XmlHttpRequests to remote web servers. Thanks WebKit1!

    Sadly, WebKit2 doesn't seem to have this feature.

  • Debugging

    For some unknown reason, not all of my code works as expected and it is good to be able to debug stuff. By setting the "enable-developer-extras" property to True, I was able to um.... enable developer extras, and this adds "inspect element" to the contextual menu when one right-clicks on a stockton webview.

Wooooweee! After updating the code, not only did I have a fine desktop application, I also had a rudimentary HTML5 compliant browser that would run on an n900.

I prefer Gtk

It's true, aesthetically I prefer Gtk to Qt. Although I think I might prefer Qt to Gtk from a developer point of view.
Anyway, I figured it was time to port Stockton from Python2 to Python3, and this necessitated switching from Pyside to either PyQt or Gtk. In this regard, I went with Gtk. At the same time that I was porting to Gtk, I also attempted to port to WebKit2. Lamentably, it was during the port that I discovered WebKit2 lacked the ability to disable that CORS crap. Oh well, I submitted a bug for the missing WebKit2 feature, and switched to WebKit1.

While porting the code, I was fortunate to find https://lazka.github.io/pgi-docs/ which is an indispensable documentation source when using Python and Gobject Introspection to access various libraries from Python. Since the documentation is in HTML format, I downloaded the docs, and run them in Stockton... because I can. :)

Now quit reading, and go create a solution to a problem.

Oh yea, if you are interested in such things the source is available at https://gitlab.com/jezra/stockton

Comments
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
7 plus 9
Answer:
required
subscribe
 
2019
2016
2015
2014
2013
2012
2011
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008