=== Mrokii_ is now known as Mrokii
=== caglar is now known as Guest77758
=== ChanServ changed the topic of #ubuntu-classroom to: Welcome to the Ubuntu Classroom - https://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Questions in #ubuntu-classroom-chat || Event: Ubuntu App Developer Week - Current Session: Catch that bug Quickly! - Debugging Quickly apps with pdb - Instructors: Abd4llA
jcastrook about ready?15:01
jcastroDay 4, keep up the energy!15:01
jcastrotake it away Abd4llA!15:01
Abd4llAThanx jcastro15:01
Abd4llAOk guys good afternoon15:02
Abd4llAAs you all know today we'll be talking about debuging python apps,15:02
Abd4llAspecially Quickly apps15:03
Abd4llAWell there're tons of python debuggers out there15:03
Abd4llAbut I'd say in 90% of the cases, you'll be using "pdb"15:04
Abd4llApdb comes by default with the python installation15:04
Abd4llAAs its name shows, it stands for "Python DeBugger"15:05
Abd4llAYou can use pdb to track your program execution,15:05
Abd4llAdo post-mortum debugging15:06
Abd4llAand pretty much anything a decent debugger should do :-)15:06
Abd4llASo lets get rolling quickly with pdb15:08
=== MSK61 is now known as MAfifi
Abd4llASo to start with, lets see how a normal pdb session looks like15:09
Abd4llAjust in the terminal issue the command "pdb"15:09
Abd4llAYou'll see that it accepts normal scripts as an argument15:10
Abd4llAso we can pretty much launch pdb normally15:11
Abd4llApdb <script.py>15:11
Abd4llAthat'll launch a pdb debug session for your script15:11
Abd4llAstarting at the first line, from there you can set your break points...etc then get rolling15:11
Abd4llAor you can inject an explicit call to pdb from within your python script15:12
Abd4llAso lets see how can we do that15:12
Abd4llAFirst, as I said, this is about debugging quickly apps, but most of what we'll say today can be applied to any python scripts/programs15:12
Abd4llASo, lets start by creating the sample quickly ubuntu-application template application15:13
Abd4llAfrom your favourite workspace dir, issue create a quickly app by issuing the command15:13
Abd4llAquickly create ubuntu-application DummyApp15:14
Abd4llAAnd let me know what you see :) ?15:14
Abd4llANow as you see, this is the default template app for the ubuntu-application quickly template15:15
Abd4llAIt's pretty  dummy, so lets try adding some "yea, dummy" functionality15:16
Abd4llAthere u'll find a "save" item in the "file" menu15:16
Abd4llAso lets call some function when we click save15:17
Abd4llAclose your DummyApp15:17
Abd4llAthen navigate to the dummyapp dir15:17
Abd4llAthere, issue the command:15:18
Abd4llAquickly design15:18
Abd4llAThat'll launch "Glade"15:18
Abd4llAnow click on the file menu15:18
Abd4llAand click on the "save"15:18
Abd4llAin the properties panel on the right15:19
Abd4llAclick the "Signals" tab15:19
Abd4llAYou'll find a subitem called "activate" under "GtkMenuItem"15:20
Abd4llAThere we'll write down the name of the method to call when we click save15:20
Abd4llAlets call it "save_me"15:20
Abd4llAso write down "save_me" in the "Handler" field of the item "activate"15:21
Abd4llAnow make sure to save15:22
Abd4llAclose your glade15:22
Abd4llAnow we need to write down that method15:23
Abd4llAso in your terminal, issue the command15:23
Abd4llAquickly edit15:23
Abd4llAthat'll open all your source files15:23
Abd4llAin gedit15:23
Abd4llAnow go to the file dummyapp15:24
Abd4llAThat's our main file15:24
Abd4llAwe need to add our save_me method to the DummyappWindow class15:24
Abd4llAso navigate there, maybe under the "on_destroy" method15:25
Abd4llAadd the following method15:25
Abd4llAdef save_me(self, widget, data=None):15:26
Abd4llA    introduce_bug()15:26
Abd4llANow as you see, we're calling a method called introduce_bug15:27
Abd4llAwe'll add that function to helpers.py15:27
Abd4llAso go to the top of the dummyapp file15:27
Abd4llAand import it as follows15:27
Abd4llAfrom dummyapp.helpers import introduce_bug15:28
Abd4llAwe'll write that function ourselves15:28
Abd4llANow navigate to helpers.py inside your gedit15:28
Abd4llAand at the very bottom, write down that method15:29
Abd4llAdef introduce_bug():15:30
Abd4llA    name = "bug"15:30
Abd4llA    print "I am a " + name15:30
Abd4llA    print "I am a healthy line"15:30
Abd4llAthen save your gedit15:30
Abd4llAKeeping up so far?15:31
Abd4llANow save gedit, then close15:31
Abd4llAthen run our app by firing15:31
Abd4llAquickly run15:31
Abd4llAand click "save"15:32
Abd4llAin your terminal you should see15:32
Abd4llAI am a bug15:32
Abd4llAI am a healthy line15:33
Abd4llAMake sure your import line15:37
Abd4llAis under the line15:38
Abd4llAfrom dummyapp.helpers import get_builder15:38
Abd4llAso at the end it'll look like15:38
Abd4llAfrom dummyapp.helpers import get_builder15:38
Abd4llAfrom dummyapp.helpers import introduce_bug15:38
Abd4llANow run again15:38
Abd4llAquickly run15:38
Abd4llAclick save15:38
Abd4llAall good ?15:38
Abd4llANow that's a bug over there15:39
Abd4llAWe need to hunt it down15:39
Abd4llAthere're several ways15:39
Abd4llAbut lets choose the easiest15:39
Abd4llAfrom your command line15:40
Abd4llAissue the command15:40
Abd4llApdb bin/dummyapp15:40
Abd4llANow we're starting a pdb session15:40
Abd4llAit started at the first line of your script15:40
Abd4llApdb accepts commands15:41
Abd4llAso issue15:41
Abd4llAthat should show the help15:41
Abd4llAnow we need to add some breakpoints15:41
Abd4llAwe know that the method save_me is the one that gets called when clicking save15:41
Abd4llAso lets add a breakpoint to it15:41
Abd4llAthe comman b is used to add breakpoints15:42
Abd4llA(Pdb) b dummyapp:13415:42
Abd4llAthis way we added a breakpoint to the file dummyapp15:43
Abd4llAline number 13415:43
Abd4llAyou should match the line number of your def save_me15:43
Abd4llAmy method is defined at line 13415:44
Abd4llAso now we have a breakpoint there15:44
Abd4llAlet's run the code !15:44
Abd4llAthat'll continue execution untill the first breakpoint15:44
Abd4llAnotice the command "c"15:45
Abd4llAnow we notice that it'll stop when it reads the function definition15:45
Abd4llAthat's not what we want15:46
Abd4llAwe wanna stop when it starts executing15:46
Abd4llAso lets try that again15:46
Abd4llAclose the app15:46
Abd4llArun it inside pdb15:46
Abd4llApdb bin/dummyapp15:46
Abd4llAnow this time, lets make the breakpoint at the introduce_bug() method call line15:46
Abd4llAthe first line of the "save_me" function15:46
Abd4llA(Pdb) b dummyapp:13515:47
Abd4llAnow lets continue execution till first breakpoint15:47
Abd4llA(Pdb) c15:47
Abd4llAyou'll see that the application shows15:47
Abd4llAand now we need to click "file-> save"15:48
Abd4llAthere you'll see pdb stoping at the break point15:48
Abd4llAGood ?15:48
Abd4llAnow lets try some pdb commands15:49
Abd4llA(Pdb) l15:49
Abd4llAthat'll list the code15:49
Abd4llA(Pdb) w15:49
Abd4llAstack trace15:49
Abd4llANow we can either execute the next line using "n" or step into the method "introduce_bug"15:50
Abd4llAusing s15:50
Abd4llAso lets see15:50
Abd4llA(Pdb) s15:50
Abd4llAwe're there now15:50
Abd4llA(Pdb) n15:50
Abd4llAwill go to the next line15:50
Abd4llA(Pdb) l15:51
Abd4llAlist the code there15:51
Abd4llAnow I see that the "print "I am a " + name" line is the one that introduces a bug and I wanna skip it15:51
Abd4llA(Pdb) j 5015:51
Abd4llAThat way we jumped to the next line15:52
Abd4llA(Pdb) c15:52
Abd4llAwill continue execution without the buggy line and will print "I am a healthy line" only15:52
Abd4llAGood ?15:52
Abd4llALets try another way to trace that bug15:53
Abd4llAclose your session15:53
Abd4llAand edit your code15:53
Abd4llAquickly edit15:53
Abd4llAgo to dummyapp file15:53
Abd4llAin save_me method15:54
Abd4llAadd the following line before the call to "introduce_bug"15:54
Abd4llAimport pdb; pdb.set_trace()15:54
Abd4llAso the final method will be15:54
Abd4llA    def save_me(self, widget, data=None):15:55
Abd4llA        import pdb;pdb.set_trace()15:55
Abd4llA        introduce_bug()15:55
Abd4llAnow run the app15:55
Abd4llAquickly run15:55
Abd4llAgo to file->save15:55
Abd4llAyou'll see that a pdb session will start @ the termincal15:56
Abd4llAthat's another way to launch ur pdb , from within the code15:56
Abd4llAnow type args15:56
Abd4llAthat prints the arguments15:56
Abd4llA(Pdb) args15:57
Abd4llAalso there's u and d15:57
Abd4llA(Pdb) u15:57
Abd4llAthat goes to the upper frame15:57
Abd4llA(Pdb) d15:57
Abd4llAThat goes to the lower one15:57
Abd4llA(Pdb) s15:57
Abd4llAstep into the introduce_bug method15:58
Abd4llA(Pdb) n15:58
Abd4llAnow you can alter your name variable15:59
Abd4llA(Pdb) name = "Not a bug"15:59
Abd4llAThat was a quick introduction for Pdb guys :)15:59
Abd4llASo thanks alot guys , more time would've been convenient :)15:59
Abd4llAbut hopefully it was fun :-)16:00
=== ChanServ changed the topic of #ubuntu-classroom to: Welcome to the Ubuntu Classroom - https://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Questions in #ubuntu-classroom-chat || Event: Ubuntu App Developer Week - Current Session: Making your application translatable in Launchpad - Instructors: dpm
dpmThanks Abd4llA, and hi everyone!16:01
dpmWelcome to this session on setting up your project for translations in Launchpad.16:01
dpmMy name is David Planella and I'm the Ubuntu Translations Coordinator, where I work with our translations community to bring you a localized operating System.16:02
dpmI also tend to help with any topics related to translations and Launchpad, and that's what we're going to talk about today :)16:02
dpmThat's a really exciting topic to me, as Launchpad makes it really easy to make your applications translatable and available to everyone in almost any language, and I hope you enjoy it as much as I do.16:02
dpmTranslators are really awesome people!16:03
dpmAnyway, let's get started, shall we?16:03
dpm= Assumptions =16:03
dpmI will start with an application ready set up for translations, so I'm not going to go into much detail there.16:03
dpmMy intention is to focus in getting you started with exposing your project's translations to everyone for translation.16:04
dpmIn any case, if you've got questions on this, feel free to ask either during or at the end of the session, and I'll be more than happy to answer them16:04
dpmWe're going to be using these tools:16:04
dpm    bzr16:04
dpm    quickly16:04
dpm    python-distutils-extra16:04
dpmIn particular quickly, which we'll use to start with a nearly ready-made project with translations set up16:04
dpm(You can install it by running the 'sudo apt-get install quickly' command or you can get it from Applications > Ubuntu Software Center)16:05
dpm 16:05
dpm= Creating the project and setting it up for translations =16:05
dpm 16:05
dpmWe'll use quickly to create a project called 'fooby', and then we'll set up the last touches needed to configure translations.16:06
dpmSo if you've got all those tools installed, you can simply fire up a terminal window (Applications > Accessories > Terminal) and run the following command:16:06
dpm    quickly create ubuntu-application fooby16:07
dpmThis will create an application named 'fooby'16:07
dpmand give you some information about it on the first run16:07
dpmthen change to the fooby folder:16:08
dpm    cd fooby16:08
dpmAnd finally run:16:08
dpm    python setup.py build_i18n16:08
dpmThat should have finished the last bits to set up translations16:08
dpmin particular it created the po folder to contain the translations template and the translations16:09
dpmyou can see the template:16:09
dpm    ls po16:09
dpmhave a look at it:16:09
dpm    gedit po/fooby.pot16:09
dpmIt's important to get a bit familiar with it, but you don't have to remember the whole format16:10
dpmyou should simply know what it is for now :)16:10
dpmA few words on translation templates:16:10
dpm * Gettext: They follow the gettext format: http://is.gd/fC8p616:10
dpm * Name: They are generally named after your project, with a .pot extension. E.g. fooby.pot16:11
dpm * One template per app: Generally applications need only one template16:11
dpm * Layout: They generally live in the po/ folder, along with the translations16:11
dpm * Content: They are text files which contain:16:11
dpm    * A header with metadata16:11
dpm    * A set of message pairs: msgid are the original strings extracted from the code and exposed to translators, and msgstr are the placeholders for the translations, which are always empty in the templates.16:11
dpm * Launchpad import: They are imported into Launchpad and exposed for translations for all languages in https://translations.launchpad.net/$YOUR_PROJECT16:12
dpm * Updates: You update the template whenever you have new strings in your app and you think they are stable for translation (generally shortly before release)16:12
dpm * Tools: you update templates with gettext based tools:16:12
dpm    * generally intltool -> 'cd po && intltool-update -p'16:12
dpm    * or increasingly python-distutils-extra for python projects -> 'python setup.py build_i18n -p'16:13
dpmYou don't have to remember all of this16:13
dpmBut at least you should know how that you must update the template from time to time16:13
dpmand the command to do it16:13
dpmYou'll see that your project still does not contain any translations, but let me give you a quick overview, so you know what we're talking about:16:13
dpmA few words on translations:16:14
dpm * Template-based: They are created from the template and share the same gettext format16:14
dpm * Name: They are named after the $CODE.po scheme, where $CODE is an ISO 639-2 code. E.g. ca.po for Catalan, de.po for German. Some have an optional country specifier. E.g. pt_BR.po (Portuguese from Brazil)16:14
dpm * Layout: they are all in the same directory as the POT template. So:16:14
dpm    * po/fooby.pot16:14
dpm    * po/ca.po16:15
dpm    * po/pt_BR.po16:15
dpm     * ...16:15
dpm * Creation: Launchpad creates them for you the minute someone translates the first message online16:15
dpm * Code integration: you can let Launchpad commit them to a branch of your choice or you can export a tarball containing them all16:15
dpmAnyway, let's continue. Now that you've added the template to your code, you can commit it:16:16
dpmYou can run the following commands:16:16
dpm    bzr add po16:16
dpm    bzr commit -m 'Created my first ever awesome .pot template. Go translators, go!'16:16
dpmAnd let's publish it in Launchpad (note that you'll have to change the Launchpad URL to your user name instead of 'dpm'):16:17
dpm    bzr push lp:~dpm/fooby/translations16:17
dpmNothing particularly hard to understand on the naming scheme above: dpm is my user name, fooby is the project and translations is the branch name16:17
dpmOk, so that completed the first step!16:18
dpm 16:18
dpm= Setting up code hosting =16:18
dpm 16:18
dpmWe want our project to be available to everyone to translate, so we'll need to publish it in Launchpad.16:18
dpmThat's beyond the scope of this session, so we'll continue from the already registered fooby project in Launchpad:16:18
dpm    https://code.launchpad.net/fooby16:18
dpmIn case you are interested, though, registering a new project in Launchpad is as easy as going to https://launchpad.net/projects/+new16:19
dpmSome of the URLs will not allow you some of the pages due to permissions, so if you have your own project in Launchpad, just substitute the 'fooby' part in the URL with your project's Launchpad id16:20
dpmThe first thing we'll have to do in our project is registering a bzr branch,16:20
dpm    so we'll simply go to the Code tab in Launchpad, choose the "Configure code hosting" link16:20
dpmand then on the "Link to a Bazaar branch already on Launchpad" you can enter the branch we published earlier on (~dpm/fooby/translations)16:21
dpmA shortcut is to simply go to:16:21
dpmto do this16:21
dpmSo now we have all we need to start setting up translations.16:21
dpmYou see that all components in Launchpad are integrated, so you set up a branch to be linked to translations16:22
dpmJust as a recap, you can see and explore the resulting code from here:16:22
dpm    https://code.launchpad.net/fooby16:22
dpmFeel free to browse it (http://bazaar.launchpad.net/~dpm/fooby/translations/files)16:22
dpmor download it (bzr branch lp:fooby) and play with it16:23
dpmOk, so code hosting setup: (./) Finished!16:23
dpm 16:23
dpm= Setting up translations in Launchpad =16:23
dpm 16:23
dpmNow we come to the most interesting part16:24
dpm1. Telling Launchpad where translations are hosted16:24
dpmThe first step it to tell Launchpad that we want to host translations there.16:24
dpmOn your Launchpad's project, just click on the Translations tab, or go to this URL:16:24
dpm(remember to change 'fooby' to your project's name)16:25
dpm    https://translations.launchpad.net/fooby/+configure-translations16:25
dpmThen choose the "Launchpad" option to tell Launchpad translations will be done there, and click on "Change"16:25
dpmThat was an easy one, wasn't it?16:26
dpm2. Configuring permissions16:26
dpmNow we are going to tell Launchpad how we want our translations permissions to be (i.e. who and how can translate it),16:26
dpmand which branch translators should focus on.16:26
dpmSimply go to the Translations tab again and click on the "Change permissions link"16:27
dpmOr here's the direct link: https://translations.launchpad.net/fooby/+settings :)16:27
dpmI recommend the following setup:16:27
dpm    Translations group: Launchpad Translators16:28
dpm    Translations permissions policy: Structured16:28
dpm    Translation focus: trunk (or choose your branch here)16:28
dpmAssigning the translations to a translation group will make sure a team for each language will review translations before they are submitted, ensuring the quality of translations16:29
dpmA translations group is a group of teams, one per language, that takes care of translations in their language16:30
dpmThey can be specific to a project or generic. I recommend the Launchpad Translators group because it contains a set of already established and experienced teams:16:31
dpmas per the Structured policy16:31
dpmThis gives you a good balance between openness and quality control:16:32
dpmOnly the team members of an established team will be able to translate your project16:32
dpmAnd for languages without a team it will allow everyone to translate, facilitating the barrier of entry to translators at the expense of QA16:33
dpmThe other extremes are Open or Restricted16:33
dpmYou can learn more about these here:16:33
dpm    https://help.launchpad.net/Translations/YourProject/PermissionPolicies16:34
dpmIt's the project maintainer's call, but I personally discourage them to use Open16:34
dpmOk, we're nearly there, next step:16:34
dpm3. Setting up what needs to be translated16:34
dpmYou need to also tell Launchpad what needs to be translated. That's again quite easy. On the Translations tab again, choose the trunk series and specify your branch there16:35
dpmDirect link: https://launchpad.net/fooby/trunk/+linkbranch16:35
dpmAnother easy one16:35
dpm4. Configuring imports and exports16:35
dpmThat's for me the most interesting bit16:36
dpmThe settings on this section basically enable Launchpad to do the work of managing translations for you16:36
dpmYou can tell Launchpad to import your translation templates automatically whenever you do a commit16:36
dpmSo you don't have to upload them manually16:37
dpmIf you are migrating a project with existing translations, you can tell it to import them too16:37
dpmAnd finally, you can let Launchpad commit translations automatically to a branch of your choice16:37
dpmI find that just awesome16:38
dpmSo for the imports, on the Launchpad page, on the "Import translations from branch" section:16:38
dpmI recommend choosing "Import template files" and then "Save settings"16:39
dpmFor exports: look at the "Export translations to branch" section and then click on the  "Choose exports branch" link16:39
dpmSo that was it!16:40
dpm4 easy steps that should not take you more than a few minutes to set up, and your app is ready for the world to translate!16:40
dpmJust a few final words:16:40
dpm 16:40
dpm= Play with translations =16:40
dpm 16:40
dpmAs a developer, it might be interesting to see how translators do their work.16:41
dpmExceptionally (remember how I advised not to use Open permissions, tough :) I've set the translations permissions on the fooby project to Open16:41
dpmSo you can submit translations16:41
dpmand get a feel for the work that translators do16:41
dpmAs a developer, it will give you an understanding on how they work. It is always interesting to get to know other workflows16:42
dpmand it's always good to have an insight on all areas of contribution related to your project16:43
dpmYou can start translating fooby here:16:43
dpm 16:43
dpm= Summary =16:43
dpm 16:43
dpmMost of the steps described here today you'll only need to do once, unless you need to change the settings. They were:16:43
dpm 1. Setting up code hosting (in case you hadn't already)16:44
dpm 2. Setting up translations in Launchpad16:44
dpm    2.1. Telling Launchpad that it's hosting your translations (https://translations.launchpad.net/fooby/+configure-translations)16:44
dpm    2.2. Configuring permissions: recommended -> Structured, Launchpad Translators (https://translations.launchpad.net/fooby/+settings)16:44
dpm    2.3. Setting up the translations branch (https://launchpad.net/fooby/trunk/+linkbranch)16:44
dpm    2.4. Configuring imports and exports (https://translations.launchpad.net/fooby/trunk/+translations-settings)16:44
dpmSo really, once your project is set up for translation, the only things you'll have to remember are:16:45
dpm  to update the template before a release,16:45
dpm  announce to translators that they can start their work,16:45
dpm  and merge the translations to your main branch.16:45
dpmIf you are using the same branch for translation imports and exports, you won't even have to do that!16:45
dpmSo here's a reminder on how to do these steps:16:46
dpmUpdating the translation template16:46
dpmpython setup.py build_i18n -p                   # To update the template16:46
dpmbzr commit -m"Updated translation template"     # Commit your local changes16:46
dpmbzr push                                        # Push changes to the remote branch16:46
dpm 16:47
dpmCall for translations16:47
dpmJust send an e-mail to launchpad-translators(at)losts(dot)launchpad(dot)net or to the list where the coordination of your project's translation is happening16:47
dpm 16:47
dpmJust to finish, you'll find more information on the topics covered in this session here:16:47
dpm * https://help.launchpad.net/Translations/YourProject16:48
dpm * https://help.launchpad.net/Translations/YourProject/BestPractices16:48
dpmSo that was it! I hope you enjoyed it and that I can soon see your projects up for translation in Launchpad16:48
dpmDoes anyone have any questions?16:49
ClassBotMAfifi asked: What about non-python based projects?16:49
dpmThe Launchpad part is the same for those. Let's take a C project, for example16:49
dpmthe only differences between languages, or rather between build systems, is how you update the template16:50
dpmIn a GNOME application in C using autotools, for example, you'd just go to the po folder16:50
dpmand call intltool-update -p16:51
ClassBotMAfifi asked: What if I want to submit a translation in a language no team exists for?16:51
dpmIt all depends on the permissions you've set up for your project16:51
dpmWith Open and Structured permissions, the translations would just be accepted16:52
dpmWith Restricted, they'd be marked as suggestions, but would not be included in the project16:52
dpmuntil there is a team which reviews them16:53
dpmAs the maintainer, you can bypass that and do a manual upload of the translations for which there isn't a team16:53
dpmBut I'd rather avoid bypassing translation teams16:53
dpmand try to find someone that can review the translations before them being accepted16:54
dpmoh, MAfifi meant for translators16:54
dpmAs a translator, the same as above applies, only that you cannot bypass translation teams as a maintainer can do16:55
dpmso for Structured, it there is not a team, you'd be able to submit translations, the same as in Open16:55
dpmFor Restricted, you'd be able to submit suggestions, which are recorded in Launchpad, but would not make it into the project until a team for the language is created16:56
dpmAny more questions?16:58
ClassBotapachelogger asked: how do I make my plasmoid translatable?16:59
dpmnice question, I don't think I can answer in the last minute, but we can continue on #ubuntu-translators16:59
dpmAs an exchange, you get an intro:16:59
dpmok, bye everyone, I hope you enjoyed the talk. now let's leave the room for the always awesome apachelogger and his talk on "Widgetcraft <3"17:00
=== ChanServ changed the topic of #ubuntu-classroom to: Welcome to the Ubuntu Classroom - https://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Questions in #ubuntu-classroom-chat || Event: Ubuntu App Developer Week - Current Session: Widgetcraft <3 - Instructors: apachelogger
apacheloggerthank you dpm for your talk and the intro :)17:01
apacheloggerwelcome to an intro on Widgetcraft (imagine scary music)17:01
apachelogger... also known as the art of creating Plasma Widgets (imagine not so scary music but thunder ;))17:01
apacheloggerMy name is Harald Sitter, and I am opporunistic by design.17:02
apacheloggerFirst please make sure you have the dependencies: sudo apt-get install kdebase-workspace-bin kdebase-runtime17:02
apacheloggerAlso you will need a common editor.17:02
apacheloggerThere is a Plasma specific sort-of IDE in the works, but it has yet to see a release that I would call usable.17:03
apacheloggerPlease write DONE in the -chat channel once you are done installing17:03
apacheloggerso I know when we can do fun things.17:03
apacheloggerany more people who are not DONE yet? ^^17:04
apacheloggerI think we can skip the intro and do useful things then ;)17:04
apacheloggerbut first let me at least outline some basics17:05
apacheloggerPlasma is the technology underneath KDE's workspace components (mostly called desktop)17:05
apacheloggerit comes in currently (I think) 3 favors, proper desktop, netbook sort-of desktop and mobile (yes for mobile phones)17:05
apacheloggerUsually Plasma Widgets writen natively for Plasma are called Plasmoids.17:06
apacheloggerPlasma can also run Apple Dashboard widgets and Google Gadgets for examples... but only Plasmoids are the real deal ;)17:06
apacheloggerYou can write them in either JavaScript or C++ or Ruby or Python.17:06
apacheloggerHowever only the former two are guaranteed to be available on every system, so I recommend those.17:07
apacheloggerHence we will also use JavaScript today.17:07
apacheloggerAny questions thus far?17:07
apacheloggerVery well.17:08
apacheloggercoding \o/17:08
apacheloggerA basic routine that you will almost always need when starting off with a new Plasmoid is the following:17:09
apacheloggerNAME=doctor-questionmark          # Set a shell variable17:09
apacheloggermkdir -p $NAME/contents/code/     # Create everything up to the code dir.17:09
apacheloggertouch $NAME/metadata.desktop      # Create the metadata file, which contains name and description...17:09
apacheloggertouch $NAME/contents/code/main.js # Create main code file of the plasmoid.17:09
apacheloggerYou can copy this verbatim into a terminal to get started with our little example.17:09
apacheloggerThis will create the basic outline for any JavaScript based Plasmoid.17:10
apacheloggerFor other languages it is basically the same, just that the file extension of the main.js would be different :)17:10
apacheloggerFirst let us set up the meta data. For that open the metadata.desktop file and fillit with content.17:11
apacheloggerYou can copy the stuff from here: http://people.ubuntu.com/~apachelogger/uadw/09.10/doctor-questionmark/metadata.desktop17:11
apacheloggerAs you can probably tell from looking at that file, the meta data bascially just defines name, comment, icon, author and other not all that useful information.17:12
apacheloggerBUT whenever you create a new plasmoid, do not forget to change the 'Name' and 'X-KDE-PluginInfo-Name' values17:12
apacheloggerthose 2 get used to identify the plasmoid internally, so if you forget to change one it can easily happen that your plasmoid does not show up or loads inproperly etc. etc.17:13
apacheloggerIs everyone done with the metadata.desktop?17:13
apacheloggerAnd you know what, that was already all the politics ;)17:15
apacheloggerWe all know what comes after the politics... the code ;)17:15
apacheloggerSo please save the file and close it.17:15
apacheloggerAnd open contents/code/main.js instead.17:15
apacheloggerThis sweet apple pie of an empty file will soon contain our beautiful code, of which I am not yet sure what it will be...17:16
apacheloggerHow about starting with a simple hello world?...17:16
apacheloggerI will indent code lines so they are easier visible for you.17:17
apachelogger    // First create a layout we can stuff things into17:17
apachelogger    layout = new LinearLayout(plasmoid);17:17
apacheloggerwhat is probably noteworthy at this point is that 'plasmoid' thing there, it is part of the initial environment we get in a plasmoid and by having it in brackets it becomes 'parent' of our layout17:18
apacheloggerthe term parent here relates to live time mostly, if the parent of an object in a plasmoid explodes, all its children will too17:18
apachelogger    // Then create a label to display our text17:19
apachelogger    label = new Label(plasmoid);17:19
apacheloggerI hope until now it is still barable complicate17:19
apachelogger    // Add the label to the layout17:19
apachelogger    layout.addItem(label);17:19
apacheloggerNow here is an inherted goodness, since Plasmoids are based on KDE which is based on Qt we have cool layouting features, which means for simple things we do not have to worry about layout very much.17:20
apacheloggerWe simply create such a layout and add items to it...17:20
apacheloggerOf course something is still missing for our hello world.17:20
apacheloggerText ;)17:20
apachelogger    // Set the text of our Label17:20
apachelogger    label.text = 'Doctor ?';17:20
apachelogger    // Done17:20
apachelogger(for the record: I do like doctor who better than hello world ;))17:21
apacheloggerYou can now run this using plasmoidviewer $NAME (if you still have your terminal open) or plasmoidviewer PATHTOPLASMOIDFOLDER17:21
apacheloggerDoes everyone has a working plasmoid?17:22
apacheloggerAlso, there is a new trick I would like you to tell about. If you are on KDE 4.5 (default for Kubuntu 10.10) you will have a new command called 'plasma-windowed' using this command you can run most Plasmoids just like any other application in a window, is that not superb?17:23
apacheloggerYou can try that with our new plasmoid right now.17:23
apacheloggerOr if you have the facebook plasmoid, try that17:23
apacheloggerplasma-windowed facebook17:23
apacheloggerPretty neat feature.17:24
apacheloggerSo, lets build up on this example.17:24
apacheloggerHow about a button? Buttons are cool!17:24
apacheloggerJust continue in the main.js17:25
apachelogger    // Create a new button17:25
apachelogger    button = new PushButton;17:25
apachelogger    // Add the button to our layout17:25
apachelogger    layout.addItem(button);17:25
apacheloggerI personally have made it a habit to immediately after creating add objects to a layout.17:26
apacheloggerEspecially in large projects it can easily happen that you forget that and suddenly there is a button floating around somewhere where it does not belong17:26
apachelogger    // Give the button some text17:26
apachelogger    button.text = 'Do not EVER click me';17:26
apachelogger*save* the file17:26
apacheloggerand try it again17:27
apacheloggerIt looks a bit silly, does it not?17:27
apacheloggerThe layout placed the button next to the text... not awesome at all... I would really like it to be below the text. Easy to do.17:28
apacheloggerWe just tell our layout to align stuff vertically, rather than horizontally (which seems to be the default).17:28
apachelogger    // Switch our layout to vertical alignment17:28
apachelogger    layout.orientation = QtVertical;17:28
apachelogger*save* and try again17:28
* apachelogger finds it much more attractive now17:29
apacheloggereveryone done?17:29
apacheloggerWe are pretty fast today so I am pondering a coffe break... or maybe better not.17:31
apacheloggerOf course our button does not do anything (well, other then be there, sometimes that is already a lot ;))17:32
apacheloggerNow what could we do to improve the situation a bit?17:32
apacheloggerHow about a nice image?17:32
apacheloggerThere is nothing like a good picture to spice up things a bit :D17:32
apacheloggerFirst let us get the picture.17:32
apacheloggerFor that we will create an own 'images' folder and place our image in there, so everything stays nicely structured.17:33
apacheloggerIf you are still outside the doctor-questionmark folder in a terminal you can use the following command to do that:17:33
apacheloggermkdir -p $NAME/contents/images/17:33
apacheloggerwget -O $NAME/contents/images/troll.png http://people.ubuntu.com/~apachelogger/uadw/09.10/data/troll.png17:33
apacheloggerIf not, just go to your contents folder, create the images folder in there and download the picture http://people.ubuntu.com/~apachelogger/uadw/09.10/data/troll.png into that folder17:33
apacheloggerNow for the code:17:34
apachelogger    // Labels can also contain images, so we will use a label again17:34
apachelogger    troll = new Label(plasmoid);17:34
apachelogger    // But this time we set an image. The image path is constructed automatically by us telling it in what directory it is and what name it has17:34
apachelogger    troll.image = plasmoid.file("images", "troll.png");17:34
apacheloggerSo, we do not only have a well structured folder setup, it also makes our code more readable.17:35
apachelogger(also in case you should notice, I did intentionally not add the label to our layout, in case you have not, nevermind)17:36
apachelogger    // So that our image fits in we need to tell the label to consume as much space as possible and necessary17:36
apachelogger    troll.sizePolicy = QSizePolicy(QSizePolicyMaximum, QSizePolicyMaximum);17:36
apacheloggerUsually Plasmoids will try to consume as little space as possible, this of course is a problem with a big image because then it would get cut off.17:37
apacheloggerBy telling our troll to try to use as much space as possible we can solve this 'problem'.17:37
apachelogger    // We only want to show the image after the user dared pressing the button, so we set it not visible and also do not add it to our layout17:38
apachelogger    troll.visible = false;17:38
apacheloggerHere is the reason I did not add the image to our layout.17:38
apacheloggerInstead the behaviour should be like this: user starts plasmoid, plasmoid looks nice, user is foolish enough to press button, troll comes up, user falls off chair.17:39
apacheloggerWhat is left to make that happen is making our button actually o things.17:39
apacheloggerAn for that we will use a very cool feature of Qt calle signal an slot (only in a simpler version).17:40
apacheloggerThe basic iea is that most objects in Qt emit a signal when certain things happen.17:40
apacheloggerOur button for example will emit one when it is clicked.17:40
apacheloggerAnd those signals can be attached to so-called slots, which are basically just functions.17:41
apacheloggerSo we want that when the button is clicked a specific function is to be executed.17:41
apachelogger    // First add a function to handle clicking on the button17:41
apachelogger    function onClick()17:41
apachelogger    {17:41
apachelogger        // Once our button gets clicked we want to show an image.17:41
apachelogger        troll.visible = true;17:41
apachelogger        // We add the new image to our layout, so it gets properly aligned17:42
apachelogger        layout.addItem(troll);17:42
apachelogger(keep in mind, our layout is putting items below each other, so our troll will be appearing at the very bottom right now)17:42
apachelogger        // To prevent problems we set the now useless button to not visible17:42
apachelogger        button.visible = false;17:42
apachelogger    }17:43
apachelogger^ do not forget this curly bracket there, to indicate the end of the function17:43
apachelogger    // Now we just tell our button that once it was clicked it shall run our function17:43
apachelogger    button.clicked.connect(onClick);17:43
apachelogger*save* and run again17:43
apacheloggerSince bulldog98 just pointed out that the window does not resize...17:45
apacheloggerYes, that is a bug (or maybe intentional) with plasmoidviewer, the plasmoid as seen in Plasma will resize properly. In fact if you resize the plasmoidviewer window the plasmoid will look just fine.17:45
apacheloggerNow since we are running out of time let us stop hacking and prepare a packge we can use to distribute our newly made Plasmoid.17:46
apacheloggerWell, package is maybe a bit of an overstatement, they really are just zip files with .plasmoid as file ending.17:47
apacheloggerThe crucial thing that makes it work is the folder set up we used at the very beginning.17:47
apacheloggerSo creating a packge we can share with people we want to scare is as easy as creating a zip.17:47
apacheloggerFor example using the following command:17:48
apacheloggercd $NAME &&17:48
apacheloggerzip -r ../$NAME.plasmoid . &&17:48
apacheloggercd ..17:48
apacheloggerThat again will only work if you still have the terminal with NAME set of course :)17:48
apacheloggerotherwise just create a zip of the content of our folder and change the file ending.17:48
apacheloggerIt is however curcial that you only package the content, not the folder17:49
apacheloggerYou can find a finished plasmoid and the code at http://people.ubuntu.com/~apachelogger/uadw/09.10/17:49
apacheloggerThis .plasmoid file can either be installed via the Plasma GUI ways (i.e. like you would usually add a plasmoid) or by using the command line tool plasmapkg17:50
apacheloggerplasmapkg -i $NAME.plasmoid17:50
apacheloggereither way the plasmoid should then show up in your widgets list and be ready to use \o/17:50
apacheloggerSo where to go from here?17:51
apacheloggerObviously this was but a simple introduction to Plasmoid programming17:51
apacheloggerand also not very fancy I must say17:51
apacheloggerYou can however try http://people.ubuntu.com/~apachelogger/udw/10.07/trollface-6/ this plasmoid.17:52
apacheloggerIt basically does a very similar thing to ours but introduces fancy animations and a way to get rid of the image again.17:52
apacheloggerAlso at http://people.ubuntu.com/~apachelogger/udw/10.07/videos/ I created some videos which show case some basic plasmoids.17:53
apacheloggerAt this point I should mention that Amarok, the music player, also uses plasmoids, so it is not all that difficult to get the same plasmoid with no code changes into Amarok and Plasma at the same time (if that makes any sense)17:54
apacheloggerYou can find a lot more information at the Plasma community page at http://community.kde.org/Plasma17:54
apacheloggerThere are pointers to tutorials for all supported programming languages as well as ready to go examples.17:54
apacheloggerAlso, if you want to pursue writing Plasmoids in JavaScript you will need the API reference at http://techbase.kde.org/Development/Tutorials/Plasma/JavaScript/API17:55
apacheloggerJavaScript is cool for simple plasmoids, but should you feel too limited by it, you can try Ruby or Python, they are not more complicated but give you greater control.17:56
ClassBotbulldog98 asked: can I simply convert your template to C++?17:56
apacheloggerThat depends on what you mean by convert.17:56
apacheloggerYou basically can use the very same program logic but you will have to adopt it to C++ code constraints.17:57
apacheloggere.g. a Plasmoid in C++ is contained within at least one class17:57
apacheloggerAlso you cannot do things like label.text = 'foo';17:57
apacheloggerInstead you will use setter methods, like label.setText("foo");17:58
apacheloggerSo direct conversion is not possible, because the languages are just too difficult.17:58
apacheloggerAlso if you need help or have further questions feel free to drop into the Plasma IRC channel #plasma17:59
apacheloggerThat is it.17:59
apacheloggerGood luck with creating your brilliant Plasmoids and have fun with steveire who is going to tell you about a magical thing called grantlee in a bit :)18:00
apacheloggerI wonder what grantlee is anyway....18:00
steveireHehe, you will soon find out18:00
steveireHello everyone and welcome to my talk.18:00
=== ChanServ changed the topic of #ubuntu-classroom to: Welcome to the Ubuntu Classroom - https://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Questions in #ubuntu-classroom-chat || Event: Ubuntu App Developer Week - Current Session: Using Grantlee to create application themes - Instructors: steveire
steveireI am Stephen Kelly, lead developer of Grantlee and part of the KDE community, mostly working on kdepim. I am a full-time employed Qt consultant and I write and maintain Grantlee in my spare time18:00
steveireSo what is Grantlee ?18:00
steveireI assume that any of you here attending the talk have done some googling to find out what it is and what it does, as the talk title is low on details.18:01
steveireGrantlee is a string template system. Such systems are common in web frameworks See more here: http://en.wikipedia.org/wiki/Template_engine_%28web%2918:01
steveireYou can see in the comparison table at that link that Grantlee supports all features of most other comparable systems.18:01
steveireThe only missing feature is i18n support, which should be available in a few months. That is the only open bug against Grantlee :) https://bugs.kde.org/buglist.cgi?product=grantlee18:01
steveireGrantlee is actually based on the design and syntax of the Django template system (but does not depend on Django itself)18:02
steveireIt is fully implemented in QtCore and QtScript, so it can be extended with C++ and with javascript18:02
steveireIt can even be used in gtk applications just by linking to QtCore and QtScript becuase Qt can run the gtk event loop18:03
steveirePackages are available for Lucid and Maverick: http://packages.ubuntu.com/search?keywords=grantlee18:03
steveireString template systems are used in web frameworks to create html markup to send to clients that request it. The template is a file containing the html that should be sent back to the browser, but with place holders for things like your username, your messages, the color that you have chosen in your profile etc.18:03
steveireWebsites often use such systems for scalability and code resuse18:04
steveireOn the desktop, we don't have web servers to generate html, but it is common for applications to create themed output using html. For example, Evolution email client can render the email viewer with different themes. This is done by generating different html with different css for each theme.18:04
steveireKMail also allows theming using various styles.18:05
steveireThe problem with an approach like that is that the html is often hardcoded into the source code, making it difficult to change existing themes or add new themes.18:05
steveireKMail had that exact problem, and in the past there were only 6 hardcoded themes available18:06
steveireIf a theme needed to be fixed or a new theme added, the application needed to be changed, compiled, packaged, and reach the distros before the fix became available to the users18:06
steveireDuring Summer of Code 2010 Ronny Yabar ported KMail and Akregator the RSS feed reader to use Grantlee. http://ronnyml.wordpress.com/2010/08/26/gsoc-final-report-messageviewer-kmail-and-akregator-ported-to-grantlee/18:07
=== SergioMeneses_ is now known as SergioMeneses
steveireThe project was a very useful step in the development of Grantlee becaus it shows what is possible, including sharing themes among users using GetHotNewStuff18:08
steveireSoon it can be used to create distro specific themes, such as a theme for the fluffy kde distro18:09
steveireWith this change it becomes easier to fix existing themes if they are broken, and it becomes easier for third party developers to create and share themes without having to send them upstream and have them compiled into the application.18:09
steveirekde-look.org can be used to share themes already: http://kde-look.org/index.php?xcontentmode=46&PHPSESSID=ee7d4bf311c5da8621c927303587bbc318:10
steveireThere are not many available, but it shows the infrastucture is in place which is already to familiar to artists and users (opendesktop.org)18:10
steveireAs a side note I would also like to say that Grantlee can generate not only HTML, but can generate any kind of text based markup - even computer code.18:11
steveireA developer could create templates for getting started creating plasmoids for example.18:12
steveireIn the Grantlee examples there is an application which can generate code for IDEs in C++ python and ruby languages: http://steveire.wordpress.com/2010/04/06/using-grantlee-for-code-generation/18:12
steveireFor application theming though, the more interesting use case is html generation.18:12
steveireAnother application in the Grantlee examples is the books example:  http://grantlee.org/apidox/examples.html18:13
steveireWe can get started by installing grantee through a package manager18:13
steveiresudo aptitude install libgrantlee-dev18:14
steveireAfter that we can download the grantlee source so that we can build the examples: apt-get source libgrantlee018:14
steveireOnce that is finished we can start navigating to where the examples are18:15
steveirecd grantlee-0.1.1/18:15
steveirecd examples/18:15
steveirecd books18:16
steveireThe books example is derived from the books example available in Qt: http://doc.trolltech.com/4.7/demos-books.html18:16
steveireTo build it we create a separate build directory.18:16
steveiremkdir build18:16
steveirecd build18:16
steveirecmake ..18:16
steveireThere is no need to install it18:16
steveireThe books example uses sqllite to manage a database of books. Grantlee makes it possible to create a html page from the table of data and theme it in any possible way.18:17
steveireAfter it is build you can run the example by executing it on the command line18:18
steveireThe top of the application shows the books in the database, and allows managing the authors, the genre, the rating etc.18:18
steveireNear the bottom of the application you can choose a theme to use when exporting the books to a html file and an export button for doing the actual exporting.18:19
steveireIf you click the export button it will ask for a location to save the html file (default to ~/book_export.html)18:20
steveireTry the export and open the file in a web browser. You will see the same data that is in the application now in the html file.18:21
steveireTry changing some of the data, like the rating or a genre and export again. You can then refresh the browser to see an updated html page18:21
steveireA html export feature like that is common in applications allowing you to export contacts for example or notes.18:22
steveireKJots has that feature too and actually uses Grantlee already for the export.18:22
steveireIf you're not following along, in the screenshots you can see the generated output from a plain theme, a colored theme, and a theme that regroups the output by Author. You can also see I am not a talented artist :)18:23
steveireUsing the combobox in the application you can also try out the different available themes.18:24
steveireThe regrouping is possible because of a powerful system of tags and filters in the template system.18:24
steveireGrantlee has all of the same features as Django templates have, so all of the same tags are available: http://docs.djangoproject.com/en/dev/ref/templates/builtins/18:24
steveireJust so there is no misunderstanding, Grantlee does not depend on Django or on Python. Grantlee depends only on the Qt4 framework. All tags and filters are written in native Qt4 code.18:25
steveireJust like Django, Grantlee can be extended by third partes by writing new tags and filters18:25
steveireThe tags and filters can't be implemented in python (yet), but can be implemented in either Qt C++ or in Javascript18:26
steveireThe wide range of tags available and the fact that there are many existing developers with Django experience means that really compelling themes can be created.18:26
steveireSo what does a theme file look like? There are some examples in the documentation and the links I have already given.18:27
steveireWe can walk through some of the features of theme files now: http://grantlee.org/apidox/for_themers.html18:27
steveireThe first example shows all the basics of template files.18:28
steveireIt is possible to make comments with {# comment tags #}18:28
steveireIt is possible to put placeholders into the template with {{ curly_braces }}18:28
steveireAnd it is possible to have more complicated structures like {% if %} condtions and {% for %} loops.18:28
steveire{% this %} is the extensible tag part of the template syntax18:29
steveireThe {% for %} tag is used to loop over the book objects in the book example. http://www.gitorious.org/grantlee/grantlee/blobs/master/examples/books/themes/simple.html18:29
steveireIn that template snippet, we have {% for book in books %}. books is a list of books from the database. Notice how the for loop is similiar to a python for loop, so it is familiar to people who have used python, and it is intuitive even for those that have not18:29
steveireFor each book, we create a html row with <tr> tags, and put attributes of the book into the placeholders, such as {{ book.title }} and {{ book.author }}18:30
steveireThis, as you would expect replaces the placeholders with the actual title and author for each row.18:31
steveireIn this case book is an object, and {{ book.title }} calls the title method on the book object and puts the returned value into the placeholder.18:31
steveireOther structures apart from objects are supported, such as QHash (like a python dictionary) and QList (like a python list). For more details of what is possible see http://grantlee.org/apidox/for_app_dev.html18:31
steveireFor the advanced coders, there is now even greater flexibility in the types of objects Grantlee can handle : http://steveire.wordpress.com/2010/09/29/grantlee-pairs-up-with-the-other-template-system/18:32
steveireGrantlee also supports advanced features like template including and inheriting. That allows sharing of snippets within a theme or with other themes.18:32
steveireAll of the themes in the books example share a common base template which sets up the structure of the output so that all the themes are consistent18:33
steveireWe can see that one in grantlee-0.1.1/examples/books/themes/base.html18:34
steveireIt defines a simple html structure with a html <head> element and a <body> element18:35
steveireIt also contains several elements I have not mentioned before: {% block %} elements18:35
steveireblock elements are the basis for the template inheritance and reuse system.18:36
steveireThe base template defines some placeholder blocks which the inheriting themes can fill, and reuse the rest18:36
steveireLooking again to the simple theme : http://www.gitorious.org/grantlee/grantlee/blobs/master/examples/books/themes/simple.html18:37
steveireAt the top it declares that it extends the template called "base.html".18:37
steveireIn a complex system there could be many possible base templates to inherit from with a different structure in each.18:38
steveireThe simple theme too has some block elements.18:38
steveireThese ones are used to fill the place holders defined in the base.html18:39
steveireSome of them also use the keyword {{ block.super }}18:39
steveireThis tells Grantlee that the block in the base template should be reused, not overridden18:40
steveireSo the "My Books" part of the header is defined in the base template, and the name of the theme is defined in simple.html, and they are combined into the title as you can see in the screenshot.18:41
steveireA theme could of course decide not to use the {{ block.super }} keyword, and not get the "My Books" part.18:41
steveireIt is optional to override all or no blocks in the base template18:42
steveireWe can make some simple edits to the theme now.18:42
steveireStart by editing the base.html so that the title line looks like {% block title_row %}<tr style="background-color:blue"><th>Author</th><th>Title</th><th>Genre</th><th>Rating</th></tr>{% endblock %}18:43
steveireYou can then re-export without rebuilding or even restarting the books application, refresh the browser and the displayed html will be updated wiht a blue background18:44
steveireSee the other theme files for more simple examples of changes that you can make to the generated output.18:44
steveireAdding such a capability to an existing application is ver easy.18:45
steveireIt uses the Qt QVariant and QMetaType system and supports all the basic Qt types.18:46
steveireIt is actually quite similar to the way QtQuick QML is used.18:46
steveireApart from KMail and KJots it is also used in several other code generation projects, and in a proof of concept twitter application by Ryan Paul:  http://steveire.wordpress.com/2010/05/20/grantlee-in-use/18:47
steveireThat's all I have prepared. I hope it was informative for you and you can consider using Grantlee for your next application theming or code generation needs.18:48
steveireThe grantlee community hangs out in the #grantlee channel on IRC18:49
steveireAnd is also reachable through the kdepim mailing list if you have any questions18:49
steveireSome more useful links to get started on understanding and using Grantlee:  http://www.gitorious.org/grantlee/pages/Home http://steveire.wordpress.com/2009/06/27/some-clarifications-regarding-grantlee/ http://grantlee.org/apidox/ http://www.djangobook.com/en/2.0/chapter04/ http://steveire.wordpress.com/18:50
steveireAny documentation relevant to Django is also relevant to Grantlee, so there are lots of ideas to find on the web :)18:50
steveireThanks for attending the talk. In a few minutes there will be a talk about enriching applications with zeitgeist data. Don't miss it :)18:52
=== ChanServ changed the topic of #ubuntu-classroom to: Welcome to the Ubuntu Classroom - https://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Questions in #ubuntu-classroom-chat || Event: Ubuntu App Developer Week - Current Session: Enriching applications with Zeitgeist data - Instructors: seiflotfy
jcastrook, looks like Seif is having connection problems19:18
jcastroWe might need to bump this class until tomorrow, please stand by!19:18
jcastrook since Seif can't get online we'll take a break until the top of the hour19:22
jcastroso smoke if you got em!19:22
=== mhall119_ is now known as mhall119
=== MSK61 is now known as MAfifi
=== ChanServ changed the topic of #ubuntu-classroom to: Welcome to the Ubuntu Classroom - https://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Questions in #ubuntu-classroom-chat || Event: Ubuntu App Developer Week - Current Session: Using Quickshot to collect screenshots" in multiple languages for s - Instructors: flan
flanWell, I guess that means it's time.20:01
flanFirst time I've done anything like this, so please let me know if I'm getting off-topic.20:01
flanOkay, so, this is a presentation on using Quickshot, a program designed to help you write better documentation by making it easier to get screenshots.20:02
flanIt's still not in Ubuntu's standard library, but it should be packaged and available by 11.04. For now, we have PPAs and Bazaar access.20:04
flanWe'll be using the latter of those options for today, if anyone wishes to follow along with the client itself.20:04
flanTo begin, you'll need to instal bzr, if you haven't done so already.20:04
flanI'd imagine most of you have, for some reason or other.20:04
flanIf not, though, it's a simple matter of "sudo apt-get install bzr".20:05
flanAround the 10th, Quickshot will be formally packaged into its final PPA form, but we're still working through last-minute changes and bug-fixes, so it's best to work with source right now.20:05
flanI'm going to assume everyone's got bzr now.20:06
flanIf not, please stop me.20:06
flanSo the next step is to pull the client's source from Launchpad, where we're hosting it.20:06
flanOh, before that, I should mention who "we" are.20:06
flanjenkins and I are Quickshot's principal authors.20:07
flanPlease feel free to ask us anything after the session is over.20:07
flanTo pull its source, use the command "bzr branch lp:quickshot".20:07
flanThis will create a quickshot/ directory under your current path.20:07
flanYou can delete it once this is done.20:07
flanThis lesson, I mean.20:08
flanThere's a lot of revision history, so it may take a minute or two.20:08
flanI'll use that time to spam you with information about what Quickshot it.20:08
flanIt's the screenshot-capturing tool created for the Ubuntu Manual project (http://ubuntu-manual.org/); it addresses a critical issue we encountered in preparation for 10.04: our inability to capture and catalogue thousands of screenshots in a limited timeframe.20:08
flanWe needed something that could ensure that we'd be able to capture screenshots in a consistent manner across languages, always have them available to drop into the documentation's build process, and allow for volunteers to help out with very little training.20:08
flanOur solution was to create a client-server system that would centralise rules and data, which formed the basis of the original Quickshot: a bunch of simple PHP scripts, text files, and a monolithic Python client cobbled together in a couple of weeks.20:09
flanThe new version is far more robust.20:09
flanThe server is implemented using Pylons and has the ability to scale to any number of hosted projects and languages.20:09
flanThe client is Python with Glade, designed to work with any number of servers (and with plans for full internationalisation support for the next iteration).20:09
flanThere's a decoupled client library that allows anyone to programmatically interact with the server, to script screenshot captures as part of a controlled build process.20:09
flanContributor credit is logged on a per-project basis, so volunteers don't have to be anonymous if they don't want to be.20:10
flanThe server provides a means of allowing any number of owners to review and accept screenshots submitted by volunteers.20:10
flanAnd progress reports are neatly broken up by language and stage, making gauging performance in large projects easy.20:10
flanInitially, I'd like to have everyone play the role of a volunteer, capturing a screenshot or two to learn how the process works in case you want to deploy Quickshot to support your own projects and need to train users.20:10
flan(If you never use it again, maybe you'll be able to mention it to someone who will need something like it)20:11
flanAfter that, anyone who's interested will be invited to hold the role of owner over what we've done today, letting you see the other half of the system.20:11
flanWhile we're waiting for any remaining pulls to finish, does anyone have any questions? I'll entertain them in either channel.20:11
flanOkay, I'm going to continue.20:13
flanBefore I have any of you run the client, a disclaimer is in order: there is a lot of code and it has not been thoroughly peer-reviewed.20:13
flanIf you do not feel comfortable trusting that what you've just downloaded is safe, you are not obligated to execute it, and you can still benefit from this lesson.20:13
flanIf you're in the doesn't-fee-safe-running-unsigned-code group, please follow with the discussion and jump in again when we get to the server-management part.20:13
flanFor those willing to actively follow along, please let me know what you get when you type "echo $LANG".20:13
flanI'll add your languages to the server so you don't get any "language not supported" messages.20:14
ClassBotgoogle-fu asked: I've tried Quickshot a while ago and from what I remember, in order to use the program you have to create a new user and log in to that user for the program to work. I find this thing annoying, is this still required?20:14
flanNo, not for this demonstration.20:14
flanThat's still a requirement for our parent project, the Ubuntu Manual Project.20:14
flanBut it's now fully optional, and can be toggled on a per-project basis.20:15
flanSame with screen resolution.20:15
flanWe won't be changing any of that stuff today.20:15
ClassBotTobiS asked: whats the line to pull Quickshot from the remote repository?20:16
flanbzr branch lp:quickshot20:16
flanOkay, I'm going to continue.20:18
flanPlease paste the following command: "wget http://flan.uguu.ca:5000/appdevweek/10-10/%5Bappdevweek%5D10-10.qsproj"20:18
flanThis will download a "qsproj" file, which is really just a chunk of text that tells Quickshot about a project. Live details are always pulled on connection.20:18
flanWhen done, type "cd quickshot/source", followed by "bin/quickshot".20:18
flanYou will see some WNCK-related warnings. These are entirely benign, so don't worry about them.20:19
flanBrowse for the file you just downloaded in the "Local files" section of the Quickshot window, then click "Get started!"20:19
rooliganWhere to issue wget?20:19
flanIn any terminal.20:19
rooliganIn any directory?20:20
flanSorry. I should have been more clear.20:20
flanYeah. It just downloads a file.20:20
flanYou may wish to join #ubuntu-classroom-chat. There's more discussion going on there.20:20
flanAfter a brief moment, you should see a list of six screenshots.20:21
flanIf you see a message about the connection to the server timing out, that's not entirely unexpected (the server we're using today is single-threaded). Just retry or click "Reload" when you see the empty list.20:21
flanThis presumes you've pointed Quickshot at the .qsproj file.20:21
flanJust in case anyone missed that part.20:21
flanYou'll all also see another window in front of the list of screenshots. Feel free to enter any information you'd like, or use "anonymous@example.org" and leave the other fields blank.20:21
flanThis window will only appear once. If you wish to change your settings, you can access the window under the "Edit" menu.20:21
flanOkay, now please resist the temptation to click anything.20:22
flanAnd let me know if I'm going too quickly.20:22
flanI'd like a volunteer who is using a non-English Ubuntu environment to help get us started.20:22
flanSo, serapophis has volunteered. Yay.20:23
flanserapophis, please pick the 'gedit' screenshot by either double-clicking it or highlighting it and clicking 'Forward'.20:24
flanYou'll be presented with a list of steps on the left and a message on the right saying "No reference screenshot available"; the rest of you will see something similar soon.20:24
flanQuickshot uses any accepted language's version of a given screenshot as a reference for future captures, but nothing's been accepted yet.20:24
flanOnce you're comfortable with what you've been asked to do, click "Capture".20:24
flanAt this point, I'd like to ask everyone else to either click the "Quickshot progress" link on their clients or visit http://flan.uguu.ca:5000/appdevweek/10-1020:24
flanYou'll all see three progress bars, one for 'en', which includes 'en_US' and 'en_GB', and one for the language of our brave volunteer. And daker's crazy language. Il est fou.20:25
flanQuickshot automatically reduces languages into a parent if no specialization was declared.20:25
flanIf we created en_CA, Canadian screenshots would be captured independently of American ones.20:26
flanThis is for languages that have significant differences between dialects.20:26
flanOkay, so, getting back on topic, serapophis, please foloow any on-screen instructions.20:27
flanAll you should see is a message telling you you have three seconds, after clicking 'OK', to give gedit focus.20:27
flanIt'll automatically look at the last-activated window and try to use that if you don't explicitly give focus to any window.20:27
flanPlease let us know once you're presented with a window that asks you to confirm that everything looks good.20:28
flanThe rest of you will be doing this soon.20:28
flanExcept you'll have the benefit of reference screenshots.20:28
flanOkay, serapophis, just click 'Submit'.20:29
flanEveryone else, reload the page I asked you to open.20:29
flanYou should see progress in the de_DE field.20:29
flan...Or maybe you won't.20:29
jenkinsi was about to say the same :)20:30
flanHave you been returned to the screenshot list, serapophis?20:30
flanOkay, it might just be taking a while to upload.20:30
flanI guess I'll need to work on that. Sorry.20:30
flanThe interface is supposed to freeze during the upload process, but I figured it would be graceful.20:31
flanOkay... I was able to upload an English one without issue...20:32
flanserapophis, what sort of connection do you have?20:32
jenkinsi guess we can carry on with the en one I will try and work out what if it is just serapophis connection20:34
flan13:37 <+flan> Okay, so we're a little off from where we should have been, but  can I get everyone else to try taking a screenshot for gedit now?20:37
flanYou should now all see a reference screenshot on the right side of the window.20:37
flanjenkins, please take the IRC screenshot so I can let them see it, too.20:38
jenkinswill do20:38
flanIf you click this reference screenshot, you'll see a full-size (but JPEG-compressed, for transmission speed purposes) version of what was captured.20:38
flanOkay, for our German users, try capturing the IRC screenshot.20:40
flanYou'll now see what everyone else is seeing with Gedit.20:40
flanFeel free to take whatever screenshots you want for the next couple of minutes.20:40
flanIn the meantime, I'd like everyone's OpenID. You should have one from Launchpad.20:41
flanMine is https://launchpad.net/~red-hamsterx ; yours will be similar, only with your name at the end.20:41
flanThe Quickshot server doesn't use passwords, opting instead for OpenID. The virtues of this system are the subject of another lesson, though.20:41
flanOther OpenID providers are okay, too, of course; Launchpad's probably just something you've probably all used.20:41
flanOkay, for anyone who's offered their OpenIDs, you can now log in at http://flan.uguu.ca:5000/appdevweek/10-1020:43
flanThe field's in the top right.20:43
flanIt should be the same process as with any other OpenID-enabled site.20:43
flanYou provide your URL, your provider tells Quickshot that you're really you, and you get access.20:44
flanWARNING: Quickshot, like almost every program, has the ability to run arbitrary commands on your system. In a moment, your peers will be able to control the commands it runs. Please be sure to check the command to be executed before you capture a screenshot.20:44
flanI don't think anyone here's malicious in the slightest, but it doesn't hurt to be paranoid.20:44
flanOnce you've logged in, you'll notice that there's now a new bar in the top right that says "Manage version". Each language will also be clickable.20:45
flanFirst, click any language with progress. You'll notice that some screenshots are in the "pending" state, which means that they can be approved or rejected.20:45
flanPlease feel free to play around, but show a little restraint, since the server is, again, single-threaded, so you don't want to choke out anyone else.20:45
flanAlso, this is actually running on a home connection, so please refrain form clicking the 'download archive' links; I need my bandwidth for other things.20:46
flanSo, yeah, just click around.20:46
flanSubmit multiple versions of pending screenshots and see what happens.20:46
flanThis is what people who are managing Quickshot projects will see, allowing them to collaboratively decide what to accept and what to reject.20:47
flan(We're very open to feedback on how to make it simpler, if there's room for improvement)20:47
flanAs you accept screenshots, the credit report on the project page will also be filled out.20:47
flanOnce you've played around with that stuff to your satisfaction, go back to http://flan.uguu.ca:5000/appdevweek/10-10 and click 'Manage version' in the upper right.20:49
flanYou can use this itnerface to add new languages (like fr_CA, for crazy Quebec types), change screenshot details, change the order of screenshots, and add new screenshots.20:50
flanYour changes will be immediately reflected on every Quickshot client.20:50
flanThere's also a feature that allows to you translate a screenshot's steps, but we won't be playing with it today.20:50
flanYou'll notice that 'en' doesn't appear in this section.20:51
flanThat's because it's actually a property of the parent project, http://flan.uguu.ca:5000/appdevweek20:51
flanThis means that every Quickshot project that's a part of AppDevWeek needs to support English.20:52
flanBut de_DE and fr_FR are specific to this one week.20:52
flanOh. Please do not toggle the username or resolution settings.20:52
flanWe don't want to force anyone to create a new user account for this demonstration. That would just be mean.20:52
flanAnyway, please feel free to keep playing with the system for the next little while (I'll leave the project active for a couple of hours).20:53
flanI don't really have anything else to say or add, but I do hope you've found this informative and know that, yes, there is now a tool that exists to make putting screenshots into big documentation projects a not-so-daunting task.20:54
flanIt just involves getting a bunch of volunteers together.20:54
flanWe'll be launching production-ready versions of the client and server shortly after the next edition of the Ubuntu Manual is out, around the 10th of October.20:54
flanThe code, and a set-up guide for the server (and maybe a brief user guide for the client) will be available at http://quickshot.org.20:55
flanIf you have any questions, please ask either myself or jenkins.20:55
flanIf you want to know how something was built, please ask me.20:55
flanIf you want to report a bug or usability enhancement, please ask jenkins. (He's better at handling criticism. =P)20:55
flanIf you know of any projects that could benefit from Quickshot, please let them know about it,.20:57
jenkinsapport will still sent the logs to launchpad with out a hard crash iirc20:57
flanAnd let them know what we can always be found in #ubuntu-manual.20:57
flanAnd now I clear the stage for the next session.20:57
flanThank you for your patience and interaction, everyone.20:57
flanOkay, so I've got the channel to myself, to bend to my twisted, evil whims.20:58
flanNow I just need some twisted, evil whims.20:58
flanAnyone else want server access?20:58
flanJust costs an OpenID URL.20:59
flan(Your OpenID provider retains rights to your soul and banking information)20:59
=== ChanServ changed the topic of #ubuntu-classroom to: Welcome to the Ubuntu Classroom - https://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Questions in #ubuntu-classroom-chat ||
=== yofel_ is now known as yofel

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!