ChaniBlog











{December 29, 2008}   adventures in plasmaland, part 1

huzzah! I finally fixed all of plasma-overlay’s known bugs, and made the config ui actually work :) it only took a couple of days to round up the last few things, surprisingly. now I finally have the option to write code that is *not* bugfixes for my damn soc project.

I think it’s about time I did some fun little plasmoids instead of working on big crazy things. yes, we’re in feature freeze, but I’ve been bugfixing for 4 damn months :P I need a break. I have a ton of ideas for small, (hopefully) simple plasmoids and I want to try them out. I also thought it’d be fun to try and do them in ecmascript (or javascript or qtscript or whatever you call it) to see just how hard it is to do this. :)

so, join me as we dive into plasmaland and try to create a brand new widget fropm scratch without any of that silly crashy c++ :) right now I have no idea how to do this; I knlow plenty about plasma internals, but almost nothing about the language bindings or how a modern widget needs to be made.

let’s start with techbase. hmm. plasma’s tutorials page has a c++ tutorial… not quite what we’re looking for, and I’m not sure whether it’s up-to-date, but it’s sure to give us *some* useful info.

well, looks like we need a .desktop file to start out (ok… I already knew that from seeing them in every applet’s folder, but I had forgotten). there’s a nice little example here to copy, or I could grab one from an existing applet.

as for other files in the plasmoid… I imagine this will depend on whether I want to make a plasmagik package that can be bundled up and downloaded easily (hooray for GHNS) or just a folder in svn that can be compiled and installed like the oher c++ plasmoids there. hmmm. well, I can only find one scripted plasmoid in playground and it’s not being compiled, so it’s time to ask for help.

ok, so it turns out that while it’s *possible* to have a scripted plasmoid that gets installed when I compile and install from svn, it’s a small amount of extra work (that of writing a proper CMakeLists.txt) and I first have to have a regular plasmagik package anyways. the usual method of getting scripted plasmoids to show up in plasma is either the “install new widgets” button in the add widgets dialog or `plasmapkg -i` – so let’s start with making a regular package and maybe I’ll fiddle with cmake at the end. NTS: the install button only works with zipped packages; unzipped folders can only be installed manually with plasmapkg.

so I guess before I should go any further I should probably tell you what plasmoid I’m writing. :) I’m going to make a little popup menu that lists all the kcm modules (spot the redundancy ;) because I just don’t like the new system settings app. in kde3 I found a little applet that gave me quick access to any config module from my panel, and I miss it. I’ve already memorized where most of the options were in that old tree structure, so I might as well keep using it.

this should be pretty simple: all I need to do is get a list of all the modules, display that list (preferably within categories), and then have the config module launched when its entry is clicked.

so, we start at the very beginning with a folder. I hate thinking up names for things, so… let’s call the plasmoid kconfigmenu. now, according to the plasmagik structure, we need a metadata.desktop and a contents/ folder. apparently we should have a metadata.xml too, but there’s no real explanation of that, so we’ll skip it for now (the tiger plasmoid seems to do just fine without one).

so, what to put in our metadata.desktop? well, let’s steal one of the examples and modify it to suit our needs. change the name and comment, pick an appropriate icon (I’m not going to be making any of my own art for this, just using existing icons), set the author and so on… that techbase page mentions some other options that aren’t shown (like a minimum plasma version) but I’m just going to skip those for now.

now that we’ve got our metadata, maybe we can put in some code. we need a code/ folder in contents/ and then a file called main.js in code/.

so now… what the hell do we put *in* this main file?
haven’t the foggiest. my knowledge of javascript is pretty faint, too. but let’s start by trying to make an applet that fails to launch with a specific message: that should be easier than trying for some hello-world with widgets right away, because Applet has a setFailedToLaunch function and I should be able to figure out how to call that in javascript, right?

from looking at the tiger plasmoid, I get the impression we start with an applet already existing, conveniently called “applet”. ok, let’s try using that.

well, I installed it, and it showed up in the appletbrowser all pretty, but actually running it didn’t go so well. it failed to launch, yes, but with the wonderfully unhelpful message “script initialization failed”.

next step: running it in plasmoidviewer. from there it’s easy to watch the debug output, and among some odd things that make me question the sanity of the bindings, I see this:

QScriptApplet::reportError: Error:  "ReferenceError: setFailedToLaunch is not defined"  at line  3

ouch.

so… do the qtscript bindings not expose that function, or am I doing something else wrong?

several hours later…

they don’t have it. they’re also missing a bunch of other stuff. I’m gonna go into technical details now that are farily irrelevant to people only wanting to *use* the bindings and not actually understand them.

So I fixed a blatant bug in libplasma and added a couple of functions; seems we have this AppletScript class that has to exist to expose protected members, because bindings can’t access those and they cover fairly important bits of Applet. had to add some methods to that class; there are probably more things that’ll need adding later, but let’s just get config and failedtolaunch stuff working first.

so then in the qtscript bindngs there’s a QScriptApplet that inherits AppletScript and does some odd binding-magic… it exposes the applet directly, which is fairly useless because only slots (and maybe qinvokables, etc) are actually accessible that way. it also has a half dozen static methods, some of which expose useful Applet functions and some of which do other strange but presumably useful things. I started trying to add functions here to expose AppletScript API, but then I realised that that way lies madness. I also find it really weird that things like update and setLayout are static functions that jump through strange hoops to get an applet pointer. it’s already weird enough that we’ve got some things accessible through applet and some as top-level functions (from the script’s point of view).

I decided the sane way to add a bunch of functions that merely expose AppletScript API would be to put them in their own class and have QScriptApplet expose an instance of that… then I realised that doing that meant I could also give my new class functions to expose bits of Applet that couldn’t be directly accessed. yay! to the script it’ll look like just one happy applet object.

another hour or so later…

huzzah! I have an interface… it only has one function, setFailedToLaunch, but that one function does work. :) now I just have the long task of writing a function for every useful method… *sigh*

hello world!
we’ll continue writing this applet after I write myself some bindings. ;)

goddamnit fuck. I had another whole day’s worth of writing here, and it just vanished into thin air when I pressed the save button. wordpress and konqueror are both pissing me off a lot recently. :(

I don’t feel like rewrting it all. suffice it to say, qtscript is weird and hates enums and its documentation about them is wrong to boot. still, I made the damn things work in the end. for certain values of ‘work’.

I’ve spent all day working on those bindings. not exactly what I’d planned, but it is fun. :)



{December 22, 2008}   can I get any lazier?

I’ve never really cared much for studying. Trying to memorize facts seems incredibly boring (although digits of pi aren’t ;) and it’s always a struggle to actually get anything done.

This semester i had two math classes – and sfu math classes are hard, so i can’t just ignore them and expect an A. ;) So i decided to use a tool pete uses for language training to help me memorize the boring bits of the math classes (which turned out to be almost all of them).

It’s called anki, and it’s a cute little flashcard program written in pyqt4. It also has a web interface and a client for the iphone iirc, although i haven’t used those. It was originally designed for learning japanese, but it’s expanded since then. It’s got LaTeX support, so writing crazy math equations isn’t a problem. The spaced learning system trains your brain to remember all the facts you’ve entered – all you have to do is enter those facts, and then actually use the software for a few minutes each day. :)

I didn’t start using it until after the first midterm, and i haven’t been very consistent with the actually-using-it bit… But i think it really helped me. I had pretty much no motivation to learn the material; i seem to have lost interest in math. :( But entering facts into anki helped me think about it – i had to break things down into little pieces that’d work well as flashcards – and kept me reading the textbook when i couldn’t be bothered with the homework.

One thing that doesn’t work so well: cramming a bunch of data in right before a midterm. Spaced learning doesn’t work when there’s no time for things to be spaced in ;) my second midterms didn’t go so well. By the time the final came, though, i had more than half of each course’s material in there. I had to study the things that weren’t in there – a lot of which i’d completely forgotten and had to relearn – but for subjects that were in anki, i just skimmed the material and looked at a couple of things i’d been getting wrong a lot.

I think this worked out pretty well. I got a nice mark on the final for macm 201. I didn’t do as well on math 152, but i still ended up with a B+. Some things anki just can’t help with; evaluating integrals takes more.. Lateral thinking, i think. Just knowing a bunch of facts isn’t enough. but when material *can* be broken down into lots of little facts, anki signifigantly reduces the effort required – and turns something i’d normally find horridly boring into something almost like a game, where i can just keep clicking and answring questions as it asks them. :)

so if you’ve got lots of facts you need to memorize, and you don’t like doing it (does anyone?), give anki a try. :)



{December 11, 2008}   fosscamp day 2, and exams

this blog post is a bit delayed; I blame exams. sunday I had to head home, and my first exam was on tuesday; it went surprisingly well for one day of studying. now I’m studying for math; my next exam is saturday morning. with a snow warning. ugh. still, being at home studying beats being at school sitting in lectures. so long as I actually do accomplish the studying bit ;)

as for fosscamp… saturday I skipped coffee. maybe that was a bad idea, because my head felt muddled all day. there was talk about leadership in the morning, except I don’t think anything actually was produced from that other than a list of challenges leaders face. then there was a discussion on community… it sounds like canonical has some friction between its paid and unpaid developers. :) I’m glad we don’t have that in kde; I’m not even sure who gets paid around here. it just doesn’t really matter. what I got out of that discussion was that having a healthy culture is very important; people can be counterproductive in all kinds of dumb ways if they don’t feel like they’re on the same team.

the next talk I was at was a more technical one – it was about cool futuristic user interfaces, some of which already exist for the army or in other places, but haven’t really made it into the real world. we heard about some neat stuff that’s been done with fancy hardware, and we were just getting into a discussion about what useful stuff we might be able to do with generic hardware (ie your laptop’s mic and camera) when lunchtime came and we were herded outside. I wish we’d gotten to that stuff sooner. it’s kinda odd that while computers are getting more powerful so quickly, we’re still sitting in front of basically the same interface, still using pretty much the same desktop… well, at least the desktop part can change now :) but it’d be nice to see some research into new UI concepts that people would actually want to use. I’m not sure about voice control, but I wondder if a webcam could be used to fake focus-follows-mind… ;) although I imagine it’d take a fair bit of processing power to track even basic movements, so maybe that’d be a waste of resources. I dunno.

anyways, after lunch I was online for a while, then showed off shiny kde bling. I wish I’d prepared a bit more for that; I wanted to talk about the frameworks, but discovered they’re kinda hard to explain, and my laptop was broken in several ways so I borrowed someone else’s, which didn’t even have extragear installed… anyways, a few of us ended up chatting outside the doorway for a while after our time was up, and I got to show off a few more things on my own laptop.

when the conference was over, blauzahl somehow talked people into letting us go hunt down the android statue and take pictures there. I’m feeling too lazy to track down the photo of that – it’s on riddell’s blog. after dinner that night (we found a sushi place that rather obviously wasn’t used to vegetarians, but I sorted things out eventually) some people were playing cards back at the hotel :) great way to spend an evening. Cambridge rules for the chariman’s game are a fair bit different from the ones played at SFU, though.

no hot tub party that night, unfortuantely… I was completely exhausted, and had a plane to catch in the morning. it seems kinda weird how tired I get at conferences; I didn’t even have a time zone change this time! and blauzahl claims to have been awake half the night, but still managed to get up in the morning and accompany me to the airport. :)

so now I’m back in canada, back to studying (or attempting to). wish I could have stayed for all of UDS… although it is kinda disconcerting being at a conference where “the desktop” is assumed to mean “the gnome desktop”.

one disappointing thing: the food quality wasn’t what I had expected. yes, I’m picky. the hotel breakfast had a strong focus on eggs and bacon, and service from people who need tips to survive is just as annoying as (if not more so than) service where tips aren’t even understood. maybe I just don’t like service in general – I’ve always preferred ATMs to going inside banks. and lunch at google, while healthy and certainly adequate, wasn’t as cool as I was expecting – apparently at UDS they’re allowed into the actual cafeteria which is much nicer. I’m jealous ;P

I suppose I should go back to studying now… it’s really hard to *care* about exams when I’m so close to freedom…



{December 6, 2008}   fosscamp day 1

whee! the first day of fosscamp is over. apologies if this isn’t the most coherent of posts; I haven’t figured out how to keep my sanity at these events ;)

I arrived yesterday evening, feeling jetlagged despite being in hte same timezone. met far too many people, forgot most of their names, and discovered delicious delicious brownies. there were also ridiculously humongous drinks at the hotel bar; chris cheney bought one, and there are pictures out there somewhere now. :)
I was up far too late chatting with people, but my memory is as bad as usual, and I haven’t had time to look at my written notes. oh well…
in the morning I found out my n810 is having serious charging issues :/ there’s something funny about the charging socket, and it seems to be getting steadily worse :( by this afternoon I was spending five minutes fiddling every time I tried to plug it in. wah. that’s gonna be a pain. I’m just glad it still charges at all.

anyways, we got onto the mystery bus and headed off to google, where quite a few people were milling around. there was yummy juice, and a schedule up on a whiteboard, and it quickly started filling up… people continued adding to it all morning, which made planning a bit hard :) several times I wanted to be in two rooms at once, and tried to bounce around and catch at least some of everything… but that usually backfires on me, so I tried to limit myself to two rooms per hour ;)
I should have written more notes; I’ve already forgotten much of the morning. at 10 there was openldap and audio stuff in the morning, but audio turned out to be kernel-level discussions – cool, but not interesting to me. openldap… I dunno. sounds like they’re relying on ubuntu to do a lot of work, which makes me wonder what other distros are gonna do (not to mention ubuntu’s standard attitude towards kde).
at 11 blauzahl was talking about bugs, and I was mostly in another room… umm… I have no idea what room, though. blank spot there. maybe it was one of the many times I ran into someone in a hallway and struck up a random conversation.
at 12 there was a talk on opensocial, which sounded really interesting, but I gave it up to go to the talk on ui innovation. that was… well… nothing new, really, except in that it’s new to *gnome*. they’re wishing it was easier for users to try out new apps and applets, give feedback, etc… and for developers to share their work without a huge amount of packaging hassle. that’s just crying out for DXS imho; the only interesting bit is that they think it’d be good to be able to do stuff for entire applications (possibly including c/c++ ones), not just little applets. which reminds me of klik.

at 1 we had lunch! yaay food! :) I had a really interesting conversation with arne about translations and input methods. sounds like some changes are needed in how input is handled, to make input methods (chinese etc) less of a hack… but change is always hard. I hope he’s successful. :)

at 2 there was some oss biz thing, but my attention span didn’t hold out past the “how much money do these oss companies actually get” phase, so I wandered off and found people talking xrandr n’stuff. someone was really happy to have his touchscreen working with both rotation and compiz – although the mouse behaviour while rotated was amusingly broken :) then I got into some sort of kde discussion with adrien (the nepomuk guy) and a kde user… it’s so nice to hear that people are impressed with 4.2 and like what we’re doing :)
at 3 I meant to spend my time in hte nepomuk talk (we need to get more apps taking advantage of it! app devs, are you aware of the potential?) but my mind wandered off and I found myself walking around aimlessly… I can’t quite remember where I ended up. I know that I was getting really tired and decided to have a nap, but then I needed to plug in my n810 again, and then I found myself at a table chatting about desktops with a gnome ui guy. while we get lame complaints about being “too vista” or “too mac”, they get “too kde4” for their mockups ;) you just can’t win.
after that I wandered into another random talk… on… messaging. except it turned out to really be about thunderbird, and whether or not it was going to integrate with this or that someday in the future. and I was kinda too exhausted to process half of what people were saying by then. meh. one thing I like about kde, we’ve got so much integration, at least between our apps… and as kde4 matures we’ll have even more, I suppose…

I’m sure there were other interesting things scattered throughout the day, but… I’m too tired to bother reading my scribbly notes.

dinner was nice. yummy food, interesting conversation (the not-entirely-unlike-dxs thing started to sound a lot more interesting, and we discussed dreams of security that wouldn’t be too complicated for regular users)… and then I got back and there was pizza! yum. I went back to my room and was too tired to leave again, until blauzahl and riddell came by and convinced me to go out for a swim. :) that was nice. hot tubs ftw.
now it’s late, of course, and I’m going to collapse into bed so that I can survive another day. :) hopefully I’ll be talking about something tomorrow, but I find myself trying to find excuses not to…

it’s really awesome to be back among foss geeks, btw. :) so many bright people around, so many great conversations… it’s gonna be hard to go home and cram for exams on sunday.



et cetera