== Dev Week -- Simple Lenses with Singlet -- mhall119 -- Thu, 3rd Feb, 2012 == {{{#!irc [16:01] alright, welcome everybody [16:02] so what is Singlet? [16:02] well, it's a python library for writing Unity lenses [16:03] but Lenses are just DBus and GObject, they don't *need* a dedicated python library [16:03] in fact, many community lenses are already being written in python withut Singlet [16:03] so then, why Singlet? [16:04] because as a Python developer, I hate GObject and DBus [16:04] it's not that they're bad technologies, it's just that they're not "pythonic" [16:04] so using them in python feels unnecessarily complicated [16:05] I wrote my first 2 Unity lenses using them, and Singlet developed out of that [16:06] so Singlet itself works to hide all of those non-pythonic bits from you, so as a developer you get a nice, clean, simple interface [16:06] Singlet does this with a combination of traditional object-oriented abstraction, and a bit of Python meta-class programming [16:06] http://mhall119.com/2011/12/writing-unity-lenses/ gives an introduction and has some example source code [16:07] whoops, wrong link [16:07] http://mhall119.com/2012/01/simplified-unity-lens-development-with-singlet/ [16:07] that one [16:07] if anybody here has done any Django programming, it should look familiar to you [16:08] that's because I borrowed heavily form the way Django used simple Python classes as models, and from there can automatically do a lot of the boiler-plate work for you [16:08] Singlet does the same, you give it a little meta-data to describe your lens [16:08] define some categories [16:08] and then implement the search() method [16:09] and behind the scenes it's instantiating the GObject classes you'll need and connecting everything to DBus for you [16:10] Singlet also includes helper commands for running your Lens as a daemon process, and generating the .lens and .service files needed to install it, all from the meta-data you provide [16:10] any questions so far on what Singlet is? [16:11] alright, moving along [16:11] the example given in http://mhall119.com/2012/01/simplified-unity-lens-development-with-singlet/ shows how to make a simple Lens with one built-in Scope [16:12] if you attended davidcalle and mhr3's Lens session on Tuesday, you'll know that they can either exist in the same code, or separate code [16:12] In Singlet 0.1, which only works on Oneiric, this was all it could do [16:13] but Singlet 0.2, which was upgraded for Precise, introduces the ability to separate them [16:13] http://mhall119.com/2012/01/singlet-part-0-2/ [16:13] Singlet 0.2 is being packaged for Precise, and will be available in the default repositories [16:14] this means you can write lenses and scopes that use Singlet, and make them easily installable [16:15] Now you don't *have* to use Singlet to write a Python lens, but it cuts the amount of code you need to write to get one started in half [16:15] and it also means that you have a compatibility layer between your code and any possible API changes [16:15] for example, in the move from Unity 4(Oneiric) to Unity5(Precise), the Lens API changed [16:15] but Singlet's API didn't [16:16] so a Lens written for Singlet 0.1 on Oneiric would be able to run without modification on Singlet 0.2 on Precise [16:18] As for packaging, sometime soon we will have a Quickly template for writing Singlet lenses and scopes [16:18] for anybody not familiar with Quickly, it's a tool for rapid application development [16:19] it'll create any files and directories you need to get started on a specific kind of project (like command-line program, desktop app, or Unity lens) [16:19] it also provide packaging files for you, so that your app can be uploaded to the Ubuntu Software Center [16:19] there are already a handful of Unity lenses and scopes in the Software Center [16:20] There are 10 minutes remaining in the current session. [16:20] and with Singlet + Quickly, we'll open the door for opportunistic developers to put together lenses that will feed their desired content directly into the Unity dash [16:21] Lenses are one of the most exciting and unique features for extending Unity, and I expect to see a large number of them being developed for Ubuntu 12.04 [16:21] and, hopefully, a large number of them will be doing it with Singlet [16:21] alright, any questions before I'm out of time? [16:23] alright, thanks to those you attended [16:24] anybody interested can get the project and code from https://launchpad.net/singlet [16:24] and the above blog entries will serve as a tutorial for writing Singlet lenses and scope, at least until I can put a more formal tutorial together }}}