Marco Islas Blog

Download/Upload with BAM


Download/Upload with BAM

Originally uploaded by markuz

Today, BAM, the movil Internet connection have been working quite good. I'm downloading some torrents and songs from Frostwire while seeding those torrents that I have already finished.

Beside that Java uses a lot cpu, downloading songs with Frostwire have been for long, my choice.

Comics: Reasons why people who work with computers seem to have a lot of spare time

Comics: xkcd: Not enough work

Damn. I knew it! somebody was watching us at the office...
xkcd: Not enough work

Happy family


2009-03-08-124345.jpg

Originally uploaded by markuz

Cristina and I. We are a happy family

Starting to GDM in 22 seconds


Best bootchart ever

Originally uploaded by markuz

drivel

Testing drivel

Young Frankenstein - Dr. Fronkonsteen meets EYE-gor

PyGTK: Playing with gtk.GenericCellRenderer

Some time ago, I made a program that have a list of items, those items have a property that allow/deny the user to delete that item. I could put a colum saying that the item can or can't be deleted, but that would make my application a bit ugly, showing a colum with only two type of data "yes" or "not", instead, we show the specific row using a color do distinguish between those kind of items.

I end by setting the color to the background of the cell renderer using the "background" property. This was better than shoing another column, but still was ugly, because using the background property makes the cells looks splitted.

Recently, I discover the pygtk's GenericCellrenderer, this cell renderer allows you to implement your very own custom CellRenderer. and then, I could "draw" using Cairo to draw my cell's background. This let me use gradients, or even draw complex images in the background of the cell.

Playing with GenericCellRenderer

It's obvious that this is not the only use of the gtk.GenericCellRenderer, you can use it to represend anything you want, being a pixmap, maybe an object, a code bar.. I don't know, that's up to you.

Creating your own CellRenderer is quite simple, the first you have to do is subclass gtk.GenericCellRenderer, and implement this four methods:

def on_get_size(widget, cell_area)
def on_render(window, widget, background_area, cell_area, expose_area, flags)
def on_activate(event, widget, path, background_area, cell_area, flags)
def on_start_editing(event, widget, path, background_area, cell_area, flags)
 
The main methods are on_get_size, that tells the size of the cell, this value is going to be passed to on_render method. The method "on_render" is the one where you are about to work on, since all the "drawing" is made here.

Just as an example, this is the code I use in the on_render method:

        def on_render(self, window, widget, background_area, cell_area, expose_area, flags):
                cairo_context = window.cairo_create()
                x = cell_area.x
                y = cell_area.y
                w = cell_area.width
                h = cell_area.height
                if x == 0:
                        curve_to = 'start'
                elif (x + w ) == widget.allocation.width:
                        curve_to = 'end'
                else:
                        curve_to = None
                self.render_rect(cairo_context, x, y, w, h, 1, curve_to)
                pat = cairo.LinearGradient(x, y, x, y + h)
                color = gtk.gdk.color_parse("#87D8F5")
                pat.add_color_stop_rgba(
                                                        0.0,
                                                        self.get_cairo_color(color.red),
                                                        self.get_cairo_color(color.green),
                                                        self.get_cairo_color(color.blue),
                                                        1
                                                        )
                color = gtk.gdk.color_parse(self.get_property('background'))
                pat.add_color_stop_rgb(
                                                        1.0,
                                                        self.get_cairo_color(color.red),
                                                        self.get_cairo_color(color.green),
                                                        self.get_cairo_color(color.blue)
                                                        )
                cairo_context.set_source(pat)
                cairo_context.fill()
                context = widget.get_pango_context()
                layout = pango.Layout(context)
                layout.set_text(self.get_property('text'))
                layout.set_width(cell_area.width)
                widget.style.paint_layout(window, gtk.STATE_NORMAL, True,
                                        cell_area, widget, 'footext',
                                        cell_area.x, cell_area.y,
                                        layout)
 
I already have imported gtk, pango and created some other methods like render_rect, get_cairo_color and the property methods.

One of the disadvantages I saw is that you can't create a pangocairo context from the CellRenderer, this is because the CellRenderer is not a widget, and doesn't have the create_pango_layout, but you can use the widget.style.paint_layout to write whatever you want.}

The full code of this is Here

Feb 27 2009

If you like the way vim do the search/replace, then you should read this how to for use the regular expressions in vim.

EVDO in Salamanca, Gto

BAM in Salamanca
Finally we have EVDO in Salamanca, the speed is no t the best, maybe a fault of the Linux usb serial module that makes franklin to work slower than it should. Anyway, it is better than nothing.

And 1 clown

From here
<Th3No0b> Im going to be the next hitler
<Th3No0b> Im going to kill all the jews and 1 clown
<RageAgainsttheAmish> why the clown
<Th3No0b> See? no one cares about the jews
<RageAgainsttheAmish> lmao
More Here

Apple you liars


Apple you liars

Originally uploaded by markuz

Apple Safari 4 is out, and in their "All features" page, they say that Apple Safari is the first and only web browser that pass the Acid3 test. They lie, at least midori does it and have been installed in my computer since a while.

F.C. ICTC

Fuck.. another goal..No matter we lose by 9-0getting ready..

On last Monday, the ICT Consulting crew play our very first match in the local Foot Ball Soccer League. As anyone can expect, we loose, this was our very first match! we had never played before, just imagine a bunch of engineers that are at least 8 hours of the day sit on their chairs in front of the computer and suddenly they are playing soccer. You know that you are not in ready for this when you run 25 meters and finish with your tongue out.

Well, this is just the start, and we'll be better in the next games.

Know the current unix time (for the party)

This is how you can know the Unix time in your machine using python, nothing complicated and nothing that many readers didn't know, but its the "UNIX time" fever face-wink.png
python -c "import time; print time.mktime(time.localtime())"
Btw.. if you want to know the hour where the Unix time will be "1234567890" use this:

python -c "import time; print time.strftime('%Y-%B-%d %H:%M:%S',time.localtime(1234567890))"

Christine and DBus part II

If you are following christine commits then you notice that I have been working a bit on dbus, first because I want co control christine with my keyboard buttons (previous, next, play, stop).

I also create some functions to allow a small program use this functions (you can see all this in libchristine/christine_dbus/ package).

Now, I feel the need to create dbus functions for everything.. but it's not possible, so, please, give me a clue about what you want to see in the dbus package.

I'm about to create several signals, but again, I need your help to create a good enough signal stack.

Visitors Statistics

4
360
653330

Technorati