Posts about kde (old posts, page 12)

2007-05-16 11:37

A KDE hack: Faster mail searches in kmail, using mairix

Kmail searches slowly.

I have been a kmail user for a couple of years, since I settled in my own home office with my own computer.

I like the thing.

However, it annoys me that it takes sooooo long to find a message in my mailstore. Hey, it's only 13000 messages!

So, while I wait for KDE4 to bring all its searching goodness, I decided to see if I could hack something quickly.

Enter mairix: a mail indexer/search thing.

Convincing mairix to index all my mail was rather simple (here is my ~/.mairixrc):

base=/home/ralsina/
maildir=Mail/*...
maildir=.kde/share/apps/kmail/dimap...
omit=Mail/mairix
database=~/.mairix_db

What does it do?

  • It indexes mail stored at ~/Mail and everywhere in my kmail imap folders.
  • It stores search results in ~/Mail/mairix and ignores its contents when searching. The results are stored as links, so they waste no disk space.

After running mairix so it builds its DB (took about a minute, which is less than most kmail searches) , you can search for things like this:

[[email protected] ~]$ time mairix b:bartleblog
Matched 6 messages

real    0m0.232s
user    0m0.012s
sys     0m0.204s

And the result can be seen in kmail, in the mairix folder:

mairix1.png

However, there is a problem. It will work for the first search, but not for the second one. On the second search, you get the same content listing, but all messages appear empty.

That's because kmail saves an index file of each folder. To work around that, I wrote a little shell wrapper, kmairix:

#!/bin/sh
rm ~/Mail/.mairix* -f
mairix $*

And you use that instead of calling mairix directly.

But there are still improvements to be done. If your kmail is currently displaying the mairix folder, searching doesn't update the message list.

DCOP to the rescue! We can switch to the inbox, then back to mairix (adjust as needed for yourself):

dcop kmail KMailIface selectFolder /Local/inbox
dcop kmail KMailIface selectFolder /Local/mairix

Missing pieces:

  • How about switching to the kmail window? Sadly, the kwin DCOP interface seems incomplete. Maybe assigning kmail a hotkey and work from there? Let me know if you have any ideas.

    UPDATE as suggested by Anno Heimburg: just call kmail.

  • A GUI (of course!) probably with a tray icon...

  • A way to auto-update the Mairix DB when new mail arrives. I am thinking about doing it with incron but have not done it yet.

So, here is the final version, put it somewhere in your path, and use ALT+F2 to search your mails :-)

#!/bin/sh
rm ~/Mail/.mairix* -f
mairix $*
dcop kmail KMailIface selectFolder /Local/inbox
dcop kmail KMailIface selectFolder /Local/mairix
kmail

2007-05-11 12:01

New Bartleblog Feature: Menu Editor

Took a while to implement, but BartleBlog finally got a functional menu editor:

bartleblog12.png

Right now, it only works with the mootools-based menu gadget, but I will start working on the yahoo menu version in a moment.

The only thing not working is the preview button, because it needs more support on the backend side.

2007-05-10 14:07

Today's first hour of hacking...

... has been all about UI.

I have always had a problem when writing PyQt apps: stock icons.

Which ones should I use? Where are they?

I usually fished through the crystalsvg icon set until I found one that seemed to be what I needed, and then copied it to my app.

Sadly, that's annoying in several ways:

  1. Since those are PNG icons, you need to find the right size.
  2. Not all icons are there for all sizes!
  3. Because of 2, I need to check three or four folders to see all the icons.

So, I decided to cut my losses, and see what else could be done. And here it is:

bartleblog11.png

I am now using all SVG icons, from the reinhardt set that will look equally out of place in all OSs, but which I like (and I think look awesome with this relaxed Domino theme). And because they are all SVG, I don't care about sizes, and they are all in the same place, and all is good.

And whenever Oxygen is released, all I need to do is switch the files around and that's that. Which is nice, too.

Of course there is a catch... it does look out of place, and I expect many to find it ugly. So what, since I am the only user of this app! ;-)

2007-05-09 15:06

Today's two hours of hacking

  • Done with the main blog config dialog.
  • Fixed a dozen bugs
  • Generate the blog in a reasonable place
  • Fixed a lot of UI bugs (tab orders, sizes)

Still lots and lots of things to be done, tho.

2007-05-08 21:05

Making your QTextBrowser show remote images

It's remarkably easy to turn your QTextBrowser into a limited web browser, at least good enough to show images from the web.

Here's all the code:

from PyQt4 import QtCore,QtGui
import urllib, os, md5

class PBrowser(QtGui.QTextBrowser):
    def loadResource(self, type, name):
        url=unicode(name.toString())
        ret=QtCore.QVariant()
        if url.startswith('http://'):
            dn=os.path.expanduser('~/.bartleblog/cache/')
            if not os.path.isdir(dn):
                os.mkdir(dn)
            m=md5.new()
            m.update(url)
            fn=os.path.join(dn,m.hexdigest())
            if not os.path.isfile(fn):
                urllib.urlretrieve(url, fn)
            ret=QtGui.QTextBrowser.loadResource(self, type, QtCore.QUrl(fn))
        else:
            ret=QtGui.QTextBrowser.loadResource(self, type, name)
        return ret

And here's bartleblog taking advantage of it:

bartleblog10.png

It even has a primitive cache and everything ;-)

2007-05-07 18:52

Neat KDE style: Domino

Today I was fiddling with my desktop and decided to check what KDE styles were available in Arch Linux.

Then I tested Domino.

It's very, very, very nice.

domino.png domino2.png

I have no idea how good it is performance-wise (my notebook is pretty brawny) but hey, I am a boring guy, and I'm wowed.

2007-05-05 18:29

Giving BartleBlog the push it needs

I found a couple of hours to hack, and decided to spend them on BartleBlog.

Here's what got done:

  • UI for blog preferences (still need to do maybe ten of these little modules).
  • Search for files in reasonable places (instead of using the DB in the current folder, for example).
  • Started work on a first-use wizard
  • Started working on a original and simple help system (resource files, yay! ;-).
  • Implemented (lamely) posting of "stories" which are static pages that are not part of the blog's flow.

I intend to spend a couple of hours on it every day for the next ten days or so. After that, who knows, maybe a release will be reasonable.

2007-05-01 19:39

What I am plotting...

...nothing.

Ok, here's what I have been doing:

  • Daddy work. Lots of it. Fun!
  • Actual work. Lots of it. Fun, but not so much!
  • Worked a little more in RA-Flip. Play/Stop/Pause is done. The editing mode and opening/saving files is pretty much done, so it will be fully functional as soon as I can spend an afternoon in it.
  • Tobogan (My slideshow software). It works nicely. There are many rough spots and it needs a few features:
    • Some way to edit the CSS for individual slides in a nice manner. Like setting backgrounds and colours (and not much else)
    • A nice way to save the slideshow so it ends all in a single folder.
    • Many UI details
    • Docs
    • A site
  • BartleBlog: it has worked well for me for a long while, since I have been posting this blog using it. And really, it's a nice blog, isn't it? ;-) But of course, there is stuff to be done:
    • Many UI details
    • Decent flickr and openomy uploaders/managers
    • Some extra gadgets I have in mind
    • Docs
    • A site

And that's all I have in mind right now. Except maybe a graphical Befunge interpreter, but that's not really important ;-)

2007-04-27 13:30

BOP: Ball Oriented programming

Some of you may be familiar with weird programming languages. Some of you may even know about bidimensional languages. Some of you may have seen Flip, where computation is performed by balls bouncing off things.

Now you can see Flip using Qt. My Ra-Flip interpreter. I wrote it in a lark after finding out about Flip in Good Math, Bad Math and shares no code with the original, but it's a simple language ;-)

It's almost feature-complete. Missing are:

  • Levels (to make it threedimensional)
  • Input
  • Start-stop-pause-delay controls

Here is the mandatory screenshot:

flip.png

But that really doesn't do it justice, so here's a video:

The fun starts around 35 seconds in. The program prints an infinite series of even numbers and stores odd numbers in a ... I am not sure how to call that. A circuit?

I may think about writing a something-to-Flip compiler, so you can write your programs in some sort of simplistic imperative language and then see them as a pinball machine.

It may be cute if an artist could spend a few hours making nicer gadgets, before I do it (it won't be pretty ;-)

And yes, this is probably the most useless program written using Qt, right there with kyes.

Contents © 2000-2018 Roberto Alsina