Wednesday, August 16, 2006

Order of the zoom actions - vote for your favourite toolbar layout here

In a previous post I talked about taking the number of KolourPaint toolbar buttons down to a minimum, partly in response to the new KDE 4 default of "Text Under Icons" and partly, to fix the dumping ground the toolbar has become.

Thanks very much to everyone who commented on the proposal.

Recall that KolourPaint in KDE 3 looked like this:



New Proposal for KolourPaint / KDE 4


And now, based on your feedback, my latest proposal for KolourPaint in KDE 4 is:


Due to popular demand, I've added back the "Open" and "Save" buttons. I feel that just having a "Save" button as suggested is not sufficient for a paint app where one may open pictures often - this is different to a database app, like Kexi, where one usually manipulates just one DB.

As for concerns regarding removing buttons effectively hiding functionality from users less comfortable with computers, it is difficult to cater for a broad audience but I think overall, the new toolbar layout is more useful for more people since it's less cluttered and has bigger, easier to click buttons. It is of course configurable - this discussion is merely about the most popular defaults.

As you can see from above, I've also made fixed those Undo / Redo buttons so that they don't keep changing their labels (e.g. from "Undo: Text" to "Undo: Connected Lines") so that their sizes remain small (otherwise, think about the German translationa) and constant.

Also, thanks for some of the more creative ideas that were posed but unfortunately, I won't have time to implement them for now.


Dumping Text from the Zoom Actions


It was suggested that I dump the text from the zoom buttons (like KDE 3) to save space. I played with this but unfortunately, the smaller buttons are much harder to click:


So, large buttons with text it is.


Order of the Zoom Actions


But a remaining issue is the order of the zoom actions:


Which one is the best? Answer: I don't know.

B1 is used by KolourPaint in KDE 4 and Acrobat Reader. The ordering of the zoom actions is certainly more conventional but for some reason, seems clunkier.

B2 is used by okular. But the zoom actions look reversed. Yet, for some reason, the order feels more natural (I guess I zoom in "[+]" more often and as a left-to-right reader, it should come first?).

C2 is used by KolourPaint in KDE 3. The advantage of this scheme is that I frequently press [+] a few times until it's zoomed in enough and then I can just move the mouse a short distance to [-] to adjust. In contrast, this adjusting is made more difficult by the [+] and [-] buttons being far apart as in the cases of B1 and B2. So C2 is my favourite.

But I haven't really decided and in any case, this should be standardised across KDE apps so it would be great if you could vote for the one you prefer by adding a comment to this blog entry.

The final design will be chosen based on your votes so vote now!

Tuesday, August 15, 2006

No one checks credit card signatures

Everyone, I think, knows this. Was just pointed to this article at zug.com:

The Credit Card Prank. Absolutely hilarious, starting with the second page.

Have not had time to read Part 2 because I've spent too much time blogging :)

Log system events to VC 12 (CTRL+ALT+F12)

... as inspired by Mandrake 7.2 (2000):

The service syslog starts the system logger syslogd,
which reads /etc/syslog.conf. Add *.* /dev/tty12
to this config file and voila!

ssh tunnelling, tunneling or port forwarding

This is the most straightforward explanation of SSH tunnelling I have ever found. Unfortunately, this page doesn't show up as the first hit in google if you spell "tunnelling" with one 'l'.

This command is equivalent to the example given on that page:


ssh myuserid@gate -L 7777:work:22 cat -


Now for some clarification of this weird but effective syntax:

1. Traffic on port 7777 on your local machine goes to "gate" via the ordinary ssh port. "gate" forwards this traffic on to port 22 on "work".

As port 7777 is a local port, you can choose this to be pretty much anything from 1024 onwards and don't have to reconfigure your firewall.

You can change port 22 (ssh) to e.g. http to access the web server on "work" as if you were sitting at "gate". Now access http://localhost:7777/!

2. The name lookup for "work" occurs on "gate", not your local machine. This is very useful.

3. The "cat -" is a hack to keep the tunnel open.


I'm no network guru and have been wanting to learn this for ages but only found explanations that go on for pages about how great ssh forwarding is without actually giving a straightforward example. Others were obsessed with the intricacies of command line options.

For these reasons and because I don't have time to read a tutorial longer than documents I give to lawyers, I still have no idea how to write iptables rules by hand. If all documentation was like that we would all be spending most of our lives reading instead using computers. Hardly, a "simple primer" as claimed. So when I find a simple tutorial about iptables, I'll blog it.

Thursday, August 10, 2006

The fun of politics 2: Tuckey vs Beazley

If you think the antics inside Australian parliament are funny, wait till you see our favourite politicians outside of parliament. Wilson Tuckey, a hard right-wing government member takes on I'm-trying-be-prime-minister-for-the-3rd-time, Opposition Leader, Kim Beazley:


Beazley: Take your tablets mate.
[...]
Tuckey: Don't you insult me with tablets ... I am as entitled to stand here as you are.
[...]
Beazley: Why don't you take your weak worthless self in there with the weak worthless legislation?
[...]
Tuckey: Don't you call me weak and worthless you [mouths "stupid"] fat so and so.


But there's nothing like the actual video. Use one of the following links from most direct to least (sometimes, embedded video in Linux can be painful):


Direct WMV Stream

Page with embedded stream

Commentary (click on "clip")

Google News search (it's hard to get to the original story as it seems to have been censored off most news sites' main pages)


This whole confrontation was about the government's proposed, tough, new immigration laws that will have boat people being imprisoned at sea! In fact, so tough that several government members later crossed the floor and one resigned. Notice that Beazley was caught off guard in that video and accused the legislation of being "weak", as Tuckey picked up on.

Other interesting happenings include an opposition member bringing in a
stuffed chicken (check out the pic!), getting ejected from parliament along with a fellow member who exclaimed "such a poultry offence" (pun intended).

Lastly, sorry, I haven't checked my email for a few days. I'm very busy but just couldn't help but put up this gag that made my day. I'll deal with email and LCA preparations on Sunday (I promise this time). If something's urgent, please email me through my yahoo account.

Sunday, July 30, 2006

Brad Hards: thanks!

I met up with Brad Hards who was in Sydney yesterday. It's really great to meet someone in person that until now, I had only known on the internet (the only other person I've met in this way was Bart Oldeman from DOSEMU).

We had a very short meeting but he gave me some of his "old" hardware: a P4 3GHz HT machine and a P3 1GHz laptop, both with loads of disk space and importantly, RAM (1GB and 512MB respectively). This is truly impressive stuff that will dramatically improve my productivity:

With the hardware I was using before (and will still be using for a few days until I get the new stuff setup), a 2 line change to kdelibs/kdeui meant that I had to wait several minutes for cmake/make to rediscover libkdeui's dependencies, compile and install (and yes, I am compiling in the kdeui/ directory only), while the computer was thrashing due to the lack of RAM (224MB), worsened by a slow hard disk (10MB/s maximum sequential read). Not to mention the lack of disk space (7.6MB remaining).

So this new hardware is really, really nice stuff and super appreciated - less time waiting, more time coding. Thanks Brad!

I hope Scott Wheeler's Adopt-a-Geek program will restart at some point so that other KDE developers can benefit from such generous donations as well.

An interesting suggestion that Brad made was that perhaps some of us KDE devels in Australia (e.g. also Seb Ruiz, Hamish Rodda) could get together to do a state-of-KDE-4 talk at linux.conf.au in Sydney 2007. I think that would be a great idea so stay tuned :)

Wednesday, July 12, 2006

Why are languages so hard to learn?

I don't mean programming languages which seem trivial to pick up once one has seen a few. After all, one of my lecturers once said "anyone can program - even I can program".

So I mean natural languages. I've primarily used English since an early age. Since then, I've seriously tried to learn French, Mandarin, Japanese and now Mandarin again i.e. I spent a couple of years on each.

However, I usually only get as far as the basics like "My name is ...", "I live at ..." and "My grandmother is ... years old". After that, I get swamped in too much vocab and cannot remember anything. Did I start at too old an age? I hear that people in Europe learn a lot of languages at an early age (e.g. German, French, Italian and English) and they're very good at it.

What is it that makes natural languages so hard to learn compared to programming languages? Most programming languages are Turing complete after all! Even C++ templates at compiletime but that's another story...

So the only things I can remember now are:

je ne parle francais pas [I'm missing the circumflex under the 'c', sorry]
wakarimasen
ζˆ‘δΈηŸ₯道

Any tips on how to pick up a language in the shortest possible time? I only need to be able to participate in conversations and read.

On dodging questions again

About my blog entry on How to dodge questions,
Timothy Warner writes:


'Clarence recommends a three-step approach for dodging a 'stumper' question
...
Clarence Dang's recommendation to "stall for time"'


Nono, you got me wrong there. I definitely do not endorse the three-step "Change, Stall, Intimidate" approach I describe. I simply wrote about it because I hate watching people use it.

In reply to aseigo on toolbars

Regarding my blog entry that the new KToolBar default of "Text Under Icons" takes too much space, Aaron Seigo writes:


"the problem is not bigger toolbar buttons, which are good for usability in many ways ... the real problem is that we cram so many (often stupid) things into our toolbars ...

"so when 'mail' appears in a painting program's toolbar (kolourpaint) one really ought to say themselves, 'wait a minute! this isn't an email program!"


I agree it could be solved by a more careful selection of toolbar actions. But the problem is that I didn't decide on the existing ones like "mail" - kdelibs did. The only ones I added were the zoom actions. Sure I could override the KDE defaults with noMerge="1" like I did with the "View" menu but this something that should really be solved on the kdelibs level.

Back to the question of which ones should go. Here's my personal preference:



6 actions - measuring that up with "Text Under Icons", it's actually smaller than the KDE 3 KolourPaint with "Icons Only". This is great but how do I know that the majority of people agree with my personal opinion? I would fight tooth and nail to keep the undo/redo and zoom actions, at least, but maybe everyone else in the world really does email their doodles all the time?

I agree in principle with bigger icons but the text just adds to the visual clutter after one learns what the buttons are. If we have fewer buttons, won't tooltips be sufficient?

Tuesday, July 11, 2006

KolourPaint paint engine experiment works

Today was one of those days where I started out thinking "I should really do some real [thesis] work today ... but half an hour of KDE hacking first can't hurt ..." Naturally, it is now almost midnight and the only thing I have done is KDE hacking. Maybe KDE programming has a secret ingredient that makes it addictive - NiKotine?

Anyway, given the sweeping Qt4 changes in the painting classes, I was extremely worried that it would not be possible to port the KolourPaint backend such that it would a) still perform OK b) support both XRENDER and non-XRENDER. In the meantime, I was fighting a battle to simply get KolourPaint compiling given the pace of kdelibs changes (see my previous blog entry's comments for an example). But today, I finally managed to hack around the last few important QPixmap/QPainter bugs and can demonstrate some 100% working tools: the Rectangle, Rounded Rectangle, Ellipse, Line, Connected Lines, Curve and Polygon:



[Note: if you appreciate abstract art and can see some deep meaning in the picture that I did not intend, feel free to contact me for licensing terms :)]

From this screenie, it should be obvious that KDE's new toolbar default of "Text Under Icons" does not work unless one has a screen with 5,000 x 5,000 resolution. As for why the Tool Box is in such a weird place and orientation, the short version is: breakages due to KToolBar changes. I will fix this and the longstanding problem of unconfigurable icon size by creating a new KToolPalette class after LiveUi (aka. XMLGUI2) is merged into trunk as I expect the merge will break all underlying assumptions all over again. Hopefully, blackarrow / Hamish Rodda will implement the class before I do so that I won't have to do any work :)

Previously, I got KolourPaint to not suck 100% of CPU doing QPixmap -> QImage -> QPixmap translations for opaque drawing operations but transparency was still unreliable and really slow. Now, I have opaque and transparent operations working with and without XRENDER.

So now that I have the underlying infrastructure working, porting the rest of the tools should be fairly straightforward and more importantly, now appears possible. Expect a set of fully working tools real soon now.

But don't use it for anything serious yet: shortcuts don't work (must have checked out kdelibs at a bad time), attempting to save causes a crash in kdelibs (yes, my previous piece of abstract painting was much better):


ASSERT: "d" in file /home/kde4/dist/include/ksharedptr.h, line 108
Aborted


I doubt the clipboard works due to the Qt4 changes and more importantly, I have rigged up assertions such that almost any tool not in the above list will cause KolourPaint to crash as the way they play with the paint engine violates some invariants. Sorry.

Finally, given the amount of time I've wasted hacking around QPainter bugs (read my commit messages and see), I'm going to try to charge Trolltech for bug reports (hey, they charge for the toolkit). Wish me luck :)

Wednesday, July 05, 2006

Got kdelibs compiling

This is with:

trunk/qt-copy -r558252
trunk/KDE/kdelibs -r558279

Make sure you run the ./apply_patches script in qt-copy.
Manually apply 0119-qaction-widgetfactory.diff - K3WidgetAction from kdelibs needs the QActionWidgetFactory class. Two Hunks will fail. Replace them with this:


--- src/gui/widgets/qtoolbar.cpp (revision 558285)
+++ src/gui/widgets/qtoolbar.cpp (working copy)
@@ -271,7 +271,16 @@ QToolBarItem QToolBarPrivate::createItem
item.hasCustomWidget = true;
return item;
}
+ }
+
+ if (action->toolBarWidgetFactory()) {
+ item.widget = action->toolBarWidgetFactory()->createToolBarWidget(q);
+ if (item.widget) {
+ item.hasCustomWidget = true;
+ return item;
+ }
}
+
if (action->isSeparator()) {
item.widget = new QToolBarSeparator(q);
QObject::connect(q, SIGNAL(orientationChanged(Qt::Orientation)),
--- src/gui/kernel/qaction.cpp (revision 558285)
+++ src/gui/kernel/qaction.cpp (working copy)
@@ -54,7 +54,7 @@ static QString qt_strippedText(QString s

QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0),
visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false),
- menuRole(QAction::TextHeuristicRole)
+ menuRole(QAction::TextHeuristicRole), factory (0)
{
#ifdef QT3_SUPPORT
static int qt_static_action_id = -1;


I have no idea if this is correct but KolourPaint -r558316 runs.

If you get this message even after invoking the dbus daemon:


FATAL: Session bus not found


$DBUS_SESSION_BUS_ADDRESS and $DBUS_SESSION_BUS_PID are not set because you ran dbus using:

dbus-launch --auto-syntax


instead of:

eval `dbus-launch --auto-syntax`


as dbus-launch actually prints out the shell commands used to set those environment variables.

Lastly, changing button order and making it not configurable is a worrying trend:



I hope this is a birthday prank or something...

Xine out of memory error message

If you see this when starting xine (1.1.1):


This is xine (X11 gui) - a free video player v0.99.4.
(c) 2000-2004 The xine Team.
video_decoder: can't create new thread (Cannot allocate memory)
abort: video_decoder.c:510: _x_video_decoder_init: Aborting.


check your "ulimit -v". Xine seems to hog at least 256MB of virtual address space, even if it's not actually backing that with physical memory.

Ordinarily, I use the ulimit mechanism to automatically kill runaway processes that are sucking too much vmem (on the assumption that it is all backed with pmem). Without ulimit, Linux would be swapping so badly that I wouldn't be able to run "top" to kill the offending process.

But now, I have to up this figure just for xine...

Tuesday, June 27, 2006

How to dodge questions

Update (2006-07-12): I do not endorse this technique. I hate it (see the "It simply drives me nuts" bit). I am merely documenting it to expose those people who use it.

This is what I call the "CSI" (not the TV show) technique - Change, Stall, Intimidate:

First, change the topic: "I think that's a very good question. It certainly raises some interesting issues related to what I said before."

Second, stall by talking about what you said before, for about 2 minutes.

Third, intimidate the person who posed the question by asking "Does that answer your question?" By this time, the audience is so bored that that person will not have the guts to pursure further questioning, in order to save the audience from listening to junk for another 2 minutes. However, if that person is somehow not discouraged and persists, say "Now as I said before" and repeat the "stall" step. Alternatively, s/he would have forgotten his/her original question by now.

It simply drives me nuts when I'm in a meeting and the speaker uses this technique when they clearly have no clue (I'll blog on other techniques used to say nothing, some other day). But from what I can see, this works like a charm. And now you know how to do it and sound intelligent too - great for those "strategic" business meetings that we all inevitably find ourselves in.

Exams over

Yay! The highlight was an invigilator saying:

"For those whose don't know the date, today is the 26th of June 2002".

Wednesday, June 21, 2006

NULL in SQL

Should a null QString be identical to an empty QString? Is there sanity in having undefined vs empty strings in PERL? What about null vs empty strings in Java?

It's those annoying cases in programming that always require extra checks. In SQL, it's NULL. Comparisons with it almost always return "unknown" (which is usually interpreted as false). Worse still, "NOT unknown" is still "unknown". So when one writes:


CHECK (attribute = 0 OR attribute = 1)


SQL will happily allow the insertion of a row with a NULL "attribute". So this must be rewritten as:


CHECK (attribute IS NOT NULL AND (attribute = 0 OR attribute = 1))


See, I just dropped a few marks for this tiny mistake...

Oh, and BTW, Oracle morphs empty strings into NULLs, which is the pinnacle of insane behaviour.

Poseidon - Movie Review

Watched Poseidon on Monday with a friend from high school. I normally watch movies in the evenings on weekends so it was rather surprising how few people there are on a Monday night (could be counted on 2 hands) even though this cinema is in Sydney city.

It's essentially Titanic except they're trapped in an upside-down ship and it isn't boring (it probably won't win any film awards as a result :)).

Quite a thriller as a bunch of the characters break away from the main group to save themselves, as the water rises inside the ship and fiery debris is abound. They drop one by one. I say "a bunch of characters" because character development is fairly poor, there are too many main characters (think "Copland" but not as bad), some of the actors look the same and could have gotten away with playing another character for a bit without anyone noticing.

For black humour, the kid resembles the one from "The Sixth Sense" so just after the ship has tipped over, and with encouragement from a former fireman, he jumps down from where he's hanging, I could just imagine him making the observation "I see dead people".

Nevertheless, the acting of all the characters is exceptional and the life-death decisions they make are rather gripping. The camera work is excellent in building up and maintaining the tension. The pan around the ship at the start is stunning (and could probably only have been done via computer graphics).

Now for plot problems:
1. The elderly man mentions something to his business partners (?) about someone regrettably leaving and that they know the consequences of this. He seems to try to get in contact with this mystery man (but later throws his mobile phone into the ocean). It is implied that this person leaving is going to result in some disaster but this seems to have no bearing on the plot (unless it was disaster). Anyone know what's going on?

2. The captain orders the ship to do a starboard flank. However, the "rogue wave" is shown to be approaching from the right of the ship. So the captain actually turned the ship into the wave!

3. The area with the main dance floor of the ship is claimed to be airtight and the air bubble will keep the ship afloat. But air must be pulled from the outside otherwise, even in normal situations, air would run out quickly and everyone would die of carbon dioxide poisoning (exhaled breath). Therefore, it can't be airtight.

Summing up, an exceptional thriller for people who appreciate simple entertainment. On my Prime - Spiderman 1/2 - Batman Begins scale, where Prime = hopelessly boring, Spiderman = ok-good and Batman Begins = exceptional, it scores somewhere between Spiderman and Batman.

Monday, June 19, 2006

Oral exam on software engineering ethics, fun

There were 3 questions:

1. Free choice

2. One out of nine possible questions based on seminars. At the examination, three are chosen randomly and the student gets to pick one out of those three.

3. One out of eight possible questions based on lectures. Chosen similarly to 2.

Pigeonhole principle comes in handy here: If one wants to prepare for question 2 fully, they only need to prepare 9 - 3 + 1 possible answers. Similarly for 3. Now, pigeonhole principle seemed to me like a stupidly obvious theorem when it was taught but since it's saved me some work, at least now I can appreciate it.

So what questions did I end up picking? Well for the free choice, I chose a rather controversial topic on copylefting software. I won't start another flamewar except to say that I BSD license everything these days so you know my position. It was rather rushed and unfortunately, I don't think the markers were convinced.

The second was the technical problems with the Therac 25.

The third was about how patents might stifle innovation and aren't suitable for software. A key example I used was Eolas' patent claim against Microsoft: "Distributed hypermedia method for automatically invoking external application providing interaction and display of embedded objects within a hypermedia document", where Microsoft lost $US521 million, for implementing something fundamental to web browsers. Imagine if people went around patenting "1+1" and suing school children for practising maths. You certainly can't get away with that but with software, somehow people have.

Friday, June 09, 2006

QWidget::contextMenuEvent()

KolourPaint places widgets on top of a KToolBar for its "Colour Box" (a great abuse of KToolBar, I know - I'll be looking at fixing this). Unfortunately, in Qt4, right clicking on a colour patch (e.g. the transparent or green, circled in red below):



no longer selects the background colour - it brings up the toolbar popup menu instead:


(neat "Lock Toolbars" option BTW)

It turns out that implementing QWidget::mousePressEvent() no longer stops your parent from receiving the right mouse press that would invoke contextMenuEvent(). Spotting the new contextMenuPolicy, I figured that I would just set my children widgets to Qt::NoContextMenu ("the widget does not feature a context menu"). Doesn't work.

They way I got around it was to get the children to eat/accept() the contextMenuEvent(). Another undocumented, subtle change between Qt3 and 4...

In the meantime, I have started porting KolourPaint4 to a new "kpPainter" that abstracts away QPainter (not committed to SVN yet). Rectangles now work and are no longer 1 pixel higher and wider than they should be. Eventually, this abstraction will allow me to dump the Qt graphics routines for a better graphics library.

C++ class member function pointers

This prints -7:


#include <stdio.h>

struct Moo
{
int func () const { return -value; }
int value;
};

int main ()
{
Moo m; m.value = 7;

int (Moo::*funcPtr) () const = &Moo::func;
printf ("%d\n", (m.*funcPtr) ());
return 0;
}


Gotta love the "int (Moo::*) ()" syntax - pointer to any member function of class "Moo" as long as it returns an "int" an accepts nothing.

And of course, "(m.*funcPtr) ()", which invokes the pointed-to function with "m" as "this".

Wednesday, June 07, 2006

The fun of Politics

Don't buy joke books - read the Australian House of Representatives Hansard instead:

http://www.aph.gov.au/hansard/reps/dailys/dr250506.pdf:


"Mr ABBOTT (Warringah -- Leader of the House)
(12.34 pm) -- I move:
That that snivelling grub over there be not further heard.

[...]

Mr Abbott -- If I have offended grubs, I withdraw
unconditionally

[...]

Mr Swan interjecting --

The DEPUTY SPEAKER -- The member for Lilley
walks a fine line by calling the Deputy Speaker an idiot.

Mr Crean interjecting --

The DEPUTY SPEAKER -- The member for
Hotham walks a fine line by clapping."


I don't understand how politicians can get anything done admist these antics.