Monday, September 18, 2006

Chemical MIME types hit Debian

Daniel Leidert reported that the chemical-mime-data deb package has hit Debian. This package makes the chemical MIME types known to desktop environments like Gnome and KDE. Daniel, cheers!

Thursday, September 14, 2006

KDE/Ruby CMake magic?

I have commited my what's this about?? keyword cloud thingy to SVN into trunk/playground/utils/whatsthisabout. today. I am trying to use CMake as a build tool, but ran into a number of problems, one being the lack of a good example. After asking around on #kde-ruby it turned out that there is no known example.

OK, no problem. I'm a hacker, right? Jerome Pansanel pointed me to the KDE cmake modules. FindRUBY.cmake was there, so that's one step. Something that was missing was a module to detect the Korundum KDE/Ruby bindings, so I added FindKorundum.cmake. Since I am not a CMake experienced hacker, things might be off; comments most welcome!

However, when I add a find_package(KDE3), I get the error:
CMake Error: KDE3_DIR is not set.  It must be set to the directory containing KDE3Config.cmake in order to use KDE3.
And I have no idea on how to address that.

Additionally, I have struggle with the FindRUBY.cmake. I would expect ${RUBY_LIBRARY} to point to the directory where Ruby libraries are installed. But it points to /usr/lib, which is returned by puts Config::CONFIG["libdir"]. Tips most welcome here too.

Monday, September 11, 2006

KDE::HTMLPart GUI for tagging cloud

Everyone seems to blog about Ruby. Well, now do I too. Today I wrote three Ruby scripts to that allow me to tag my PDFs, just like I do with webpages using my del.icio.us account, something I wanted to do for some time already. In KDE4 keyword support mockups I suggested to do this with xattr, so I did. This is using a ruby xattr wrapper.

thisisabout


The first script allows adding a keyword. It is a simple script and allows adding one keyword per call. Syntax: thisisabout [tag] [file]. The code:

#!/usr/bin/ruby

# Copyright (C) 2006 Egon Willighagen
# License: GPL

require 'xattr'

tag = ARGV[0]
file = ARGV[1]

if (file == nil)
p "syntax: thisisabout [TAG] [FILE]"
exit
else
description = File.get_attr(file, "keywords")
if (description != nil)
words = description.split
if (words.include?(tag))
p file + " already has the tag " + tag
else
description = description + " " + tag
end
else
description = tag
end
File.set_attr(file, "keywords", description)
end

thisisnotabout


Removing a tag is done with a similar script:

#!/usr/bin/ruby

# Copyright (C) 2006 Egon Willighagen
# License: GPL

require 'xattr'

tag = ARGV[0]
file = ARGV[1]

if (file == nil)
p "syntax: thisisnotabout [TAG] [FILE]"
exit
else
description = File.get_attr(file, "keywords")
newdescription = ""
if (description != nil)
words = description.split
words.each do |word|
if (word == tag)
# skip word
else
if (newdescription.length > 0)
newdescription = newdescription + " "
end
newdescription = newdescription + word
end
end
else
description = tag
end
File.set_attr(file, "keywords", newdescription)
end

whatsthisabout


The third script is where KDE comes in. It has a --nogui option if you don't want to GUI too show up. The code:

#!/usr/bin/ruby

# Copyright (C) 2006 Egon Willighagen
# License: GPL

require 'getoptlong'
require 'rdoc/usage'
require 'Korundum'
require '/home/egonw/bin/whatsthisabout'

class MainWindow < KDE::MainWindow

def initialize( name, counts )
super(nil, name)
setCaption("What's This About??")

vbox = Qt::VBox.new( self )
@browser = KDE::HTMLPart.new( vbox )

setCentralWidget(vbox)

@browser.begin()
counts.each {|key, value|
fontSize = (6*value)/2
@browser.write("");
@browser.write( key )
@browser.write("
");
}
@browser.end()
end

end

opts = GetoptLong.new(
[ '--nogui', '-n', GetoptLong::NO_ARGUMENT ],
[ '--help', '-h', GetoptLong::NO_ARGUMENT ]
)

startPath = nil
gui = "yes"
opts.each do |opt, arg|
case opt
when '--help'
RDoc::usage
when '--nogui'
gui = "no"
end
end

if ARGV.length == 1
startPath = ARGV[0]
elsif ARGV.length == 0
startPath = '.'
else
RDoc::usage
exit 0
end

wat = WhatsThisAbout.new
counts = wat.getKeywords(startPath)

if (gui == "yes")
about = KDE::AboutData.new("whatsthisabout", "What's This About??", "0.1")
KDE::CmdLineArgs.init(about)

a = KDE::Application.new()

window = MainWindow.new( "What's This About??", counts )
window.resize( 600, 300 )

a.mainWidget = window
window.show

a.exec
else
counts.each do |bla, bla2|
puts bla + " " + bla2.to_s
end
end

The obligatory screenshot:


In due time I will put this in KDE SVN, but I need to make a reasonable cmake script yet. Anyone who can tell me how I can have cmake check wether the required Ruby libraries are installed? There are other things to do too:

  1. make a backup/restore facility
  2. use a database instead of recursively finding tags

Because I have my PDFs in a SVN repository and share them between some work places, the first todo would mean I could share my tags too. The second would just mean a serious speedup.

Saturday, September 09, 2006

KryoMol and KOpenBabel

I have not been posting here as much lately as I had hoped to, but have been quite busy with other things. So no Strigi plugin for Bioclipse yet (Strigi is still gaining momentum), and no new release of kfile_chemical.

However, there is progress on the KDE desktop other than the evolution of Kalzium: Armando Navarro Vázquez released a new version of KryoMol and Jerome Pansanel setup a SourceForge project for a KDE GUI to OpenBabel.