My pretty face [ László Monda's Blog ]
Exploring the cyberspace, one quadrant at a time!
 
Main Page | Blog | Projects

Archive for December, 2005

Why KDE Rules?

Saturday, December 31st, 2005

A wonderful article has been written on why KDE rules.

It's hard to be open toward all kinds of technologies because there are so many of them, but we should embrace as many as we can especially if they're that powerful.

What is Bloat?

Friday, December 23rd, 2005

OSNews has an excellent podcast on bloat. Listen it if you really wanna uderstand this concept.

GStreamer Kicks Ass

Tuesday, December 20th, 2005

GStreamer seems to be an extremely powerful multimedia framework to me. Though I'm not really familiar with it yet, it's not hard to see its power by checking out an example script in its distribution.

Let's see player.py:

#!/usr/bin/env python

import sys
import gst
import gst.play

def nano2str(nanos):
    ts = nanos / gst.SECOND
    return '%02d:%02d:%02d.%06d' % (ts / 3600,
                                    ts / 60,
                                    ts % 60,
                                    nanos % gst.SECOND)

def stream_length_cb(play, ns):
    print 'stream length: %s' % nano2str(ns)

def have_video_size_cb(play, w, h):
    print 'video size %d %d' % (w, h)

def found_tag_cb(play, src, tags):
    for tag in tags.keys():
        print "%s: %s" % (gst.tag_get_nick(tag), tags[tag])

def main(args):
    if len(args) != 2:
        print 'Usage: %s file' % args[0]
        return -1

    filename = args[1]

    play = gst.play.Play()
    play.connect('stream-length', stream_length_cb)
    play.connect('have-video-size', have_video_size_cb)
    play.connect('found-tag', found_tag_cb)
    play.connect('eos', lambda p: gst.main_quit())

    # Setup source and sinks
    play.set_data_src(gst.element_factory_make('filesrc'))
    play.set_audio_sink(gst.element_factory_make('osssink'))
    play.set_video_sink(gst.element_factory_make('fakesink'))

    # Point location to our filename
    play.set_location(filename)

    # Start playing the stream
    play.set_state(gst.STATE_PLAYING)
    gst.main()

if __name__ == '__main__':
    sys.exit(main(sys.argv))

The metadata GStreamer exposes is also impressive to watch.

title: Behind These Hazel Eyes
track number: 3
genre: Pop
album: Breakaway
artist: Kelly Clarkson
date: 731581
title: Behind These Hazel Eyes
track number: 3
genre: Pop
album: Breakaway
artist: Kelly Clarkson
date: 731581
duration: 199000000000
bitrate: 237413
layer: 3
mode: Joint Stereo
emphasis: None
stream length: 00:03:13.997503777

Given how powerful GStreamer and Python is, it'd be not hard to write a basic audio player, like XMMS that implements the most usual use cases in a very short amount of time, only with one or two thousands of lines of code using Python, GStreamer and Glade.

As a sidenote, GStreamer has much more power than demonstrated here. It's a robust, complex, high-level multimedia framework which may dominate our universe one day. So beware and read on.

Writing a Widget Using Cairo and PyGTK 2.8

Tuesday, December 20th, 2005

The article with the above title has just appeared some days ago. Cairo finally makes us able to create state-of-the-art widgets. It reminds me of PostScript because of its vector-graphics nature, but it's not a language, but an API.

It has multiple backends like X surfaces, hardware accelerated OpenGL surfaces or bitmap buffers. Very powerful.

GNOME Community Rocks!

Tuesday, December 20th, 2005

I've made some explorations around the blogs of the GNOME hackers in the past few days. Many of them are really talented, active and sharp, always in the state of constant exploration. I love that mentality! Federico Mena-Quintero is especially a hardcore hacker who is working on GNOME from the beginnings and is currently doing massive performance optimizations on it.

Planet GNOME is also very active and is worth reading.

Developing in C# under Linux

Wednesday, December 14th, 2005

Unfortunately developing C# applications under Linux is still a pain. I've tried out many different C# editors in the past few days (there are not so many) which work under Linux and I found Eclipse with the Improve C# plugin the best. This thing doesn't even support class browsing, but it's generally usable and has a good VCS support.

Monodevelop is obviously more stable than its previous release, but it's still not there and has no version control integrated yet. It'll probably maturing stable in the next few months, though.

Decorating the Desktop

Wednesday, December 14th, 2005

I took some steps to make my desktop look nicer. In short I've just set up the Blue Swirl GDM theme and the Clearlooks GTK theme. They're so hot! Damn!

Thanks Dömi for pointing out to Blue Swirl.

Using GDK for Image Manipulation

Sunday, December 11th, 2005

Using GDK for manipulating images is not so easy as one might think. You need to know well the API semantics in order to load, manipulate and save an image. I've just written a sample application that demonstrates the above scenario.

Here it goes:

#!/usr/bin/env python

import sys
import gtk

if len(sys.argv) != 3:
    print 'usage: x-this-image source-image destination-image'
    sys.exit()

source_filename = sys.argv[1]
destination_filename = sys.argv[2]

pixbuf = gtk.gdk.pixbuf_new_from_file(source_filename)
width = pixbuf.get_property('width')
height = pixbuf.get_property('height')

gtkwin = gtk.Window()
gtkwin.realize()
gdkwin = gtkwin.window

gc = gdkwin.new_gc()
red = gtk.gdk.Color(65535, 0, 0)
gc.set_foreground(red)
gc.set_rgb_fg_color(red)
gc.set_line_attributes(10, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_BUTT, gtk.gdk.JOIN_MITER)

pixmap = gtk.gdk.Pixmap(gdkwin, width, height)
pixmap.draw_pixbuf(None, pixbuf, 0, 0, 0, 0)

pixmap.draw_line(gc, 0, 0, width-1, height-1)
pixmap.draw_line(gc, width-1, 0, 0, height-1)

pixbuf.get_from_drawable(pixmap, gdkwin.get_colormap(), 0, 0, 0, 0, width, height)
pixbuf.save(destination_filename, 'jpeg')

I couldn't wait to test this babe on some sample images. See it for yourself:

source.jpg:

Image

destination.jpg:

Image

Enabling Title Streaming in XMMS

Friday, December 9th, 2005

A buddy of mine has written about how one can enable title streaming in XMMS. You can easily set the thing in Preferences > Audio I/O Plugins > MPEG Layer 1/2/3 Player > Streaming. I consider this a bad usability decision, inactivating a useful feature by default.

Thanks Medve. You made my life easier.

MediaWiki on SourceForge, Part 2

Friday, December 9th, 2005

In a previous post of mine, "MediaWiki on SourceForge", I wrote about the topic of this post and this time I wanna correct the informations I gave there.

Diego Torres Milano, developer of the JGlade project contacted me several days ago that I should update my blog mentioning that MediaWiki cannot be installed on SourceForge. He kindly pointed out to his script which is meant to install MediaWiki on SourceForge.

I couldn't use his script, because it seemed a bit buggy, I haven't had the time and I'm not so motivated installing MediaWiki on SourceForge right now since I'm using DokuWiki on monda.hu for Ultimate Commander. I recommended him to write a howto on the topic since the suckiness of bash scripts in these complex scenarios is unavoidable, but he thinks a script is a better way to do the thing.

He told me that SourceForge allows to write the /tmp/persistent/ directory. You typically wanna create your /tmp/persistent/<your-project> directory and put the related files into it. This way one can install any web application on SourceForge.

Anyways, I you wanna install MediaWiki on SourceForge you should really give his script a try. He's also helpful and very willing to improve his script so contact him if things don't go well.

Thanks Diego.