cat /dev/maxilys

A glance in the mind of a KDE/Linux developer to see how ideas turn into code.

2007-02-27

KDE: Hello Kassie!

Good bye K.S.A. Welcome Kassie, the Kate Advanced Session Selector... plus "ie" to make the name sound more feminine, to match with Kate. And Kassie is also a feminine first name, so...

It was hard and fun. I crashed and froze Kicker more than once, and I enjoyed its auto-restart feature in between the hundreds of times I restarted it manually through DCOP. The crashes and freezes were due to the fact I was trying try to do something way out of my league: To hijack a drop action to Cuba... No! From where it began to a dialog that I inserted in the middle of the drop action.

It failed but I learned a lot of interesting things about KDE/Qt while browsing their docs. Definitively not a waste of time. It could have work if were already in 2008, not because of KDE 4 that will be released for a long time at this moment but because I will probably be able to do what I wanted. I say this because of this thought that haunts my mind when I see my code: I could never have done this last year. Last year, at the end of February, I was working on Serenity 0.2 to release it in March. Amazing... :-)

Well, "Kassie" was I saying. Instead of the programmatic torture I was trying to inflict to KDE, I made something very simple: I just let the drop action go to its completion (the release of the button) then I show my little menu. And what's on the menu? See for yourself!

[Image][Image]


Another auto-reverse menu! ;-) And, yes, the icons are so big intentionally. I tried with regular little icons but the big ones are better, they bring you comfort or, in other words, usability. Any way, the menu shouldn't grow very much and big icons won't be a problem, even if your have 45 available sessions --as somebody told to me-- because what it shows to you are only the running instances of Kate. (Of course, if Kate isn't running at all, no menu will appear.)

So, when you drop files on Kassie's icon, she... it proposes you to choose where you want to drop them, either into one of the running instances or in a new one. And the last entry "Cancel" is here because you never know where to click to close a menu. A clearly defined area is very convenient. And thanks to the auto-reverse menu, it's always "at the other end" of the menu, never in your way to click by error.

To sum up, here are all the ways you can open files with Kassie's popup menu:
  • You open an available session and you drop files on the window.
  • You create a new session with a name and you drop files onto it.
  • You simply launch Kate and drop files onto its window.

And when you drop files on Kassie's icon:
  • The files can be added into a running session/instance.
  • The files can be used to create a new instance or session (if you don't forget to save it to give it a name).

The hidden features: Kassie always keeps accurate lists of the available sessions (You can manage them by hand without worring.) and of the running instances so that you never need to tell to Kassie to update anything. It's automagic. ;-) Kassie will warn you if you try to create a session that already exists and it proposes you to open it instead. If you try to re-open a session, you will get a little warning too. Right now that's all Kassie does but --if there are no problem-- I will add to it the possibility to propose you to bring the already opened session to the current desktop.

All this for the version 0.2! There are other ideas that crossed my mind but I dropped all of them because I didn't want to make your panel fall below your screen because of a too heavy Kassie. ;-)

And now, a little warning...

Warning...

To anyone who uses my script to open a URL in a new tab of Konqueror, I noticed a little flaw. It may look like sometimes that nothing happens anymore, whatever the number of times you click. In that case, STOP clicking! Then restore that minimized Konqueror that now shows a dozen of copies of the page you wanted to see... or worst --if it gets on your nevers. :-)

As I said, it was a little warning. Nothing serious. :-D

...Warning


Then comes the improved script:

#! /bin/bash
ALLKONQ=`dcop "konqueror*"`
for THIS in $ALLKONQ
do
HIDDEN=`dcop $THIS konqueror-mainwindow#1 hidden`
MINIMIZED=`dcop $THIS konqueror-mainwindow#1 minimized`
PROFILE=`dcop $THIS konqueror-mainwindow#1 currentProfile`
if [ "$HIDDEN"=="false" -a "$MINIMIZED"=="false" \
-a "$PROFILE"=="webbrowsing" ]
then
KONQ=$THIS
fi
done
if [ -z $KONQ ]
then
konqueror $1 &
else
dcop $KONQ konqueror-mainwindow#1 newTab $1
fi


I guess that shaded windows should also lead to a problem of... well... visibility but there's nothing to do this time. Konqueror doesn't provide any DCOP access to this information. Wait for KDE 4 and D-Bus. Maybe.

Hmm... I wonder what D-Bus management looks like in KDE 4. (Cough) I have to go I think I let the water running in my tub... ;-)

Labels: , ,

2007-02-24

KDE: Late midday news

The Kate Session Applet is on its way toward completion. I added the auto-close feature and enabled the use of the keyboard modifiers during drop to launch a new instance of Kate.

The auto-close feature was really fun to implement. I knew I had to set a flag to signal a menu opening and then... what? I didn't investigate how Qt does to close a menu but there are --at least-- no public method. So, what I did is set a flag when Qt sends the signal aboutToShow() and unset it when I receive aboutToHide(). And finally, in my slot that is called after a click, I just refused to open the menu when the flag is set and unset it for the next time.

It didn't work. Period. When the second click occurs, Qt closes the menu before (re-)opening it. It's stupid but logic.

So I did something also stupid. I didn't unset the flag in the slot connected to the signal aboutToHide(). I thought that this way the menu would open only once and all I'll have to do would be to find another place to unset the flag.

It worked... sort of. The menu opened only every two clicks. It's stupid but logic too. :-)

The solution came from one of these mysterious background process that I initiated in my mind while I was typing this blog... and realizing that what I was typing meant that the menu would open only every two clicks. (I really have a twisted mind...)

To open the menu I do:
x = theMenu->exec( theButton->mapToGlobal(QPoint(x, y)) );

So...
if ((x == -1) && (theButton->hasMouse()))
{
// It was a click on "my" button that closed the menu.
// I will just refuse the next opening.
// Since Qt already closed the menu, it will look like
// that it was the click that did it... and it did!
menuIsOpened = true;
}
else
{
// The click occured on an entry of the menu
// or elsewhere that lead to the closure.
// I'm free to open on next click.
menuIsOpened = false;
}

(And no, I'm not that verbose in my comments.)
$ make
(blah blah blah...)
$ su
# password:
# make install ; exit
(blah blah blah...)
$ dcop kicker kicker restart

And it just works... Right now while I'm typing.

As for the keyboard modifiers, I decided to use them when I realized that dropping files on Kate's icon in the panel used to launch a new instance and that I implemented just the opposite: Drops re-use the first instance of Kate that KDE will find. (Again this problem of the virtual desktops and the invisible openings...) Any way, I allowed you to hold whatever keyboard modifier you want (Shift, Control, Alt, Meta) when you drop files and in that case a new instance will be launched.

This behavior is even better than before because you need to use a keyboard modifier only once. If you have some after-thoughts, you just have to drop the new files directly on Kate.

I just got an idea. What if you could choose on which Kate you want to drop your files when several instances are opened? I mean, instead of letting KDE decide for you. That's easy through DCOP and Kate is nice enough to let us know what session she uses, how many files it contains. And there's probably more. I barely scratched the surface while I was looking if it was possible to have the title of the windows. It isn't but the name of the sessions will do the trick. I will investigate further. If it's not too much for a poor little applet...

Maybe.

Labels: , ,

2007-02-23

KDE: Itch by itch

I found an itch to scratch. I wanted to be able to let Akregator open the links I click in tabs instead of scattering windows all over the desktop. That proved to be an itch very difficult to scratch. "Brain Yoga for the Dummies" didn't help. Your brain has to be more flexible than a contortionist.

The stick I used to scratch the itch is DCOP. This is the only way to open a tab in Konqueror programmatically. I could remember that it was possible but I didn't retrieve what should have been stored in my "database" on my harddisk.

So, I launched kdcop and started digging. Here is what I got:

#! /bin/bash
ALLKONQ=`dcop "konqueror*"`
for THIS in $ALLKONQ
do
HIDDEN=`dcop $THIS konqueror-mainwindow#1 hidden`
PROFILE=`dcop $THIS konqueror-mainwindow#1 currentProfile`
if [ "$HIDDEN"=="false" -a "$PROFILE"=="webbrowsing" ]
then
KONQ=$THIS
fi
done
if [ -z $KONQ ]
then
konqueror $1 &
else
dcop $KONQ konqueror-mainwindow#1 newTab $1
fi


What this little script does is to ask through DCOP the list of all actually running Konquerors. It picks the first one that uses the webbrowser profile and isn't hidden some way. Then it asks this Konqueror to open a new tab with the URL from the command line or, eventually, it launches a new Konqueror if it hasn't found any suitable one.

This way, the script doesn't re-use a Konqueror with which you opened views to directories. The size of my Konqueror window when I browse through files isn't suitable to view HTML pages and I didn't want the script to force me to resize windows. Besides, when I'm done and close --instinctively-- the window, I won't loose all the tabs --intentionally-- opened onto directories.

Well, I put this script under the name newTab in my path and I asked Akregator to use the command newTab %u when I middle-click a link.

Now, in Akregator, I gather all the articles I may find interesting in a row of tabs for me to review later. And since the script doesn't ask Konqueror to raise its window, the tabs are opened in the background, i.e. Akregator remains on top until I feel I'm done with it.

The only problem is... the virtual desktops. They are very handy but, so far, I haven't found the DCOP way to distinguish what's on the current desktop from what's on the other ones --if it exists-- so the tabs may be opened in an invisible Konqueror, depending on in which way DCOP sorts all the available ones.

This is a KDE problem. Of course, the KApplications don't need to know on which desktop they are but IMHO there should still be an easy way to know where they are. Ask to the developer of Taskbar v2...

Any way, it's still a handy script. I haven't tested it yet but it should be possible to use this script as "default browser" so that all KApplications use tabs instead of launching multiple instances of Konqueror. Well, if there wasn't this problem of invisible openings.

After that, I found another itch to scratch: This --excellent-- Kate Sessions Menu applet. It's no longer on my Kicker but I loved it. When I didn't use Kate as a simple viewer, I always used K.S.M. I can't even remember how I worked without Kate's sessions.

What I didn't like was that I had to keep another Kate icon in my Kicker just to be able to drop files on it. And I lost too many drops because I dropped on K.S.M. I asked the author if he intended to implement the possibility of dropping. It's been such a long time that I don't remember what he answered.

I tried to implement the feature into K.S.M. and I understood why the author hasn't done anything yet. It's simply impossible.

Kicker's world is a kind of very private club. You can enter in its garden, talk a walk, sit on a bench and pretend you belong but, sooner or later, you will encounter a sign saying "Members only". In other words, Kicker isn't opened enough. If your applet doesn't belong to Kicker's build tree, you have a very limited access to its lib. You can choose either a container to do what you want in it or an icon with a menu.

If you go the icon way, like K.S.M. does, you're a KPanelMenu and, as the name says, you're a menu. The icon is, well, elsewhere, out of your reach to enable drops on it.

So, I went the other way: the KPanelApplet. That's not much better. Kicker provides some facilities so that your applet shows the same menu than the other applets when you click on the --ridiculously-- small menu button but that's all. You have a container but you're on your own.

I will spare you how I got the --stupid-- idea of using the KPanelApplet from developer.kde.org tutorials section and what I had to do to build it on KDE 3 while it is still designed for KDE 2.

By the way... Come on! KDE 4 is on its way, how is that possible to find anything related to KDE 2 on the big KDE central website. Ever heard of spring cleansing?

Whatever. After a night spent in coding and learning new tricks, I have rebuilt K.S.M. under the name "Kate Sessions Applet". For the developers who understand this kind of things, this is QToolButton and QPopupMenu that I open manually when the button is clicked. I didn't use the intergated popup menu because the menu arrow always points to the bottom whereever K.S.A. is and the menu always tries to open itself under the applet while there are well-established positions for an applet to open it.

Talking about menus. I made something that I always wanted to see in KDE: an auto-reverse menu. If K.S.A. is in the bottom panel, the Kate sessions are ordered from bottom to top and the other entries are on top of the menu. I've always found stupid that the least used entries are the first ones your mouse encounters when a menu opens itself above something.

That's why I put the KMenu on a panel on top of the screen so that its menu looks "normal". With the KMenu in a bottom panel, the first entry your mouse hovers is "Shutdown". I don't think that's the most logical way it should be.

Interlude...

I had to go away to take care of my 5 year-old niece, Alice. We played with Dora the Explorer on the family computer. It's funny to hear her trying to speak English.

She's quite amazing with a computer. She already knows how to switch it on, select her account (on Windows) and double-click to launch a game. I taught her everything because, when she comes to my house, I let her play with SuperTux, TuxPaint, Mr Tuberling or even LBreakout in kids mode.

We also played with Legos then I re-learned how to plait Scoubidous. (According to Google, it's also the english name, instead of "Scooby-Doo" as I supposed it was.)

During these few hours, she says something that stunned me: She's eager to have her own baby and she already knows that she wants a baby girl. She complained that it takes too much time even if she summed up the whole process as going to the hospital, taking a meal and putting the baby in bed. I think she mixes things up --a lot!

Whatever. I love to hear her talking about the fantasy world she lives in. I better do because she never stop talking... :-)

...Interlude


Back into my own fantasy world. I was saying "auto-reverse menu". Here is what I'm talking about:

[Image] [Image]


As you can see, K.S.A. is already working, including the drop feature. I will think about adding a menu arrow if it doesn't pose other problems. What I really need to do is adding the possibility to close the menu with a second click on the icon. And the extra feature I want to add is the possibility to launch Kate with a middle-click. A left-click opens the menu, a right-click opens Kicker's menu. Only the middle-click does nothing yet. And I also have to tune the build tree because K.S.A. still uses the name "helloworldapplet". :-D

Well, I hope Blogger won't flood the Planet with all my old blogs. It forced me to change to the new version... against my will. I didn't want to gave my email address to Google but, apparently, I had no choice. Now, let's hope I won't receive more spam that I already do. Wait and see...

Labels: , ,

2007-02-13

KDE: Octember, the 3rd

A lot of people --including me-- don't care about any thing if there isn't a least a snapshot. So, here are my snapshots of the Desktop Text Configuration module, version 0.3.

Note that I simplified a lot of things. Especially, no more decimal values and much less tickmarks. That's question of a usability. Over-precise decimal values are useless when you can't see the difference with a naked eye. And when you provide a slider to enter a vague value (less/more or min/max), there's no need to have a hundred of tickmarks. I applied my "rule of the quarters": Zero, 1/4, 1/2, 3/4, maximum. The rest are details.

Now, let's go with the images! First, the improved dialog.



Next, the presets in action. I did nothing but select an (oversized) font and the colors. The presets did the rest.

[Preset: Solid Shadow]


[Preset: Fuzzy Shadow]


[Preset: Solid Halo]


[Preset: Fuzzy halo]


And if you wonder what "Octember" is, that's the name of a font I found on my harddisk while browsing for fonts to do my snapshots. I used respectively "Sandoval", "Almonte Woodgrain", "BoyzRGross" and "OctemberScript" which is now on my desktop with a customized fuzzy halo.

Don't ask where I found the fonts, I don't know. All I remember is that I googled for free fonts and that the site was white and red. That doesn't help much...

Now, run to KDE-Apps, I haven't packaged the new version of the module yet but it should appear very soon.

Labels: ,

KDE: Horror movie

After some deep thinking, I removed some more organic guts from my Desktop Text Configuration module. Totally useless, like those spare parts you always have after you build a computer from scratch.

And I added one little thing: Presets. Very simple: Solid shadow, Fuzzy shadow, Solid halo, Fuzzy halo. That's all. When you choose one of the presets, the module set all necessary values for you: offset, size, decay and opacity. You can change the settings before to apply or not. It's up to you. I find it very nice.

Well, that will be all for today. I'm leaving in 10 minutes. No snapshot. Maybe tonight.

Labels: ,

2007-02-12

KDE: One step into the light

Monday morning... already. I'm done. My desktop text configuration module is working.

Update: The Desktop Text Configuration module is already available from KDE-Apps.

As you can see herebelow, it has few left in common with what the old module was. (I oversized the desktop font for a better snapshot.)



I don't want to criticize the code of the previous author but let's say in my flourish way that I ripped off some organic guts and replace them with straight copper pipes. ;-) Especially, the old module sometimes cut a part of the shadow. Mine copes with any size of text, even if it is wider than the preview area. That's useless because the text has to be really huge but, at least, I'm sure to have a valid preview for the "normal" cases.

Now, the last thing to do before the release is to rename pretty much everything --the files and the classes-- to make this module really mine... or, rather, because "textshadowedit" isn't an appropriate name any more.

Labels: ,

2007-02-11

KDE: Beyond the shadows

For some reason, I put my nose into the sources of that old "Desktop Textshadows" module and I sneezed because of the dust. Two years old already and not a single update so, as vacations away from Serenity, I decided to do some spring cleansing.

First, I broke apart the dialog that was strangely designed with a lot of useless spacers. Then I made the module actually use the colors of the desktop configuration for its preview. That was the really tricky part because I had to find a way to set a color for the preview background that doesn't make disappear either the text or the shadow.

At this very moment, I wrote a mail to the author to ask for the permission to publish my patched version of his module on KDE-Apps, or else to offer him my work. And I got frustrated because I didn't get an immediate answer.

I may look calm but, inside, I'm a volcano or maybe a super-nova. Instead of wasting my burst of energy against the author who has probably something more important to do, I attacked this poor defenseless module again and again.

I added the possibility to choose the colors of the text and the shadow and I greatly simplify my method to choose the preview background and I went to bed.

Today, I'm wondering why I wouldn't make the next step: To gather all the options relating to the desktop texts. Right now, things are scattered in every corners of the control center. You choose the font at one place. The options to change the colors are well hidden at some place where you can activate the shadow but not configure it. That's why this "Desktop Textshadows" was written. Another place to go. And if you want to activate the hidden feature --Tooltips over the desktop icons-- all you can do is launch a text editor.

So I will extend the module to become the missing page of the desktop configuration: "Desktop text configuration" or something like that.

Whatever the author of the module might say, it's mine now! ;-)

I thought that managing the font would be difficult but it isn't. KDE provides the KFontRequester. Qt provides QFont and that's all I need to change the font of the desktop... for the most part. I already took care of the hardest part: Setting the colors. The other options are too easy to handle to be worth a mention. So...

I'm going to bed because it's already sunday but the result of my boredom should appear soon on KDE-Apps.

Labels: ,

2007-02-06

KDE: Codename "Destiny"

Serenity must be cursed --- or maybe it's me --- because it looks like I can't make any major release without having to make another one a few days later because of a big bug that escapes my vigilance.

And this time, it wasn't even fun to debug. Nothing exploded under my nose. Somebody (Hello Luis!) reported that Serenity crashes KDM at login time. So I tried.

I got not much to see. A black screen and only the activity light of the screen blinking from green to orange. All I could do was a reset, restart in runlevel 3 and edit kdmrc to use another style, to finally be able to switch back to runlevel 5, login and try to find what I did wrong.

So far, I haven't found any log reporting the reason of the crash. Of course, I found what caused the problem but I had to adopt the painfully slow trial-and-error approach. I had to guess what could crash KDM, remove it from Serenity's sources one way or another, make install and test.

Unfortunately I was able to look at KDM sources to see what widgets it uses. That gave me the wrong idea the KDM didn't like the way Serenity intercepts all QFrame drawings. I went two times through the build-test-crash-reboot process to realize that the SereneFrames pose no problem to KDM.

So here I found myself at the very beginning of serenity.cpp, checking every line. I saw nothing until I got around the 1100th line.

There! Something really strange.

I put a temporary patch, build, log out... and back in! The login dialog was using Serenity style. Victory!

I changed my patch into definitive code and made some extensive --totally useless-- tests to check that I didn't provoke any undesired side-effects. There were --of course-- none so I could leave Serenity alone until today.

Today, I took care of some cosmetic things. I didn't like the default settings Serenity used. I changed two of them: now, by default, the global style is Zen and the textbox focus highlight is activated. I did this because although KDM is launched by root, the style doesn't use his settings during login.

I will investigate on this matter because I don't like the idea of imposing my preferences to everybody. And I also need to find where root stores his serenityrc because it's not in $HOME/.qt/ as expected.

Oh yeah, why was I mocking myself and my code? That's because when I looked in Serenity's sources around which line the bug was, I just realized that all I did was for nothing! Apparently I was distracted or interrupted while I was implementing my "super-killing optimization" because it does nothing or close to nothing. It just wastes 8 bytes (I think) for two QColors that aren't used... anywhere! I'm like this squirrel that stores nuts for the winter and forgets where it put them once it turns its back.

(I feel so ashamed that I'm going to hide for a while...) ;-)

Labels: , ,

2007-02-04

KDE: Boolean release

To release or not release... ;-) Well, that's not the question any more. Serenity 1.7 is out in the wild. Go and get it! (Somebody complained that it was hard to retrieve anything when you are here on the blog. So...)

Believe or not but what I find the hardest in a release is making the snapshots. One can put only three snapshots on a KDE-Look page while there are so many features I'd like to show. Besides, I prefer to show Serenity in action in the "real world" than making patchworks like I did in my previous post... Especially when making "patchworks" takes so much time... for a maniac like me that can't stand to see things misaligned even by a single pixel. (I feel it's so careless.)

Whatever. I also had many things to keep in mind, like the fact that my previous free webhost doesn't allow you to store files bigger than 500 KB. I've found another one without size limitation but I had so many problems of unresponsiveness during my FTP session that I abandoned it for a third one. That's the first one I found when I decided to change of webhost but my account was cancelled because I didn't use it immediately or soon enough. Its only problem is that the server isn't properly configured to deliver RPM. The packages are sent as text files. Well, we ain't living in a perfect world apparently. ;-)

Back to my snapshots. I had in mind the idea to show symbol-less buttons. (The third snapshot.)

News flash: RPM packages of Serenity for all the versions of SUSE from 9.3 to 10.2 are now available on OpenSUSE.org. (Thanks Donnie.) Close the parentheses. Amazing world... :-D


"Symbol-less buttons" was I saying. Here came the troubles. I could apply the change so it worked but for some reason the configuration dialog couldn't remember this setting. I was already starting to feel tired... My archives were already stored on my distant website with an HTML page stating their sizes. A bug at this moment meant: Re-build everything. Grumble, grumble. (That's all I write because I'm polite.)

That was it. A long lasting hidden bug. During the update from 1.5 to 1.6 I changed the symbol visibility option from boolean to integer, i.e. from a yes/no checkbox to a combobox with multiple choices... except in one place: when the dialog reads the configuration. That explained everything... and the title of my post.

A stroke of virtual hammer and I was done.

$ make
$ su
# make install ; exit


ALT+F2: kwin --replace

If you want to have "fun", type "kwin --replace" in a Konsole. By the way, the shortcut to restart the X-Server is CTRL+ALT+BACKSPACE. ;-)

I went through that painful archives building process... and I got my reward this morning: Serenity on OpenSUSE.org. Next step is to be on SUSE 10.3 CD's. :-D

Labels: , ,