SimpleLensesWithSinglet

Dev Week -- Simple Lenses with Singlet -- mhall119 -- Thu, 3rd Feb, 2012

   1 [16:01] <mhall119> alright, welcome everybody
   2 [16:02] <mhall119> so what is Singlet?
   3 [16:02] <mhall119> well, it's a python library for writing Unity lenses
   4 [16:03] <mhall119> but Lenses are just DBus and GObject, they don't *need* a dedicated python library
   5 [16:03] <mhall119> in fact, many community lenses are already being written in python withut Singlet
   6 [16:03] <mhall119> so then, why Singlet?
   7 [16:04] <mhall119> because as a Python developer, I hate GObject and DBus
   8 [16:04] <mhall119> it's not that they're bad technologies, it's just that they're not "pythonic"
   9 [16:04] <mhall119> so using them in python feels unnecessarily complicated
  10 [16:05] <mhall119> I wrote my first 2 Unity lenses using them, and Singlet developed out of that
  11 [16:06] <mhall119> 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
  12 [16:06] <mhall119> Singlet does this with a combination of traditional object-oriented abstraction, and a bit of Python meta-class programming
  13 [16:06] <mhall119> http://mhall119.com/2011/12/writing-unity-lenses/ gives an introduction and has some example source code
  14 [16:07] <mhall119> whoops, wrong link
  15 [16:07] <mhall119> http://mhall119.com/2012/01/simplified-unity-lens-development-with-singlet/
  16 [16:07] <mhall119> that one
  17 [16:07] <mhall119> if anybody here has done any Django programming, it should look familiar to you
  18 [16:08] <mhall119> 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
  19 [16:08] <mhall119> Singlet does the same, you give it a little meta-data to describe your lens
  20 [16:08] <mhall119> define some categories
  21 [16:08] <mhall119> and then implement the search() method
  22 [16:09] <mhall119> and behind the scenes it's instantiating the GObject classes you'll need and connecting everything to DBus for you
  23 [16:10] <mhall119> 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
  24 [16:10] <mhall119> any questions so far on what Singlet is?
  25 [16:11] <mhall119> alright, moving along
  26 [16:11] <mhall119> 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
  27 [16:12] <mhall119> 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
  28 [16:12] <mhall119> In Singlet 0.1, which only works on Oneiric, this was all it could do
  29 [16:13] <mhall119> but Singlet 0.2, which was upgraded for Precise, introduces the ability to separate them
  30 [16:13] <mhall119> http://mhall119.com/2012/01/singlet-part-0-2/
  31 [16:13] <mhall119> Singlet 0.2 is being packaged for Precise, and will be available in the default repositories
  32 [16:14] <mhall119> this means you can write lenses and scopes that use Singlet, and make them easily installable
  33 [16:15] <mhall119> 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
  34 [16:15] <mhall119> and it also means that you have a compatibility layer between your code and any possible API changes
  35 [16:15] <mhall119> for example, in the move from Unity 4(Oneiric) to Unity5(Precise), the Lens API changed
  36 [16:15] <mhall119> but Singlet's API didn't
  37 [16:16] <mhall119> so a Lens written for Singlet 0.1 on Oneiric would be able to run without modification on Singlet 0.2 on Precise
  38 [16:18] <mhall119> As for packaging, sometime soon we will have a Quickly template for writing Singlet lenses and scopes
  39 [16:18] <mhall119> for anybody not familiar with Quickly, it's a tool for rapid application development
  40 [16:19] <mhall119> 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)
  41 [16:19] <mhall119> it also provide packaging files for you, so that your app can be uploaded to the Ubuntu Software Center
  42 [16:19] <mhall119> there are already  a handful of Unity lenses and scopes in the Software Center
  43 [16:20] <ClassBot> There are 10 minutes remaining in the current session.
  44 [16:20] <mhall119> 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
  45 [16:21] <mhall119> 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
  46 [16:21] <mhall119> and, hopefully, a large number of them will be doing it with Singlet
  47 [16:21] <mhall119> alright, any questions before I'm out of time?
  48 [16:23] <mhall119> alright, thanks to those you attended
  49 [16:24] <mhall119> anybody interested can get the project and code from https://launchpad.net/singlet
  50 [16:24] <mhall119> 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
  51 

MeetingLogs/devweek1201/SimpleLensesWithSinglet (last edited 2012-02-03 09:29:02 by dholbach)