[15:55] <dpm> Allright, we're about to start the 3rd day of Ubuntu App Developer Week, is everyone ready?
[16:00] <dpm> All right, let's get started!
[16:00] <dpm> Welcome to the 3rd day of Ubuntu App Developer Week
[16:01] <ClassBot> Logs for this session will be available at http://irclogs.ubuntu.com/2011/09/07/%23ubuntu-classroom.html following the conclusion of the session.
[16:01] <dpm> Our first speaker has developed a really slick app to check your webmail directly from your desktop. Welcome Dmitry Shachnev who's going to tell us all about Unity Mail!
[16:01] <dpm> mitya57, I'll leave the room for you now
[16:01] <mitya57> So, let's start
[16:01] <mitya57> I'm Dmitry Shachnev, currently student at Moscow University
[16:02] <mitya57> I am developer of Unity Mail,
[16:02] <mitya57> ReText (retext.sf.net),
[16:02] <mitya57> TQ Educational suite (tq-suite.sf.net) and some other things
[16:03] <mitya57> Since my first distro was Mandriva, I'm also known as Mandriver
[16:03] <mitya57> Unity Mail is an application that displays unread messages count on your Launcher,
[16:04] <mitya57> as well as Notify-OSD notifications
[16:04] <mitya57> and mail subjects in Messaging Menu (this is currently only for Oneiric)
[16:05] <mitya57> It works with any IMAP4 or IMAP4-SSL server, not only with GMail as some people think
[16:05] <mitya57> It also support multiple accounts
[16:05] <mitya57> *supports
[16:06] <mitya57> It's written in Python and uses GObject-Introspection,
[16:06] <mitya57> I'll say more about this later
[16:07] <mitya57> Three days ago I released the new version, 0.8
[16:07] <mitya57> (the Natty backport will come soon, too)
[16:07] <mitya57> It has Messaging Menu integration and new configuration dialog
[16:08] <mitya57> Screenshot: http://ubuntuone.com/4VNpTopZZxmGN2fyXY4ZmD
[16:08] <mitya57> It's also the first release working on Oneiric
[16:08] <mitya57> So, now about used technologies
[16:09] <mitya57> GObject-Introspection (http://live.gnome.org/GObjectIntrospection) is a new GNOME framework
[16:10] <mitya57> for accessing C-language API in many languages,
[16:10] <mitya57> such as Python, Vala, and so on
[16:11] <mitya57> In Ubuntu, Python bindings are provided by python-gobject package
[16:12] <mitya57> The most known component is Gtk API,
[16:12] <mitya57> which allows working with both Gtk2 and Gtk3
[16:12] <mitya57> It's recommended alternative for PyGtk,
[16:13] <mitya57> read more about porting here: http://live.gnome.org/PyGObject/IntrospectionPorting
[16:13] <mitya57> But there are many other bindings,
[16:14] <mitya57> You can use any API provided by gir1.2-* packages
[16:14] <mitya57> Here is Unity Mail's import string:
[16:14] <mitya57> from gi.repository import GObject, GLib, Gtk, Unity, Notify, Indicate
[16:15] <mitya57> The last three are Ubuntu-specific technologies, so let's speak more
[16:15] <mitya57> about them
[16:16] <mitya57> Unity Launcher API provides a way to set a count badge or a progress-bar
[16:17] <mitya57> for a specific .desktop file
[16:17] <mitya57> https://wiki.ubuntu.com/Unity/LauncherAPI
[16:17] <mitya57> This page contains an overview and code examples for Python and Vala
[16:18] <mitya57> Indicate API
[16:18] <mitya57> It provides a way to add an indicator to your panel, or integrate
[16:19] <mitya57> with existing menu (Messaging Menu in my case)
[16:20] <mitya57> I used this page as a documentation:
[16:20] <mitya57> http://www.kryogenix.org/days/2011/01/16/working-with-the-ubuntu-messaging-menu
[16:21] <mitya57> Note that UM doesn't make that envelope blue or green, it just add some items
[16:21] <mitya57> If you want to add your items to Messaging Menu,
[16:22] <mitya57> you'll need to set up a server (basically the container connected to a .desktop file_
[16:22] <mitya57> and any number of clients (entries)
[16:23] <mitya57> Each entry can contain a time (which'll be displayed like "30 min" or "2 h")
[16:23] <mitya57> or just a number (count), i.e you can add a client titled "Inbox" with a mails count
[16:24] <mitya57> Time in UM case
[16:24] <mitya57> Then, Notify API
[16:24] <mitya57> You SHOULD NOT use pynotify because it is based on Gtk2 and is deprecated
[16:25] <mitya57> Gir-Notify usage is very simple, like this:
[16:25] <mitya57> Notify.init('unity-mail')
[16:26] <mitya57> Notify.Notification.new(title, message, icon).show()
[16:26] <mitya57> You can see more advanced-usage examples in 'tests' directory
[16:26] <mitya57> of libnotify tarball
[16:27] <mitya57> And there is one another important component - GNOME Keyring
[16:28] <mitya57> Currently there's no Gir for it - wait a moment, I'll find a bug about that
[16:29] <mitya57> It's https://bugs.launchpad.net/ubuntu/+source/libgnome-keyring/+bug/802173
[16:29] <mitya57> and https://bugzilla.gnome.org/show_bug.cgi?id=598414 for upstream
[16:29] <mitya57> so we use python-gnomekeyring binding,
[16:30] <mitya57> which is the only reason for us not moving to Python3
[16:30] <mitya57> Also, it adds a Gtk2 dependency, so I really don't like it
[16:31] <mitya57> You can read more about it here:
[16:31] <mitya57> http://blogs.codecommunity.org/mindbending/bending-gnome-keyring-with-python-part-1/
[16:32] <mitya57> Credits to Andre Ryser who added GNOME Keyring support to UM
[16:32] <mitya57> Now a bit about translations
[16:32] <mitya57> UM uses gettext for translations and Launchpad for hosting them
[16:33] <mitya57> Also, it uses desktop2gettext script to generate .po (source) files from .desktop files
[16:33] <mitya57> (There are actually 2 desktop files used in UM:
[16:34] <mitya57> The main, that displays in Launcher, and another one which is copied to your
[16:34] <mitya57> ~/.config/autostart/ directory and is used for auto-starting Unity Mail)
[16:35] <mitya57> http://bazaar.launchpad.net/~chromium-team/chromium-browser/chromium-translations-tools.head/view/head:/desktop2gettext.py
[16:35] <mitya57> (Originally it was developed for Chromium)
[16:35] <mitya57> More about gettext: http://docs.python.org/library/gettext.html
[16:36] <mitya57> More about using Launchpad for translating your project: https://help.launchpad.net/Translations/YourProject
[16:37] <mitya57> There were even 2 sessions about this in previous AppDeveloperWeek
[16:38] <mitya57> And also we use Bazaar for hosting code.
[16:39] <mitya57> Now - some future plans for Unity Mail
[16:39] <mitya57> You know why Unity Mail is better than other mailing clients
[16:40] <mitya57> (like Thunderbird and Evolution)
[16:40] <mitya57> First, it's written especially for WebMail services
[16:41] <mitya57> When you click it's icon your mail is opened in a web browser
[16:41] <mitya57> It uses GMail links by default, but you can set your own in the new configuration dialog
[16:41] <mitya57> You can even set a custom command by starting the URL with 'Exec:'
[16:42] <mitya57> dpm, I plan to release 1.0 firstly
[16:42] <ClassBot> dpm asked: have you thought about submitting Unity Mail for inclusion in Ubuntu?
[16:42] <mitya57> And I'll release it when there will be a gir for gnomekeyring
[16:43] <mitya57> and I'll be able to use Py3K
[16:43] <mitya57> So, some ideas for future versions:
[16:44] <mitya57>  - More configuration options, like disabling Messaging Menu
[16:44] <mitya57>    or even  Unity Launcher :)
[16:44] <mitya57>  - "Mark all as read" option
[16:45] <mitya57>   - (I don't yet know if it's possible) - Opening a mail when you click on it in the Messaging Menu
[16:46] <mitya57>  - And it really needs a new icon, maybe someone will help me with it?
[16:47] <mitya57> So, I think, that's all
[16:47] <mitya57> Please ask your questions
[16:50] <ClassBot> There are 10 minutes remaining in the current session.
[16:51] <ClassBot> gnomie asked: if i decided to give UM a try, will it conflict with thunderbird (which is already set up)?
[16:51] <mitya57> gnomie no, it won't
[16:52] <mitya57> If I have another five minutes, I'll advertise my another app - ReText editor
[16:53] <mitya57> It's an editor for markup languages, such as Markdown and reStructuredText
[16:53] <mitya57> It allows you to control all your formatting and storing documents in plain text files
[16:53] <mitya57> But it supports export to ODT, PDF, HTML and whatever you want via plugins
[16:54] <mitya57> Also it can upload documents to Google Docs
[16:55] <mitya57> And it supports tabs, which is very useful feature
[16:55] <mitya57> Screenshot: https://sourceforge.net/p/retext/screenshot/retext.png
[16:55] <mitya57> Web-site: http://retext.sourceforge.net/
[16:55] <ClassBot> There are 5 minutes remaining in the current session.
[16:55] <mitya57> It's available in my PPA, too (ppa:mitya57)
[16:59] <dpm> thanks mitya57 for a great session!
[16:59] <mitya57> So, good bye (=
[17:00] <dpm> Next up, Jelmer Vernooij will tell us all about using Launchpad for creating build recipes to rapidly get your packages to users
[17:00] <ClassBot> Logs for this session will be available at http://irclogs.ubuntu.com/2011/09/07/%23ubuntu-classroom.html following the conclusion of the session.
[17:01] <jelmer> Hello!
[17:02] <jelmer> My name is Jelmer Vernooij. I currently work in the Bazaar team at Canonical, and before that I worked on Launchpad.
[17:02] <jelmer> This app developer week session is going to be about source package recipe builds.
[17:02] <jelmer> I am going to assume that everybody here is familiar with at least basic Debian packaging. If you are not, the Ubuntu packaging guide is a great start. See http://developer.ubuntu.com/packaging/html/
[17:03] <jelmer> You should also have some familiarity with a distributed version control system. Recipe builds on Launchpad use Bazaar. A quick introduction about Bazaar can be found at http://doc.bazaar.canonical.com/latest/en/mini-tutorial/
[17:03] <jelmer> Please do interrupt me with questions if you have any.
[17:04] <jelmer> Today we are going to create a basic recipe for a small project. I have a project in mind (pydoctor), but if somebody has other suggestions I am also happy to do another project (nothing like living on the edge and doing this live).
[17:04] <jelmer> Does anybody have a suggestion for a project that doesn't take too long to build?
[17:05] <jelmer> Source package recipes are, like cooking recipes, a description of a set of ingredients (branches in this case) and a description of how to meld them together.
[17:06] <jelmer> The result of a recipe is usually a Debian source package.
[17:07] <jelmer> You can write and build recipes locally by installing the "builder" plugin for Bazaar ("apt-get install bzr-builder"). This is quite convenient when writing and testing recipes.
[17:08] <jelmer> Launchpad can also build recipes for you, and can directly upload the resulting source package to a PPA.
[17:08] <jelmer> It can do this a single time, or you can have it build the recipe daily (as long as one of the branches involved in the recipe has changed).
[17:09] <jelmer> This makes it very easy to do daily builds of a project, because Launchpad can automatically grab the source code out of the upstream version control system, as long as Launchpad can import from the upstream version control system.
[17:11] <jelmer> Once a recipe has been set up your PPA will automatically receive new packages, fresh from trunk, every day.
[17:11] <jelmer> Does anybody have a suggestion of a project we should create a recipe for?
[17:14] <jelmer> I guess not, so let's go with pydoctor (a API documentation generator for Python).
[17:14] <jelmer> Every recipe has a "base" branch> This is usually the trunk of the upstream project you're building.
[17:14] <jelmer> In our case, it would be lp:pydoctor
[17:16] <jelmer> The upstream project does not contain any Debian packaging metadata, so we will also have to merge that in.
[17:17] <jelmer> There happens to be a Debian package for pydoctor, so I have created an import of the Debian packaging branch on launchpad - https://code.launchpad.net/~jelmer/pydoctor/unstable
[17:17] <jelmer> The last thing to consider is the version string. As we create the source package from multiple branches, we don't want to just use the version in the last changelog entry of the packaging branch.
[17:18] <jelmer> If we did, that would mean that if the upstream branch changed and a new source package would be built, that source package would have the same version string (but different contents).
[17:19] <jelmer> To work around this, bzr-builder will automatically add a new dummy changelog entry indicating that a recipe build has been done, with a new version.
[17:20] <jelmer> TO give you a concrete example, let's look at the pydoctor recipe: https://code.launchpad.net/~jelmer/+recipe/pydoctor-daily
[17:20] <jelmer> You can see the recipe text at the bottom of the page below "Recipe contents"
[17:21] <jelmer> As you can see, the first line describes the version string that will be added to the changelog.
[17:22] <jelmer> The second line contains the "base" branch, in this case lp:pydoctor
[17:22] <jelmer> and the third line specifies that the lp:~jelmer/pydoctor/unstable branch should be merged and can be identified by the string "debian".
[17:23] <jelmer> The version string will be "0.3+bzr" followed by the last revision number of the base branch, then a tilde and then the revision number of the packaging branch.
[17:23] <jelmer> You can see how the identifier for the third line comes in handy here.
[17:25] <jelmer> "merge" isn't the only supported command; other options are "nest" and "nest-part". There also more variables available to use in the version string, such as {time} which will contain the current time. See https://help.launchpad.net/Packaging/SourceBuilds/Recipes for a full list.
[17:26] <jelmer> if you put the contents of the recipe in a local file, you should be able to build it with bzr-builder.
[17:26] <jelmer> For example, if you name this file "pydoctor.recipe" you can use:
[17:26] <jelmer> $ bzr dailydeb pydoctor.recipe build-pydoctor
[17:26] <jelmer> this will create a source package in the build-pydoctor directory.
[17:28] <jelmer> It is generally a good idea to test recipes locally first before adding them to Launchpad. That way you don't have to wait for a slot in the build queue, and you save build resources on Launchpad.
[17:30] <jelmer> Did that work for everybody?
[17:35] <jelmer> once you have a working recipe, you can register it on Launchpad by clicking the "Create packaging recipe" link on the branch page of one of the branches involved.
[17:36] <jelmer> There you'll have the chance to specify when the recipe should be built, what its instructions are, and what PPA should be targetted.
[17:38] <jelmer> It is possible to specify what Ubuntu releases a recipe should be built for. Of course, you will need to make sure that all of the build dependencies of your package are available in those releases (or your PPA dependencies).
[17:38] <jelmer> After you have created a recipe, the page should look roughly like the one for my pydoctor recipe (https://code.launchpad.net/~jelmer/+recipe/pydoctor-daily)
[17:39] <jelmer> If you have indicated that a recipe should be built daily, it will usually be built quickly after you update one of its branches.
[17:40] <jelmer> Are there any questions so far?
[17:47] <jelmer> As I mentioned earlier, more information can be found on the Launchpad help pages: https://help.launchpad.net/Packaging/SourceBuilds
[17:48] <jelmer> There is also a list of existing recipes that are in use on Launchpad, https://code.launchpad.net/+daily-builds
[17:49] <jelmer> as you can see, we have about 400 that build on a daily basis
[17:50] <jelmer> That's about all I had. If you have questions about recipes, please ask them now or otherwise you can always find me on this network under the nickname "jelmer"
[17:50] <jelmer> If you don't feel comfortable with recipe builds just yet, I can also recommend Matthew Revell's video cast about source package recipe builds.
[17:50] <jelmer> http://www.youtube.com/watch?v=_bG-SXNX9Ww
[17:51] <ClassBot> There are 10 minutes remaining in the current session.
[17:52] <jelmer> Thanks for your attention, happy hacking!
[17:55] <ClassBot> There are 5 minutes remaining in the current session.
[18:00] <ClassBot> Logs for this session will be available at http://irclogs.ubuntu.com/2011/09/07/%23ubuntu-classroom.html following the conclusion of the session.
[18:01] <aquarius_> Hi, all!
[18:01] <aquarius_> I'm Stuart Langridge, from the Ubuntu One team, and I'm here to talk about our app developer programme.
[18:01] <aquarius_> Do please ask questions throughout the talk: in the #ubuntu-classroom-chat channel, write QUESTION: here is my question
[18:02] <aquarius_> We want to make it possible, and easy, for you to add the cloud to your apps and to make new apps for the cloud
[18:03] <aquarius_> This is your personal cloud we're talking about here; your data. Not an enterprise cloud sort of thing :)
[18:03] <aquarius_> So we do all the heavy lifting, and your users (and you!) get the benefits.
[18:03] <aquarius_> Imagine, for example, you've made a recipe manager application.
[18:04] <aquarius_> So you can type in all the recipes you like to cook, and you've got a permanent record of them.
[18:04] <aquarius_> (For me, that would be: get a pizza base; put pepperoni on it. I reckon you can think of better recipes than that.)
[18:04] <aquarius_> (and: actual recipes, for nice food. Not, like, Launchpad recipes. :)
[18:05] <aquarius_> Don't really want to take your laptop into the kitchen, though, of course.
[18:05] <aquarius_> So, build a mobile app which you sign into with Ubuntu One, and have that show all your recipes too.
[18:05] <aquarius_> And a web app which you sign into with Ubuntu One, so that you can look up recipes while you're at a friend's house.
[18:06] <aquarius_> So you've got your stuff, wherever you are, whichever device you're on. Ubuntu, Android, iOS, Windows, webOS, whichever you want, your data's in your personal cloud and so it's everywhere for you.
[18:06] <aquarius_> This is the sort of thing that we want to make easy; giving your users and you quick access to the Ubuntu One technology.
[18:07] <aquarius_> Mobile access to your data; web app access to your data; saving files direct into Ubuntu One; publishing files and photos from all your apps; adding playlists to the Ubuntu One music streaming app; streaming the user's own music into a game you've written.
[18:07] <aquarius_> This stuff is all being heavily worked on right now as we speak.
[18:07] <aquarius_> So this talk won't be too detailed with specifics, because they might change.
[18:08] <aquarius_> But I'm more than happy to answer questions and so on! And I can probably tell you what I think the specifics are, if they're not already documented at https://one.ubuntu.com/developer/ :)
[18:08] <aquarius_> I want to give you a flavour of what will soon be possible, and answer questions, and give some pointers, and get your thoughts.
[18:09] <ClassBot> infodroid asked: you didn't mention desktop access to data... this is the primary use case i am looking at: seamless synchronisation of the user's app on the desktop
[18:09] <aquarius_> oops :)
[18:09] <aquarius_> I didn't deliberately leave it out!
[18:09] <aquarius_> desktop access to data is absolutely part of this
[18:09] <aquarius_> so you can sync a desktop app's data to other desktops, totally
[18:10] <aquarius_> and then you get to build web apps or mobile apps or both as well which also share the same data
[18:10] <aquarius_> Also, this is App Developer Week, so I can talk about what the components we're working on are and then admire all the cool ways you all come up with for snapping them together, rather than waiting for marketing to come up with a "product" for you to use :)
[18:11] <aquarius_> So, some components that can be snapped together.
[18:11] <aquarius_> You'll be able to sign in to a web application with Ubuntu One.
[18:11] <aquarius_> This means that you don't have to manage your own identity system, think about password renewal, all that.
[18:11] <aquarius_> This is just like "sign in with Facebook" or "sign in with Twitter"; it's OpenID-based, and lets your users sign in to a web app and you'll know their Ubuntu identity.
[18:13] <ClassBot> infodroid asked: I have reviewd the online docs for API Docs > Data > Store data. However it is not clear what language bindings are available to use.
[18:15] <aquarius_> infodroid, there are lots, depending on what you're trying to do
[18:15] <aquarius_> but I know that the developer site doesn't yet talk about bindings
[18:16] <aquarius_> I'm working on that :)
[18:16] <aquarius_> Once you've signed in to an app with Ubuntu One, that app can ask for permission to work with your data.
[18:16] <aquarius_> This lets you, developers, build applications that work on the desktop, on the web, on mobile phones.
[18:16] <aquarius_> The recipe manager example I mentioned above is one sort of thing you could do, there
[18:16] <aquarius_> Your users use the nice recipe manager app on Ubuntu, which you've built with Quickly or whatever you prefer
[18:16] <aquarius_> And then they can go to yourrecipemanager.com and sign in with Ubuntu One
[18:16] <aquarius_> yourrecipemanager.com then asks them for permission to access their "recipes" database
[18:18] <aquarius_> and can then show them all their recipes on the web!
[18:18] <aquarius_> Your app (yourrecipemanager.com) does this via OAuth; it goes through the standard OAuth dance to get an OAuth token which can be used to access the user's recipes data
[18:18] <aquarius_> And your users can be happy that it's secure, because yourrecipemanager.com will only have access to their recipes data; it can't read their contacts or their credit card info.
[18:18] <ClassBot> tomalan asked: Is Ubuntu One also available on other Linux Desktop Distros, like Fedora?
[18:19] <aquarius_> Certainly some people have done some work to package Ubuntu One for other distros
[18:19] <aquarius_> I think there's an ITP for Debian
[18:19] <aquarius_> and we've been pinged on #ubuntuone by people interested in putting Ubuntu One on Fedora and Arch
[18:20] <aquarius_> I don't remember the details, though, so I'm not sure what stage those bits of work are at
[18:20] <aquarius_> so, I was talking about apps working with your data
[18:20] <aquarius_> But you can imagine sharing other sorts of data between applications.
[18:21] <aquarius_> Imagine, for example, an achievements system.
[18:21] <aquarius_> You write a few games; some on the web, some on mobile phones, some on the Ubuntu desktop, some on Windows.
[18:21] <aquarius_> And every time the user achieves something in a game, you save that achievement to that user's "achievements" database.
[18:22] <aquarius_> On Ubuntu, you'd save that "trophy" into a file, and Ubuntu One will take care of synchronising that into the cloud.
[18:22] <aquarius_> On the web, your game's backend can use the REST API for file access: see https://one.ubuntu.com/developer/store_files/cloud
[18:22] <aquarius_> On Android or iOS or webOS or Blackberry or Meego or Windows Phone 7 you can do exactly the same thing; every language has an HTTP access library!
[18:23] <aquarius_> You could even write your own wrapper library for PHP or Rails or Flash or whatever you prefer (and then tell me about it so I can point to the documentation for it!)
[18:23] <aquarius_> At that point, all your games save achievements to the same place, so all your games can show you the achievements you've won in any game
[18:23] <aquarius_> And, as before, you can set up yourachievements.com where a user can log in and see all their achievements.
[18:23] <ClassBot> kermit66676 asked: So, the methods listed on the API documentation pages are all HTTP methods for the one.ubuntu.com server?
[18:24] <aquarius_> I think the API docs list all the public documented committed-to APIs
[18:24] <aquarius_> but I'd be interested to hear if there's something the docs don't cover
[18:24] <ClassBot> paglia_s asked: i'm realizing an implementation of Ubuntu One apis written in php and i've seen that apis are quite slow. Do you plan to improve speed?
[18:25] <aquarius_> paglia_s, hiya!
[18:25] <aquarius_> paglia_s, yes, we're working on that, definitely
[18:25] <aquarius_> and we're also interested in how people are using the APIs
[18:26] <aquarius_> so that we may be able to add ones which more closely return the information you want
[18:27] <aquarius_> There's loads of stuff you can do with shared data.
[18:27] <aquarius_> But Ubuntu One's not just about data.
[18:27] <aquarius_> Take the music streaming service, for example.
[18:27] <aquarius_> You can currently stream music to Android and iPhone, and you'll be able to add that music to the cloud from Ubuntu and Windows.
[18:27] <aquarius_> Maybe you want to be able to stream music back to your Ubuntu machine without syncing it, or your Mac, or your Palm Pre, or your LG mobile phone, or your toaster.
[18:28] <aquarius_> So, just use the music streaming API, which is again a simple REST HTTP API, or help people to get at their music by showing them our HTML5 web player for streaming music.
[18:28] <aquarius_> But there's more interesting ideas around music streaming than just "listen to the music".
[18:28] <aquarius_> Playlists, for example. The Ubuntu One Streaming apps on Android and iPhone know how to create playlists.
[18:29] <aquarius_> But how they do that is not a secret. Your playlists are just stored in your cloud databases.
[18:29] <aquarius_> So, why not sync your playlists from Banshee or Rhythmbox or Amarok or Exaile or Quod Libet or iTunes or Windows Media Player?
[18:29] <aquarius_> (insert your choice of player here :))
[18:29] <aquarius_> Copy the playlists from your media player into desktopcouch on Ubuntu or into the cloud directly with u1couch on Windows or the Mac or anywhere else, in the correct format, and those playlists will instantly show up on your phone!
[18:30] <aquarius_> A simple example of this is https://code.launchpad.net/~sil/%2Bjunk/m3u2u1ms/ which is a quick script I wrote to take an m3u playlist and store it in desktopcouch on Ubuntu.
[18:30] <aquarius_> So you can make your Banshee playlists available to the Ubuntu One app on your Android phone by exporting them as m3u and then importing them with the script.
[18:30] <aquarius_> And of course if you sync your playlists from your media player to Ubuntu One, then you can sync them back from Ubuntu One to your media player.
[18:30] <aquarius_> What this means is that if you've got two machines -- let's say, a desktop and a netbook -- then creating a playlist on your desktop will automatically also make it appear on your netbook.
[18:30] <aquarius_> And your netbook can either sync all your music that you store in Ubuntu One (if it's got enough space) or stream that music directly from Ubuntu One without ever syncing it locally.
[18:30] <aquarius_> Your music, everywhere; but importantly, not just your music but your playlists and scores and ratings and everything.
[18:31] <aquarius_> If you're interested in bringing this to your music player, let me know and I can help; ask questions now :-)
[18:32] <ClassBot> paglia_s asked: do you plan to add support for notes, too? Will this support also images/video...?
[18:33] <aquarius_> paglia_s, I'm not sure what you mean by "support for notes"?
[18:35] <aquarius_> paglia_s, you already can edit notes synced from tomboy on the website
[18:37] <ClassBot> jsjgruber_test asked:  I can't synchronize my desktopcouch database -- because of 503 service unavailable returns, and I hear that the servers are being worked on for this. Any news about when they will be able to handle the load?
[18:38] <aquarius_> jsjgruber_test, we're working on that, as you know, but I don't have an answer fo when that work will be completed
[18:38] <ClassBot> kermit66676 asked: yes, have there been any intentions of making an Ubuntu One gallery viewable online from a Shotwell photo collection?
[18:39] <aquarius_> kermit66676, interesting idea! If you were thinking of displaying that sort of thing on a website, the rest files API would be a good starting point
[18:39] <aquarius_> we've had a few ideas ourselves in that sort of area too :)
[18:40] <aquarius_> so, I was talking about music :)
[18:40] <aquarius_> Tighter integration is great, here; what we want to do is to make it easy for you all to build the stuff that you want on top of Ubuntu One.
[18:40] <aquarius_> So if you want to have your Amarok playlists available for streaming, it should be possible to do.
[18:40] <aquarius_> I rather like the idea of playing a Flash game on the web and having the background music be the most appropriate music chosen from *my* music collection. That'd be cool.
[18:40] <aquarius_> Ubuntu One also, as you know, does file sync.
[18:40] <aquarius_> :-)
[18:40] <aquarius_> But just syncing files is already taken care of by Ubuntu One itself, on Ubuntu and Windows.
[18:41] <aquarius_> What's more interesting is working with those files.
[18:41] <aquarius_> So, for example, imagine being able to instantly, one-click-ly, publish a file from your application to a public URL and then tweet that URL.
[18:41] <aquarius_> Instant get-this-out-there-ness from your apps.
[18:41] <aquarius_> The screenshot tool Shutter, for example, can do this already; PrtSc to take a screenshot, then "Export > Ubuntu One".
[18:41] <aquarius_> They did a bunch of hard work to do that, and I massively applaud them; nice one Shutter team!
[18:41] <aquarius_> Based on what they did, that's the sort of thing that should be easier to do.
[18:41] <aquarius_> So there are easy-to-use APIs so your apps can do the same. Imagine quickly sharing your newly created image or document or recipe with the world.
[18:41] <aquarius_> Your app could have a button to "store all my files in the cloud", or "publish all my files when I save them", or "automatically share files that are part of Project X with my boss".
[18:43] <aquarius_> More to the point, you can work with files directly *in* the cloud.
[18:43] <aquarius_> So a backup program, for example, could back up your files straight into Ubuntu One and not sync them to your local machines.
[18:43] <aquarius_> That's exactly what Deja Dup, by the great mterry, does; one of its backup options is "Ubuntu One". So to make sure you've got backups of your machine, just start Deja Dup (which is in Ubuntu 11.10), choose "Ubuntu One" for backups, and that's it; you're done.
[18:43] <aquarius_> You'll never lose data again; yay for backups!
[18:44] <aquarius_> Enabling that sort of work in *your* apps is exactly what the Ubuntu One app dev programme is all about; making it easy to add your users' personal cloud to what your app does.
[18:44] <aquarius_> And of course being able to save things in and out of the cloud means that you can get an Ubuntu One sync solution on other platforms.
[18:44] <aquarius_> So you could work with your files from your non-Android mobile phone (we've already got Ubuntu One files available in the Android Market, and it's also on Launchpad if you want to look at how it works).
[18:44] <aquarius_> Build a fuse or gvfs backend for Ubuntu or Fedora or SuSE or Arch Linux. Build a WebDAV server which works with Ubuntu One and mount your Ubuntu One storage as a remote folder on your Mac.
[18:45] <aquarius_> And web apps can work with your cloud too, for files as well as data.
[18:45] <aquarius_> Imagine, say, a torrent client, running on the web, which can download something like a movie or music from legittorrents.info and save it directly into your cloud storage.
[18:45] <aquarius_> So you see an album you want on that torrent site (say, Ghosts I by Nine Inch Nails) and go tell this web torrent client about it (and you've signed in to that web torrent client with Ubuntu One)
[18:45] <aquarius_> And the website then downloads that NIN album directly into your personal cloud -- which of course makes it available for streaming direct to your phone.
[18:45] <aquarius_> You could do that with videos as well: choose a torrentable video (say, Beyond the Game, the documentary about World of Warcraft) and download that directly into your cloud, if someone built the web torrent client.
[18:45] <aquarius_> (Of course, that would be cooler if Ubuntu One offered a video streaming service as well as music streaming, wouldn't it. Hm... ;-)
[18:45] <aquarius_> But it's not just about your content for yourself; think about sharing.
[18:45] <aquarius_> Ubuntu One lets you share a folder with people. This would be great for distribution.
[18:45] <aquarius_> Imagine that you publish an online magazine.
[18:45] <aquarius_> So, you create a folder on your desktop, and put issues of the magazine in it.
[18:46] <aquarius_> Then, you put a button on your website saying "Sign in with Ubuntu One to get our magazine".
[18:46] <aquarius_> When someone signs in, your website connects to the Ubuntu One files API, with your private OAuth token, and adds that signed-in user to the list of people that your magazine folder is shared with.
[18:46] <aquarius_> Then, whenever your magazine has a new issue, you just drop it into that folder on your desktop.
[18:46] <aquarius_> (Or even upload it to Ubuntu One directly through the website.)
[18:46] <aquarius_> All the subscribed people will get the new issue instantly, on all the machines they want it on, and in the cloud.
[18:46] <aquarius_> You could distribute anything like this. Imagine a podcast, or chapters of a novel.
[18:46] <aquarius_> It would also work for paid-for content; when someone pays, have your code share a folder with them, and put their paid-for stuff in that folder. That's all doable through the files API.
[18:46] <aquarius_> We've built the files API itself (an HTTP-based REST API) and also some wrappers for it to make it easier to use in your apps from Python and the like (and we're continuing to enhance it, and this is another place you can contribute; let me know what you want the Files API to do!)
[18:47] <ClassBot> infodroid asked: i hear that couchdb as a backend for a desktop app is really slow. is this true? are there any strategies to get around this?
[18:47] <aquarius_> infodroid, we're working on ways to make synced data a better experience for developers
[18:48] <aquarius_> (In fact I've been in a meeting room today talking about it :))
[18:48] <aquarius_> so stay in touch with what we're up to and if you're having problems, be assured that things will get better
[18:49] <aquarius_> at the moment using couchdb is problematic, we agree; for some people it works fine but there are issues
[18:49] <aquarius_> we're still working out what it's best to do about that
[18:50] <ClassBot> There are 10 minutes remaining in the current session.
[18:50] <aquarius_> staying in touch with what's going on can be done by following the blog (http://voices.canonical.com/ubuntuone/) and we're on twitter as well :)
[18:51] <aquarius_> and you can hang out in #ubuntuone too; we're a friendly bunch
[18:51] <aquarius_> and I'm always happy to have someone buy me a beer ;) (Or just drop me an email or ping me on irc to chat about what you're trying to do or hoping to do. I like talking about this stuff, as you may have noticed.)
[18:52] <aquarius_> OK, I've talked about a blizzard of ideas that'll be made possible, and shown you almost no code.
[18:52] <aquarius_> However, code is nothing without documentation, and that's really important.
[18:52] <aquarius_> So, as I mentioned earlier, you want https://one.ubuntu.com/developer
[18:52] <aquarius_> There you can find documentation for the files and music APIs, and for how to create and manage your Ubuntu One account.
[18:52] <aquarius_> So there's documentation for all this stuff so all of you clever people can build things that I haven't even dreamed of.
[18:52] <aquarius_> So, what I'd like to know is: what are your cool ideas? What help do you need from me in making them happen? What do you want to use Ubuntu One for in your apps and your scripts and your work?
[18:52] <aquarius_> as I say, drop me a line, ping me on irc, tweet at me or at U1 or hang out on irc and tell me what you want to get done, and we can talk about how to do it
[18:53] <aquarius_> I've got a few minutes fo questions now before you get to hear cool stuff about unity :)
[18:55] <ClassBot> There are 5 minutes remaining in the current session.
[18:55] <aquarius_> kermit66676, syncing your shotwell structures is a really interesting idea
[18:56] <aquarius_> you should already be able to sync the photos themselves -- simply mark the folde with them in as synced with Ubuntu One, and they'll be on all your machines
[18:57] <aquarius_> syncing shotwell's preferences and so on is more interesting, because it depends how they're stored
[18:57] <aquarius_> catch up with me another time (I have to leave at the end of this talk :( ) and we can talk it over?
[18:58] <aquarius_> ok, thanks all!
[19:00] <ClassBot> Logs for this session will be available at http://irclogs.ubuntu.com/2011/09/07/%23ubuntu-classroom.html following the conclusion of the session.
[19:02] <DBO> Hi everyone, my name is Jason Smith, I am a developer from the Canonical Desktop Experience team (DX for short)
[19:02] <DBO> I'll be giving a talk on supercharging applications with unity launcher integration for the next hour or so
[19:03] <DBO> anyone reading along should feel free to ask questions as they pop into their heads
[19:03] <DBO> First I want to start off by making sure everyone is familiar with the general terminology I am going to be using through this talk
[19:04] <DBO> Unity is (of course) the new shell being developed on top of GNOME for Ubuntu 11.04 and newer
[19:04] <DBO> the Launcher refers to the bar full of icons on the left side of the screen during usage of Unity
[19:05] <DBO> what we have found over the course of the last year is that application developers have desired a better way to display tiny pieces of information to users without doing rather drastic things like popping up alert boxes
[19:06] <DBO> many application authors have resorted to doing things like changing the title of their application to indicate new messages, urgency, or task progress
[19:06] <DBO> so we decided to make those three things in particular an explicit and consistent API for usage with the Unity Launcher
[19:08] <DBO> this API has been included in a library called libunity, and is available in the Ubuntu main repositories, you can also find its source code here: https://launchpad.net/libunity
[19:08] <DBO> Libunity will allow application developers to convey tiny bits of information about their application (or actually any application) they wish with very little work
[19:08] <DBO> we'll look at this piece by piece
[19:09] <DBO> I'll be using Vala as code snippets, but python and C bindings are also available (or anything else that supports GIR)
[19:10] <DBO> The first thing we do with libunity is get a LauncherEntry object
[19:10] <DBO> LauncherEntry objects serve as a control center for a single item on the launcher. They are asyncronous and currently one way (can be used to push information but not to inspect remote state)
[19:11] <DBO> LauncherEntry objects are keyed on the desktop file, so to create an entry for banshee, we would do:
[19:11] <DBO> var launcher_entry = Unity.LauncherEntry.get_for_desktop_file ("banshee.desktop");
[19:12] <DBO> the resulting launcher_entry will be remotely watched and tracked by the Unity Launcher as soon as it is created
[19:12] <DBO> (there is a caveat here that you must have a running main loop for any communication to work, otherwise it will queue until you run your main loop)
[19:13] <DBO> you may create as many launcher entry objects as you like, for as many different applications as you like in a single program. This is useful for creating applications to bridge public API's between two different programs (say skype where we dont have source code access)
[19:14] <DBO> now that we have a LauncherEntry, we can do 4 different, useful things with it
[19:14] <DBO> 1) Mark or unmark the application as urgent
[19:15] <DBO> 2) Set a count on the object (useful for unread messages)
[19:15] <DBO> 3) Set a progress on the object
[19:15] <DBO> 4) Add quicklist menu items to the object
[19:15] <DBO> Each of these is very simple, so we will just go through them in order, at the end I will post the entire source code for the example program
[19:16] <DBO> Setting our launcher_entry as urgent is as easy as "launcher_entry.urgent = true"
[19:17] <DBO> this state will be immediately communicated over dbus to unity where it will be reflected on the launcher
[19:17] <DBO> setting this back to false will reset the state
[19:17] <ClassBot> mhr3 asked: aren't there other methods to mark app urgent? shouldn't those be used instead?
[19:17] <DBO> Yes, there are other methods for marking an application as urgent
[19:18] <DBO> these methods are based on window hints applied to the xproperties of a related window
[19:18] <DBO> while these methods are quite useful, and should be preferred when the make sense
[19:18] <DBO> there are some cases where they dont, such as when an application that has no mapped windows still wishes to be marked urgent
[19:19] <DBO> Ubuntu One is an example of such an application
[19:19] <DBO> it will mark itself urgent when the user runs out of space, even though it has no mapped windows
[19:20] <ClassBot> kermit66676 asked: so there has to exist an <app_name>.desktop file somewhere? That file has to be included in a deb package by convention?
[19:21] <DBO> In short yes, there must be a desktop file somewhere. This is what the unity launcher considers an "application"
[19:21] <DBO> However, that file does not have to be added by a deb package
[19:21] <DBO> there was a bug last cycle where the daemon responsible for matching wouldn't seen manually added desktop files
[19:22] <DBO> but that has been fixed now
[19:22] <DBO> Libunity also allows users to set a count and a progress very simply, the api is almost identical for this so we'll just do them together
[19:23] <DBO> launcher_entry.count = 1;
[19:23] <DBO> launcher_entry.count_visible = true;
[19:23] <DBO> these two lines of code set the count to 1, then instruct the launcher to actually display the count. The count and its display are decoupled so it can be turned on and off as needed
[19:23] <DBO> similarly, progress can be done as:
[19:24] <DBO> launcher_entry.progress = 0.0;
[19:24] <DBO> launcher_entry.progress_visible = true;
[19:24] <DBO> again, the progress is set to 0, and then made visible
[19:25] <ClassBot> Trevinho asked: is actually impossible to check if a launcher entry is actually shown in the unity bar and maybe notified when it is there... Is this something planned (or that I can do :) )?
[19:25] <DBO> Currently there is no method for checking the contents of the launcher, this is a planned feature we feel desperately needs fixing :)
[19:26] <DBO> and yes Trevinho, this is certainly something you could do :)
[19:26] <DBO> ask me in #ayatana later and I will help you with the dbus work if needed
[19:26] <DBO> The last major item libunity allows developers to modify the launcher with is the addition of new quicklist items
[19:27] <DBO> these are done using the dbusmenu library, which has been covered in previous sessions and is fairly well documented, so I will only deal with the basic coupling code required for libunity
[19:27] <DBO> first we need to create a quicklist
[19:28] <DBO> some example code looks a bit like:
[19:28] <DBO> var ql = new Dbusmenu.Menuitem ();
[19:28] <DBO>     var item1 = new Dbusmenu.Menuitem ();
[19:28] <DBO>     item1.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Item 1");
[19:28] <DBO>     var item2 = new Dbusmenu.Menuitem ();
[19:28] <DBO>     item2.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Item 2");
[19:28] <DBO>     ql.child_append (item1);
[19:28] <DBO>     ql.child_append (item2);
[19:28] <DBO> this will create a quicklist, called ql, containing two label items
[19:28] <DBO> those items have signals on them you can subscribe to in order to get information about when they are clicked :)
[19:28] <DBO> adding them to the launcher is then as easy as:
[19:29] <DBO> launcher_entry.quicklist = ql;
[19:29] <DBO> This concludes the basic usage of libunity
[19:29] <DBO> unfortunately there are some limitations currently
[19:29] <DBO> and they mostly deal with applications wishing to use concurrent libunity connections
[19:30] <DBO> First, an application wishing to show a state on the launcher MUST remain active. The launcher watches the application on the session bus, and when it dies it reverts any changes it has made to the launcher icons state
[19:31] <DBO> so progress, count, urgent, and menu items all go away if you application dies
[19:31] <DBO> Second, state is currently last write overwrites previous data for multiple connections
[19:32] <DBO> this is very limiting and needs to be fixed, but people should be aware of it in the mean time :)
[19:32] <ClassBot> mhr3 asked: what is undone when the process which changed something on the launcher disappears?
[19:33] <DBO> The changes go away :) I think I was slow to answer this but if I wasn't clear, yeah, the changes just get reverted :)
[19:34] <ClassBot> mhr3 asked: any plans with the DockManager spec? :)
[19:34] <DBO> DockManager is a beautiful specification, and I really deeply regret we dont support it
[19:34] <DBO> its very comprehensive and covers a lot of corner cases pretty well
[19:35] <DBO> the one major advantage I think the libunity implementation covers better is it allows multiple consumers AND multiple subscribers
[19:35] <DBO> so you could, in theory, have many docks all listening to the same signals from applications
[19:35] <DBO> this was a shortcoming of dock manager (if I recall correctly)
[19:36] <ClassBot> kermit66676 asked: how come the Dbusmenu code is not masked using something more intuitive, such as ql = new Unity.Quicklist()? That would make it independent of the underlying technology (even though it might never change to something else).
[19:36] <DBO> I think the thought process is that dbusmenu is used in more places that just libunity (in the indicators for example), so making it a consistent API across the entire ecosystem was important
[19:36] <DBO> oh I forgot to pastebin the program :)
[19:37] <DBO> here we are: http://paste2.org/p/1636674
[19:39] <DBO> As libunity grows, I hope we can see it used more consistently across the ubuntu desktop. Items in the desktop switcher, nautilus, and maybe the dash will see increased usage of these signals and display the same hints
[19:40] <DBO> anyhow, unless there are more questions, that is about all I got
[19:44] <ClassBot> rsajdok asked: Why did you choose value instead python?
[19:44] <DBO> Vala is just the language I used in the example
[19:44] <DBO> its all gobject introspection
[19:44] <DBO> so you can use python too
[19:45] <DBO> I picked vala here just because thats what my test program is written in and I didn't feel like re-writing it :)
[19:51] <ClassBot> There are 10 minutes remaining in the current session.
[19:55] <ClassBot> There are 5 minutes remaining in the current session.
[20:00] <ClassBot> Logs for this session will be available at http://irclogs.ubuntu.com/2011/09/07/%23ubuntu-classroom.html following the conclusion of the session.
[20:01] <Lethalman> alright :)
[20:01] <Lethalman> hi all, I'm Luca Bruno and I contribute to the Vala project
[20:01] <Lethalman> juergbi is the project leader
[20:01] <Lethalman> vala is a new programming language with C#-like syntax that compiles to C and targets the GObject type system
[20:02] <Lethalman> I'm going to introduce the basics and the features of the vala language
[20:02] <Lethalman> the homepage can be found at https://live.gnome.org/Vala
[20:02] <Lethalman> you can get the vala compiler with "apt-get install valac", this is likely going to install at least vala 0.12 on an up-to-date system
[20:03] <Lethalman> so what's good with vala... :)
[20:03] <Lethalman> vala has syntax support for most of GLib/GObject features like classes/interfaces, properties, RTTI, virtual methods, signals, GValue and GVariant boxing/unboxing, error handling and optionally GIO features like GAsync and GDBus
[20:03] <Lethalman> it also provides generics, closures, delegates, contract programming, duck typing and some other cool stuff without any additional run-time!
[20:04] <Lethalman> https://live.gnome.org/Vala/Documentation#Projects_Developed_in_Vala
[20:04] <Lethalman> these are some applications written in vala
[20:04] <Lethalman> so, let's start by taking a look at the hello world: http://paste.debian.net/127646/
[20:05] <Lethalman> you can compile it with "valac hello.vala" then run it with "./hello"
[20:05] <Lethalman> args is the well known array of strings passed to the command line
[20:05] <Lethalman> string[] denotes an array of strings, while "print" refers to "GLib.print" which is static method mapped to g_print()
[20:06] <Lethalman> in vala you can have namespaces, and GLib is the default namespace
[20:06] <Lethalman> for reference, the online documentation for GLib can be found here: http://valadoc.org/glib-2.0/GLib.html
[20:07] <Lethalman> the main() static method is the entry point for applications, it will be executed first
[20:07] <Lethalman> at the very basics you might want to see what happens behind the scenes... if you want to see the generated C code, compile with "valac -C hello.vala" then read "hello.c"
[20:07] <Lethalman> vala has most of the basic glib types like int, bool, int16, uint16, float, double, string, structs, enums, flags, classes, interfaces and so on
[20:08] <Lethalman> so let's take a look at the next example: http://paste.debian.net/127644/
[20:08] <Lethalman> we're defining the "Foo" class that extends the "Object" class
[20:08] <Lethalman> then the "bar" property of type int with automatic getter and setter (you can also define custom getter and setter)
[20:08] <Lethalman> we have a constructor which takes an int value and sets the bar property, "this" refers to the instance of the class
[20:09] <Lethalman> in main() we create a new Foo instance and assign it to the local variable foo
[20:09] <Lethalman> the "var" keyword is meant to exploit type inference, so the type of foo is Foo... useful when you're lazy at writing long types ;)
[20:09] <Lethalman> you can find other examples of type inference in vala here: https://live.gnome.org/Vala/Tutorial#Type_Inference
[20:10] <Lethalman> for completeness let me say that the print() method supports printf-like format (man sprintf), so that you can format the arguments to the output very easily
[20:10] <Lethalman> the first important thing to notice is that we don't manually manage the foo variable lifetime in the example, instead vala does manage it
[20:10] <Lethalman> vala has automatic memory management using reference counting when possible, so you don't have to manually call ref() or unref() functions for gobjects
[20:11] <Lethalman> in this case, the foo variable is automatically unref()'d once it goes out of the scope
[20:11] <Lethalman> for more information about the memory model see both http://developer.gnome.org/gobject/stable/gobject-memory.html#gobject-memory-refcount and https://live.gnome.org/Vala/ReferenceHandling
[20:12] <Lethalman> what's special in this example is that Foo is a registered GObject class in C and bar is a regular GObject property
[20:12] <Lethalman> so, if you tell valac to autogenerate the header (valac -H sample.h sample.vala), C applications can use the class directly
[20:13] <Lethalman> in general, vala performs very well in the interoperability area
[20:13] <Lethalman> vala can talk to C using vala bindings (.vapi files) without additional run-time
[20:13] <Lethalman> that is, vala calls C functions directly without the need of any FFI
[20:14] <Lethalman> in fact .vapi files are just descriptions of the API of C libraries
[20:14] <Lethalman> e.g. in order to use a foreign package called gtk+-2.0.vapi that is installed in your system, just use valac --pkg gtk+-2.0 yourprogram.vala so that vala compiles your program against gtk+-2.0 and you can use the gtk symbols
[20:15] <Lethalman> a .vapi file has the same syntax of a .vala file, thus easy to write manually, see json-1.0.vapi (short enough for a pastebin) for example: http://paste.debian.net/127656/
[20:15] <Lethalman> don't worry, bindings can also be autogenerated from GIR files ;) (http://live.gnome.org/GObjectIntrospection)
[20:16] <Lethalman> to generate a somelib.vapi from a gir it's as simple as doing vapigen --library somelib SomeLib-1.0.gir
[20:16] <Lethalman> that's a little different than python or javascript or... as it's compile-time stuff
[20:16] <Lethalman> anyway, vala itself ships with many bindings, you can see the docs at http://valadoc.org/
[20:17] <Lethalman> ok some more about interoperability then we talk about some cool features :)
[20:17] <Lethalman> vala is able to autogenerate well-annotated GIR files to be used from other languages like python, javascript, etc.
[20:18] <Lethalman> that means higher level languages can talk to vala just immediately (just two steps without writing any GI annotation like in C)
[20:18] <Lethalman> let's see for example: https://live.gnome.org/Vala/SharedLibSample#Calling_vala_functions_using_introspection
[20:19] <Lethalman> what we do is first creating a test_shared.so library and tell valac to generate testShared-0.1.gir for us
[20:19] <Lethalman> once you got a gir we're done, it's only a matter of generating a typelib using the GI compiler
[20:19] <Lethalman> !y
[20:19] <ClassBot> shazzner77 asked: weird question, but I have a microcontroller that can be programmed in C. Can I use Vala for this?
[20:20] <Lethalman> that's an hard question as it highly depends on the microcontroller
[20:20] <Lethalman> most of microcontroller have different C dialects
[20:21] <Lethalman> but you can use the posix profile to generate non-glib code somehow, but it's mostly an experimental feature... it's usable to some sort though
[20:21] <Lethalman> so, let's talk about error handling
[20:21] <Lethalman> vala features error handling on top of GError, with the well known try/catch/finally syntax
[20:22] <Lethalman> in other words, you can catch errors thrown by C methods... eek! that sounds weird ;)
[20:22] <Lethalman> this is a simple example: http://paste.debian.net/128329/
[20:22] <Lethalman> in the example we try to read a file, if the file doesn't exist (FileError.NOENT) we keep throwing the error, for any other error we abort the program with GLib.error()
[20:23] <Lethalman> errors in glib are propagated using GError, so vala autogenerates the necessary code to handle that gracefully
[20:23] <Lethalman> you can define your own error types using "errordomain" like this: http://paste.debian.net/128714/
[20:24] <Lethalman> so, this is already a lot of nice features, but that's not all about it!
[20:24] <Lethalman> some cool stuff about vala is the syntax support for async operations, closures and dbus client/server
[20:24] <Lethalman> it is possible to define GIO-style async methods and calling other async methods very easily
[20:24] <Lethalman> an async method returns immediately giving control back to the caller, and when the job is completed a callback is fired
[20:25] <Lethalman> take a look at the first example here: http://live.gnome.org/Vala/AsyncSamples
[20:25] <Lethalman> the "async" keyword in front of list_dir() marks it as being a GIO-style coroutine
[20:25] <Lethalman> yield dir.enumerate_children_async() will pause the method, then it will be resumed once there's a result... that's amazingly simple
[20:26] <Lethalman> (in the meantime, thanks to nemequ for doing a great work in -chat :P)
[20:26] <Lethalman> also notice in the main() method (which is not an async method) that we used a closure to be notified when list_dir() completes its job
[20:26] <Lethalman> list_dir.begin() will initiate the async operation, then when the job is complete we free the resources with list_dir.end()
[20:27] <Lethalman> closures are an important feature of vala compared to raw C
[20:27] <Lethalman> a closure (or lambda expression, or ...) is a method created on-the-fly that shares the scope of the parent method (main() in this case)
[20:27] <Lethalman> this is very very useful for callbacks for which you need to pass user data
[20:27] <Lethalman> in fact, in the example the "loop" variable is used within the closure, but it's defined outside the closure
[20:27] <Lethalman> the general syntax for defining lambda expressions is (param1, param2, ...) => { ... body here ... }
[20:28] <Lethalman> the types of param1, param2, ... automatically match the parameters of the target type
[20:28] <Lethalman> in this case the target type is AsyncReadyCallback which is a delegate type (i.e. a type that accepts methods)
[20:28] <Lethalman> here's the definition of AsyncReadyCallback: http://www.valadoc.org/gio-2.0/GLib.AsyncReadyCallback.html
[20:29] <Lethalman> it takes two parameters, an Object and an AsyncResult... that's why we used (obj,res) => { ... } in the example
[20:30] <ClassBot> kermit66676 asked: I noticed there is no #include directive when using a library in Vala - doesn't that make things messy in bigger applications with a lot of packages - you have to watch out not to repeat class names from some other libraries? Or use namespaces all the time...
[20:30] <Lethalman> if I understood the question correctly... when you compile a project you feed to valac all the .vala files at once
[20:30] <Lethalman> valac file1.vala file2.vala ...
[20:30] <Lethalman> for what concerns collision with existing names, yes namespaces are used for that
[20:31] <Lethalman> but applications or libraries written in vala usually have their own namespace, that's the best practice
[20:31] <ClassBot> mjaga asked: is valac part of the gcc family?
[20:32] <Lethalman> no it isn't, it's a self-hosted compiler on its own
[20:32] <Lethalman> but valac uses the C compiler as it produces C code
[20:32] <Lethalman> it's very slim and compiles fast, most of the time spent on compiling is usually due to the C compiler
[20:33] <Lethalman> vala lets the underlying C compiler optimize things...
[20:33] <Lethalman> so... the async stuff is very powerful when combined with dbus :)
[20:34] <Lethalman> we can call dbus methods (well, a property in this case) in a such simple way: http://paste.debian.net/128341/
[20:34] <Lethalman> methods of UPower would have suspended your workstation, so :P
[20:35] <Lethalman> the interface in the example is a way for vala to generate proxy calls to the dbus interface
[20:35] <Lethalman> the "can_hibernate" property is mapped to the dbus property org.freedesktop.UPower.CanHibernate
[20:35] <Lethalman> what we do here is starting the async upower_query() operation, which will asynchronously connect to the system bus and request a proxy for UPower
[20:35] <Lethalman> afterwards we request the value of the "can_hibernate" property... bool.to_string() is an helper method defined by vala, you know what it does :)
[20:36] <Lethalman> vala automatically does dbus serialization of values when doing dbus stuff (the bool property in this case), even for the most complex types
[20:36] <Lethalman> this is about client code, but you can write dbus servers by just writing normal class methods
[20:36] <Lethalman> take for example this server code: http://paste.debian.net/128754/
[20:37] <Lethalman> and the following client snippet to query the server: http://paste.debian.net/128756/
[20:37] <Lethalman> compile the server with "valac dbusserver.vala --pkg gio-2.0" and the client with "valac dbusclient.vala --pkg gio-2.0"
[20:37] <Lethalman> so you can start the server with ./dbusserver and then invoke the client multiple times with ./dbusclient
[20:38] <Lethalman> if everything goes well, on the client you should see a counter increasing on each call
[20:40] <Lethalman> notice: as said in -chat not _all_ of the complex types, there might be some bug/limitation but you can use GLib.Variant manually as well
[20:40] <Lethalman> in this case we assumed the client didn't know the server codebase, otherwise we could share the same interface definition and let the server class implement it
[20:42] <Lethalman> server side we do some other stuff for acquiring the name, registering a callback when it's available
[20:43] <Lethalman> so, this vala integration is very important as our desktops are leading toward async and dbus more and more
[20:43] <Lethalman> there are several projects that massively use such advanced features of vala successfully
[20:43] <Lethalman> after this low level stuff we can take a look at some GUI with GTK+: http://live.gnome.org/Vala/GTKSample
[20:43] <Lethalman> reference docs for gtk3 can be found here: http://valadoc.org/gtk+-3.0/index.htm
[20:43] <Lethalman> the "using Gtk;" statement on the top means that the Gtk namespace is merged in the file
[20:44] <Lethalman> therefore we can use "new Window ()" instead of "new Gtk.Window ()", and so on
[20:44] <Lethalman> also notice window.title = "First GTK+ Program";
[20:44] <Lethalman> window.title is a gobject property, we saw them in the first hello world example
[20:44] <Lethalman> in this case vala will generate the C code for calling gtk_window_set_title (GTK_WINDOW (window), "First GTK+ Program") properly
[20:44] <Lethalman> in the example we can also see the button.clicked.connect() call: it's used to connect to the "GtkButton::clicked" signal!
[20:45] <Lethalman> the first argument is the callback that will be fired when the signal is emitted
[20:45] <Lethalman> you can also specify a method (static method or instance method) as the signal callback, not only a closure
[20:45] <Lethalman> I've written an equivalent code here without the use of a closure: http://paste.debian.net/128743/
[20:45] <Lethalman> yeah, it's more typing without closures ;)
[20:46] <Lethalman> as you can see writing gui with vala is very simple, and you can take advantage of async operations for doing I/O without blocking the GUI!
[20:46] <Lethalman> so now we're connecting to a signal, but in vala defining signals is as easy as putting a "signal" keyword in front of a method declaration
[20:46] <Lethalman> an example of signal definition can be found here: https://live.gnome.org/Vala/Tutorial#Signals
[20:47] <Lethalman> in that code we defined a full gobject signal named "sig_1" with an int parameter... like properties, signals can be used from C as well as higher level languages
[20:47] <Lethalman> and emitting the signal is as simple as calling a normal method: t1.sig_1 (5)
[20:48] <Lethalman> ok now let's talk a little about generics
[20:48] <Lethalman> generics in vala are similar to C# or Java generics
[20:48] <Lethalman> they are used to restrict the type of data that is contained in a class, both at compile-time and at run-time (no type erasure)
[20:48] <Lethalman> for example let's use GList, which is a glib structure for doubly linked lists: http://paste.debian.net/128737/
[20:49] <Lethalman> the type List<string> will define a list whose elements are of type string
[20:49] <Lethalman> then we append to strings to the list, and print them
[20:49] <Lethalman> the foreach statement is another neat feature of vala, allowing to iterate through the elements of a collection
[20:49] <Lethalman> the syntax is simple: foreach (element_type variable_name in container_expression) { ... }
[20:50] <Lethalman> in this case we used "var" as element type to exploit the type inference
[20:50] <Lethalman> roughly speaking, in this case vala will infer the element type from the generic type of the container which is "string"
[20:50] <ClassBot> There are 10 minutes remaining in the current session.
[20:50] <ClassBot> mhr3 asked: there's this nice syntax to read/write gobject properties, are there any plans to have similar support for widget style properties?
[20:51] <Lethalman> well, not that I know of
[20:51] <Lethalman> anyway while the properties defined in a class are known at compile-time, not necessarily style properties (or child properties...) are known at compile-time
[20:52] <Lethalman> so it may lack some type checking... if you have a clear idea you can feature request it :)
[20:53] <Lethalman> you can also define your own complex types using generics like the first example here: https://live.gnome.org/Vala/Tutorial#Generics
[20:54] <Lethalman> glib offers several data structures already, but there's also libgee that provides a collection library that is written in vala and widely used
[20:54] <Lethalman> libgee is more vala-friendly and has data structures such as TreeMap, PriorityQueue, HashSet, HashMultiMap, etc.
[20:54] <Lethalman> the reference docs for libgee can be found here: http://valadoc.org/libgee-0.7/index.htm
[20:55] <Lethalman> ok... we're almost done :)
[20:55] <Lethalman> vala comes with libvala, which is a library for parsing and analyzing the vala code and generating code...
[20:55] <ClassBot> There are 5 minutes remaining in the current session.
[20:55] <Lethalman> despite the libvala API is not stable, there are many users of it like IDEs, documentation tools, code generators, etc.
[20:56] <Lethalman> for generating documentation for you projects you can use valadoc: https://live.gnome.org/Valadoc
[20:56] <Lethalman> there're lots of other neat features like lock statement, inheritance, virtual/abstract methods and properties, etc. that we didn't mention...
[20:57] <Lethalman> or experimental features like chained expressions: foo < bar < baz < mama
[20:57] <Lethalman> or regex literals like in perl: /.../ will create a GLib.Regex
[20:57] <Lethalman> if you want to know more the tutorial at https://live.gnome.org/Vala/Tutorial is a good start... and the community is wide and very active ;)
[20:58] <Lethalman> ok that's all, thanks everyone :)
[20:59] <Lethalman> ok suggested from -chat to mention our community is on the mailing list<EMAIL_ADDRESS>and on #vala on irc.gimp.org
[21:00] <ClassBot> Logs for this session will be available at http://irclogs.ubuntu.com/2011/09/07/%23ubuntu-classroom.html