Last 5 Posts from 2006

Qtopia 4.2 is now GPL!

Trolltech Qtopia was the first framework that enabled GNU/Linux to run on embedded systems, like Sharp Zaurus, that did great by end of this decade.

While it did great, being based on Trolltech Qt, it was version 2 and while Qt improved a lot in version 3, Qtopia was never updated and no free version was available.

Now Qt is in its 4th generation and have great improvements, like painting system (Arthur, similar to Cairo) and text engine (Scribe, similar to Pango). They have a really easy and intuitive API, while being very optimized, Arthur supporting even OpenGL-ES. And the big news was that Qtopia was upgraded to cope with Qt4, making things interesting again that Gtk was doing its first inroads on embedded systems.

The bad news so far was that Qtopia4 was closed source, but since Trolltech announced their Greenphone people were asking Trolltech to release it. Being a good Open Source citizen, they did a wonderful announcement releasing Qtopia 4.2 as GPL.

Great work Trolltech! Now I just hope someone will have it running on Nokia 770, bringing some competition to Maemo, at least some speed comparisons.

Radeon + Xorg + WXGA LCD TV = it works!

I managed to get my IBM Thinkpad T41 Radeon Mobility 9000 running Ubuntu Edgy with X.org 7.1 to display on my Sony Bravia 40&rdquot;!

I was trying to get this laptop to support 1360x768 at 60Hz without luck. At first, I was unable to have the open source driver to use this mode and frequency. Later I tried binary driver, but seems it doesn't support Xv, making video playback slow as hell if you want to scale it.

But after some googleing I've found a nice example of using various servers layout on top of the open source driver http://mg.pov.lt/xorg.conf. Then I found how to get the correct mode-line using read-edid (get-edid | parse-edid).

Now it is working perfectly, even with MergedFB option (radeon's own Xinerama implementation), with monitors at different resolutions working together!

Download: http://www.gustavobarbieri.com.br/xorg.conf-wxga_sony_bravia_40

New server, move to WordPress and SVN repositories changes

I'm moving away from my old server at my parent's store to http://dreamhost.com, a really cool hosting service.

After this change I also opted to move away from Blogger to WordPress, which is much nicer and full of features, like post tags.

Since dreamhost's SVN is really old (1.1.3), I'm moving my self-hosted svn projects to somewhere else. My old university projects (computer_graphics and passive_replication) and personal code playground will go to code.google.com, while Eagle will go to tigris. I still have to move these and setup everything properly, I'll post when I have those done.

No more waiting, download Canola right now!

No more waiting, just download our first beta, you need both repositories:

Maemo's repository:
Web address: http://repository.maemo.org
Distribution: scirocco
Components: free non-free
Canola's repository:
Web address: http://openbossa.indt.org/canola/repository/
Distribution: scirocco
Components: user

After you download, you need to reboot your device!

Then, take some time to use and them answer our survey.

Bug reports and wish lists should go to Tracker at Garage.

Those who like the command line/ssh, your /etc/apt/sources.list should have:

deb http://repository.maemo.org/ scirocco free non-free
deb http://openbossa.indt.org/canola/repository/ scirocco user

Learning Canola the easy way, casting Marcelo ;-)

Marcelo posted some videos explaining Canola usage, you may check it out in order to explore Canola's UI best.

What a day, now I'll sleep a bit... it's 5:22am here!

Swiftfox: optimized Mozilla Firefox build for GNU/Linux

I hate Mozilla Firefox being so slow on Ubuntu, so today I tried Swiftfox and it feels faster. Not as fast as my old Gentoo build without damn gtk support (I use kde), but it's an improvement. You can try it yourself:

echo "deb http://getswiftfox.com/builds/debian unstable non-free" >> /etc/apt/sources.list

apt-get update
apt-get install swiftfox-$YOUR_PROCESSOR

Playing videos with MPlayer and GStreamer inside SDL Applications

Both MPlayer and GStreamer can output video to some X11 Window given its ID, this is done using mplayer -wid or gst_x_overlay_set_xwindow_id(). But if you are developing an SDL application and tried it, you may have faced the same problem as I did: You can just output to whole SDL window, not just part of it.

Why does this happen?

The X Window System uses the term "Window" for any rectangular area, not just toplevel windows as we know. Toolkits often use X Windows as base for everything visible: buttons, labels, text areas and the window background itself. Every window is attached to another window, the parent window, except by the root window (that one that holds desktop wallpaper).

However, SDL is composed of just one X window and you don't have any way to create more using SDL itself. So if you want to output your video to just part of window, you need to create another X Window with desired geometry and position, using SDL's as parent.

How to work around this?

As I said, there is no SDL functions to create X Window. You need to create it yourself using Xlib functions. Xlib is the C implementation for the X protocol, a client-server. It's not that hard to develop, but you need to understand some things beforehand (You can see more information on Christophe Tronche - The Xlib Manual or Guy Keren - Basic Graphics Programming With The Xlib Library):

Display
Structure representing the connection to X server. You can get this from SDL using SDL_SysWMinfo.info.x11.display or you can create your own using XOpenDisplay().
Window
Integer that identifies some window inside a display. You can create windows using XCreateSimpleWindow() using a parent window, which you can get from SDL using SDL_SysWMinfo.info.x11.window.
XMapWindow()
XCreateSimpleWindow() doesn't display the window, you need to do it yourself. The X way to do it is call XMapWindow(). Note that X window is asynchronous and you need to wait until server process and replies. First, you need to select what events you want to listen using XSelectInput(). Then you need to have client to send commands to server, this is done by XFlush() or any call that does this, in this case we use XNextEvent(), which already waits for events from X server.

Show me the code!

Updates

Canola: I said it's fast!

I've said before that canola was fast, now you can check how fast it is scrolling a list of thousands DAAP (iTunes 6 or Rhythmbox) musics. Actually, it can be even faster, but we're running with some debug symbols and random printf(). Check it out:

Maemo Delight: Canola

So the project I'm working on is not secret anymore: Canola was announced and even we did post a preview video about its usage.

Some may ask if this compete with Nokia's Media Streamer and no, it doesn't, it's just another way to use your Nokia 770! It's fast, beautiful, need no stylus and connected.

You will love using it, I promise you ;-)

Eagle features and some screenshots

Today I updated Eagle in order to implement some user requests:

focus support
now you can use widget.focus() to give it keyboard focus.
buttons with custom images
aside from stock buttons, which have system wide (and themed) icons, you can use your own images. This also respects system's "buttons with icons" (gtk-button-images) settings and thus will not show on Maemo platform.
canvas resize callback
canvas is always placed inside scrolled window (a container with scrollbars) in order to make developer's life easier. But making the window bigger just make the scrolled window bigger, not the canvas contents. With this callback you can then get the available space and resize the internal contents.
As requested by some friends, here follows some screenshots of Eagle applications running on maemo:

Developing GObject-based classes using Emacs

If you do code GObject derivated classes using Emacs and is tired of so much typing, find and replace just to declare some classes, you must like my new set of Elisp functions: gobject-class.el

There are 3 helper functions

gobject-class-header class_name parent_class_name
Inserts in the current buffer the stuff you usually put into header (.h) files. These include common used/recommended C-pre-processor macros, typedefs, structs and G_BEGIN_DECLS and G_END_DECLS
gobject-class-code class_name parent_class_name
Inserts in the current buffer the stuff you usually put into code implementation (.c) files. These include G_DEFINE_TYPE, _class_init(), _init(), _dispose(), _finalize().
gobject-class-generate class_name parent_class_name
This is a combo of the previous, that already split the screen, create the files with gtk/glib name schema. This is what I use most.
You can bind them to some key, like gobject-class-generate to F7 using (global-set-key [f7] 'gobject-class-generate), or just call them using M-x gobject-class-generate

Please notice that both class_name and parent_class_name expects a string with underscores ("_") separating the namespace and other components. Examples: g_object, gtk_tree_view, ...

Maybe you're interested in my .emacs.

Interesting Eagle application

These days I've opted to invest money and went to my bank webpage in order to find the best option. As you can see, the webpage does not offer a good and quick overview of what happens and I don't want to fill my mind with numbers in order to compare options. Some sort/order, highlights and graphs would help me to see the big picture. All right, being a hacker I must admit it's more intersting to write an application than to deal with money... and looking at the web page source code it seems easy enough to parse it and use Eagle to view it.

It took me more to review the python re module, remember regular expression syntax and write the parser than to write the first GUI version, with a simple table (with column sort). In the end, adding graph support was really easy and I did one and my friend Elvis did another one in few minutes, the result (source code, requires Eagle from SVN) is pretty amazing:

Live patching techniques

During my last project I had to work with some libraries pre-loaded on systems, they didn't work as I wanted, but I couldn't change the system version. What to do? Live patch your libraries!

LD_PRELOAD
This is widely used by softwares that just want to run unmodified programs with unmodified libraries, but using different functions than libraries provides. As an example, ALSA does that by intercepting open(), read() and friends from LibC with a new version that check if filename is some OSS device and then route these through ALSA. This method is pretty simple and the base for others: just create a new library with functions to override and put it in higher precedence in linker or export environment variable LD_PRELOAD pointing to these library before running the application (this have the highest precendence). If you still want to use the previous (overrided) function then you must use dlopen() and load the original library and then dlsym() to get the original symbol.
Have the functions in your application
If you have your function in your own application, it will have higher precedence over libraries and will work just as LD_PRELOAD. Actually this is the same thing.
When it doesn't work...
Sometimes this just doesn't work, in my case it didn't work when I tried to override gtk_image_set_from_file() but use it from g_object_set() with a property that calls that function internally. My guess on why this doesn't work is because function call and declaration were in the same object and thus compiler may have inlined or did some other optimization. In this case you have to find an alternative solution and in my case was a even bigger hack:
  • Get an instance of GtkImageClass (use GTK_IMAGE_GET_CLASS())
  • Declare my own gtk_image_ser_property() which remember the old setter (((GObjectClass*)GtkImageClass)->set_property) and call it if property was something different than the one that call our desired function.
  • Have the class to use our setter with ((GObjectClass*)GtkImageClass)->set_property = my_gtk_image_set_property;
If you have another live patching technique you want to share, just post a comment!

GLib is a technical disaster

Yes, you read it right: GLib is a technical disaster. After some time working with it, both using, building upon and hacking its internals, you can see the mess.

One thing that really piss me off is people that, instead of solving problems, create more problems that they call a "work-around". GLib just do that: compiler-aided OO languages were badly supported in GCC? Let's fix GCC? No, let's create OO atop C, using a lot of pre-processor, make things cumbersome, error-prone, ... POSIX and its GNU/LibC implementation lacks features? Let's create a whole new string, list and hash implementation! Oh, and do not forget that missing printf(), make it g_print()!

I'm not a C++ enthusiast, but I do think it or ObjectiveC or any other compiler-aided Object Oriented language would help. Anyone that already implemented GObject subclasses know what I'm talking about. The very first thing you'll notice is that you have to copy and paste too much code, but still have to change little bits here and there, making the process error-prone. Then you have the pre-processor macros and if you already worked with them or read Linux kernel position on it, you know it's a mess and should be avoided. And how about a dynamic type system using C? Yes, GLib does have that, making things slower, bigger and impossible to compiler to optimize virtual-tables and dispatchers! And back to GCC, it's now good enough and improving support for OO languages, but GLib/GObject will win nothing, GCC still handle it as regular procedural code.

Insanity doesn't stop there, some Software Engineer Guru wanted to have "private" fields and yes, they also did it, even worse: they seem to incentive that! Any experienced hacker must know that this is just bullshit... and when you're dealing with barebone C, where you have direct access to memory, you just think "they're playing jokes". Let's suppose you could protect memory regions, why would you protect it? Against developers? Why? This idea must came from a non-programmer, because any programmer should know what to do and this just make debugging and testing more difficult. But let's face it: C doesn't offer any way to protect memory regions, so all you have to do is to have pointer to an area and use it... but they like the ClassNamePrivate, that just make things bigger, slower and painful to debug. If Operating System Kernels, that deals with critical data, don't do any fancy stuff to "protect" it, why GLib guys do?

Still looking how BSDs and Linux relates to GLib and GObject, you can see that the kernels have saner implementation of linked lists, trees and hash tables. They also have clever Object Oriented code (vfs and others). Weird enough, hacking Linux or BSDs kernels are much easier when you compare easy-of-use and consistency of APIs.

How about namespaces and method resolution? Why would I use a language that supports that? It's so cool to use gtk_label_set_text() or filling your mind with Object Hierarchies! Of course it's gtk_misc_get_padding() if I'm dealing with a GtkLabel. When using these functions you may also opt to use casts and make it even more error prone or to use those GTK_LABEL()-like macros, that do function calls and some branches.

Just to make it clear: I know other languages and libraries have problems too. Qt is another good example on how-to-not-fix-the-proper-problem: stl is broken, let's re-implement it! Why use namespaces, it's just one letter! Let's require user to pre-process their code (moc). However any of these are excuse, GLib has is a technical disaster because it tries to solve the wrong problem.

New Eagle and Maemo-TaskManager release for Maemo 2.0

Thanks to INdT sponsorship I've been able to work on Eagle port for Maemo 2.0 and some great improvements:

  • Tabs support: also known as TabWidget, Notebook and TabControl, this widget helps a lot to solve UI problems with small screens. Maemo-TaskManager now uses it to display some statistics (screenshot). It's also really easy to use, check the API.
  • Expand Policy: now developers can define expand/fill policy for both horizontal and vertical axis for widgets, just give the expand_policy parameter with one ExpandPolicy.Policy, there are some pre-defined, like All.
  • Nested Groups and Groups Without Borders: now it's possible to have nested Group elements and also specify them to use border=None so borders will be disabled. This enables you to create richer layouts within those 5 pre-defined areas.
While I have no repository for maemo, download it here.. There are other packages for other platforms at http://www.gustavobarbieri.com.br/eagle/packages/.

Maemo-TaskManager now provide CPU and Memory load graphs and its package support Application Installer, just download it here

PyGTK is getting better, stay tuned!

As you might know, INdT do take care of PyMaemo, the Python port for the Maemo platform, and as I work for INdT, I'm trying to help to improve Python on this platform, so maybe one day we get it included on Nokia 770 product.

Python VM/interpreter is quite light and fast, the showstopper is load time, mainly the import time and to be more specific, import time of C-written modules with many symbols, like PyGTK, which is really useful in Maemo.

First a basic intro on how to write Python modules in C: you need to provide a table with exported functions, these consist of a string, which will be the visible name in Python, the function pointer, parameter types and docstring. You can check more details at Extending and Embedding the Python Interpreter document.

So, how this can slow things down? The main problem is that these function pointers are address that will only be resolved by the dynamic linker when the library is loaded into RAM, and this take a lot of time.

This is not the only problem, there are others that affect us in the current version, for instance, PyGTK did initalize every GTK, GDK, ATK, Pango classes, even the unused, they did use to call classes _get_type() methods, like gtk_label_get_type(). For those not aware of GTK/Glib/GObject internals, GObjects are dynamic types, type checks are done in runtime by the GType system. When you first use a class you will call its _get_type() in some way, which will fill a static structure and register it with the GType system, which will maintain a complex structure and hash table underneath. When you use macros like GTK_LABEL() or GTK_TYPE_LABEL, you're calling functions and using the GType stuff. In regular C programs, you just do this for few classes, but PyGTK were doing this every time.

After some investigation and talking to Johan Dahlin, he did look at it and some great stuff started to show! For instance, the GType madness is gone! Now these functions are lazily called, so you just pay for what you use. Also planned is to be able to load every function in a lazy fashion, so import gtk would do almost nothing and thus be really fast. Johan is doing an excellent job and much this is already done, other are under development (like lazy-load Enum/Flags stuff) and some will be done in near future (like every function/method to be lazily imported).

Last, but not least, Rafael Ávila de Espíndola, my co-worker, is taking care of symbols visibility, adding compiler hints where appropriate to instruct it to hide some symbols, which also helps a lot

So much is being done in GTK and it will for sure improve our situation on Maemo and Desktop. Thank you Johan and Rafael!

HOWTO disable images/icons on stock GTK buttons

Maemo do not use icons/images on stock buttons, however it doesn't specify that in its "rc" (resources) file, so we need to do that in our code.

Code is really simple, however since some people already asked me, I'll publish it here ("widget" parameter can be a toplevel window):

  • C version:
    void disable_button_images( GtkWidget *widget )
    {
    GtkSettings *settings;
    
    settings = gtk_widget_get_settings( widget );
    g_object_set( G_OBJECT( settings ), "gtk-button-images", FALSE, NULL );
    }
  • Python version:
    def disable_button_images( widget ):
    settings = widget.get_settings()
    settings.set_property( "gtk-button-images", False )

Python in Maemo 2.0: repository available!

For those wondering how to get Python working in Maemo 2.0, INdT (guys from pymaemo, responsible for the port) provide a repository at http://maemo.org.br/platform/apt/ (note the domain .br!) with packages.

Worth remembering that these will go into http://repository.maemo.org after quarantine period. Python is supported by maemo, is already included in 2.0 SDK and will ship with products (at least nokia 770) soon.

Python is much more complete now: it includes bindings for Gstreamer, BlueZ, DBus and Glade! PyGame, Hildon and others are much improved and we will see bindings for other libraries available in platform soon! Stay tunned.

If you want to know more about python in maemo, check great tutorial available on website, thanks Daniel D'Andrada.

UPDATE: As Herraiz noticed in his comment, you may add the following repository to your Application Manager/Tools/Application Catalog...: Web address:

http://maemo.org.br/platform/apt/
, Distribution:
python
, Components
python

UPDATE.2:You will also need the official repository http://repository.maemo.org/ (distribution is mistral-beta, components is free) in order to get libncurses5 dependency. Note that this repository has great tools for developers, like ssh, which won't show in Application Manager, but is installable using command line sudo gainroot; apt-get install ssh

UPDATE.3: Since maemo 2.0 (mistral) was released, there is no mistral-beta distribution anymore, it is now called mistral and the great news: Python is now included in this repository! No need to have the maemo.org.br anymore. New catalog entry is http://repository.maemo.org/ (distribution is mistral, component is free)

GUADEC-2006: here we go!

GUADEC, The Gnome Conference, is about to start next 24th June, in Vilanova i la Geltrú (near to Barcelona, Spain), and I'll be there!

I'll present Python in Maemo on 30th June, at 12:00. This talk will be an overview of work done here in INdT on Python port and customization for the maemo platform and its current status; also I'll live-demo (code) small applications in python+maemo using my own library, Eagle.

Aside from presentations, conferences are good places to get together with those we just know from email and IRC and have a good time, so I'll join the GUADEC - FreeFA Football and show 'em all the Brazilian Football! :-D

Maemo Task Manager and new Eagle release

Today I've released a new version of Eagle (download versions for desktop or maemo), this new version features a Rich Text widget, bug fixes and minor improvements.

Also starring today is Maemo Task Manager, the first Eagle-Maemo application to be released.

Both Eagle and Task Manager are sponsored by my employer INdT.

Please notice these screenshots are from scratchbox environment, that's why you see kde processes there!

Make Linux boot even faster

As you might know, I'm always looking for ways to speed up my system boot.

Today I discovered fcache. It was created by Jex Axboe, from CFQ io-elevator fame, and was announced at LKML on 2006-05-15. He aims to reduce bootup times by speeding up access to files and does this laying out data linearly on disc. It happens in an extra partition that will hold cache data, this cache will be written by fcache while in "priming" mode: every read from cached partition will be appended to cache. While in "normal" operation mode, it will lookup data from cache instead of real file system.

This makes a solution even better than the one I envisioned before, that was automatic on-line defragmentation. It's simpler, more efficient and works for every file systems!

Thank you, Jens!

VoIP and Python on 770

Today I read an entry at planet.maemo from Teemu about GTalk (VoIP), it was So it is Google Talk then….

While I agree with some points, I have some to add:

  • 770 is spread as a internet device, then makes sense to pair with some big internet service provider. And Google is a big one. I can envision Google's applications like Calendar and possible other Internet-PIM to work flawlessly on 770 opera browser. It would be a great step, since device lacks a pre-installed PIM application.
  • Why wait for Telepathy? Why not try Tapioca-VoIP? It runs on your desktop today and will run on 770 as soon as we have the new software, with GStreamer 0.10. Also, Tapioca-VoIP provides Python API!

About Python comments, I really hope it will improve, I know some PyMaemo guys and they're working hard to fix problems found in current version. Meanwhile, I'm working on Eagle to make easier for us developers to have GUI for our applications on 770.

Last, but not least, My presentation at GUADEC will cover all these topics: I will demonstrate Python on Maemo by coding an Eagle application that uses Tapioca :-)

How to write Shared Libraries, by Ulrich Drepper

Today Eero Tamminen suggested at maemo-developers a good read: http://people.redhat.com/drepper/dsohowto.pdf

It explains how shared libraries works and possible optimizations on its usage, a must read for us developers.

I'm still reading, but seems really useful.

{K,}Ubuntu Dapper Drake: make it even faster

Yesterday I got my Kubuntu machine updated, it's a bit faster now, but still not as fast as I would like.

So I went to try to speed things up. Given I did not install it myself, I don't know if he did most procedures I do and I noticed the guy didn't. Some things I did:

File System Speedups: since I use a laptop (slow disks) with dm-crypt, making filesystem as fast as possible is crucial. Also, avoid forced fsck since it may show while booting for a talk/presentation (as it already did!) and avoid huge reserved space for super user, since HD is not that big. Changes:

  • Save previous ext3 state: dumpe2fs $EXT3_PARTITION > ext3-state.txt
  • Turn off forced fsck runs: tune2fs -i0 $EXT3_PARTITION
  • Turn on dir_index on ext3, for faster searchs and file lookup: tune2fs -O dir_index,sparse_super,has_journal,filetype $EXT3_PARTITION
  • (Possibly) reduce amount of reserved space for super user. It defaults to 5%, but maybe it's too much for you, or it's not needed (if you use /home partition) calculate amount with AMOUNT=512*100/$FS_SIZE_IN_MB to reserve 512mb. Set it with tune2fs -m$AMOUNT $EXT3_PARTITION; tune2fs -m0 $HOME_EXT3_PARTITION
  • Have ext3 to rebuild indexes and thus use dir_index (first unmount partitions, you may boot from a livecd): fsck.ext3 -fCD $EXT3_PARTITION
  • User greater ext3 commit interval. It defaults to 5 seconds, but on laptops with good battery you can make it 15-60. I use 15 (home) and 60 (system, also with noatime) for fail-safety: edit /etc/fstab and append commit=15 to filesystem options.

Hardware Settings: it's all about hdparm. Edit /etc/hdparm.conf and make sure, at least dma=on and interrupt_unmask=on are set.

Network: If you often change networked and non-networked environments, you may notice boot can take a lot if you have interfaces as "auto" in /etc/network/interfaces. Remove them all from auto and install ifplugd, it will then detect if network is physically available and if so launch them. You may also install and configure wpasupplicant in order to automatically change among WEP, WPA and WPA2 wireless networks, but be aware to set wpa-conf /etc/wpa_supplicant.conf in interface option in /etc/network/interfaces

X.org: use 16 instead of 24 bits-per-pixel, at least it will consume less memory.

Kernel: use latest Con Kolivas' kernel patch. It makes desktop more responsive.

Services: disable unused services in /etc/rcS.d and /etc/rc2.d. I do not use PCMCIA, PPP, EVMS, NFS and a bunch of other services. Also, readahead seems to be optimized to GNOME rather KDE, so I disabled it too (readahead-desktop).

My system (IBM ThinkPad T41, 512mb of RAM, 40Gb Fujitsu MHT2040HA, 1.6Ghz/1MB cache Pentium-M) boots to KDM in 45s, remember that I use dm-crypt! It's still far from how many seconds I think it should take, but things are still improving in GNU/Linux.

GStreamer, Python, OpenGL and Applications that rocks!

Today I attended Thomas vander Stichele GStreamer 0.10: Past, Present and Future presentation. First of all, Thomas did really great, nice talk, nice slides, live coding using python and cool applications.

What really caught my attention was demonstration of Elisa, a Python application that uses OpenGL and GStreamer to provide an incredible interface, responsive, beautiful and organic. There is no screenshot online, but worth the pain to download, install and try it!

Other applications that were demonstrated:

  • PITIVI: non-linear video editor.
  • Togra: it provides easy-to-use and fast OpenGL scriptable in Python, one example used it to show video textures, some balls bouncing with the surface being a video from GStreamer.

Also, he demo'ed how 0.10 is responsive to seeks and instantaneous paused-playing transition... these were horrible before. He said the core was reworked to be thread safe, memory leaks and dead locks. Great work!

Eagle in Maemo

Today I hacked Eagle to add Maemo platform. Port was quite trivial because Maemo is almost pure GTK with some extra classes to fit better embedded systems.

However I opted to not port every component, like HildonColorButton or HildonNote because I think they're not well designed, they don't even provide signal "changed", used by Eagle's DataWidget to persist data automatically. As API will change in Maemo 2.0, I won't bother with this until then.

In previous screenshot you can see my little platform specific addition: automatic generated menu. Another addition is support for fullscreen button

KDE 3.5, Katapult and Yakuake

Today I did update my Gentoo to KDE-3.5.1, it really worth the compile time :-) It's much more polished than 3.4.3, nice integration with HAL

, more optimizations and nice improvements to some apps, I just tested Kopete so far and it was great.

Then I tried to little applications: Katapult and Yakuake.

The first is a nice application that have no main screen, it stay invisible until you press Alt+Space, then it shows a semi-transparent centered that show documents, applications or other catalog data as you type. For example, if you type 1+2 it will use the Calculator catalog and show the result. If you type amarok it will use the Application Launcher catalog and if you hit Enter, it will open it. You can also browse the bookmarks and other stuff. More catalogs will come since Ubuntu guys are maintaining it.

The second is another application without a main screen, when you hit F12 a konsole KPart will show from the top edge like Quake games do. You can use other skins, just browse kde-look, and you can right-click the background to change terminal color and also make it semi-transparent! It will hide as soon as it loose focus, but F12 brings it again in the same state!

Motorola headset HS801 and GNU/Linux

I'm entering the bluetooth world, just bought a usb-bluetooth dongle (lsusb: Bus 003 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle) and a headset Motorola HS801.

I could set it up to work with GNU/Linux, but it was not that easy, so here follows the instructions:

  1. You will need an ALSA kernel module called snd-bt-sco, it's not in kernel tree yet and most distros doesn't ship it, so get it from here: http://bluetooth-alsa.sourceforge.net/ I'm using version 0.41 without glitches. Gentoo users could use ebuilds from bug report #91558.
  2. Load the ALSA-Bluetooth module: modprobe snd-bt-sco.
  3. If you want to use Skype or other applications that doesn't support ALSA, just OSS, use the OSS emulation layer, with /etc/modules.d/alsa:
    alias snd-card-1 snd-bt-sco
    alias sound-slot-1 snd-card-1
    
    alias sound-service-1-0 snd-mixer-oss
    alias sound-service-1-1 snd-seq-oss
    alias sound-service-1-3 snd-pcm-oss
    alias sound-service-1-8 snd-seq-oss
    alias sound-service-1-12 snd-pcm-oss
    
    # Set this to the correct number of cards.
    options snd cards_limit=2
    I also use aoss with some applications, so I have in /etc/asound.conf:
    pcm.dsp1 {
    type plug
    slave.pcm "snd_headset"
    }
    
    ctl.dsp1 {
    type plug
    slave.pcm "snd_headset"
    }
    
    ctl.mixer1 {
    type plug
    slave.pcm "snd_headset"
    }
  4. Then pair your device with your computer, I have set up /etc/bluetooth/hcid.conf with:
    options {
    autoinit yes;
    security auto;
    pairing multi;
    pin_helper /usr/lib/kdebluetooth/kbluepin;
    }
    Then KDE will prompt me with a nice GUI to enter device's PIN.
  5. Manual test before continue: discover your device hardware address using hcitool scan and then run the btsco daemon manually: btsco -v $HWADDR, then play some sound to it using ALSA play: aplay -d plughw:Headset /path/to/sound.wav, if it doesn't work, then you need to check previous steps!
  6. If everyting was right, then you could use some tool to automatically start btsco. I use KDE bluetooth daemon (kbluetoothd): Right-click the systray icon and choose Configuration/Configure Services..., then Device Discovery, add a new job called Headset and enable it, then choose Listed devices only and Add device, choose pooling times about 30 seconds and click Configure, enter this script there.

You can use this wiki as base, it's a Gentoo-wiki, but it's well written and you can understand the concepts and use it in other distros: http://gentoo-wiki.com/HOWTO_use_a_bluetooth_headset

Back from LinuxConf.AU to normal life

Now I'm back from LinuxConf.AU and trying to fix things up so I can move to my new job at INdT.

I've uploaded my photos to http://fotos.gustavobarbieri.com.br/LinuxConf-AU-2006

Also, I have my Bungy Jump movies at http://www.gustavobarbieri.com.br/videos/bungy_jump/aj_hacket-nz/.

I've bought some nice electronics like a PlayStation2 (and I want to run Linux on it!) and also a bluetooth headset and usb-dongle, so you may expect some posts about these things in near future... just after I move to Recife and have a normal life again.

TurboGears rules!

These days I checked out TurboGears, a Python rapid web development megaframework. It bases on well-known projects like CherryPy and SQLObject together with new components like Kid Template and Mochikit JavaScript Library to provide you a powerful platform to develop your web projects. I really enjoyed it!

Once web development for python was all Zope and Plone related. However these technologies have a big learning curve that makes beginners uncomfortable, unlike Python, that makes user life easy from beginning yet providing power to experienced users. I'm an experienced python programmer and already did Perl/CGI and PHP programming for years, but could not learn Zope or Plone in one afternoon. As I'm not a professional web developer, I don't want to spend more than one afternoon just to learn the framework basics!

Then various frameworks came, most of them were incomplete in some sense and they were all incompatible, most of them have great features but some limitations or design goals that made me avoid them.

I don't know if it were due to Ruby on Rails success or if the python community agreed in a coincident timeframe, but this last year two pupils were born: DJango and TurboGears. Both are really well documented and have useful tutorials and screencasts. The first were born from inside a web-publish site and have really great administrative features, however it does not extensively use other projects: it have it own Object-Relationa-Map, template system and more. The last doesn't have so many ready-to-use tools yet (version 0.8), but by using existing tools like SQLObject and CherryPy it's evolving really fast and have promising features to come in version 0.9. That's why I opted for TurboGears.

TurboGears allows you to develop a MVC web applications, you just need to code your views using Kid or other template plugin (0.9 will ship with others, like Cheetah), code your controllers with methods that should be accessible from web-server being exposed and your models using sqlobject. It's so versatile that you may use most of your controller methods to return not just HTML/XML but also JSON (without changing the source code!) that, associated with Mochikit, makes it extremely easy to code dynamic HTML like AJAX interfaces together with plain HTML!

Version 0.9 also includes:

Identity system
handles permissions and authentication
CatWalk
General model browser and editing system
ModelDesinger
Design your SQLObjects in a visual, WYSIWYG fashion
Widgets
Avoid writing forms manually. This handles validation and presentation to you!
It's a great framework, but it's a bit unstable until 1.0 comes. I plan to publish some examples as soon as I have them :-)

Heading to LinuxConf.AU!

This week will be a great week. Thursday and Friday I'll have party because I've graduated at University, most of my family members and friends will join me and it must be cool! Then, on Saturday afternoon I leave Brazil heading to Dunedin, New Zealand, to participate at LinuxConf.AU, where I'll present a talk on Wednesday and watch other cool presentations by great people, like Aaron Seigo, Andrew Tridgell, Keith Packard, Rusty Russell and others! I never thought I would met them! :-)

Eagle: easy GUI using python

Remember my post Crap code of the moment: libgip (and how to make it better)? I implemented most of things I listed in my post, did some tutorials and documentation.

After that post I started to wonder how difficult was to code a basic prototype and I thought it was easy, so in about 4 hours I coded a basic abstraction using Python and GTK+2. It was just a GtkWindow with 5 areas (combination of GtkHBox and GtkVBox) and a few widgets.

Then I started to play with it and after writing some documentation and the tutorial I added more interesting stuff. Some required stuff is still missing, like a "grid" (a.k.a. GtkTextView, QListView, ...), automatic thread support, menu and toolbars.

Now it's reasonable mature and has even an entry at Python Package Index: http://www.python.org/pypi/eagle/ and also a home page at http://www.gustavobarbieri.com.br/eagle/. Code repository is at http://code.gustavobarbieri.com.br/eagle (it uses SVN).

Remember: Ealge is not meant to be "yet another" toolkit, instead it build atop existing toolkits adding features and some restrictions to help you to develop your applications. Narrowing the scope of what can be done with this library, things could be made easier to its users, like the automatic layout in one of the 5 areas and the label at right of user entry components.