Friday, 10 December 2010

zapt code lives here:

bzr branch lp:zapt

Hi hi, new project, xapt, :)


Here is a project i have started on an informal bassis, but is uber xciting from an exploratory pov...


So far so good. Code seems clean and lessons learned seem positive...

Vid to come of the code i have so far worked on...

Monday, 4 October 2010

Old times

I wrote this a while back, its a PathBar port to pyclutter with some added candy and bugs.

This code is old, probably > 12 months?  I am not even sure the code runs nowadays.  Problem with clutter was/is that it did not preform well with certain hardware.  Its a lovely toolkit though that make so many aspects of interface development a real pleasure.

I wanted to post this mostly so I don't forget about it.

Another Paul Henry brain explosion

Maybe people saw this?

@Paul Henry

This tripe actually made me mad.

Paraphrasing MLK; who cares about the skin colour, the place of birth, the faith held dear, it is the content of the heart and the contributions to society that matter.

Clearly this is not a value you hold innately.

Enough with face values! Think before you speak. If this is too much of a challenge or TVNZ priorities are so deranged that they consider antics like this the only way to rate, stop being exploited, or get off air.

I love the fact the Warriors have an Afghani in their team. I love the fact we have a Governor General with a non-Anglo name. I love the fact that Auckland may not be an Anglo/Pacific dominated society in 25-50 years.

If NZ gonna be something worthwhile its gonna have to embrace different and if you ain't excited about that: - welcome to the meteor that's gonna make you a ridiculed fossil.

But I guess you got your indefensible salary for saying this shit so you can keep on truckin'. Sad.

Tuesday, 28 September 2010

Custom Widgets

Published as part of the Ubuntu Community Learning Week

Custom widgets Notes

Plain Text version:


  • This is a collection of realisations i have had with regards my adventures creating custom widgets
  • There are often many ways to accomplish similar ends
  • there may be more correct ways to accomplish things than as presented here
  • this will be a python/gtk/cairo -centric chat

So why would we want to use custom widgets?

  • solve specific problems in interesting and (perhaps) more effective ways
  • Add visual flare and identity to an application
  • encourages experimentation with new ways of interacting with an app or providing feedback
  • great way to get to know the nitty-gritty of toolkits
  • If you are of the right disposition, they can be really fun to code and test
  • If you get good at it, you can free yourself from the default toolkit and let your imagination run wild

What are the draw backs?

  • Can be difficult to test, and get right!
  • Many behaviours that may need implementing to reach the status quo
  • Accessibility issues
  • May not coexist well with different themes or the 'feel' of the surrounding GUI components

Before you start: get familiar with existing widgets

  • Its best to research what existing widgets are capable of. this can save you a lot of time and if often an eye-opener
  • Even if you conclude no gtk widget exists sufficient to your needs, its instructive to see how other widgets are structured, i.e. api and classes may hint at a good architecture for your own widget
  • You are going to have to subclass a gtk widget at some point, which is best?
  • Eventboxes or DrawingAreas or some other gtk widget?
  • Be familiar with what a gtk.Widget provides for free so you dont go implementing unnecessary things


  • IMHO, Provides a great canvas for creating custom widgets
  • receive events such as button-presses, button-releases, key-presses, focus-in... etc
  • A lightweight starting point
  • I am a fan of gtk.EventBox.set_visible_window(False)
  • Your event box no longer draws its own background

Why is having no background good?

  • You can still draw to the area allocated to your EventBox either with cairo or gtk.Style
  • You can achieve a composited effect
  • A parent container could have an unusual background, say a coloured gradient
  • You may want to draw a non-rectangular shape to your EventBox on-top of a funky background

Lets see some code

Python Script:

  • demonstrates drawing on a parent container
  • drawing to your 'own' EventBox
  • connecting to events
  • button-press/release
  • key-press/release
  • focus-in/out

Fitting in: part 1 - gtk.Style

Python Script:

  • gtk.Style provides a palette of colours derived from the current gtk-theme
  • You can access these when drawing your widget or once your widget is realised
  • gtk.Style also provides simple draw methods, handy ones include:
  • paint_layout
  • paint_box
  • paint_flat_box
  • paint_(v|h)line
  • Caveat 1: Some themes do not implement all paint_* methods :(
  • Caveat 2: Often to achieve the desired effect you need to supply the correct 'hint' to the paint method
  • Caveat 3: Hint names can be difficult to track down, usually Google is your friend, failing that, gtk source code is a fall-back
  • Caveat 4: Even with the correct hint things may not draw as expected ;(
  • You may need an actual & realised widget to paint from ;O

  • An example: Say you want to imitate the frame of a gtk.Viewport, achieve the correct colour etc (Note: python-like psuedo-code follows...)
  •*args, window=vbox_window, hint='viewport') = Fail
  • the colour does not reliably match the colour of an actual viewport frame
  •*args, window=vbox_window, hint='viewport') = Success
  • we needed to call the paint_hline method from an actual to achieve the intended result

"style-set" signal

  • If you store colour information or font size, do it in a way such that colours and dimensions can be updated when the user changes themes
  • You can achieve this by connecting to the "style-set" signal

Fitting in: part 2 - cairo and mask_surface

  • Firstly, FYI: cairo rocks. Learn it well :-D
  • using cairo and masking is a another effective way of doing fancy visuals that fit in with their surroundings
  • Its tricky to explain but,
  • With CairoContext.mask_surface(...) you can provide an image with an alpha channel ((semi-)transparent pixels)...
  • and composit it with a colour derived from the gtk-theme
Check out software-center with a dark theme: - the clouds in the Get Software section take on dark greys from the gtk-theme

Cool! So we wrote a custom widget that looks great. What now?

Remember accessibility!

What is accessibility?

Python Script:

  • Its additional contextual information about what your widget does and how it relates to other components around it
  • Example: A visually impaired person may require assistance from a screen reader such as Orca. For Orca to provide meaningful assistance to our user, your widget needs provide information about itself to Orca.

The basics of implementing accessibility

  • Starting with an existing gtk widget gets you a long way, nevertheless...
  • Accessibility can be a tricky topic to get 100% right but there are some basics you should always cover...
  • Firstly, install Orca and Accerciser from the repositories.
  • Testing with these apps will give you a good indication as to how well your app/widget is doing accessibility-wise
  • Read up on the atk toolkit, its the gtk of accessibility

  • What is your widgets name and description?
  • What is its role?
  • How does it relate to other components?

Atk minima:

  • a11y = my_widget.get_accessible()
  • a11y.set_name('..') # this is different from gtk.Widget.set_name()
  • a11y.set_description('..')
  • a11y.set_role( atk.ROLE_* )
  • a11y.set_relationship(..)

Thats all for now. Go wild and experiment with your widget ideas!!!!

Saturday, 14 August 2010

Scrape the audio track from flv video...

gst-launch-0.10 filesrc location=file.flv ! decodebin ! audioconvert ! lame ! filesink location=file.mp3

Saturday, 3 July 2010

Software Center!

So i never got to UDS Part 2, oh well... :P

Nevertheless, I have been busy in Software Center land and i extremely happy with the progress i have been making!

At UDS i managed to demo a pure GTK version of the lobby screen and I also had a coded mockup of a pure GTK detailsview.  Feedback was mostly positive and over the last few months i have continued working on the bits, seeing numerous prototypes and code rewritten time an again!  About 4 weeks ago mpt provided some nice detailed specs from which i could work from with regards an updated lobby screen, so that is what i set about doing.

Now i am settling on what i think will be the code that makes it into Maverick.  I am really happy that past code i have experimented with has been brought forward, matured and is now forming quite a nice library of classes and methods which i have been working with on and ongoing basis.  Such classes i have separated out from their original files into what I am calling mkit, which holds fairly generic (useful) methods and classes.

So far I have seen my file merged into Software Center trunk, along with  Community feedback seems positive, there have been 2 or 3 articles on OMG Ubuntu! and both author and commenteers seem to approve of the implementations.

I am hopeful that my Gtk implementation will be merged into trunk in the next few weeks.  I think it is a really beautiful example of what Gtk is capable of given the time and effort.

In the coming weeks i plan to bring a semi rewrite of up to scratch as i think that looks much nicer than the current incarnation. 

So without further adieu, here are some screenshots of stuff i have been working on lately:

 The Lobby Screen:

The App Details View:

Oh, and pssst!  The latest work is also awesomely Gtk theme friendly!!!  Check out the amazing Dust:

Thursday, 20 May 2010

UDS rundown - Part 1

A bit of background, courtesy the Ubuntu Wiki:

At the beginning of a new development cycle, Ubuntu developers from around the world gather to help shape and scope the next release of Ubuntu. The summit is open to the public, but it is not a conference, exhibition or other audience-oriented event. Rather, it is an opportunity for Ubuntu developers -- who usually collaborate online -- to work together in person on specific tasks. Small groups of developers will participate in short Forum and Workshop (formerly called "BoF"/Birds-of-a-Feather) sessions. This allows a single project to be discussed and documented in a written specification. These specifications will be used for planning the new release of Ubuntu, as described in FeatureSpecifications and TimeBasedReleases.

So there were many sessions that i attended, what i post here is by no means exhaustive, more the stuff that is particularly relevant and of interest to me.

Day 1
On Monday the first session of note was Search and indexing. The session dealt with finding use cases for tracker in Ubuntu. While the technologies behind tracker are impressive there are still significant roadblocks to fulfilling its potential use-cases. I raised the point that in my experience tracker 0.7 is almost counter productive in its current form because it displays so many search results that a user is no closer to finding what they want. Ideally some ranking mechanism is needed, and there was talk of taking trends from zeitgeist and ranking file searches with this added context (exciting!). It also became apparent that there was little awareness of competing products, such as search offerings in Win7, particularly when it came to subtle & contextual UI design to help narrow search results. The gist, tracker does not have useful user facing apps at this point, and is probably not going to be leveraged in Ubuntu 10.10.10 by default.

Ending the day, the OneConf to rule the all session was fascinating. The focus was on making use of Ubuntu One/Ubuntu single-sign-on accounts to sync user settings and configurations. Particularly intriguing for myself as a software-center hacker was the idea to be able to sync installed packages from software-center by leveraging Ubuntu One. Cool. There is a lot of interest from mvo on this subject, so hopefully this feature will materialize during the Maverick development cycle. They also discussed integrating Ubuntu One into the Ubiquity installer, that way many of the installation choices could be synced from the cloud. Also Cool.

Day 2
At the PyGtk base class library for fast app development, the impressive Rick Spencer basically put a call out for ideas for quickly widgets or qwidgets. Qwidgets are widgets that you can get up and running and useful in no more than four lines of python. Suggestions included a text-editor, spreadsheet, google maps, WebCam, MediaPlayer, SQLLiteGrid and Empathy Buddies qwidget's. There was also some discussion around making connecting to event signals (widget.connect('clicked', do_something) more like what is done in C#, there was excitement about the idea but i am not sure if this is a serious consideration.

The Desktop is your IDE session illustrated the innovation capable by the Ubuntu community. The session revolved around a novel experiment called groundcontrol, a project that could reshape our expectations with regards to what a development environment could look like. Still in its infancy, groundcontrol makes it easy for so-called opportunistic developers to get involved in free-software projects. Groundcontrol breaks down many of the hurdles to contributing/bug-fixing, mainly by simplifying launchpad interaction and exposing bzr functionality (lp-login, branch, commit, push, making merge proposals) directly in the gnome file manager (nautilus). Most of the talk was about extending groundcontrol to offer a comprehensive range of development tools (gfx editor, source code viewer, class browser, version control, build environment) in a user-friendly and discoverable way. My recollection is the discussions got a bit side-tracked, but were nonetheless interesting. Following the session I tried groundcontrol; the nautilus integration is very nice, but i found groundcontrol to be a bit buggy and slow compared to the command line. So for now I'll stick with the bzr in the terminal.

At Simpler Image Management in Ubuntu, the current batch of image management tools and newcomer Shotwell were reviewed and compared. After some discussions, Shotwell was selected as the default image manager for Ubuntu 10.10.10. I couldn't agree more as F-spot is a hideous mess. However, Shotwell is not without its fair share of short-comings and todo's. Though, with a full-time effort behind Shotwell, and ubuntu user feedback, Shotwell could become the best free-software image management app! And again supprising that many Ubuntu desktop folk were unfamiliar with the competition, i.e. never used Picasa3, which is in my opinion THE BEST IMAGE MANAGEMENT SOFTWARE available. FYI: Its fast, featureful and free (as in beer) and it runs beautifully on top of wine in Ubuntu.

Dearest to my heart on Tuesday was the Software Center Roadmap. Funnily enough I very nearly missed it as the session showed up in the Foundations track, rather than the Desktop track where i expected it to be! Nevertheless i made it on time and it was great. There was so much positive feedback for the lastest version, and i felt very proud to be apart of the project. There was a quick overview from mpt of the UI changes to come, nothing major, but some tweaks here and there and stuff to handle incoming features. Ratings and reviews seem likely to be pushed out to 11.04, though mvo and Rick Spencer did not see wholly eye-to-eye on this matter, so watch this space. Purchasable apps are a priority for the next release, though a slowly-slowly approach will see only a couple of apps for sale come 11.04, mostly as a way to identify issues and test social and technical procedures. A killer feature slated for inclusion will be the ability to serve up a fresh range software post-release. This is great if you want the latest & greatest apps on offer and takes us a lot closer to the AppStore modus operandi. Apps will be vetted then pushed to PPA which will then be automatically made available to s-c via some sort of PPA broadcast mechanism. I am super excited by this feature as it makes s-c a much more dynamic experience!

Thats all for Part 1. Ciao.

Friday, 14 May 2010

Catch up...

This post comes to you from the Ubuntu Developer Summit, La Hulpe, Brussels.


Tell me six months ago, hell, even two months ago, this would be the case and i would not have believed it for one moment.

So how did i get here? I haven't made a post to this blog in quite some time, but fatefully, my last post is about a little piece of code i wrote called This code exists because i responded to a call for help for a then fledgling application named Ubuntu Software Center (S-C). S-C's purpose is to make it as simple as possible for Ubuntu desktop users to browse and install software from within the myriad of free applications made available on Ubuntu.

A while after i had working, i was put in contact with Michael Vogt, or mvo as he is known online. From this point we started to regularly chat on irc and i became interested in making further contributions to the project. A release later and my code went public to the millions of people around the world who use Ubuntu as their operating system of choice. My personal satisfaction was immense, and i was so excited for the project.

A few months before the release of the Lucid Lynx (the then development version of Ubuntu), mvo said he had put my name forward for sponsorship to UDS Brussels. At the time i thought little of it as it seemed unlikely to me that i would meet their criteria. Thankfully i was wrong!!

So here i am... in Brussels. So far my time here has been great. Along with mvo, i have met the other S-C developers, Gary Lasker and Olivier Tolloy. What a super great team of people we have. Everone is so interesting, humble and friendly. Mvo is amazing, he has undoubted technical skills, he is friendly, quietly spoken and unflappable. Gary has great music taste and has a particularly impressive knowledge of _good_ NZ music for an American. And Olivier is thoughtful, great to have a beer with, and a great room mate. I have also had lunch with fellow New Zealander and design rockstar, Matthew Paul Thomas (mpt) and have had the opportunity to meet many of the other community rockstars.

As a first timer to UDS its been an eye-opening experience. Eye-opening in the sense that the whole exercise is actually a very smooth and efficient process. To see the processes behind one of the worlds greatest collaborative projects is fascinating, and fills you with such a sense of hope. Hope that future will be filled with the similar examples of international generosity and collaboration. The way a diverse community so enthusiastically deals with both the technical and social considerations gives me so much faith in mankind.

So with plans for the future direction of Ubuntu nearing completion, i am as enthused as ever about working with a great team on a hugely exciting project. I look forward to the coming six months with great anticipation.

Kindest Regards,


Friday, 11 September 2009

Ubuntu Software Store location bar prototype

So a call went out for community contributions to the embryonic Ubuntu Software Store, and some tasks were listed.

The Location bar task looked a fun challenge. So I opened gedit and started hacking away with pygtk, cairo and pango. Here are the results:

My list of things to add:
o Make the parts clickable
o I want to support icons [Done] 
o I want to try and animate the addition of parts [Done] 

o Add a navigate-back button for when the pathbar becomes too big for the allocated width.

Code is here.