~simon van der linden

To content | To menu | To search

Friday, January 22 2010

Progess in the PyGI land

Again I end up writing about it too late. I had a rather unpleasant semester which kept me quite busy. It's over know, and I'm about to leave for a week of vacation in the snowy Alps. So, here is a quick 'n dirty note about the current state of PyGI development.

The first not-so-recent piece of news is that PyGI is now hosted on git.gnome.org, we got a bugzilla product for it, and the IRC channel where you can harrass us about it is now #pygi (yep, we definitively burried PyBank).

On the code side, we changed the way constructors get wrapped. PyGI used to wrap alternate constructors and select one for the default constructor. Unfortunately, those constructors were not suited for class inheritance, since they are only able to create instances of their base class. Thus, we changed PyGI to use Python GObject's constructor as default constructor, which takes values for properties as keyword arguments. Alternate constructors are made available as class methods for convenience, but will throw an error if they are being used in subclasses.

We also changed the way structures are created, to allow one to create instances regardless of the presence of an allocator and a freeing function. There are still a few things to fix regarding structures support, but what is to change is not clear yet.

More recently, I restored the overrides support. I put a module proxy in front of both the dynamic module and the overrides module, if there is one. When a member is accessed, it is first resolved in the overrides module. It was a bit tricky to make the dynamic module available to the overrides one, but I think the solution is rather elegant. Here is how writing an overrides module it looks like (please imagine the indentation, the blog engine stripped it; don't know why :-/ ):

from ..types import override
from ..importer import modules
 
Gdk = modules['Gdk']
 
 
class Rectangle(Gdk.Rectangle):
 
    def __init__(self, x, y, width, height):
        Gdk.Rectangle.__init__(self)
        self.x = x
        self.y = y
        self.width = width
        self.height = height
 
    def __new__(cls, *args, **kwargs):
        return Gdk.Rectangle.__new__(cls)
 
    def __repr__(self):
        return '<Gdk.Rectangle(x=%d, y=%d, width=%d, height=%d)>' % (
		    self.x, self.y, self.width, self.height)
 
Rectangle = override(Rectangle)
 
 
__all__ = [Rectangle]
 
 
import sys
 
initialized, argv = Gdk.init_check(sys.argv)
if not initialized:
    raise RuntimeError("Gdk couldn't be initialized")

So, all you need to do in order to override a dynamically-generated wrapper is to subclass it, and register the subclass using the override decorator.

You can also do stuff at the module creation, like calling the module initialization function.

Note that in order to avoid exporting internal variables (Gdk.modules, for example), you can restrict the things to export in all.

Then put the file with the same name as the namespace in $(pyexecdir)/gtk-2.0/gi/overrides/.

I think that's it for now. Again, thanks to Tomeu and Johan for their cooperation on all this. Zach just submitted a patch for callbacks and virtual functions too. Thanks, Zach! Sorry, no time to review that now; I'll make it top-priority when I'll be back.

Oh, yeah, and:

fosdem-2010.png

See you and happy hacking!

Saturday, January 16 2010

Bar-ça.

Betania and Joan wearing pieces of clothing with Barça's colours during an instance of El Clasico in the context of La Liga. «El Clasico» is a football match between rivals Real Madrid and FC Barcelona.

That day, El Barça scored 6-2! We (Betania, Joan, Mate, Xavier and I) had been to l'Ovealla Negra in Poble Nou, a pub in an ancient industrial building, to watch the match. The atmosphere was fantastic, the game thrilled everybody. And of course la fiesta continued in the streets till late in the night...

Marina Metro Station, Barcelona. May 2, 2009.

Gear: Nikon F100 with 1.8/85. Tri-X. Epson V750.

Friday, January 15 2010

Attire.

Typically castellers wear white trousers, a black sash, a bandhana (kerchief, here with the Arreplegats de la Zona Universitaria's emblem) and a coloured shirt (light green in this case). The sash supports the lower back and is used by other castellers in the team as a hold when climbing up the tower.

Campus Nord, Barcelona. May 8, 2009.

Gear: Hasselblad XPan with 4/45. Tri-X. Epson V750.

Thursday, January 14 2010

Cheerful.

Joyful castellers after the descerregat (successful building and dismantling) of a human tower.

Campus Nord, Barcelona. May 8, 2009.

Gear: Hasselblad XPan with 4/45. Tri-X. Epson V750.

Wednesday, January 13 2010

Ensemble.

Castellers from different teams together hold up the base of the human tower (they form the pinya), up to 10-person high! They also cushion the impact in case people fall from the upper levels.

Campus Nord, Barcelona. May 8, 2009.

Gear: Hasselblad XPan with 4/45. Tri-X. Epson V750.

Monday, January 11 2010

Rising.

In front of the university buildings in Barcelona, castellers are raising human towers, as they often do for holidays. Building human towers is a quite recent tradition (18th century) originally from Tarragona, a city a hundred kilometers to the south-west of Barcelona.

Campus Nord, Barcelona. May 8, 2009.

Gear: Hasselblad XPan with 4/45. Tri-X. Epson V750.

Sunday, January 10 2010

Rounded.

Montjuic, Barcelona. April 2009.

Gear: Hasselblad XPan with 4/45. Tri-X. Epson V750.

Ambient.

From top to bottom: Xavier, Antoine, and Simon

L'Ovella Negra del Poble Nou, Barcelona. April 2009.

Gear: Nikon F100 with 1.8/85. Tri-X. Epson V750.

Those are my first shots with that lens (they brought it when they came to visit me), at full aperture (ambient light in a pub). I find them amazing! Focus must be pinpoint though; I have to practice.

Nationalism.

La Rambla, Barcelona. April 23, 2009.

Note: I don't support that campaign.

Gear: Hasselblad XPan with 4/45. Tri-X. Epson V750.

Saturday, January 9 2010

Sant Jordi.

Top & bottom: Selling books and roses, Rambla de Catalunya
Middle: Leopoldo Abadia doing autographs, Plaça de Catalunya

Sant Jordi's Day, Barcelona. April 23, 2009.

Gear: Hasselblad XPan with 4/45. Tri-X. Epson V750.

- page 1 of 12